Created
March 23, 2017 12:02
-
-
Save mykola-den/21027f99713e42d3b22749c8ed85d0f3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var result1=[]; | |
| var result2=[]; | |
| var attrs=Xrm.Page.getAttribute().map(function(x){return x.getName()}) | |
| var SetRedLabel = function (attirbuteNameArray) { | |
| var start=Date.now(); | |
| /// <summary>Set redlabel for the crm field</summary> | |
| Xrm.Page.ui.controls.get(function (control) { | |
| return (control.getAttribute && attirbuteNameArray.contains(control.getAttribute().getName())) | |
| }) | |
| .forEach(function (control) { | |
| var id = control.get_controlId() + "_c"; | |
| var element = document.getElementById(id); | |
| if(!element){ | |
| return;} | |
| element.style.color = "#ff0000"; | |
| var innerSpan = element.getElementsByTagName("span"); | |
| if (innerSpan.length === 0) { | |
| return; | |
| } | |
| innerSpan[0].className = ""; | |
| }); | |
| var end=Date.now(); | |
| result1.push(end-start); | |
| }; | |
| console.log("stop1 "+Date.now()); | |
| var oldWay =function(attrs){ | |
| var start=Date.now(); | |
| attrs.forEach(function(a){ | |
| a = Xrm.Page.getAttribute(a); | |
| a.controls.get().forEach(function (control) { | |
| var id = control.get_controlId() + "_c"; | |
| var element = document.getElementById(id); | |
| if(!element){return;} | |
| element.style.color = "#ff0000"; | |
| var innerSpan = element.getElementsByTagName("span"); | |
| if (innerSpan.length === 0) { | |
| return; | |
| } | |
| innerSpan[0].className = ""; | |
| }); | |
| }); | |
| var end=Date.now(); | |
| result2.push(end-start); | |
| }; | |
| for (var i=0;i<100;i++) | |
| { | |
| SetRedLabel(attrs); | |
| oldWay(attrs); | |
| } | |
| console.log(result1,result2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment