Disclosure of Invention
The embodiment of the invention provides a method and a device for debugging a browser page of a set top box, which are used for improving the efficiency of page debugging.
The method for debugging the browser page of the set top box provided by the embodiment of the invention comprises the following steps:
acquiring a resource file downloaded from a server by a browser, and caching the resource file, wherein the resource file comprises page source code content;
creating a debugging window, filling the cached page source code content in the debugging window, and displaying the debugging window filled with the page source code content;
after receiving an editing instruction of a user, editing the source code content of the page according to the editing instruction;
and after receiving a debugging window closing instruction of a user, sending the edited resource file to the browser so that the browser loads the edited resource file.
Because the page source code content is filled in the debugging window for displaying, developers can edit and modify the page content in real time through a remote controller or a keyboard, thereby realizing the debugging function and improving the page debugging efficiency.
Optionally, the creating a debugging window, filling the cached content of the page source code in the debugging window, and displaying the debugging window filled with the content of the page source code includes:
creating an editing window and a plurality of text windows;
filling the page source code content in the editing window;
searching file paths in script tags in the page source code content, and filling the searched file paths in the plurality of file windows;
and displaying the filled editing window and the plurality of file windows.
Optionally, the editing instruction is generated after the user presses the first key;
the debugging window closing instruction is generated after the user presses the second key.
Optionally, the sending the edited resource file to the browser includes:
and sending the edited resource file to the browser and indicating the main page loaded by the browser.
Correspondingly, an embodiment of the present invention provides a device for debugging a browser page of a set top box, including:
the resource caching module is used for acquiring a resource file downloaded by a browser from a server and caching the resource file, wherein the resource file comprises page source code content;
the presentation module is used for creating a debugging window, filling the cached page source code content in the debugging window and displaying the debugging window filled with the page source code content;
the editing module is used for editing the page source code content according to an editing instruction after receiving the editing instruction of a user;
and the resource reporting module is used for sending the edited resource file to the browser after receiving a debugging window closing instruction of a user so as to enable the browser to load the edited resource file.
Optionally, the presentation module is specifically configured to:
creating an editing window and a plurality of text windows;
filling the page source code content in the editing window;
searching file paths in script tags in the page source code content, and filling the searched file paths in the plurality of file windows;
and displaying the filled editing window and the plurality of file windows.
Optionally, the editing instruction is generated after the user presses the first key;
the debugging window closing instruction is generated after the user presses the second key.
Optionally, the resource reporting module is specifically configured to:
and sending the edited resource file to the browser and indicating the main page loaded by the browser.
Accordingly, an embodiment of the present invention provides a computing device, including:
a memory for storing program instructions;
and the processor is used for calling the program instruction stored in the memory and executing the method for debugging the browser page of the set top box according to the obtained program.
Accordingly, an embodiment of the present invention provides a computer-readable non-volatile storage medium, which includes computer-readable instructions, and when the computer reads and executes the computer-readable instructions, the computer is enabled to execute the method for debugging the browser page of the set top box.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the present invention will be described in further detail with reference to the accompanying drawings, and it is apparent that the described embodiments are only a part of the embodiments of the present invention, not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Fig. 1 exemplarily shows a structure of a system architecture provided by an embodiment of the present invention, where the system architecture may be a set-top box, and includes abrowser module 100 and adebugging module 200.
Thebrowser module 100 may include, among other things, a network module, a resource loader, and other modules. The other modules may include an interpretation rendering layout module and a layer module, the network module is configured to download a resource file of a page to be loaded from an authenticated server, and the resource loader is configured to load the resource file downloaded by the network module.
Thedebugging module 200 comprises a resource caching module, a presenting module, an editing module and a resource reporting module; the resource caching module is used for caching the resource file downloaded by the browser player network module, the presenting module is used for presenting the resource file, the editing module is used for editing the resource file according to user operation, and the resource reporting module is used for sending the edited resource file to a resource loader of the browser.
At present, the process of originally loading a page by a browser of a set top box may be as shown in fig. 2, and after the browser of the browser completes authentication from a specified address, the browser loads home page data sent by a server. And at the same time, according to the user operation and according to the page content, the resource loader may be called again, and the network module is used for updating or requesting a new page by the server.
And the page and the resource file acquired by the network module are sent to the resource loader. And the resource loader starts to send the content to the analysis layout rendering module for analysis, layout and rendering, and finally the content is presented through the layer module.
Based on the above description, fig. 3 exemplarily shows a process of debugging a browser page of a set top box according to an embodiment of the present invention, where the process may be executed by a device for debugging a browser page of a set top box, and the device may be a set top box or may be located in a set top box.
As shown in fig. 3, the specific steps of the process include:
step 301, acquiring a resource file downloaded by a browser from a server, and caching the resource file.
The resource file may include the page source code content, mainly all resource files needed in the rendering process. The resource caching module is mainly used for intercepting the resource file from a network module of the browser and storing the resource file locally according to a certain format.
The resource file can be divided into a main resource file (which is a page file in html format to be presented by a browser) and other resource files such as js script files, css style files, img graphic files and the like which are quoted in the page. The resource loading module of the browser applies for the main resource file from the network module, and then applies for other resource files needed in the main resource file according to the analyzed content of the main resource file.
When the resource caching module caches the resource file, the picture resource file (img format) is filtered, and the graph cannot be edited during debugging. Thus the volume of buffered data is greatly reduced.
And simultaneously, only the main resource file which is newly downloaded by the browser network module and other non-main resource files behind the main resource file are cached locally by utilizing the characteristic that the browser requests the main resource first each time. If a new main resource file download is encountered, all files in the cache are cleared, and the files are stored again according to the rule. The method not only ensures the requirement of the debugging module, but also prevents files in the cache from being excessively accumulated.
When the resource cache module stores data, a mode of managing files based on lists is used: the method comprises the steps of firstly taking the name of a downloaded file from a downloading module of a browser, storing the name of the downloaded file in a self-managed list, sequentially accumulating the names of the files downloaded later in the list, simultaneously storing the content of the downloaded file in a specific folder, and sequentially naming 1.txt 2.txt 3.txt … n.txt according to the downloading sequence.
When the resource cache module receives a data request of the presentation module, the corresponding index position is found from the list according to the file name of the request, and the corresponding file content is obtained.
Step 302, a debugging window is created, the cached page source code content is filled in the debugging window, and the debugging window filled with the page source code content is displayed.
When the debugging window is created, an editing window and a plurality of text windows can be created first, and the page source code content is filled in the editing window. And then searching file paths in script tags in the source code content of the page, filling the searched file paths into a plurality of file windows, and filling one file path into one file window during filling. And finally, displaying, namely presenting, the filled editing window and the file windows so that a user can edit through keys.
For example, taking the Android system as an example, the Android window programming presentation is used, and the layout display of the data is completed by using both Editview and Textview.
1. Creating an android window (Activity), mainly creating an edit window (edit window) and dynamically creating a plurality of textviews (text windows).
2. And filling the page source code content into Editview, and data in Editview, so that a user can edit the page source code content through keys and the like.
3. Searching for an src attribute in a script tag in page source code content, wherein the src attribute corresponds to a file path, finding content contained behind the src, for example, (' text/javascript ', ' src '/page/engine.js ' >) and filling content "/page/engine.js" in the dynamically created textview. Since multiple script tags may be used in one page, multiple textviews may be established. Among them, the textview can add the support of click action. And after clicking action, sending the textview content to a resource caching module to request for obtaining data. The obtained data operates again according to 1-3 steps.
And 303, after receiving an editing instruction of a user, editing the page source code content according to the editing instruction.
After receiving the editing instruction of the user, the content of the page source code can be edited in the debugging window by the root editing instruction. It should be noted that the programming instruction is generated after the user presses the first key, where the first key may be a single key or a combination of multiple keys, and the first key may be a key on a remote controller or a keyboard of the set top box, or a virtual key on an APP associated with the set top box on another terminal.
And after the editing is finished, exiting the window through a specific key, and updating the content in the editview into the corresponding page source code content. Until all the modification windows are backed off. And sending the modified page source code contents to a resource reporting module, namely a modified resource file.
Step 304, after receiving a debugging window closing instruction of a user, sending the edited resource file to the browser, so that the browser loads the edited resource file.
The debugging window closing instruction is generated after a user presses a second key, the second key can be a single key or a combination of multiple keys, and the second key can be a remote controller of the set-top box or a key on a keyboard or a virtual key on an APP associated with the set-top box on other terminals.
The debugging window closing instruction indicates that the user and the resource source code content are edited, and at the moment, the resource reporting module can send the edited resource file to the browser, wherein the main page loaded by the browser can be indicated.
The resource reporting module mainly realizes two types of interfaces with a resource loading module of the browser, wherein the first type is the resource loading module which sends new data to the browser through a debugging module; the first type is to request the browser resource loading module to load a certain main page.
The resource reporting module receives the page data (which may be a main resource page or may have additional resource files) edited by the content presentation module, and then retransmits the page data to the resource loading module of the browser through the first type of interface. And simultaneously, the resource loading module of the browser reloads the main resource page which is just updated through the second type of interface.
In order to better explain the embodiment of the present invention, the following describes a process of debugging a browser page of a set top box in a specific implementation scenario.
As shown in fig. 4, the process specifically includes:
instep 401, the user makes a key combination activation.
Step 402, saving the name of the loaded main resource of the current browser.
Step 403, acquiring the name of the currently loaded page, and taking out the currently loaded page from the cache.
Step 404, creating a debugging window, and filling the content of the page source code into the content of the debugging window.
Step 405, a user edit input is received.
Step 406, determining whether the user clicks the src attribute content, if yes, proceeding to step 407, and if no, proceeding to step 408.
Step 407, find the resource name specified by the src attribute.
And step 408, the user finishes editing by using the special building and closes the debugging window step by step.
Step 409, sending all the modified page contents to a resource loader of the browser, and requesting the resource loader to reload the main resources.
The specific contents of each process in the embodiments of the present invention have been described in the above embodiments, and are not described again.
The embodiment shows that the resource file downloaded from the server by the browser is obtained, the resource file is cached, the debugging window is created, the cached page source code content is filled in the debugging window, the debugging window filled with the page source code content is displayed, after an editing instruction of a user is received, the page source code content is edited according to the editing instruction, and after a debugging window closing instruction of the user is received, the edited resource file is sent to the browser, so that the browser loads the edited resource file. Because the page source code content is filled in the debugging window for displaying, developers can edit and modify the page content in real time through a remote controller or a keyboard, thereby realizing the debugging function and improving the page debugging efficiency.
Based on the same technical concept, fig. 5 exemplarily shows a structure of a device for debugging a browser page of a set top box according to an embodiment of the present invention, where the device may execute a process of debugging the browser page of the set top box, and the device may be located in the set top box or may be the set top box.
As shown in fig. 5, the apparatus includes:
theresource caching module 501 is configured to obtain a resource file downloaded by a browser from a server, and cache the resource file, where the resource file includes a page source code content;
apresentation module 502, configured to create a debugging window, fill the cached content of the page source code in the debugging window, and display the debugging window filled with the content of the page source code;
theediting module 503 is configured to, after receiving an editing instruction of a user, edit the content of the page source code according to the editing instruction;
and theresource reporting module 504 is configured to send the edited resource file to the browser after receiving a debugging window closing instruction of the user, so that the browser loads the edited resource file.
Optionally, the presentingmodule 502 is specifically configured to:
creating an editing window and a plurality of text windows;
filling the page source code content in the editing window;
searching file paths in script tags in the page source code content, and filling the searched file paths in the plurality of file windows;
and displaying the filled editing window and the plurality of file windows.
Optionally, the editing instruction is generated after the user presses the first key;
the debugging window closing instruction is generated after the user presses the second key.
Optionally, theresource reporting module 504 is specifically configured to:
and sending the edited resource file to the browser and indicating the main page loaded by the browser.
Based on the same technical concept, an embodiment of the present invention provides a computing device, including:
a memory for storing program instructions;
and the processor is used for calling the program instruction stored in the memory and executing the method for debugging the browser page of the set top box according to the obtained program.
Based on the same technical concept, the embodiment of the invention provides a computer-readable non-volatile storage medium, which comprises computer-readable instructions, and when the computer reads and executes the computer-readable instructions, the computer is enabled to execute the method for debugging the browser page of the set top box.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.