Event handling method, device, equipment and computer-readable storage medium

By mounting and automatically delegating HTML elements, the problem of low maintenance efficiency between HTML elements and event processors is solved, efficient event processing and querying is achieved, and different browser environments are adapted.

CN113392357BActive Publication Date: 2025-07-25WEBANK (CHINA)
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110742531.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-06-30
Publication Date
2025-07-25
Estimated Expiration
2041-06-30

AI Technical Summary

Technical Problem

In the prior art, maintenance efficiency between HTML elements and event processors is low. Especially when the number of HTML elements on the page is huge, maintenance difficulty at the code level increases, reducing maintenance efficiency.

Method used

By mounting the HTML element to be delegated in the page, adding the first event processor, and associating the configuration information, uninstalling unnecessary processors, determining the unique identifier and common parent element, and mounting the second event processor based on the event type, realizing the automated delegation of events.

Benefits of technology

It improves the maintenance efficiency between HTML elements and event processors, reduces memory usage, simplifies the query process, improves event triggering efficiency, and implements a non-invasive transformation, solving the compatibility problems of different browsers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113392357B_ABST
    Figure CN113392357B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of financial technology (Fintech), and discloses an event processing method, including: mounting events on the hypertext markup language (HTML) elements to be entrusted in a page to add a first event processor to the HTML elements to be entrusted; associating and storing each of the first event processors and the configuration information corresponding to the first event processor, and uninstalling the first event processors of each of the HTML elements to be entrusted; determining the unique identifier corresponding to each of the HTML elements to be entrusted, and determining a common parent element in each of the HTML elements to be entrusted; mounting an event 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 present invention also discloses an event processing device, equipment and computer-readable storage medium. The present invention realizes the automatic delegation of events and improves the maintenance efficiency between HTML elements and event processors.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of financial technology (Fintech), and particularly to an event processing method, apparatus, device, and computer-readable storage medium. Background Art

[0002] With the development of computer technology, more and more technologies (such as big data, distributed, artificial intelligence, etc.) are applied in the financial field. The traditional financial industry is gradually transforming into financial technology (Fintech). However, due to the security and generality requirements of the financial industry, higher requirements are also put forward for risk event monitoring technology.

[0003] When a user uses a web page, it is often necessary to interact with a web server. For example, various data or information are uploaded and published through the web page, including uploading and saving various data such as text, pictures, or files to the server, and being able to further display the data saved on the server through the web page.

[0004] In existing web pages, there are many HTML (hypertext markup language) elements on the page. In order to enable the HTML elements to implement corresponding page behaviors, and due to different browsers, in order to prevent incompatibility problems caused by different browsers, it is necessary to manually add specific identifiers to the HTML elements that need to listen for events, and then bind specific event handlers to facilitate maintaining the mapping relationship between the HTML elements and each event handler. However, since it is necessary to manually maintain the mapping relationship between each HTML element and each event handler, when the number of HTML elements on the page is huge, it increases the maintenance difficulty at the code level and reduces the maintenance efficiency between the HTML elements and the event handlers.

[0005] The above content is only used to assist in understanding the technical solution of the present invention, and does not represent an admission that the above content is prior art. Summary of the Invention

[0006] The main objective of the present invention is to provide an event processing method, apparatus, device, and computer-readable storage medium, aiming to solve the technical problem of low maintenance efficiency between HTML elements and event handlers.

[0007] To achieve the above objective, the present invention provides an event processing method, and the event processing method includes the following steps:

[0008] Perform event mounting on the hypertext markup language (HTML) elements to be entrusted in the page to add a first event handler to the to-be-entrusted HTML elements;

[0009] Associate and store each of the first event handlers and the configuration information corresponding to the first event handlers, and unload the first event handlers of each of the HTML elements to be delegated;

[0010] Determine the unique identifier corresponding to each of the HTML elements to be delegated, and determine the common parent element among each of the HTML elements to be delegated;

[0011] Mount an event on the common parent element based on the event type of the first event handler, so as to add a second event handler to the common parent element.

[0012] Further, the step of associating and storing each of the first event handlers and the configuration information corresponding to the first event handlers, and unloading the first event handlers of each of the HTML elements to be delegated includes:

[0013] Based on the event type of the first event handler, associate and store each of the first event handlers and the configuration information corresponding to the first event handlers in a first preset storage area;

[0014] Unload the first event handlers of each of the HTML elements to be delegated.

[0015] Further, the first preset storage area includes the eventStorage attribute of each of the HTML elements to be delegated, and the step of unloading the first event handlers of each of the HTML elements to be delegated includes:

[0016] Traverse each of the HTML elements to be delegated in sequence. If the first event handler is stored in the eventStorage attribute of the currently traversed HTML element, unload the first event handler corresponding to the currently traversed HTML element until all the HTML elements to be delegated are traversed.

[0017] Further, the step of determining the unique identifier corresponding to each of the HTML elements to be delegated includes:

[0018] Based on the element name, timestamp, and random number of each of the HTML elements to be delegated, determine the unique identifier corresponding to each of the HTML elements to be delegated;

[0019] The method further includes:

[0020] Based on each of the first event handlers and the unique identifier, determine the event handler list corresponding to each of the HTML elements to be delegated, and store the event handler list in a second preset storage area.

[0021] Further, after the step of mounting an event 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:

[0022] When detecting the target event type triggered currently, determining a target common parent element corresponding to the target event type in the HTML elements of the page;

[0023] In the event processor mounted on the target common parent element, obtaining a third event processor corresponding to the target event type;

[0024] Triggering the third event processor to determine whether a target unique identifier exists for a target HTML element corresponding to the target event type through the third event processor;

[0025] 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.

[0026] Further, the step of determining a target event processor corresponding to the target event type based on the target unique identifier includes:

[0027] Based on the target unique identifier, determining a list of event processors corresponding to the target HTML element in a second preset storage area;

[0028] Based on the list of event processors, obtaining the target event processor in a first preset storage area.

[0029] Further, the step of determining a target common parent element corresponding to the target event type in the HTML elements of the page includes:

[0030] Based on the event bubbling mechanism of the browser, determining a target common parent element corresponding to the target event type in the HTML elements of the page.

[0031] In addition, to achieve the above object, the present invention further provides an event processing device, where the event processing device includes:

[0032] A first mounting module, configured to mount an event on a to-be-delegated hypertext markup language (HTML) element in a page to add a first event processor to the to-be-delegated HTML element;

[0033] A storage module, configured to associatively store each of the first event processors and configuration information corresponding to the first event processors, and unmount the first event processors of each of the to-be-delegated HTML elements;

[0034] A determination module, configured to determine a unique identifier corresponding to each of the to-be-delegated HTML elements, and determine a common parent element among each of the to-be-delegated HTML elements;

[0035] A second mounting module, configured to perform event mounting 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.

[0036] In addition, to achieve the above object, the present invention further provides an event processing device, where the event processing device includes: a memory, a processor, and an event processing program stored on the memory and executable on the processor, and when the event processing program is executed by the processor, the steps of the foregoing event processing method are implemented.

[0037] In addition, to achieve the above object, the present invention further provides a computer-readable storage medium, where an event processing program is stored on the computer-readable storage medium, and when the event processing program is executed by a processor, the steps of the foregoing event processing method are implemented.

[0038] By mounting events on the to-be-delegated HyperText Markup Language (HTML) elements in a page to add a first event processor to the to-be-delegated HTML elements; then associating and storing each of the first event processors and the configuration information corresponding to the first event processors, and uninstalling the first event processors of each of the to-be-delegated HTML elements; then determining a unique identifier corresponding to each of the to-be-delegated HTML elements, and determining a common parent element among each of the to-be-delegated HTML elements; and then 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 present invention realizes automatic delegation of events, automatically mounts event processors of event types corresponding to multiple HTML elements onto a common parent element, and associates and stores the event processors of each HTML element, without the need to spend effort maintaining the correspondence between HTML elements and event processors, improves the maintenance efficiency between HTML elements and event processors, is convenient for querying without occupying additional memory space, and improves the efficiency of subsequent event triggering. Description of the Drawings

[0039] Figure 1 is a schematic structural diagram of an event processing device in a hardware operating environment related to the embodiment solution of the present invention;

[0040] Figure 2 is a schematic flowchart of the first embodiment of the event processing method of the present invention;

[0041] Figure 3 is a schematic diagram of functional modules of an embodiment of the event processing device of the present invention.

[0042] The realization, functional features and advantages of the object of the present invention will be further described with reference to the accompanying drawings in conjunction with the embodiments. Specific embodiments

[0043] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0044] As Figure 1 shown, Figure 1 is a schematic structural diagram of an event processing device in the hardware operating environment involved in the embodiment solution of the present invention.

[0045] The event processing device in the embodiment of the present invention may be a PC, or a smart phone, a tablet computer, an e-book reader, an MP3 (Moving Picture Experts Group Audio Layer III) player, an MP4 (Moving Picture Experts Group Audio Layer IV) player, a portable computer and other movable terminal devices with a display function.

[0046] As Figure 1 shown, 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. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and optionally the user interface 1003 may further include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a 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 optionally be a storage device independent of the aforementioned processor 1001.

[0047] Optionally, the event processing device may further include a camera, an RF (Radio Frequency) circuit, sensors, an audio circuit, a WiFi module, and so on. Among them, the sensors such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor. Among them, the ambient light sensor can adjust the brightness of the display screen according to the brightness of the ambient light, and the proximity sensor can turn off the display screen and / or the backlight when the mobile event processing device is moved to the ear. As a kind of motion sensor, the gravity acceleration sensor can detect the magnitude of the acceleration in each direction (generally three axes). When stationary, it can detect the magnitude and direction of gravity, and can be used for applications that identify the posture of the event processing device (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; of course, the event processing device can also be configured with other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be elaborated here.

[0048] Those skilled in the art can understand that Figure 1 the terminal structure shown in does not constitute a limitation on the event processing device, and may include more or fewer components than shown in the figure, or combine some components, or have different component arrangements.

[0049] As Figure 1 shown, in the memory 1005 as a kind of computer storage medium, an operating system, a network communication module, a user interface module, and an event processing program may be included.

[0050] In Figure 1 the event processing device shown, the network interface 1004 is mainly used to connect to the background server and communicate with the background server for data; the user interface 1003 is mainly used to connect to the client (user side) and communicate with the client for data; and the processor 1001 can be used to call the event processing program stored in the memory 1005.

[0051] In this embodiment, the event processing device includes: a memory 1005, a processor 1001, and an event processing program stored on the memory 1005 and executable on the processor 1001. Among them, when the processor 1001 calls the event processing program stored in the memory 1005, the following operations are performed:

[0052] Mount events on the HTML elements to be entrusted in the page to add a first event processor to the HTML elements to be entrusted;

[0053] Associate and store each of the first event processors and the configuration information corresponding to the first event processor, and unload the first event processors of each of the HTML elements to be entrusted;

[0054] Determine the unique identifier corresponding to each of the to-be-delegated HTML elements, and determine the common parent element among each of the to-be-delegated HTML elements;

[0055] Mount an event on the common parent element based on the event type of the first event handler, so as to add a second event handler to the common parent element.

[0056] Further, the processor 1001 can call the event handling program stored in the memory 1005 and also perform the following operations:

[0057] Based on the event type of the first event handler, associate and store each of the first event handlers and the configuration information corresponding to the first event handler in a first preset storage area;

[0058] Unload the first event handlers of each of the to-be-delegated HTML elements.

[0059] Further, the processor 1001 can call the event handling program stored in the memory 1005 and also perform the following operations:

[0060] Traverse each of the to-be-delegated HTML elements in sequence. If a first event handler is stored in the eventStorage attribute of the currently traversed HTML element, unload the first event handler corresponding to the currently traversed HTML element until all the to-be-delegated HTML elements are traversed.

[0061] Further, the processor 1001 can call the event handling program stored in the memory 1005 and also perform the following operations:

[0062] Based on the element name, timestamp, and random number of each of the to-be-delegated HTML elements, determine the unique identifier corresponding to each of the to-be-delegated HTML elements;

[0063] Based on each of the first event handlers and the unique identifier, determine the event handler list corresponding to each of the to-be-delegated HTML elements, and store the event handler list in a second preset storage area.

[0064] Further, the processor 1001 can call the event handling program stored in the memory 1005 and also perform the following operations:

[0065] When detecting the currently triggered target event type, determine the target common parent element corresponding to the target event type among the HTML elements of the page;

[0066] Among the event handlers mounted on the target common parent element, obtain the third event handler corresponding to the target event type;

[0067] Trigger the third event processor to determine whether a target unique identifier exists for the target HTML element corresponding to the target event type through the third event processor;

[0068] If a target unique identifier exists, based on the target unique identifier, determine the target event processor corresponding to the target event type, and trigger the target event processor.

[0069] Further, the processor 1001 may call the event handling program stored in the memory 1005 and further perform the following operations:

[0070] Based on the target unique identifier, determine the event processor list corresponding to the target HTML element in the second preset storage area;

[0071] Based on the event processor list, obtain the target event processor in the first preset storage area.

[0072] Further, the processor 1001 may call the event handling program stored in the memory 1005 and further perform the following operations:

[0073] Based on the event bubbling mechanism of the browser, determine the target common parent element corresponding to the target event type among the HTML elements of the page.

[0074] The present invention also provides an event handling method, refer to Figure 2 , Figure 2 which is a schematic flowchart of the first embodiment of the event handling method of the present invention.

[0075] It should be noted that when an event processor needs to be added to an HTML element, the native method addEventListener of the page needs to be called. However, this native method cannot be directly used to implement the event handling process of this embodiment. Therefore, in the embodiment of the present invention, three parameters need to be passed into addEventListener: event type, event processor, and event processor configuration. In this embodiment, in order to overcome the influence brought by page platform differences (unable to directly obtain the events already added to the HTML element), the addEventListener method needs to be encapsulated twice to form the addEvent method. Specifically, the event processor and the event processor configuration are classified according to the event type, and then associated with the HTML element in the form of an object, and the association between the HTML element and the event processor is achieved in advance to form the addEvent method, that is, the applied event handling method.

[0076] In this embodiment, the event handling method includes the following steps:

[0077] Step S101: Mount an event on the hypertext markup language (HTML) element to be delegated on the page to add a first event handler to the HTML element to be delegated.

[0078] In this embodiment, first obtain the HTML element to be delegated on the page. The HTML element to be delegated refers to the HTML element that needs to apply this application among all the HTML elements on the current browser page.

[0079] Next, mount an event on the HTML element to be delegated to add a first event handler to the HTML element to be delegated. That is to say, when starting to call the addEvent method, add a first event handler to the HTML element to be delegated.

[0080] Step S102: Associate and store each of the first event handlers and the configuration information corresponding to the first event handlers, and unmount the first event handlers of each of the HTML elements to be delegated.

[0081] In this embodiment, when the mounting of the first event handler on the HTML element to be delegated is completed, associate and store each of the first event handlers and the configuration information corresponding to the first event handlers. Specifically, according to the event type of the first event handler, associate and store each of the first event handlers and the configuration information corresponding to the first event handlers in a first preset storage area. For example, save the first event handler and the configuration information in the form of a "key-value pair" in the eventStorage attribute of the HTML element. At this time, in addition to having their own event handlers, each HTML element also saves all the event handlers and their configuration information in the eventStorage attribute according to the event type. That is to say, the first preset storage area is the eventStorage attribute of each HTML element, so as to search for the event handlers of each HTML element in the eventStorage attribute later.

[0082] Subsequently, unload the first event handlers of each of the to-be-delegated HTML elements. Specifically, traverse all the to-be-delegated HTML elements, and based on the event handlers saved in the eventStorage attribute of the current element, unload the event handlers on the current element one by one. That is, if there is an event handler stored in the eventStorage attribute of the currently traversed HTML element, unload the first event handler on the current element. It should be understood that since the event handlers of each HTML element already exist in the first preset storage area, the first event handlers of each of the to-be-delegated HTML elements can be unloaded at this time, which can reduce the multiple storage of content and the consumption of storage space for each to-be-delegated HTML element. Moreover, by unloading the first event handlers of the to-be-delegated HTML elements, the separate use of the addEvent method can also be achieved without affecting any original functions, truly achieving a non-intrusive transformation.

[0083] Step S103: Determine the unique identifier corresponding to each of the to-be-delegated HTML elements, and determine the common parent element among each of the to-be-delegated HTML elements.

[0084] In this embodiment, when the unloading of the event handlers is completed, determine the unique identifier corresponding to each of the to-be-delegated HTML elements, generate a globally unique identifier eventSourceSymbol for each to-be-delegated HTML element, and save the unique identifier eventSourceSymbol as an attribute of the HTML element in the corresponding to-be-delegated HTML element, which is convenient for quickly querying or retrieving relevant parameters of the to-be-delegated HTML element such as event handlers based on the unique identifier in the future.

[0085] Then, determine the common parent element among each of the to-be-delegated HTML elements, and find the common parent element corresponding to all the to-be-delegated HTML elements through a recursive algorithm.

[0086] Specifically, for all the to-be-delegated HTML elements, first compare the first two sub-HTML elements. If element 1 contains element 2, it means that element 1 is the parent element of element 2, and return element 1. If element 1 does not contain element 2, then try to determine whether the parent element of element 1 contains element 2, and so on, to obtain the parent elements of element 1 and element 2; use the calculation results of the first two elements (the parent elements of element 1 and 2), and then calculate with element 3, and the parent element of element 1, 2, and 3 will be obtained, and so on, until the common parent element of all elements is found.

[0087] Step S104: Mount an event on the common parent element based on the event type of the first event handler, and add a second event handler to the common parent element.

[0088] In this embodiment, after obtaining the common parent element, the event types corresponding to each first event handler are obtained, that is, the event types of all first event handlers, and event mounting is performed on the common parent element based on the event types of the first event handlers, so as to add a second event handler to the common parent element, where the number of second event handlers is the same as the number of event types of the first event handlers.

[0089] It should be understood that in the embodiment of the present invention, the first event handler is added to the HTML element through the addEvent method of secondary encapsulation. Equivalent to when adding an event, the relationship between the HTML element and the event handler is collected. Therefore, different browsers can adaptively add their corresponding event handlers according to their actual HTML elements. At this time, the problem of incompatibility between different browsers does not need to be considered (so there is no such defect problem); in addition, the collected event handlers are saved in the form of references on the eventStorage attribute of the first preset storage area corresponding to the HTML element, which not only does not occupy extra memory space but also is convenient for quick query (obtaining a certain HTML element also obtains all its event handlers).

[0090] It should be noted that in this embodiment, the addEvent method is obtained through secondary encapsulation, providing a non-invasive transformation solution that does not damage the structure of the existing business code: only when adding an event handler to an HTML element, replacing it with the addEvent method provided by this solution has completed the necessary prerequisite for automated transformation (classifying all involved event handlers by element and type), and then calling the transformation method provided by this solution once more can complete the transformation.

[0091] It should be understood that under the conventional solution, manual maintenance is required. Even when binding HTML elements and events, generally, it is necessary to sort out the relationship between each HTML element and its various types of events and then make transformations at the code level. As the amount of code increases, it will inevitably cause a large amount of costs.

[0092] The event handling method proposed in this embodiment mounts events on the hypertext markup language (HTML) elements to be delegated in a page to add a first event handler to the HTML elements to be delegated. Then, it associates and stores each of the first event handlers and the configuration information corresponding to the first event handlers, and unmounts the first event handlers of each of the HTML elements to be delegated. Then, it determines the unique identifier corresponding to each of the HTML elements to be delegated, and determines a common parent element in each of the HTML elements to be delegated. Then, it mounts an event on the common parent element based on the event type of the first event handler to add a second event handler to the common parent element, realizing automated event delegation. The event handlers of the event types corresponding to multiple HTML elements are automatically mounted on the common parent element, and the event handlers of each HTML element are associated and stored. There is no need to spend effort maintaining the correspondence between the HTML elements and the event handlers, improving the maintenance efficiency between the HTML elements and the event handlers. It is convenient to query without occupying additional memory space, improving the efficiency of subsequent event triggering. It achieves non-invasive transformation and solves the problem at the root cause.

[0093] Based on the first embodiment, a second embodiment of the event handling method of the present invention is proposed. In this embodiment, step S102 includes:

[0094] Step S201, based on the event type of the first event handler, associate and store each of the first event handlers and the configuration information corresponding to the first event handlers in a first preset storage area;

[0095] Step S202, unmount the first event handlers of each of the HTML elements to be delegated.

[0096] In this embodiment, according to the event type of the first event handler, each of the first event handlers and the configuration information corresponding to the first event handlers are associated and stored in a first preset storage area. For example, the first event handler and the configuration information are saved in the eventStorage attribute of the current HTML element in the form of a "key-value pair". At this time, in addition to having their own event handlers, each HTML element also saves all the event handlers and their configuration information in the eventStorage attribute according to the event type. That is to say, the first preset storage area includes the eventStorage attributes of each of the HTML elements to be delegated.

[0097] Then, unmount the first event handlers of each of the HTML elements to be delegated.

[0098] Further, in one embodiment, the first preset storage area includes the eventStorage attributes of each of the HTML elements to be entrusted, and step S202 includes:

[0099] Traverse each of the HTML elements to be entrusted in sequence. If a first event handler is stored in the eventStorage attribute of the currently traversed HTML element, unload the first event handler corresponding to the currently traversed HTML element until all the HTML elements to be entrusted are traversed.

[0100] Specifically, traverse all the HTML elements to be entrusted. Based on the first event handler saved in the eventStorage attribute of the currently traversed HTML element, unload the first event handlers on the current element in sequence, that is, if a first event handler is stored in the eventStorage attribute of the currently traversed HTML element, unload the first event handler on the current element until all the HTML elements to be entrusted are traversed.

[0101] The event handling method proposed in this embodiment associates and stores each of the first event handlers and the configuration information corresponding to the first event handlers in the first preset storage area based on the event type of the first event handler; then unloads the first event handlers of each of the HTML elements to be entrusted. By unloading the first event handlers, it is possible to avoid the first event handlers mounted while storing the first event handlers in the eventStorage attribute of the HTML element, avoid occupying additional memory space, and improve resource utilization.

[0102] Based on the first embodiment, a third embodiment of the event handling method of the present invention is proposed. In this embodiment, step S103 includes:

[0103] Step S301, determine the unique identifier corresponding to each of the HTML elements to be entrusted based on the element name, timestamp, and random number of each of the HTML elements to be entrusted;

[0104] This event handling method further includes:

[0105] Step S302, determine the event handler list corresponding to each of the HTML elements to be entrusted based on each of the first event handlers and the unique identifier, and store the event handler list in the second preset storage area.

[0106] In the traditional solution, since manual maintenance is involved, the readability and maintainability of the code need to be considered. When creating an identifier for each HTML element, the identifier needs to be created in combination with elements, scenarios, events, etc. It not only needs to be globally unique but also ensure readability. Usually, for each HTML element to be delegated, a unique identifier is obtained according to the element name, scenario identifier, and event type identifier. For these scenarios, specific scenarios and event types need to be identified, so the generated identifier is relatively complex.

[0107] In this embodiment, in order to avoid manual maintenance and improve the automatic convenience of event processing, therefore, based on the element name, timestamp, and random number of each of the HTML elements to be delegated, the unique identifier corresponding to each of the HTML elements to be delegated is determined, that is, the unique identifier eventSourceSymbol is automatically generated in the way of "element name + timestamp + random number", and eventSourceSymbol is saved as an element attribute in the corresponding HTML element. Since the processing times of different HTML elements to be delegated generally vary, therefore, combining the parameter of the timestamp can effectively realize the generation of the identifier. Further, in order to avoid the processing of different HTML elements to be delegated at the same time point, therefore, a random number is further combined to generate the identifier, truly ensuring the uniqueness of the identifier, and moreover, the acquisition of the timestamp and the random number is relatively simple, without the need to identify specific scenarios and event types, truly achieving the automation and simplicity of the process.

[0108] Then, based on each of the first event processors and the unique identifier, with the unique identifier as the key and the event processor corresponding to the HTML element to be delegated as the value, the event processor list (key and value) corresponding to each of the HTML elements to be delegated is determined, and the event processor list is stored in the second preset storage area so as to facilitate accurately finding the event processors of each HTML element according to the unique identifier subsequently.

[0109] It should be noted that in this embodiment, the event processor list is stored in the second preset storage area with the unique identifier and the event processor. Different from the event processors and configuration information stored in the first preset storage area, this embodiment improves the flexibility of information storage and also improves the flexibility of subsequent information search.

[0110] In this embodiment, a globally shared storage space can also be created to store all the event types corresponding to the first event processors, for example, stored in the third preset storage area, so as to save the event types that have not been saved.

[0111] The event processing method proposed in this embodiment determines the unique identifier corresponding to each HTML element to be delegated based on the element name, timestamp and random number of each HTML element to be delegated, thereby realizing simple and automatic generation of the unique identifier; then, based on each of the first event handlers and the unique identifier, determines the event handler list corresponding to each HTML element to be delegated, stores the event handler list in a second preset storage area, and associates the storage to facilitate subsequent accurate search for the event handler of each HTML element according to the unique identifier, thereby improving the flexibility and convenience of information storage and search in the event processing scheme.

[0112] Based on the above embodiments, a fourth embodiment of the event processing method of the present invention is proposed. In this embodiment, after step S104, the method further includes:

[0113] Step S401, when the currently triggered target event type is detected, determining a target common parent element corresponding to the target event type in the HTML element of the page;

[0114] Step S402, obtaining a third event handler corresponding to the target event type from among the event handlers mounted on the target common parent element;

[0115] Step S403, triggering the third event handler to determine whether a target HTML element corresponding to the target event type has a target unique identifier through the third event handler;

[0116] Step S404: If there is a target unique identifier, a target event handler corresponding to the target event type is determined based on the target unique identifier, and the target event handler is triggered.

[0117] In this embodiment, when the currently triggered target event type is detected, the target common parent element corresponding to the target event type is determined in the HTML element of the page. Specifically, based on the event bubbling mechanism of the browser, the target common parent element corresponding to the target event type is determined in the HTML element of the page. Specifically, when an HTML element in the browser triggers a certain event, the browser will start from the current element, find its parent elements at all levels in turn and check whether there are events of the corresponding type. If so, they will be triggered in turn until the process reaches the root element of the document, that is, the HTML element. Then, in the event handler mounted on the target common parent element, the third event handler corresponding to the target event type is obtained. The third event handler is essentially the same as the second event handler mentioned above. This is only for the purpose of distinction, that is, to determine the third event handler whose event type is consistent with the target event type among all the event handlers mounted on the target common parent element.

[0118] Next, trigger the third event processor, determine the target HTML element corresponding to the target event type through the third event processor, and determine whether the target HTML element has a target unique identifier. If there is a target unique identifier, determine that the target HTML element belongs to the HTML element to be delegated. Further, based on the target unique identifier, determine the target event processor corresponding to the target event type, and trigger the target event processor.

[0119] Further, in one embodiment, step S404 includes:

[0120] Step a, based on the target unique identifier, determine the event processor list corresponding to the target HTML element in the second preset storage area;

[0121] Step b, based on the event processor list, obtain the target event processor in the first preset storage area.

[0122] In this embodiment, first, according to the target unique identifier, determine the event processor list corresponding to the target HTML element in the second preset storage area, and based on the event processor list, obtain the target event processor in the first preset storage area, that is, obtain the target event processor in the eventStorage attribute of the target HTML element, so as to implement the specific process of event handling through the target event processor.

[0123] The event handling method proposed in this embodiment, when detecting the currently triggered target event type, determines the target common parent element corresponding to the target event type in the HTML elements of the page; then, among the event processors mounted on the target common parent element, obtains the third event processor corresponding to the target event type; then triggers the third event processor to determine whether the target HTML element corresponding to the target event type has a target unique identifier through the third event processor; then, if there is a target unique identifier, based on the target unique identifier, determine the target event processor corresponding to the target event type, and trigger the target event processor, realizing the triggering of the target event processor, and further realizing the page function.

[0124] In addition, an event handling device is also proposed in an embodiment of the present invention. Refer to Figure 3 , the event handling device includes:

[0125] The first mounting module 10 is used to mount events on the HTML elements to be delegated in the page to add a first event processor to the HTML elements to be delegated;

[0126] A storage module 20, configured to associatively store each of the first event handlers and the configuration information corresponding to the first event handlers, and unload the first event handlers of each of the to-be-delegated HTML elements;

[0127] A determination module 30, configured to determine the unique identifier corresponding to each of the to-be-delegated HTML elements, and determine a common parent element among each of the to-be-delegated HTML elements;

[0128] A second mounting module 40, configured to perform event mounting on the common parent element based on the event type of the first event handler, so as to add a second event handler to the common parent element.

[0129] Further, the storage module 20 is further configured to:

[0130] Based on the event type of the first event handler, associatively store each of the first event handlers and the configuration information corresponding to the first event handlers into a first preset storage area;

[0131] Unload the first event handlers of each of the to-be-delegated HTML elements.

[0132] Further, the storage module 20 is further configured to:

[0133] Traverse each of the to-be-delegated HTML elements in sequence. If a first event handler is stored in the eventStorage attribute of the currently traversed HTML element, unload the first event handler corresponding to the currently traversed HTML element until all the to-be-delegated HTML elements are traversed.

[0134] Further, the determination module 30 is further configured to:

[0135] Based on the element name, timestamp, and random number of each of the to-be-delegated HTML elements, determine the unique identifier corresponding to each of the to-be-delegated HTML elements;

[0136] Based on each of the first event handlers and the unique identifier, determine an event handler list corresponding to each of the to-be-delegated HTML elements, and store the event handler list into a second preset storage area.

[0137] Further, the event processing device is further configured to:

[0138] When detecting the currently triggered target event type, determine a target common parent element corresponding to the target event type among the HTML elements of the page;

[0139] Among the event handlers mounted on the target common parent element, obtain a third event handler corresponding to the target event type;

[0140] Trigger the third event processor to determine whether a target unique identifier exists for the target HTML element corresponding to the target event type through the third event processor;

[0141] If a target unique identifier exists, based on the target unique identifier, determine the target event processor corresponding to the target event type, and trigger the target event processor.

[0142] Furthermore, the event processing device is further configured to:

[0143] Based on the target unique identifier, determine a list of event processors corresponding to the target HTML element in a second preset storage area;

[0144] Based on the list of event processors, obtain the target event processor in a first preset storage area.

[0145] Furthermore, the event processing device is further configured to:

[0146] Based on the event bubbling mechanism of the browser, determine a target common parent element corresponding to the target event type among the HTML elements of the page.

[0147] In addition, an embodiment of the present invention further provides a computer-readable storage medium, on which a merchant rating program is stored. When the merchant rating program is executed by a processor, the steps of the event processing method described in any one of the above are implemented.

[0148] The specific embodiments of the computer-readable storage medium of the present invention are basically the same as the embodiments of the above event processing method, and will not be described in detail here.

[0149] It should be noted that in this article, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or system. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article or system including the element.

[0150] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages and disadvantages of the embodiments.

[0151] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art can be embodied in the form of a software product. This computer software product is stored in a storage medium as described above (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions for causing a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in various embodiments of the present invention.

[0152] The above are only the preferred embodiments of the present invention, and do not limit the patent scope of the present invention accordingly. Any equivalent structure or equivalent process transformation made by using the content of the specification and drawings of the present invention, or directly or indirectly applied in other related technical fields, shall be equally included in the patent protection scope of the present invention.

Claims

1. An event handling method, characterized in that, The described event handling method includes the following steps: Perform event mounting on the HTML elements to be entrusted in the page to add a first event handler to the HTML elements to be entrusted; Based on the event types of the first event handlers, associate and store each of the first event handlers and the configuration information corresponding to the first event handlers in a first preset storage area; Uninstall the first event handlers of each of the HTML elements to be entrusted; Determine the unique identifier corresponding to each of the HTML elements to be entrusted, and determine the common parent element in each of the HTML elements to be entrusted; Perform event mounting on the common parent element based on the event type of the first event handler to add a second event handler to the common parent element; When the target event type triggered currently is detected, determine the target common parent element corresponding to the target event type in the HTML elements of the page; In the event handlers mounted on the target common parent element, obtain the third event handler corresponding to the target event type; Trigger the third event handler to determine whether the target HTML element corresponding to the target event type has a target unique identifier through the third event handler; If there is a target unique identifier, based on the target unique identifier, determine the event handler list corresponding to the target HTML element in a second preset storage area; Based on the event handler list, obtain the target event handler in the first preset storage area.

2. The event handling method according to claim 1, characterized in that The first preset storage area includes the eventStorage attribute of each of the HTML elements to be entrusted, and the step of uninstalling the first event handlers of each of the HTML elements to be entrusted includes: Traverse each of the HTML elements to be entrusted in sequence. If the first event handler is stored in the eventStorage attribute of the currently traversed HTML element, uninstall the first event handler corresponding to the currently traversed HTML element until all the HTML elements to be entrusted are traversed.

3. The event processing method according to claim 1, wherein The step of determining the unique identifier corresponding to each of the HTML elements to be entrusted includes: Based on the element name, timestamp, and random number of each of the HTML elements to be entrusted, determine the unique identifier corresponding to each of the HTML elements to be entrusted; The method further includes: Based on each of the first event handlers and the unique identifier, determine the event handler list corresponding to each of the HTML elements to be entrusted, and store the event handler list in a second preset storage area.

4. The event processing method according to claim 1, wherein The step of determining the target common parent element corresponding to the target event type in the HTML elements of the page includes: Based on the event bubbling mechanism of the browser, determine the target common parent element corresponding to the target event type in the HTML elements of the page.

5. An event processing device, characterized in that, The event handling device includes: A first mounting module, configured to perform event mounting on the HTML elements to be entrusted in the page to add a first event handler to the HTML elements to be entrusted; A storage module, configured to associatively store each of the first event processors and the configuration information corresponding to the first event processor in a first preset storage area based on the event type of the first event processor; unload the first event processors of each of the to-be-delegated HTML elements; A determination module, configured to determine the unique identifier corresponding to each of the to-be-delegated HTML elements, and determine a common parent element among each of the to-be-delegated HTML elements; A second mounting module, 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; when detecting a currently triggered target event type, determine a target common parent element corresponding to the target event type in the HTML elements of the page; in the event processor mounted on the target common parent element, obtain a third event processor corresponding to the target event type; trigger the third event processor to determine whether a target HTML element corresponding to the target event type has a target unique identifier through the third event processor; if there is a target unique identifier, determine a list of event processors corresponding to the target HTML element in a second preset storage area based on the target unique identifier; and obtain the target event processor in the first preset storage area based on the list of event processors.

6. An event processing device, characterized in that, The event processing device includes: a memory, a processor, and an event processing program stored on the memory and executable on the processor, and when the event processing program is executed by the processor, the steps of the event processing method according to any one of claims 1 to 4 are implemented.

7. A computer-readable storage medium, characterized in that, An event processing program is stored on the computer-readable storage medium, and when the event processing program is executed by a processor, the steps of the event processing method according to any one of claims 1 to 4 are implemented.

Citation Information

Patent Citations

  • Method and device for determining corresponding processing according to event collection correlated with webpages

    CN103425775A

  • System for determining layouts of webpages

    US10460018B1