Disclosure of Invention
The invention mainly aims to provide a method for loading a script plug-in by a Widget engine and the Widget engine, which can improve user experience.
The invention provides a method for loading script plug-ins by a Widget engine, which comprises the following steps:
the method comprises the steps that a Widget engine obtains attributes which are pre-configured by script plug-ins needing to be loaded in a Widget package;
and loading the script plug-in into a browser engine according to the attribute preset by the script plug-in.
Preferably, the step of the Widget engine obtaining the attribute pre-configured by the script plug-in stored in the Widget package further includes the following steps:
and searching the needed script plug-in by the Widget engine, and storing the needed script plug-in the Widget package.
Preferably, the pre-configuring specifically includes:
and adding keywords in the configuration file of the Widget package, and identifying script plug-ins needing to be loaded through the attributes of the configuration keywords.
Preferably, the pre-configuring further specifically includes:
adding extension keywords in a configuration file of the Widget package, and setting the name and the path of the script plug-in the attribute; or,
and adding standard keywords in the configuration file of the Widget package, and setting the name of the script plug-in the attribute.
Preferably, the step of loading the script plug-in into the browser engine according to the attribute preconfigured by the script plug-in specifically includes:
the method comprises the steps that a Widget engine reads keywords of a configuration file of a Widget package to obtain attributes of script plug-ins needing to be loaded;
acquiring an interface function of the script plug-in according to the attribute, and calling the interface function to acquire an entry function operated by the script plug-in;
and calling the entry function, and loading the script plug-in into a browser engine.
The invention also provides a Widget engine, comprising:
the acquisition module is used for acquiring the attribute which is configured in advance by the script plug-in needing to be loaded in the Widget package;
and the loading module is used for loading the script plug-in into the browser engine according to the attribute preset by the script plug-in.
Preferably, the apparatus further comprises:
and the storage module is used for searching the needed script plug-in and storing the needed script plug-in the Widget package.
Preferably, the pre-configuring specifically includes:
and adding keywords in the configuration file of the Widget package, and identifying script plug-ins needing to be loaded through the attributes of the configuration keywords.
Preferably, the pre-configuring further specifically includes:
adding extension keywords in a configuration file of the Widget package, and setting the name and the path of the script plug-in the attribute; or,
and adding standard keywords in the configuration file of the Widget package, and setting the name of the script plug-in the attribute.
Preferably, the loading module is specifically configured to:
reading keywords of a configuration file of the Widget package to obtain the attribute of the script plug-in needing to be loaded;
acquiring an interface function of the script plug-in according to the attribute, and calling the interface function to acquire an entry function operated by the script plug-in;
and calling the entry function, and loading the script plug-in into a browser engine.
The method for loading the script plug-in by the Widget engine and the Widget engine can directly call the plug-in interface through the Widget engine, load the script plug-in advance, and do not need to declare in the script, thereby improving the user experience.
Detailed Description
The invention can load the script plug-in advance, does not need to declare the loaded plug-in the script, directly uses the plug-in interface and can improve the user experience. The script plug-in may be a plug-in that does not require a window operation and conforms to the NETSCAPE plug-in specification.
The browser engine referred to below may be used to process Web hypertext on a mobile terminal; the Widget engine can be positioned above the browser engine and is used for operating the browser engine; NETSCAPE plug-in standard is Web hypertext plug-in specification proposed by network view company; < object >, which is a hypertext language keyword; < embed >, which is a hypertext language keyword; the Widget package can be a folder or a compressed package of a folder.
Referring to fig. 2, an embodiment of a method for loading a script plug-in by a Widget engine according to the present invention is provided, where the method includes:
step S20, the Widget engine acquires the attribute pre-configured by the script plug-in needing to be loaded in the Widget package;
and step S21, loading the script plug-in into the browser engine according to the attribute preset by the script plug-in.
As shown in step S20, the properties of the script plug-in can be pre-configured to determine the script plug-in that needs to be loaded. In this embodiment, the method may be applied to a mobile terminal, and the mobile terminal may provide services provided by the mobile terminal itself to the mobile Widget for access through a script plug-in mode. The mobile terminal classifies script plug-ins according to the types of services, such as multimedia playing plug-ins, hardware device plug-ins, network plug-ins, telephone plug-ins, file operation plug-ins, database service plug-ins, and the like. The mobile Widget can analyze the Widget package according to the requirement, extract the attribute of the script plug-in the configuration file and determine the plug-in needing to be loaded. In the Widget package, a corresponding script plug-in may be stored in advance. The attributes include the name, type, path, version number of the script plug-in, and/or the URL of the update plug-in, etc.
The mobile terminal may be a handheld intelligent electronic device such as a mobile phone and a Personal Digital Assistant (PDA).
As shown in step S21, the Widget engine may call a plug-in interface of the script plug-in according to the pre-configured attributes (such as name, path, etc.), and load the script plug-in to be loaded into the browser engine.
According to the method for loading the script plug-in by the Widget engine, the plug-in interface can be directly called by the Widget engine, the script plug-in is loaded in advance, and the statement in the script is not needed, so that the user experience is improved. Meanwhile, due to the fact that resources of the mobile terminal are limited, the method has a more remarkable effect when used in the mobile terminal.
Referring to fig. 3, another embodiment of the method for loading a script plug-in by a Widget engine according to the present invention is provided, where the method further includes, before step S20:
and S200, searching the needed script plug-in by the Widget engine, and storing the needed script plug-in the Widget package.
In step S200, in this embodiment, the Widget engine may search for a needed script plug-in from script plug-ins provided by the mobile terminal, and store the needed script plug-in into the Widget package as a standby. The searching can be to search for a needed (including version updating) script plug-in the mobile terminal, and save the attribute (including name, path, type and the like) of the script plug-in to the configuration file of the Widget package through pre-configuration; the searching may also be performed outside the mobile terminal, for example, by searching for a required script plug-in through a network, downloading and storing the script plug-in into the Widget package according to a network path (for example, a URL), and storing the attribute of the script plug-in into a configuration file of the Widget package through pre-configuration.
In this embodiment, the pre-configuring may specifically include:
and step A, adding keywords in the configuration file of the Widget package, and identifying script plug-ins to be loaded through the attributes of the configuration keywords. The keywords comprise standard keywords and extended keywords; and aiming at the standard keyword, the Widget engine has corresponding configuration in advance. And corresponding keywords can be selected and added for configuration according to the attribute (type attribute) of the script plug-in which needs to be loaded. The types of the script plug-ins comprise standard script plug-ins and extended script plug-ins; the standard script plug-in may be provided by a service operator of the mobile terminal and the extended script plug-in may be provided by a third party. The pre-configuration can be completed by a Widget system tool, or other tools other than Widget.
In this embodiment, the step a may specifically include:
step A1, adding extension keywords in the configuration file of the Widget package, and setting the name and path of the script plug-in the attribute; or,
step A2, adding standard keywords in the configuration file of the Widget package, and setting the name of the script plug-in the attribute.
The step a1 may specifically be: xml, adding keyword < NETSCAPELIB >, setting name of script plug-in name attribute of < lib > sub item, and setting path of script plug-in path attribute.
The step a2 may specifically be: xml, add keyword < standby > in the configuration file config of the Widget package, and set the name of the script plug-in the name attribute of the < lib > sub-item.
Referring to fig. 4, in this embodiment, the step S21 specifically includes:
step S210, the Widget engine reads the key words of the configuration file of the Widget package to obtain the attribute of the script plug-in needing to be loaded;
step S211, obtaining an interface function of the script plug-in according to the attribute, and calling the interface function to obtain an entry function operated by the script plug-in;
step S212, calling the entry function, and loading the script plug-in into the browser engine.
In step S210, in this embodiment, the Widget engine of the mobile terminal reads the configuration file config.xml of the mobile Widget, and obtains the corresponding attribute of the script plug-in to be loaded according to the keyword < NETSCAPELIB > and < standardliib >, so as to conveniently read the script plug-in to be loaded.
In step S211, in this embodiment, the Widget engine of the mobile terminal may find the script plug-in that needs to be loaded according to the attribute of the script plug-in that needs to be loaded, which is obtained in step S210, by using the interface function provided by the operating system of the mobile terminal. And opening the script plug-in to be loaded to obtain an interface function provided by the script plug-in to the outside. The interface function includes: initializing the interface function of the plug-in, obtaining the interface function of the plug-in entry function, closing the interface function of the plug-in, and the like. The interface function is an export interface function specified by the script plug-in.
The Widget engine constructs a data type variable defined by a browser engine, and calls the initialization plug-in interface function as a parameter to initialize the script plug-in; the Widget engine calls the interface function for obtaining the plug-in entry function to obtain the entry function operated by the script plug-in.
In step S212, in this embodiment, the Widget engine of the mobile terminal may call an entry function run by the script plug-in, and embed the plug-in the browser engine.
After receiving the mobile Widget closing message, the Widget engine can check whether an interface function of the closing plug-in of the script plug-in exists, and if so, the Widget engine calls the interface function of the closing plug-in to unload the plug-in; the Widget engine may then shut itself down.
Referring to fig. 5, an embodiment of the Widget engine 30 of the present invention is provided, which includes an obtaining module 31 and a loading module 32; the obtaining module 31 is configured to obtain an attribute preconfigured by a script plug-in to be loaded in the Widget package; the loading module 32 is configured to load the script plug-in into the browser engine according to the attribute preconfigured by the script plug-in.
The obtaining module 31 may obtain the configured attributes of the script plug-in advance, and determine the script plug-in to be loaded. The loading module 32 may call a plug-in interface of the script plug-in according to the configured attributes (such as name, type, path, and the like), and load the script plug-in to be loaded into the browser engine.
The Widget engine 30 of this embodiment may directly call a plug-in interface, load a script plug-in advance, and need not to make a statement in a script, thereby improving user experience. Meanwhile, because the resources of the mobile terminal are limited, the Widget engine 30 is used in the mobile terminal, which has a more significant effect.
Referring to fig. 6, another embodiment of the Widget engine 30 of the present invention is provided, where the Widget engine 30 further includes a storage module 33, which is configured to search for a needed script plug-in and store the needed script plug-in a Widget package. The searching can be to search for a needed (including version updating) script plug-in the mobile terminal, and save the attribute (including name, path, type and the like) of the script plug-in to the configuration file of the Widget package through pre-configuration; the searching may also be performed outside the mobile terminal, for example, by searching for a required script plug-in through a network, downloading and storing the script plug-in into the Widget package according to a network path (for example, a URL), and storing the attribute of the script plug-in into a configuration file of the Widget package through pre-configuration.
In this embodiment, the pre-configuring may specifically include adding a keyword to a configuration file of the Widget package, and identifying a script plug-in to be loaded by configuring an attribute of the keyword.
In this embodiment, the pre-configuring may further specifically include: adding extension keywords in a configuration file of the Widget package, and setting the name and the path of the script plug-in the attribute; or, adding a standard keyword in a configuration file of the Widget package, and setting the name of the script plug-in the attribute.
In this embodiment, the loading module 32 may be specifically configured to: reading keywords of a configuration file of the Widget package to obtain the attribute of the script plug-in needing to be loaded; acquiring an interface function of the script plug-in according to the attribute, and calling the interface function to acquire an entry function operated by the script plug-in; and calling the entry function, and loading the script plug-in into the browser engine.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.