The content of the invention
It is a primary object of the present invention to solve existing loading object identification code redundancy, later stage code maintenance is very cumbersome, multipleThe problem of miscellaneous.
To achieve the above object, the present invention provides a kind of method for handling loading object, the side of the processing loading objectMethod includes:
Obtain Webpage source code;
Judge whether perform data request code during the Webpage source code is loaded;
If performing data request code during the Webpage source code is loaded, the loading pre-set is calledObject identification code;
The loading object identification code is performed, loading object is shown on the page.
Preferably, if described perform data request code during the Webpage source code is loaded, call pre-Also include before the step of loading object identification code first set:
The loading object identification code is set, and the loading object identification code includes the pattern parameter of loading object.
Preferably, it is described to perform the loading object identification code, also include after the step of loading object is shown on the page:
Judge whether request of data is completed;
If request of data is completed, the loading object is hidden.
Preferably, the step for judging whether to perform data request code during the Webpage source code is loadedSuddenly include:
Judge during the Webpage source code is loaded whether to server to send hypertext transfer protocol requests,The hypertext transfer protocol requests include the request method of data resource, the identifier of data resource;When in the loading netThe hypertext transfer protocol requests are sent to server during page page source code, then show loading the WebpageThe data request code is performed during source code, otherwise shows to be not carried out during the Webpage source code is loadedThe data request code.
Preferably, it is characterised in that it is described to perform the loading object identification code, the step of loading object is being shown on the pageAlso include afterwards:
Change the pattern parameter that object is loaded in the loading object identification code;Or
Delete the loading object identification code.
In addition, to achieve the above object, the present invention also provides a kind of client, and the client includes:
Acquisition module, for obtaining Webpage source code;
First judge module, for judging whether perform request of data generation during the Webpage source code is loadedCode;
Calling module, if for performing data request code during the Webpage source code is loaded, callThe loading object identification code pre-set;
Display module, for performing the loading object identification code, loading object is shown on the page.
Preferably, the client also includes:
Setup module, for setting the loading object identification code, the loading object identification code includes the pattern of loading objectParameter.
Preferably, the client also includes:
Second judge module, for judging whether request of data is completed;
Hidden module, if being completed for request of data, the loading object is hidden.
Preferably, first judge module, specifically it is additionally operable to judge during the Webpage source code is loadedWhether to server hypertext transfer protocol requests are sent, the hypertext transfer protocol requests include the requesting party of data resourceThe identifier of formula, data resource;Passed when sending the hypertext to server during the Webpage source code is loadedDefeated agreement request, then show to perform the data request code during the Webpage source code is loaded, otherwise showThe data request code is not carried out during the Webpage source code is loaded.
Preferably, the client also includes:
Modified module, the pattern parameter of object is loaded in the loading object identification code for changing;Or
Removing module, for deleting the loading object identification code.
The method and client of processing loading object provided by the invention, by being multiplexed loading object identification code to loading objectIt has been shown that, avoid loading the redundancy of object identification code, reduce the difficulty of later stage code maintenance, can largely reduce generation in later stageThe human cost and time cost that code is safeguarded.
Embodiment
It should be appreciated that preferred embodiment described herein is merely to illustrate and explain the present invention, it is not used to limit thisInvention.
Referring to Fig. 1, Fig. 1 is a kind of flow chart of method for handling loading object provided in an embodiment of the present invention, such as Fig. 1 institutesShow, the method for the processing loading object comprises the following steps:
Step S10, Webpage source code is obtained.
In the above-described embodiments, the Webpage source code can be JS (JavaScript, Java script).It can pass throughWLAN obtains Webpage source code, can also obtain Webpage source code by mobile data.Webpage source codeIt can be the source code of the Webpages such as the video playback page, news pages, application program loading page.
By performing Webpage source code, corresponding Webpage can be generated.For example, if Webpage source code is videoPage source code is played, the video playback page is produced according to video playback page source code, video can be shown in the video playback pageData.
Step S20, judge whether perform data request code during the Webpage source code is loaded.
In the above-described embodiments, the data request code can be the code for including hypertext transfer protocol requests, pass throughDigital resource can be asked to server by performing data request code, for example, video data resource, voice data money can be askedSource etc..
In the above-described embodiments, if performing data request code during the Webpage source code is loaded, needThe data resource for wanting the reception server to return, thus need to show loading object, the loading object is used to prompt the user with numberAccording to the state of resource downloading, specifically, loading object can be time schedule bar, can include information such as " loading "Textbox or animation or picture etc..Please if being not carried out data during the Webpage source code is loadedCode is sought, then the data resource for not needing the reception server to return, it is not necessary to display loading object.
Optionally, in above-described embodiment, step S20 specifically may comprise steps of:Judge loading the webpage pageWhether include counting to server transmission hypertext transfer protocol requests, the hypertext transfer protocol requests during the source code of faceAccording to the request method of resource, the identifier of data resource;When being sent out during the Webpage source code is loaded to serverThe hypertext transfer protocol requests are sent, then show to perform the request of data during the Webpage source code is loadedCode, otherwise show to be not carried out the data request code during the Webpage source code is loaded.
Specifically, please if sending HTTP to server during the Webpage source code is loadedAsk, then show to perform the data request code, it is necessary to which the reception server is returned during the Webpage source code is loadedThe data resource returned, the data resource of the return are the data resource determined according to the identifier of data resource.Waiting number, it is necessary to call loading object identification code during according to resource, to complete showing the step of loading object on the page.The loadingObject can prompt the user with the state of data download, and specifically, loading object can be time schedule bar, can includeThe textbox or animation of information such as " loading " or picture etc..If loading the mistake of the Webpage source codeCheng Zhongwei sends hypertext transfer protocol requests to server, then shows not hold during the Webpage source code is loadedThe row data request code, it is not necessary to the data resource that the reception server returns, it is not necessary to call loading object identification code.
Step S30, if performing data request code during the Webpage source code is loaded, calling is set in advanceThe loading object identification code put.
In the above-described embodiments, the pattern of the loading object in the loading object identification code pre-set can be by super literaryThis markup language (HyperText Markup Language, HTML) and CSS (Cascading StyleSheets, CSS) set loading object style.
In the above-described embodiments, the loading object identification code pre-set is called, it is possible to reduce code redundancy, load object generationThe later maintenance process of code is also fairly simple.A loading object identification code can is pre-set in different Webpages to enterRow calls, it is possible to reduce the written in code time.
Supplementary notes, before step S30, loading object identification code can be set, in the loading object identification code of settingPattern parameter including loading object, pattern parameter can be changed, if different pattern parameters is set, by performing loadingObject identification code can generate the different loading object of pattern, for example, animation, picture, word, timeline and Progress box can be setDeng the pattern of loading object.
Step S40, the loading object identification code is performed, loading object is shown on the page.
In the above-described embodiments, when performing loading object identification code, it can read in loading object identification code and load objectPattern parameter, object is loaded according to corresponding to the production of pattern parameter, specifically, loading object can be needed for loading dataTimeline, downloading data percentage Progress box, animation or word etc..Loading object is shown on the page, user can be allowed to knowTrack data download progress, meets user's request.
Optionally, after the step s 40, loading object identification code can be adjusted.Specifically, loading can be changedThe pattern parameter of object is loaded in object identification code.Changed by customized pattern parameter, load object identification code after being performed,The loading object with different patterns can be generated.The adjustment of loading object identification code is also included deleting loading object identification code, for example,In later stage code maintenance, it is not necessary to when loading object identification code, can once delete loading object identification code, simplify later stage deletion loadingThe operation of object identification code.The method for the processing loading object that above example provides can apply to the shifting such as mobile phone, tablet personal computerDynamic terminal, the platforms such as website can also be applied to.
Referring to Fig. 2, Fig. 2 is the schematic flow sheet of another embodiment of method of the processing loading object of the present invention.Fig. 2 institutesIt is the embodiment after being improved based on embodiment illustrated in fig. 1 to show embodiment, is theed improvement is that, in the step S40 shown in Fig. 1Step S50 and S60 are added afterwards, wherein:
Step S50, judge whether request of data is completed.
In the above-described embodiments, if request of data is completed, explanation need not show loading object, it is necessary to enter to loading objectRow is hidden.Specifically, after service end returns to all data, determine that request of data is completed.
If step 60, request of data are completed, the loading object is hidden.
In the present embodiment, if request of data is completed, after loading object is hidden, the display in the page can be simplifiedObject, improve the visual effect of the page.Specifically, the visual attribute of the loading object can be arranged to see thisState, to complete the hiding operation to loading object.
The method for the processing loading object that above example provides, is carried out by being multiplexed loading object identification code to loading objectIt has been shown that, avoid loading the redundancy of object identification code, reduce the difficulty of later stage code maintenance, can largely reduce later stage code dimensionThe human cost and time cost of shield.
The present invention further provides a kind of client.Fig. 3 is the functional module signal of the embodiment of client one of the present inventionFigure.In this embodiment, client 100 includes:Acquisition module 101, the first judge module 102, calling module 103 and display mouldBlock 104.Wherein, acquisition module 101 is used to obtain Webpage source code.First judge module 102 is used to judge described in loadingWhether data request code is performed during Webpage source code.If calling module 103 is used to load the WebpageData request code is performed during source code, then calls the loading object identification code pre-set.Display module 104 is used to performThe loading object identification code, loading object is shown on the page.
In the above-described embodiments, the Webpage source code can be JS (JavaScript, Java script).Acquisition module101 can obtain Webpage source code by WLAN, can also obtain Webpage source code by mobile data.NetPage page source code can be the source code of the Webpages such as the video playback page, news pages, application program loading page.By holdingThe Webpage source code that row acquisition module 101 obtains, can generate corresponding Webpage.For example, if Webpage source code isVideo playback page source code, the video playback page is produced according to video playback page source code, can be shown in the video playback pageVideo data.
In the above-described embodiments, the data request code can be the code for including hypertext transfer protocol requests, visitorFamily end 100 can ask digital resource by performing data request code to server, for example, video data can be asked to provideSource, voice data resource etc..
In the above-described embodiments, if performing data request code during the Webpage source code is loaded, needThe data resource that the reception server returns is wanted, it is necessary to show loading object, the loading object is used to prompt the user with dataThe state of load, specifically, loading object can be time schedule bar, can be the word for including information such as " loading "Frame or animation or picture etc..If being not carried out data request code during the Webpage source code is loaded,The data resource for not needing then the reception server to return, it is not necessary to display loading object.
Whether the first judge module 102 is specifically additionally operable to judge during the loading Webpage source code to serviceDevice sends hypertext transfer protocol requests, and the hypertext transfer protocol requests include the request method of data resource, data moneyThe identifier in source;Please when sending the HTTP to server during the Webpage source code is loadedAsk, then show to perform the data request code during the Webpage source code is loaded, otherwise show in loading instituteThe data request code is not carried out during stating Webpage source code.
Specifically, please if sending HTTP to server during the Webpage source code is loadedAsk, then show to perform the data request code, it is necessary to which the reception server is returned during the Webpage source code is loadedThe data resource returned, the data resource of the return are the data resource determined according to the identifier of data resource.Waiting number, it is necessary to call loading object identification code during according to resource, to complete showing the step of loading object on the page.The loadingObject can prompt the user with the state of data download, and specifically, loading object can be time schedule bar, can includeThe textbox or animation of information such as " loading " or picture etc..If loading the mistake of the Webpage source codeCheng Zhongwei sends hypertext transfer protocol requests to server, then shows not hold during the Webpage source code is loadedThe row data request code, it is not necessary to the data resource that the reception server returns, it is not necessary to call loading object identification code.
In the above-described embodiments, the pattern of the loading object in the loading object identification code pre-set can be by super literaryThis markup language (Hyper Text Markup Language, HTML) and CSS (Cascading StyleSheets, CSS) set loading object style.
In the above-described embodiments, calling module 103 calls the loading object identification code pre-set, it is possible to reduce code is superfluousIt is remaining, it is also fairly simple to the later maintenance process of loading object identification code.Pre-set a loading object identification code, calling module103 cans are called in different Webpages, it is possible to reduce the written in code time.
In the above-described embodiments, display module 104 can be read in loading object identification code when performing loading object identification codeThe pattern parameter of object is loaded, object is loaded according to corresponding to the production of pattern parameter, specifically, loading object can be loadingTime needed for data, downloading data percentage Progress box etc..Loading object is shown on the page, number can be let the user know thatAccording to download progress, meet user's request.
Referring to Fig. 4, Fig. 4 is the high-level schematic functional block diagram of another embodiment of client of the present invention.Embodiment illustrated in fig. 4It is the embodiment after being improved based on embodiment illustrated in fig. 3, thes improvement is that, increases in the client 100 shown in Fig. 1Setup module 105, wherein:
Setup module 105 is used to set the loading object identification code, and the loading object identification code includes the sample of loading objectFormula parameter.
Specifically, setup module 105 can set loading object identification code, the loading object of setting by self-defined modeCode includes loading the pattern parameter of object, and pattern parameter can be changed, if different pattern parameters is set, by holdingRow loading object identification code can generate the different loading object of pattern, for example, can set animation, picture, word, timeline andProgress box etc. loads the pattern of object.
Referring to Fig. 5, Fig. 5 is the high-level schematic functional block diagram of another embodiment of client of the present invention.Embodiment illustrated in fig. 5It is the embodiment after being improved based on embodiment illustrated in fig. 3, thes improvement is that, increases in the client 100 shown in Fig. 1Second judge module 106 and hidden module 107, wherein:
Second judge module 106 is used to judge whether request of data is completed, if hidden module 107 is complete for request of dataInto, then by it is described loading object be hidden.
In the above-described embodiments, if request of data is completed, explanation need not show loading object, it is necessary to enter to loading objectRow is hidden.Specifically, after service end returns to all data, determine that request of data is completed.In the present embodiment, if data pleaseCompletion is asked, after loading object is hidden, the display object in the page can be simplified, improve the visual effect of the page.SpecificallyFor, the visual attribute of the loading object can be arranged to invisible mode, to complete the hiding behaviour to loading objectMake.
Referring to Fig. 6, Fig. 6 is the high-level schematic functional block diagram of another embodiment of client of the present invention.Embodiment illustrated in fig. 6It is the embodiment after being improved based on embodiment illustrated in fig. 3, thes improvement is that, increases in the client 100 shown in Fig. 1Adjusting module 108, wherein:
Adjusting module 108 is used to change the pattern parameter for loading object in the loading object identification code, or for deletingThe loading object identification code.
Specifically, adjusting module 108 can be used in modification loading object identification code the pattern parameter for loading object.Pass throughCustomized pattern parameter modification, loading object identification code can generate the loading object with different patterns after being performed.AdjustMould preparation block 108 can be also used for deleting loading object identification code, for example, in later stage code maintenance, it is not necessary to when loading object identification code,Loading object identification code can be once deleted, simplifies the operation of later stage deletion loading object identification code.
The client that above example provides, loading object is shown by being multiplexed loading object identification code, avoids addingCarry the redundancy of object identification code, reduce the difficulty of later stage code maintenance, can largely reduce the manpower of later stage code maintenance intoSheet and time cost.
The preferred embodiments of the present invention are these are only, are not intended to limit the scope of the invention, it is every to utilize this hairThe equivalent structure or equivalent flow conversion that bright specification and accompanying drawing content are made, or directly or indirectly it is used in other related skillsArt field, is included within the scope of the present invention.