Disclosure of Invention
The invention mainly aims to provide an event processing method, an event processing device, event processing equipment and a computer readable storage medium, and aims to solve the technical problem of low maintenance efficiency between an HTML element and an event processor.
To achieve the above object, the present invention provides an event processing method, including the steps of:
carrying out event mounting on an HTML element to be commissioned in a page so as to add a first event processor for the HTML element to be commissioned;
Storing each first event processor and configuration information corresponding to the first event processor in an associated mode, and unloading each first event processor of the HTML element to be delegated;
determining a unique identifier corresponding to each to-be-commissioned HTML element, and determining a public parent element in each to-be-commissioned HTML element;
and carrying out event mounting on the public parent element based on the event type of the first event processor so as to add a second event processor for the public parent element.
Further, the step of storing the first event processor and the configuration information corresponding to the first event processor in association, and unloading the first event processor of each HTML element to be delegated includes:
Based on the event type of the first event processor, associating and storing each first event processor and configuration information corresponding to the first event processor to a first preset storage area;
And unloading the first event processor of each to-be-delegated HTML element.
Further, the first preset storage area includes eventStorage attributes of each HTML element to be delegated, and the step of unloading the first event handler of each HTML element to be delegated includes:
And traversing each HTML element to be commissioned in sequence, and unloading the first event processor corresponding to the currently traversed HTML element if the first event processor is stored in eventStorage attributes of the currently traversed HTML element until the traversal of each HTML element to be commissioned is completed.
Further, the step of determining the unique identifier corresponding to each HTML element to be delegated includes:
determining unique identifiers corresponding to the HTML elements to be delegated based on the element names, the time stamps and the random numbers of the HTML elements to be delegated;
the method further comprises the steps of:
And determining an event processor list corresponding to each to-be-commissioned HTML element based on each first event processor and the unique identifier, and storing the event processor list to a second preset storage area.
Further, after the step of performing event mounting on the common parent element based on the event type of the first event processor to add a second event processor to the common parent element, the method further includes:
when the current triggered target event type is detected, determining a target public parent element corresponding to the target event type in HTML elements of the page;
acquiring a third event processor corresponding to the target event type from event processors mounted on the target public parent element;
Triggering the third event processor to determine whether a target unique identifier exists in a target HTML element corresponding to the target event type through the third event processor;
If the target unique identifier exists, determining a target event processor corresponding to the target event type based on the target unique identifier, and triggering the target event processor.
Further, the step of determining the target event handler corresponding to the target event type based on the target unique identifier includes:
determining an event processor list corresponding to the target HTML element in a second preset storage area based on the target unique identifier;
And acquiring the target event processor in a first preset storage area based on the event processor list.
Further, the step of determining the target public parent element corresponding to the target event type in the HTML element of the page includes:
And determining a target public parent element corresponding to the target event type in the HTML elements of the page based on an event bubbling mechanism of the browser.
In addition, in order to achieve the above object, the present invention also provides an event processing apparatus including:
the first mounting module is used for carrying out event mounting on the HTML element to be commissioned in the page so as to add a first event processor for the HTML element to be commissioned;
the storage module is used for storing the first event processors and the configuration information corresponding to the first event processors in an associated mode, and unloading the first event processors of the HTML elements to be delegated;
the determining module is used for determining unique identifiers corresponding to the HTML elements to be delegated and determining a public parent element in the HTML elements to be delegated;
And the second mounting module is used for carrying out event mounting on the public parent element based on the event type of the first event processor so as to add a second event processor for the public parent element.
In addition, in order to achieve the above object, the present invention also provides an event processing device, which includes a memory, a processor, and an event processing program stored on the memory and executable on the processor, the event processing program implementing the steps of the event processing method when executed by the processor.
In addition, in order to achieve the above object, the present invention also provides a computer-readable storage medium having stored thereon an event processing program which, when executed by a processor, implements the steps of the aforementioned event processing method.
The method comprises the steps of carrying out event mounting on HTML elements to be commissioned in a page to add a first event processor for the HTML elements to be commissioned, then storing configuration information corresponding to each first event processor and each first event processor in a correlated mode, unloading the first event processor of each HTML element to be commissioned, determining unique identifiers corresponding to each HTML element to be commissioned, determining a public parent element in each HTML element to be commissioned, carrying out event mounting on the public parent element based on event types of the first event processor, adding a second event processor for the public parent element, realizing automatic commission of events, carrying out automatic mounting on event processors corresponding to event types of a plurality of HTML elements on the public parent element, storing the event processors of each HTML element in a correlated mode, and maintaining correspondence between the HTML elements and the event processors without spending effort, improving maintenance efficiency between the HTML elements and the event processors, and being convenient for triggering subsequent events under the premise of not occupying extra memory space.
Detailed Description
It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
Referring to fig. 1, fig. 1 is a schematic structural diagram of an event processing device in a hardware running environment according to an embodiment of the present invention.
The event processing device in the embodiment of the invention can be a PC, or can be a mobile terminal device with a display function, such as a smart phone, a tablet personal computer, an electronic book reader, an MP3 (Moving Picture Experts Group Audio Layer III, dynamic image expert compression standard audio layer 3) player, an MP4 (Moving Picture Experts Group Audio Layer IV, dynamic image expert compression standard audio layer 4) player, a portable computer and the like.
As shown in fig. 1, the event processing device may include a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, and a communication bus 1002. Wherein the communication bus 1002 is used to enable connected communication between these components. The user interface 1003 may include a Display, an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may further include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 1005 may be a high-speed RAM memory or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also optionally be a storage device separate from the processor 1001 described above.
Optionally, the event processing device may further include a camera, an RF (Radio Frequency) circuit, a sensor, an audio circuit, a WiFi module, and the like. Among other sensors, such as light sensors, motion sensors, and other sensors. In particular, the light sensor may include an ambient light sensor that may adjust the brightness of the display screen based on the brightness of ambient light and a proximity sensor that may turn off the display screen and/or backlight when the event processing device is moved to the ear. The gravity acceleration sensor can detect the acceleration in all directions (generally three axes), can detect the gravity and the direction when the gravity acceleration sensor is static, can be used for identifying the gesture of the event processing device (such as transverse and vertical screen switching, related games, magnetometer gesture calibration), vibration identification related functions (such as pedometer and knocking), and the like, and of course, the event processing device can be further provided with other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor and the like, which are not repeated herein.
Those skilled in the art will appreciate that the terminal structure shown in fig. 1 does not constitute a limitation of the event processing device, and may include more or fewer components than shown, or may combine certain components, or may be arranged in a different arrangement of components.
As shown in fig. 1, an operating system, a network communication module, a user interface module, and an event handler may be included in the memory 1005, which is a type of computer storage medium.
In the event processing apparatus shown in fig. 1, the network interface 1004 is mainly used for connecting to a background server and performing data communication with the background server, the user interface 1003 is mainly used for connecting to a client (user side) and performing data communication with the client, and the processor 1001 may be used for calling an event processing program stored in the memory 1005.
In the present embodiment, the event processing apparatus includes a memory 1005, a processor 1001, and an event processing program stored in the memory 1005 and executable on the processor 1001, wherein when the processor 1001 calls the event processing program stored in the memory 1005, the following operations are performed:
carrying out event mounting on an HTML element to be commissioned in a page so as to add a first event processor for the HTML element to be commissioned;
Storing each first event processor and configuration information corresponding to the first event processor in an associated mode, and unloading each first event processor of the HTML element to be delegated;
determining a unique identifier corresponding to each to-be-commissioned HTML element, and determining a public parent element in each to-be-commissioned HTML element;
and carrying out event mounting on the public parent element based on the event type of the first event processor so as to add a second event processor for the public parent element.
Further, the processor 1001 may call an event handler stored in the memory 1005, and further perform the following operations:
Based on the event type of the first event processor, associating and storing each first event processor and configuration information corresponding to the first event processor to a first preset storage area;
And unloading the first event processor of each to-be-delegated HTML element.
Further, the processor 1001 may call an event handler stored in the memory 1005, and further perform the following operations:
And traversing each HTML element to be commissioned in sequence, and unloading the first event processor corresponding to the currently traversed HTML element if the first event processor is stored in eventStorage attributes of the currently traversed HTML element until the traversal of each HTML element to be commissioned is completed.
Further, the processor 1001 may call an event handler stored in the memory 1005, and further perform the following operations:
determining unique identifiers corresponding to the HTML elements to be delegated based on the element names, the time stamps and the random numbers of the HTML elements to be delegated;
And determining an event processor list corresponding to each to-be-commissioned HTML element based on each first event processor and the unique identifier, and storing the event processor list to a second preset storage area.
Further, the processor 1001 may call an event handler stored in the memory 1005, and further perform the following operations:
when the current triggered target event type is detected, determining a target public parent element corresponding to the target event type in HTML elements of the page;
acquiring a third event processor corresponding to the target event type from event processors mounted on the target public parent element;
Triggering the third event processor to determine whether a target unique identifier exists in a target HTML element corresponding to the target event type through the third event processor;
If the target unique identifier exists, determining a target event processor corresponding to the target event type based on the target unique identifier, and triggering the target event processor.
Further, the processor 1001 may call an event handler stored in the memory 1005, and further perform the following operations:
determining an event processor list corresponding to the target HTML element in a second preset storage area based on the target unique identifier;
And acquiring the target event processor in a first preset storage area based on the event processor list.
Further, the processor 1001 may call an event handler stored in the memory 1005, and further perform the following operations:
And determining a target public parent element corresponding to the target event type in the HTML elements of the page based on an event bubbling mechanism of the browser.
The present invention also provides an event processing method, referring to fig. 2, fig. 2 is a schematic flow chart of a first embodiment of the event processing method of the present invention.
It should be noted that, when an event handler needs to be added to one HTML element, the native method addeventlister of the page needs to be called, but the native method cannot be directly used to implement the event processing procedure of this embodiment, so in the embodiment of the present invention, three parameters, namely, event type, event handler, and event handler configuration need to be introduced into the addeventlister. In this embodiment, in order to overcome the influence caused by the difference of the page platforms (the event added on the HTML element cannot be directly obtained), the addEventListener method needs to be encapsulated secondarily to form a addEvent method, specifically, the event processor and the event processor configuration are classified according to the event type, and then are associated with the HTML element in the form of an object, so that the association between the HTML element and the event processor is achieved in advance to form a addEvent method, that is, the applied event processing method.
In this embodiment, the event processing method includes the following steps:
Step S101, carrying out event mounting on an HTML element to be commissioned in a page so as to add a first event processor for the HTML element to be commissioned;
In this embodiment, the HTML elements to be delegated in the page are acquired first, where the HTML elements to be delegated refer to HTML elements that need to use the present application in all HTML elements in the page of the current browser.
Then, the HTML element to be commissioned is event-mounted to add the first event handler to the HTML element to be commissioned, that is, when the method addEvent is started to be invoked, the first event handler is added to the HTML element to be commissioned.
Step S102, storing configuration information corresponding to each first event processor and each first event processor in an associated manner, and unloading each first event processor of the HTML element to be delegated;
in this embodiment, when the mounting of the first event processor is completed by the HTML element to be delegated, the configuration information corresponding to each of the first event processor and the first event processor is stored in association, and specifically, according to the event type of the first event processor, the configuration information corresponding to each of the first event processor and the first event processor is stored in association in a first preset storage area, for example, the first event processor and the configuration information are stored in the eventStorage attribute of the HTML element in a "key value pair" form. In this case, in addition to the respective event handler, each HTML element stores all event handlers and configuration information thereof according to event types in the eventStorage attribute, that is, the first preset storage area is eventStorage attribute of each HTML element, so that the event handler of each HTML element is searched in the eventStorage attribute.
And then unloading the first event processor of each HTML element to be commissioned, specifically traversing all the HTML elements to be commissioned, and unloading the event processors on the current element in turn based on the event processor stored in the attribute of the current element eventStorage, namely unloading the first event processor on the current element if the event processor is stored in the eventStorage attribute of the currently traversed HTML element. It should be understood that, because the event handler of each HTML element already exists in the first preset storage area, at this time, the first event handler of each HTML element to be commissioned may be uninstalled, so that multiple storage of content may be reduced, and consumption of storage space of each HTML element to be commissioned may be reduced. Besides, the first event processor for the HTML element to be commissioned is unloaded, and the single use of the addEvent method can be realized, so that the original functions are not influenced, and the non-invasive transformation is truly realized.
Step S103, determining a unique identifier corresponding to each to-be-delegated HTML element, and determining a public parent element in each to-be-delegated HTML element;
In this embodiment, when the unloading of the event processor is completed, the unique identifier corresponding to each HTML element to be delegated is determined, so as to generate a globally unique identifier eventSourceSymbol for each HTML element to be delegated, and the unique identifier eventSourceSymbol is stored as an attribute of the HTML element in the corresponding HTML element to be delegated, so that the quick query or search of related parameters of the HTML element to be delegated, such as the event processor, can be conveniently implemented according to the unique identifier.
And then, determining a public parent element in each to-be-commissioned HTML element, and finding out the public parent elements corresponding to all to-be-commissioned HTML elements through a recursion algorithm.
Specifically, for all HTML elements to be delegated, first the first two child HTML elements are compared, if element 1 includes element 2, it is stated that element 1 is a parent element of element 2, and element 1 is returned. If the element 1 does not contain the element 2, trying to judge whether the parent element of the element 1 contains the element 2, and the like, obtaining the parent element of the element 1 and the parent element of the element 2, and calculating with the calculation results of the first two elements (the parent elements of the elements 1 and 2) and the element 3, obtaining the parent elements of the elements 1, 2 and 3, and the like, and finally finding the public parent elements of all the elements.
Step S104, carrying out event mounting on the public parent element based on the event type of the first event processor so as to add a second event processor for the public parent element.
In this embodiment, when a common parent element is obtained, event types corresponding to each first event processor, that is, event types of all first event processors, are obtained, and event mounting is performed on the common parent element based on the event types of the first event processors, so as to add second event processors to the common parent element, where the number of the second event processors is the same as the number of the event types of the first event processors.
It should be understood that in the embodiment of the present invention, the first event handler is added to the HTML element by the method addEvent of secondary encapsulation, which is equivalent to collecting the relationship between the HTML element and the event handler when adding the event, so that different browsers can adaptively add their corresponding event handlers according to their actual HTML elements, and at this time, different browser incompatibility problems (such as no defect problem) can be not considered (such as that of the present invention), and in addition, the collected event handlers are saved in the attribute of the first preset storage area eventStorage corresponding to the HTML element in a referencing manner, that is, without occupying additional memory space, and convenient and rapid query (to obtain a certain HTML element and all the event handlers thereof at the same time) can be obtained.
It should be noted that, the embodiment provides a non-invasive transformation scheme by obtaining addEvent method through secondary encapsulation, and does not destroy the structure of the existing service code, namely, the method addEvent provided by the scheme is replaced when an event processor is added for an HTML element, the necessary preconditions for automatic transformation (all related event processors are classified according to elements and types) are already completed, and then the transformation method provided by the scheme is called once again, so that the transformation can be completed.
It should be understood that, in the conventional scheme, maintenance needs to be performed manually, and even if binding between the HTML elements and the events is to be performed, it is generally required to comb the relationship between each HTML element and the various events thereof, and then make modification at the code level, which inevitably causes a great deal of cost with the increase of the code amount.
According to the event processing method, event mounting is conducted on HTML elements to be commissioned in a page to add a first event processor to the HTML elements to be commissioned, configuration information corresponding to each first event processor and each first event processor is stored in a correlated mode, the first event processor of each HTML element to be commissioned is unloaded, unique identifiers corresponding to each HTML element to be commissioned are determined, a public parent element is determined in each HTML element to be commissioned, event mounting is conducted on the public parent element based on event types of the first event processor to add a second event processor to the public parent element, automatic commission of events is achieved, event processors corresponding to a plurality of HTML elements are automatically mounted on the public parent element, the event processors of each HTML element are stored in a correlated mode, maintenance of corresponding relations between the HTML elements and the event processors is not required, maintenance efficiency between the HTML elements and the event processors is improved, the follow-up event can be conveniently queried under the premise that additional memory is not occupied, and the follow-up event efficiency is improved. The method is a noninvasive modification, and solves the problems from the root.
Based on the first embodiment, a second embodiment of the event processing method of the present invention is proposed, in which step S102 includes:
Step S201, based on the event type of the first event processor, associating and storing each of the first event processor and configuration information corresponding to the first event processor to a first preset storage area;
step S202, uninstalling the first event handler of each HTML element to be delegated.
In this embodiment, according to the event type of the first event processor, the first event processor and the configuration information corresponding to the first event processor are stored in association with a first preset storage area, for example, the first event processor and the configuration information are stored in the eventStorage attribute of the current HTML element in the form of "key value pair". In this case, in addition to the respective event handler, each HTML element stores all event handlers and configuration information thereof according to event types in eventStorage attributes, that is, the first preset storage area includes eventStorage attributes of each HTML element to be delegated.
And then, unloading the first event processor of each to-be-delegated HTML element.
Further, in an embodiment, the first preset storage area includes eventStorage attributes of each of the HTML elements to be delegated, and step S202 includes:
And traversing each HTML element to be commissioned in sequence, and unloading the first event processor corresponding to the currently traversed HTML element if the first event processor is stored in eventStorage attributes of the currently traversed HTML element until the traversal of each HTML element to be commissioned is completed.
Specifically, all HTML elements to be commissioned are traversed, and based on the first event processor stored in the attribute of the currently traversed HTML element eventStorage, the first event processor on the current element is unloaded in turn, that is, if the first event processor is stored in the eventStorage attribute of the currently traversed HTML element, the first event processor on the current element is unloaded until the traversal of each HTML element to be commissioned is completed.
According to the event processing method provided by the embodiment, the first event processors of the HTML elements to be commissioned are unloaded by storing the first event processors and the configuration information corresponding to the first event processors in the first preset storage area in an associated mode based on the event types of the first event processors, and the first event processors are unloaded, so that the first event processors which are mounted while the first event processors are stored in eventStorage attributes of the HTML elements are avoided, extra memory space is prevented from being occupied, and resource utilization is improved.
Based on the first embodiment, a third embodiment of the event processing method of the present invention is proposed, in which step S103 includes:
Step S301, determining a unique identifier corresponding to each HTML element to be delegated based on an element name, a time stamp, and a random number of each HTML element to be delegated;
the event processing method further comprises the following steps:
Step S302, determining an event handler list corresponding to each HTML element to be delegated based on each first event handler and the unique identifier, and storing the event handler list in a second preset storage area.
In the traditional scheme, because of the manual maintenance, the legibility and maintainability of codes need to be considered, when an identifier is created for each HTML element, the identifier needs to be created for each HTML element by combining the aspects of the element, the scene, the event and the like, so that the code is globally unique, and the legibility is ensured. In general, for each HTML element to be delegated, a unique identifier is obtained according to an element name, a scene identifier, and an event type identifier, where the scenes need to be identified to identify a specific scene and event type, so that the generated identifier is complex.
In this embodiment, in order to avoid manual maintenance and improve automatic convenience of event processing, therefore, based on the element name, the timestamp and the random number of each HTML element to be commissioned, a unique identifier corresponding to each HTML element to be commissioned is determined, that is, a unique identifier eventSourceSymbol is automatically generated by adopting an "element name+timestamp+random number" manner, and eventSourceSymbol is stored as an element attribute in a corresponding HTML element. Because the processing time of different HTML elements to be commissioned is generally different, the generation of the identifier can be effectively realized by combining the parameter of the timestamp, and further, the identifier is generated by further combining the random number in order to avoid the processing of different HTML elements to be commissioned at the same time point, so that the uniqueness of the identifier is truly ensured, the acquisition of the timestamp and the random number is simpler, the specific scene and event type are not required to be identified, and the process automation and the simplicity are truly realized.
And then, based on each first event processor and the unique identifier, determining event processor lists (key and value) corresponding to each to-be-commissioned HTML element by taking the unique identifier as a key and taking the event processor corresponding to the to-be-commissioned HTML element as a value, and storing the event processor lists into a second preset storage area so as to facilitate the follow-up accurate search of the event processor of each HTML element according to the unique identifier.
It should be noted that, in this embodiment, the unique identifier and the event processor are used as the event processor list to be stored in the second preset storage area, which is different from the event processor and the configuration information stored in the first preset storage area, so that flexibility of information storage is improved, and flexibility of subsequent information searching is also improved.
In this embodiment, a global common storage space may be created to store all event types corresponding to the first event processor, for example, to a third preset storage area, so that event types that are not stored are stored.
According to the event processing method, the unique identifiers corresponding to the HTML elements to be commissioned are determined based on the element names, the time stamps and the random numbers of the HTML elements to be commissioned, so that simple and automatic generation of the unique identifiers is achieved, then the event processor list corresponding to the HTML elements to be commissioned is determined based on the first event processors and the unique identifiers, the event processor list is stored in the second preset storage area, event processors of the HTML elements are accurately searched for according to the unique identifiers, and flexibility and convenience of information storage and searching in an event processing scheme are improved.
Based on the foregoing embodiments, a fourth embodiment of the event processing method according to the present invention is provided, and in this embodiment, after step S104, the method further includes:
Step S401, when the current triggered target event type is detected, determining a target public parent element corresponding to the target event type in HTML elements of the page;
Step S402, acquiring a third event processor corresponding to the target event type from event processors mounted on the target public parent element;
Step S403, triggering the third event processor to determine, by the third event processor, whether a target unique identifier exists in a target HTML element corresponding to the target event type;
step S404, if the target unique identifier exists, determining a target event processor corresponding to the target event type based on the target unique identifier, and triggering the target event processor.
In this embodiment, when the current triggered target event type is detected, a target public parent element corresponding to the target event type is determined in HTML elements of the page, specifically, based on an event bubbling mechanism of a browser, the target public parent element corresponding to the target event type is determined in HTML elements of the page, specifically, when one HTML element in the browser triggers a certain event, the browser starts from the current element, sequentially finds out all levels of parent elements thereof and checks whether events of the corresponding types exist, and if so, sequentially triggers until the process reaches a root element of a document, namely an HTML element. And then, acquiring a third event processor corresponding to the target event type from the event processors mounted on the target public parent element, wherein the third event processor is basically consistent with the second event processor, and the third event processor is only used for distinguishing, namely determining the third event processor with the event type consistent with the target event type from all the event processors mounted on the target public parent element.
And triggering the third event processor, determining a target HTML element corresponding to the target event type through the third event processor, determining whether the target HTML element has a target unique identifier, if so, judging that the target HTML element belongs to the HTML element to be commissioned, further determining the target event processor corresponding to the target event type based on the target unique identifier, and triggering the target event processor.
Further, in an embodiment, step S404 includes:
step a, determining an event processor list corresponding to the target HTML element in a second preset storage area based on the target unique identifier;
And b, acquiring the target event processor in a first preset storage area based on the event processor list.
In this embodiment, an event processor list corresponding to the target HTML element is determined in a second preset storage area according to the target unique identifier, and based on the event processor list, the target event processor is obtained in the first preset storage area, that is, the target event processor is obtained in the eventStorage attribute of the target HTML element, so as to implement a specific process of event processing by the target event processor.
According to the event processing method, when the current triggered target event type is detected, a target public parent element corresponding to the target event type is determined in HTML elements of the page, then a third event processor corresponding to the target event type is obtained in event processors mounted on the target public parent element, then the third event processor is triggered to determine whether a target unique identifier exists in the target HTML elements corresponding to the target event type through the third event processor, then if the target unique identifier exists, the target event processor corresponding to the target event type is determined based on the target unique identifier, and the target event processor is triggered, so that the triggering of the target event processor is realized, and further the page function is realized.
In addition, an embodiment of the present invention further provides an event processing apparatus, referring to fig. 3, where the event processing apparatus includes:
the first mounting module 10 is configured to mount an event on an HTML element to be commissioned in a page, so as to add a first event processor to the HTML element to be commissioned;
The storage module 20 is configured to store the first event processor and configuration information corresponding to the first event processor in an associated manner, and unload the first event processor of each HTML element to be delegated;
a determining module 30, configured to determine a unique identifier corresponding to each HTML element to be delegated, and determine a common parent element in each HTML element to be delegated;
and a second mounting module 40, configured to mount an event on the common parent element based on the event type of the first event processor, so as to add a second event processor to the common parent element.
Further, the storage module 20 is further configured to:
Based on the event type of the first event processor, associating and storing each first event processor and configuration information corresponding to the first event processor to a first preset storage area;
And unloading the first event processor of each to-be-delegated HTML element.
Further, the storage module 20 is further configured to:
And traversing each HTML element to be commissioned in sequence, and unloading the first event processor corresponding to the currently traversed HTML element if the first event processor is stored in eventStorage attributes of the currently traversed HTML element until the traversal of each HTML element to be commissioned is completed.
Further, the determining module 30 is further configured to:
determining unique identifiers corresponding to the HTML elements to be delegated based on the element names, the time stamps and the random numbers of the HTML elements to be delegated;
And determining an event processor list corresponding to each to-be-commissioned HTML element based on each first event processor and the unique identifier, and storing the event processor list to a second preset storage area.
Further, the event processing device is further configured to:
when the current triggered target event type is detected, determining a target public parent element corresponding to the target event type in HTML elements of the page;
acquiring a third event processor corresponding to the target event type from event processors mounted on the target public parent element;
Triggering the third event processor to determine whether a target unique identifier exists in a target HTML element corresponding to the target event type through the third event processor;
If the target unique identifier exists, determining a target event processor corresponding to the target event type based on the target unique identifier, and triggering the target event processor.
Further, the event processing device is further configured to:
determining an event processor list corresponding to the target HTML element in a second preset storage area based on the target unique identifier;
And acquiring the target event processor in a first preset storage area based on the event processor list.
Further, the event processing device is further configured to:
And determining a target public parent element corresponding to the target event type in the HTML elements of the page based on an event bubbling mechanism of the browser.
In addition, an embodiment of the present invention further proposes a computer readable storage medium, on which a merchant rating program is stored, which when executed by a processor, implements the steps of the event processing method as described in any one of the above.
The specific embodiments of the computer readable storage medium of the present invention are substantially the same as the embodiments of the event processing method described above, and will not be described in detail herein.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising one does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The foregoing embodiment numbers of the present invention are merely for the purpose of description, and do not represent the advantages or disadvantages of the embodiments.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (e.g. ROM/RAM, magnetic disk, optical disk) as described above, comprising instructions for causing a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to perform the method according to the embodiments of the present invention.
The foregoing description is only of the preferred embodiments of the present invention, and is not intended to limit the scope of the invention, but rather is intended to cover any equivalents of the structures or equivalent processes disclosed herein or in the alternative, which may be employed directly or indirectly in other related arts.