Disclosure of Invention
The invention provides a method for a Web application to call a UI input method in display equipment and the display equipment, which are used for realizing the sharing of the input method and reducing the development and maintenance cost.
In order to achieve the purpose, the invention provides the following technical scheme:
in a first aspect, the present invention provides a method for a Web application to invoke an input method of a UI in a display device, where the Web application runs on a first browser, and the UI runs on a second browser, and the method includes:
the Web application calls a first interface of the first browser to enable the first browser to send a first message to the second browser, wherein the first message is used for indicating the Web application to call the input method of the UI;
and the second browser receives the first message, generates a second browser event corresponding to the first message, and calls the input method after the UI monitors the second browser event.
Optionally, after the invoking of the input method, the method further includes:
the UI calls a second interface of the second browser to enable the second browser to send a second message to the first browser, wherein the second message comprises information input by the user through the input method;
and the first browser receives the second message, generates a first browser event corresponding to the second message, and acquires the information input by the user, which is included in the first browser event, after the Web application monitors the first browser event.
Optionally, the sending, by the first browser, the first message to the second browser includes:
the first browser sends the first message to a message distribution module, wherein the first message comprises a message source and a message destination, the message source indicates the Web application, and the message destination indicates the UI;
the message distribution module sends the first message to the second browser according to the message destination of the first message.
Optionally, the sending, by the second browser, the second message to the first browser includes:
the second browser sends the second message to a message distribution module, wherein the second message comprises a message source and a message destination, the message source indicates the UI, and the message destination indicates the Web application;
and the message distribution module sends the second message to the first browser according to the message destination of the second message.
Optionally, the first browser or the second browser communicates with the message distribution module through an RPC protocol.
In a second aspect, the invention also provides a display device comprising a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor, the processor being caused by the machine-executable instructions to: the method for the Web application to call the input method of the UI in the display equipment is realized.
In a third aspect, the present invention further provides a machine-readable storage medium, where machine-executable instructions are stored in the machine-readable storage medium, and when the machine-executable instructions are executed by a processor, the machine-executable instructions implement the method for a Web application in the display device to invoke an input method of a UI.
It can be seen from the above description that, in the embodiment of the present invention, the Web application can invoke the input method of the UI through information interaction between the browser where the Web application is located and the browser where the UI is located, thereby implementing input method sharing, saving development and maintenance costs, and reducing system resource occupation.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary examples do not represent all implementations consistent with the present invention. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the invention, as detailed in the appended claims.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in this specification and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
The display device is generally installed with a UI and various third-party-provided Web applications. The UI and the Web application run independently.
The UI generally supports an input function and meets input requirements of users. An increasing number of Web applications also require support for input functionality, for which developers develop input methods in Web applications. This results in multiple sets of input methods for the display device, increasing development and maintenance costs, and occupying system resources.
Aiming at the problems, the invention provides a method for calling an input method of a UI (user interface) by a Web application in display equipment, which enables the Web application to call the input method of the UI through information interaction between a browser of the Web application and a browser of the UI, thereby realizing the sharing of the input methods, saving development and maintenance costs and reducing the occupation of system resources.
In order to make the objects, technical solutions and advantages of the present invention clearer, the following detailed description of the present invention is provided with reference to the accompanying drawings and specific embodiments:
referring to fig. 1, a flowchart of a method for invoking an input method of a UI for a Web application in a display device according to an embodiment of the present invention is shown.
In the embodiment of the invention, both the UI and the Web application are realized based on the Web technology, so that the UI and the Web application can run in a browser environment.
The Web application runs on the first browser, and the UI runs on the second browser.
Here, the first browser and the second browser are only named for convenience of distinction and are not intended to be limiting.
As shown in fig. 1, the process may include the following steps:
in step 101, a Web application causes a first browser to send a first message to a second browser by calling a first interface of the first browser.
In the first browser, the first interface may be predefined. The first interface is used for instructing the first browser to send a first message to the second browser.
As an embodiment, the first interface may be a JavaScript interface. I.e. an interface implemented using JavaScript extensions.
When the Web application needs to use the input method, the first interface can be directly called, the first browser is triggered to send a first message to the second browser, and the first message is used for indicating the Web application to call the input method of the UI.
Here, the first interface and the first message are only named for convenience of distinction and are not intended to be limiting.
The first browser sends the message to the second browser through the step.
And 102, the second browser receives the first message, generates a second browser event corresponding to the first message, and calls the input method after the UI monitors the second browser event.
In the second browser, an event that can be identified by the second browser, referred to as a second browser event, is predefined. The second browser event has a correspondence with the first message.
And when the second browser receives the first message, generating a second browser event corresponding to the first message.
And after monitoring the second browser event through an event monitoring mechanism, the UI opens a local input method page, namely the input method of the UI, so that the user can input information required by the Web application.
Thus, the flow shown in fig. 1 is completed.
As can be seen from the flow shown in fig. 1, in the embodiment of the present invention, the Web application can directly invoke the input method of the UI by using the information interaction between the browser where the Web application is located and the browser where the UI is located, so that the input method sharing is realized, the development and maintenance costs are reduced, and the system resources are saved.
Optionally, as an embodiment, after the step 102 is executed, the flow shown in fig. 2 may also be executed. Referring to fig. 2, an implementation flow for acquiring user input information for a Web application according to an embodiment of the present invention is shown.
As shown in fig. 2, the process may include the following steps:
step 201, the UI invokes a second interface of the second browser, so that the second browser sends a second message to the first browser.
In the second browser, the second interface may be predefined. The second interface is for instructing the second browser to send a second message to the first browser.
As an embodiment, the second interface may be a JavaScript interface. I.e. an interface implemented using JavaScript extensions.
After the input method page of the UI is opened in the aforementioned step 102, the user inputs information required by the Web application on the input method page.
And after the input of the confirmation information is finished, the UI calls a second interface to trigger the second browser to send a second message to the first browser. The second message includes information entered by the user on the input method page.
Here, the second interface and the second message are only named for convenience of distinction and are not intended to be limiting.
The second browser sends the message to the first browser through the step.
Step 202, the first browser receives the second message, generates a first browser event corresponding to the second message, and obtains information input by the user, which is included in the first browser event, after the Web application monitors the first browser event.
In the first browser, an event that can be identified by the first browser, referred to as a first browser event, is predefined. The first browser event and the second message have a corresponding relationship.
And when the first browser receives the second message, generating a first browser event corresponding to the second message. The first browser event includes information entered by a user on an input method page of the UI.
And the Web application acquires the information input by the user, which is included in the first browser event, after monitoring the first browser event through an event monitoring mechanism.
That is, the Web application acquires information input through the UI input method.
At this point, the flow shown in fig. 2 is completed.
This may be accomplished by the process illustrated in FIG. 2, where information entered using the UI input method is passed to the Web application. An input method does not need to be developed in Web application, and development and maintenance cost is reduced.
Optionally, as an embodiment, a process of sending the first message from the first browser to the second browser in step 101 is described below. Referring to fig. 3, a flow of implementing step 101 is shown in the embodiment of the present invention.
As shown in fig. 3, the process may include the following steps:
step 301, the first browser sends the first message to a message distribution module.
In the embodiment of the invention, the display equipment comprises a message distribution module.
When the first browser needs to send the first message to the second browser, the first message can be sent to the message distribution module, and the message distribution module forwards the first message to the second browser.
As an embodiment, the first browser may send the first message to the message distribution module based on an RPC (Remote Procedure Call) Protocol.
The first message comprises a message source and a message destination, wherein the message source indicates a Web application, and the message destination indicates a UI.
Step 302, the message distribution module sends the first message to the second browser according to the message destination of the first message.
The message distribution module records the corresponding relation between the UI identifier and the second browser identifier. Therefore, the first message can be sent to the second browser by inquiring the corresponding relation according to the message destination (UI) of the first message.
The flow shown in fig. 3 is completed.
This can be achieved by the flow shown in fig. 3, where the first browser sends the first message to the second browser.
Optionally, as an embodiment, a process of sending the second message to the first browser by the second browser in step 201 is described below. Referring to fig. 4, a flow of implementing step 201 is shown in the embodiment of the present invention.
As shown in fig. 4, the process may include the following steps:
step 401, the second browser sends the second message to the message distribution module.
When the second browser needs to send the second message to the first browser, the second message can be sent to the message distribution module, and the message distribution module forwards the second message to the first browser.
For one embodiment, the second browser can send the second message to the message distribution module based on the RPC protocol.
The second message comprises a message source and a message destination, wherein the message source indicates the UI, and the message destination indicates the Web application.
In step 402, the message distribution module sends the second message to the first browser according to the message destination of the second message.
The message distribution module records the corresponding relation between the identification of the Web application and the identification of the first browser. Therefore, the second message can be sent to the first browser by querying the correspondence relationship according to the message destination (Web application) of the second message.
The flow shown in fig. 4 is completed.
This can be achieved by the flow shown in fig. 4, where the second browser sends the second message to the first browser.
The method provided by the present invention is described below by way of a specific example.
Referring to fig. 5, a schematic diagram of various applications installed in a display device 500 is shown in the present embodiment. Among them, the Web application 501 runs in the browser 511, and the UI502 runs in the browser 512. Browser 511 and browser 512 are in message communication through message distribution module 520.
In the browser 511, an interface, denoted as Send12(), is defined in advance for instructing the browser 511 to Send a Message (denoted as Message12) that the Web application uses the UI input method to the browser 512. And defines a browser event, denoted as inputrule, for enabling the Web application 501 to monitor the input information returned by the UI input method.
In the browser 512, an interface, denoted Send21(), is predefined for instructing the browser 512 to Send a Message (denoted Message21) carrying user input information to the browser 511. And defines a browser event, denoted as PreInputText, for enabling UI502 to listen to the message that Web application 501 requests to invoke the UI input method.
When the Web application 501 needs to use the input method, a flow shown in fig. 6 may be executed, which includes the following steps:
step 601, the Web application 501 calls Send12 ();
step 602, the browser 511 responds to the Send12() call, and sends a Message12 to the Message distribution module 520;
the Message structure of the Message12 is shown in table 1.
Message source
|
Message destination
|
Message content
|
Web application 501
|
UI502
|
|
TABLE 1
Wherein, the message content can add the information that the Web application 501 wants to transmit to the UI502 according to the actual requirement.
Step 603, the Message distribution module 520 sends the Message12 to the browser 512 where the UI502 is located according to the Message destination (UI502) of the Message 12;
step 604, the browser 512 identifies the Message12, and generates a corresponding browser event PreInputText;
in step 605, after the UI502 monitors PreInputText, the input method page is opened.
The user inputs information required by the Web application 501 on the input method page.
After completing the user input, a process shown in fig. 7 may be performed, which includes the following steps:
step 701, UI502 calls Send21 ();
the user input information is taken as an input parameter of Send21 ().
Step 702, the browser 512 responds to the Send21() call, and sends a Message21 to the Message distribution module 520;
the Message structure of the Message21 is shown in table 2.
Message source
|
Message destination
|
Message content
|
UI502
|
Web application 501
|
User input information |
TABLE 2
Step 703, the Message distribution module 520 sends the Message21 to the browser 511 where the Web application 501 is located according to the Message destination (Web application 501) of the Message 21;
step 704, the browser 511 identifies Message21, and generates a corresponding browser event InputResult;
the InputResult includes user input information.
Step 705, after the Web application 501 monitors the InputResult, it obtains the user input information.
This completes the description of the present embodiment.
The method provided by the present invention is described above, and the display device provided by the present invention is described below:
referring to fig. 8, a schematic diagram of a hardware structure of a display device according to an embodiment of the present invention is provided. The display device may include a processor 801, a machine-readable storage medium 802 having machine-executable instructions stored thereon. The processor 801 and the machine-readable storage medium 802 may communicate via a system bus 803. Also, the processor 801 may perform the above-described method of the Web application calling the input method of the UI in the display apparatus by reading and executing machine-executable instructions in the machine-readable storage medium 802 corresponding to the input method of the Web application calling the UI in the display apparatus.
The machine-readable storage medium 802 referred to herein may be any electronic, magnetic, optical, or other physical storage device that can contain or store information such as executable instructions, data, and the like. For example, the machine-readable storage medium 802 may include at least one of the following storage media: volatile memory, non-volatile memory, other types of storage media. The volatile memory may be a RAM (Random access memory), and the nonvolatile memory may be a flash memory, a storage drive (e.g., a hard disk drive), a solid state disk, and a storage disk (e.g., a compact disk, a DVD).
Embodiments of the present invention also provide a machine-readable storage medium, such as machine-readable storage medium 802 in fig. 8, including machine-executable instructions, which are executable by processor 801 in a display device to implement the above-described method for a Web application in a display device to invoke an input method of a UI.
Up to this point, the description of the display apparatus shown in fig. 8 is completed.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.