Disclosure of Invention
The embodiment of the invention provides a focus updating method and device, which are used for reducing the complexity of setting a focus.
The embodiment of the invention provides a focus updating method, which comprises the following steps:
the method comprises the steps that a terminal obtains a key value sent by a remote controller, wherein the key value is used for controlling the moving direction of a focus;
the terminal sends the key value to a first page with the largest stacking sequence in pages displayed by the terminal;
the first page displayed by the terminal determines a second position after the focus is updated according to the first position of the focus in the first page and the key value;
and the terminal acquires a second position determined by the first page and switches the focus to the second position in the first page.
Optionally, the method further includes:
when the page displayed by the terminal is switched from the first page to a second page, the terminal acquires the initial position of the focus in the second page from the second page;
and the terminal sets the focus at the initial position in the second page.
Optionally, determining, by the first page displayed by the terminal, the updated second position of the focus according to the first position of the focus in the first page and the key value, where the determining includes:
determining a page control corresponding to the first position of the first page displayed by the terminal, and determining the page control with the attribute of focus page control as a focused page control if the page control exists in the moving direction controlled by the key value;
and determining the position of the focused page control as the second position after the focus is updated.
Optionally, if the page control corresponding to the first position is determined, in the moving direction controlled by the key value, a page control exists, and a page control with the attribute of being a focused page control does not exist, searching for the page control with the attribute of being the focused page control in the document object model DOM of the first page;
and determining the position of the searched page control as the second position after the focus is updated.
Optionally, if the page control corresponding to the first position is determined, and no page control exists in the moving direction controlled by the key value, the position of a preset page control in the first page is determined as the second position after the focus is updated.
An embodiment of the present invention provides a focus updating apparatus, including:
the processing module is used for acquiring a key value sent by the remote controller, and the key value is used for controlling the moving direction of the focus; sending the key value to a first page with the largest stacking sequence in pages displayed by the terminal;
the focus calculation module is used for determining a second position of the updated focus according to the first position of the focus in the first page and the key value on the first page;
and the focus management module is used for acquiring a second position determined by the first page and switching the focus to the second position in the first page.
Optionally, the focus management module is further configured to:
when the displayed page is switched from the first page to a second page, acquiring the initial position of the focus in the second page from the second page;
setting the focus at the initial position in the second page.
Optionally, the focus calculation module is specifically configured to:
determining a page control corresponding to the first position of the first page displayed by the terminal, and determining the page control with the attribute of focus page control as a focused page control if the page control exists in the moving direction controlled by the key value;
and determining the position of the focused page control as the second position after the focus is updated.
Optionally, if the page control corresponding to the first position is determined, in the moving direction controlled by the key value, a page control exists, and a page control with the attribute of being a focused page control does not exist, searching for the page control with the attribute of being the focused page control in the document object model DOM of the first page;
and determining the position of the searched page control as the second position after the focus is updated.
Optionally, if the page control corresponding to the first position is determined, and no page control exists in the moving direction controlled by the key value, the position of a preset page control in the first page is determined as the second position after the focus is updated.
According to the method provided by the embodiment of the invention, after the key value of the remote controller for controlling the focus moving direction in the webpage is received, the key value is sent to the first page, and the first page determines the updated second position of the focus according to the current first position of the focus and the key value. Therefore, the function of focus calculation can be independently realized through each page, so that the complexity of focus management is reduced on the premise of not increasing excessive workload, and the focus management system has stronger robustness.
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.
The embodiment of the invention can be applied to various types of terminals (including but not limited to devices such as smart televisions and set top boxes), and optionally, the terminals can access various pages on the web server by using various different browsers, wherein the pages include but not limited to pages such as HTML (hypertext markup language) web pages. The embodiment of the invention can independently realize the function of focus calculation through each page, thereby reducing the complexity of focus management and leading the focus management system to have stronger robustness on the premise of not increasing excessive workload.
In the embodiment of the invention, after the terminal receives the key value of the remote controller, the browser of the terminal sends the key value to a web Interface design (Website User Interface, WebUI). WebUI refers to a web technology-based page management system. As shown in fig. 1, a schematic structural diagram of a WebUI provided in an embodiment of the present invention is shown. The WebUI comprises a page management module and a focus setting module, and of course, the WebUI also comprises other modules, which are not exemplified one by one here. The page management module is responsible for creating, updating, switching and destroying pages; and the focus setting module is responsible for setting the focus in the page according to the position of the focus acquired from the page.
After the WebUI obtains the key value of the remote controller, the WebUI confirms the current page needing the key value by using the page management module and sends the key value to the page.
In the embodiment of the invention, the page refers to a document page meeting the HyperText Markup Language (HTML) standard and is responsible for defining and displaying the page control. Fig. 1 shows a schematic structural diagram of a page provided in an embodiment of the present invention, and referring to fig. 1, in the embodiment of the present invention, a page includes a focus calculation module, which can calculate a position of a focus in the page and send the calculated position of the focus to a WebUI.
The page is also responsible for defining whether the page control can obtain focus (i.e. the attribute of the page control is a focused page control or a non-focused page control), and describes the page control identification of the next available focus of the control in the four directions of up, down, left and right (i.e. the identification value of the next page control is specified in the page control attributes nextfocusUP, nextfocusDOWN, nextfocusLEFT, nextfocusIGHT).
The page is also responsible for the processing of focus change events (focus change event refers to the page control getting focus onFocus, losing focus onBlur). And the page control for obtaining the focus is the focused page control.
With continued reference to fig. 2, the focus calculation module is responsible for receiving and converting the key value into a movement direction (direction) of the focus, and transmitting the movement direction into the focus position according to the current focus position currentFocusNode and the movement direction to calculate the position of the focus after the focus is updated.
It should be noted that the focus calculation module may be a piece of js (javascript) script program. This program needs to be embedded in the page for focus control.
Fig. 3 is a flowchart illustrating a method for updating a focus according to an embodiment of the present invention, where as shown in fig. 3, the method includes:
step 301: the terminal acquires a key value sent by the remote controller, wherein the key value is used for controlling the moving direction of the focus.
Step 302: and the terminal sends the key value to a first page with the largest stacking sequence in the pages displayed by the terminal.
Step 303: and the first page displayed by the terminal determines a second position after the focus is updated according to the first position of the focus in the first page and the key value.
Step 304: and the terminal acquires a second position determined by the first page and switches the focus to the second position in the first page.
In step 301, a key value of the remote controller corresponds to a moving direction of the focus, the correspondence is predetermined, and the terminal can determine the moving direction corresponding to the key value through the received key value.
A user sends an operation instruction carrying a key value to a terminal by using a remote controller, the remote controller is used as operation equipment to transmit the key value to a browser in the terminal, and the browser transmits the key value to a page through a WebUI; the page has an attribute that can obtain the key value, which is specified in the protocol and is not described herein again.
In step 302, the attributes of the pages include the stacking order, and the page with the higher stacking order is always displayed in front of the page with the lower stacking order. In the embodiment of the application, the page which needs to be operated by the user through the remote controller is the page displayed at the forefront, so that the page with the largest stacking sequence, namely the first page, in the pages displayed by the terminal can be determined as the page where the focus is located currently.
In step 303, in a first scenario, a first page, which may specifically be a focus calculation module of the first page, may determine a page control corresponding to the first position, and in a moving direction controlled by the key value, when a page control exists, determine the page control having an attribute of a focused page control as a focused page control. The attribute is a focused page control, the presentation focus can be located in the page control, and a user can execute corresponding actions, such as clicking operation, on the page control through the focus.
If the first page determines the focused page control, the position of the focused page control may be determined as the second position after the focus update.
It should be noted that, in the embodiment of the present invention, the page control refers to some visible Web tags in the HTML page, such as a button, a text input box, and the like.
It should be further noted that, in the embodiment of the present invention, the detailed description is only given by taking the example that the smart television accesses the page on the web server, and the schemes for accessing the web server through other terminals are all within the protection scope of the present invention, and are not described herein again.
In a second scenario, the first page may specifically be a focus calculation module of the first page, and if it is determined that a page control corresponding to the first position exists in the moving direction controlled by the key value, and a page control with a property of being a focused page control does not exist, the page control with the property of being the focused page control is searched in a Document Object Model (DOM) tree of the first page, and the position of the searched page control is determined as the second position after the focus is updated.
It should be noted that a page is a collection of a series of page controls included in the page, and these page controls form a tree-like structure, which is generally called a DOM tree.
In a third scenario, the first page may specifically be a focus calculation module of the first page, and if it is determined that a page control corresponding to the first position does not exist in the moving direction controlled by the key value, the position of a preset page control in the first page is determined as the second position after the focus is updated. The preset page control may be any page control in the first page, and is determined specifically according to an actual situation, which is not described herein again.
In step 304, the WebUI may acquire the second position from the first page, so that the focus may be set at the second position in the first page, and the switching of the focus is implemented.
The above process is described below by a detailed embodiment.
As shown in fig. 4, a schematic flowchart of the focus moving provided in the embodiment of the present invention includes:
step 401: the user operates the keys of the remote controller, the remote controller is triggered to send the corresponding key values to the intelligent television, and the browser engine in the intelligent television receives the key values of the remote controller sent by the user.
Step 402: and the browser engine calls a standard interface and sends the key value to the WebUI.
Step 403: and the page management module in the WebUI sends the key value to the focus calculation module of the first page.
Step 404: and the focus calculation module of the first page calculates a second position of the focus according to the key value and the first position of the focus in the first page, the first page stores the second position, and the second position is sent to the focus setting module in the WebUI.
Therefore, the calculation of the focus position is completed by the page, the focus movement of the page is not managed by the browser in a unified way, the position of the focus provided by the switched page is realized when a plurality of pages are switched for a plurality of times, the complexity of focus management is reduced, and the focus management system has stronger robustness.
In the embodiment of the invention, when the displayed page is switched to other pages, the first page can store the latest position of the focus in the first page, and when the displayed page is switched to the first page again, the first page can send the stored position of the focus to the WebUI, so that the WebUI can determine the position of the focus in the first page. For example, when the page displayed by the terminal is switched from the first page to the second page, the flow shown in fig. 5 may be referred to.
Step 501: when the page displayed by the terminal is switched from the first page to the second page, the page management module in the WebUI sends a focus position request to the second page.
Step 502: and the focus calculation module of the second page acquires the initial position of the saved focus in the second page.
Step 503: the second page sends the initial position to a focus setting module in the WebUI.
Step 504: the WebUI sets the focus at the initial position in the second page.
Based on the same technical concept, as shown in fig. 6, an embodiment of the present invention provides a structural schematic diagram of a focus updating apparatus.
Referring to fig. 6, the apparatus includes:
a processing module 601, configured to obtain a key value sent by a remote controller, where the key value is used to control a moving direction of a focus; sending the key value to a first page with the largest stacking sequence in pages displayed by the terminal;
a focus calculation module 602, configured to determine, according to a first position of the focus in the first page and the key value, a second position of the updated focus on the first page;
the focus management module 603 is configured to obtain a second position determined by the first page, and switch the focus to the second position in the first page.
Optionally, the focus management module 603 is further configured to:
when the displayed page is switched from the first page to a second page, acquiring the initial position of the focus in the second page from the second page;
setting the focus at the initial position in the second page.
Optionally, the focus calculation module 602 is specifically configured to:
determining a page control corresponding to the first position of the first page displayed by the terminal, and determining the page control with the attribute of focus page control as a focused page control if the page control exists in the moving direction controlled by the key value;
and determining the position of the focused page control as the second position after the focus is updated.
Optionally, if the page control corresponding to the first position is determined, in the moving direction controlled by the key value, a page control exists, and a page control with the attribute of being a focused page control does not exist, searching for the page control with the attribute of being the focused page control in the document object model DOM of the first page;
and determining the position of the searched page control as the second position after the focus is updated.
Optionally, if the page control corresponding to the first position is determined, and no page control exists in the moving direction controlled by the key value, the position of a preset page control in the first page is determined as the second position after the focus is updated.
According to the method provided by the embodiment of the invention, after the key value of the remote controller for controlling the focus moving direction in the webpage is received, the key value is sent to the first page, and the first page determines the updated second position of the focus according to the current first position of the focus and the key value. Therefore, the function of focus calculation can be independently realized through each page, so that the complexity of focus management is reduced on the premise of not increasing excessive workload, and the focus management system has stronger robustness.
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, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, implement 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.