Best JavaScript code snippet using root
Menu.js
Source:Menu.js
1define([2 "dojo/_base/declare",3 "dojo/_base/lang",4 "dojo/dom-class",5 "dijit/registry",6 "dijit/layout/ContentPane"7 ], function(declare,8 lang,9 domClass,10 registry,11 ContentPane12 ) {13 var Menu = declare("freeadmin.Menu", [], {14 constructor: function(/*Object*/ kwArgs){15 lang.mixin(this, kwArgs);16 },17 openSystem: function(tab) {18 var opened = false;19 var p = registry.byId("content");20 var c = p.getChildren();21 for(var i=0; i<c.length; i++){22 if(c[i].tab == 'system'){23 p.selectChild(c[i]);24 opened = c[i];25 if(tab) {26 var tabnet = registry.byId("tab_systemsettings");27 if(tabnet) {28 var c2 = tabnet.getChildren();29 for(var j=0; j<c2.length; j++){30 if(c2[j].domNode.getAttribute("tab") == tab)31 tabnet.selectChild(c2[j]);32 }33 }34 } else {35 c[i].refresh();36 }37 } else {38 p.removeChild(c[i]);39 c[i].destroy();40 }41 }42 if(opened == false) {43 openurl = this.urlSystem;44 if(tab) {45 openurl += '?tab='+tab;46 }47 var pane = new ContentPane({48 title: gettext('System'),49 closable: false,50 href: openurl51 });52 pane.tab = 'system';53 p.addChild(pane);54 p.selectChild(pane);55 }56 },57 openTasks: function(tab) {58 var opened = false;59 var p = registry.byId("content");60 var c = p.getChildren();61 for(var i=0; i<c.length; i++){62 if(c[i].tab == 'tasks'){63 p.selectChild(c[i]);64 opened = c[i];65 if(tab) {66 var tabnet = registry.byId("tab_tasks");67 if(tabnet) {68 var c2 = tabnet.getChildren();69 for(var j=0; j<c2.length; j++){70 if(c2[j].domNode.getAttribute("tab") == tab)71 tabnet.selectChild(c2[j]);72 }73 }74 } else {75 c[i].refresh();76 }77 } else {78 p.removeChild(c[i]);79 c[i].destroy();80 }81 }82 if(opened == false) {83 openurl = this.urlTasks;84 if(tab) {85 openurl += '?tab='+tab;86 }87 var pane = new ContentPane({88 title: gettext('Tasks'),89 closable: false,90 href: openurl91 });92 pane.tab = 'tasks';93 p.addChild(pane);94 p.selectChild(pane);95 }96 },97 openNetwork: function(tab) {98 var opened = false;99 var p = registry.byId("content");100 var c = p.getChildren();101 for(var i=0; i<c.length; i++){102 if(c[i].tab == 'network'){103 p.selectChild(c[i]);104 opened = true;105 if(tab) {106 var tabnet = registry.byId("tab_networksettings");107 if(tabnet) {108 var c2 = tabnet.getChildren();109 for(var j=0; j<c2.length; j++){110 if(c2[j].domNode.getAttribute("tab") == tab)111 tabnet.selectChild(c2[j]);112 }113 }114 } else {115 c[i].refresh();116 }117 } else {118 p.removeChild(c[i]);119 c[i].destroy();120 }121 }122 if(opened != true) {123 openurl = this.urlNetwork;124 if(tab) {125 openurl += '?tab='+tab;126 }127 var pane = new ContentPane({128 title: gettext('Network'),129 closable: false,130 //refreshOnShow: true,131 href: openurl,132 });133 pane.tab = 'network';134 p.addChild(pane);135 p.selectChild(pane);136 }137 },138 openVcp: function(tab) {139 var opened = false;140 var p = registry.byId("content");141 var c = p.getChildren();142 for(var i=0; i<c.length; i++){143 if(c[i].tab == 'vcp'){144 p.selectChild(c[i]);145 opened = true;146 if(tab) {147 var tabnet = registry.byId("tab_vcpconfiguration");148 if(tabnet) {149 var c2 = tabnet.getChildren();150 for(var j=0; j<c2.length; j++){151 if(c2[j].domNode.getAttribute("tab") == tab)152 tabnet.selectChild(c2[j]);153 }154 }155 } else {156 p.removeChild(c[i]);157 c[i].destroy();158 opened=false;159 }160 } else {161 p.removeChild(c[i]);162 c[i].destroy();163 }164 }165 if(opened != true) {166 openurl = this.urlVcp;167 if(tab) {168 openurl += '?tab='+tab;169 }170 var pane = new ContentPane({171 title: gettext('vCenter Plugin Configuration'),172 closable: false,173 //refreshOnShow: true,174 href: openurl,175 });176 pane.tab = 'vcp';177 p.addChild(pane);178 p.selectChild(pane);179 }180 },181 openSharing: function(tab) {182 var opened = false;183 var p = registry.byId("content");184 var c = p.getChildren();185 for(var i=0; i<c.length; i++){186 if(c[i].tab == 'shares'){187 p.selectChild(c[i]);188 opened = true;189 if(tab) {190 var tabnet = registry.byId("tab_sharing");191 if(tabnet) {192 var c2 = tabnet.getChildren();193 for(var j=0; j<c2.length; j++){194 if(c2[j].domNode.getAttribute("tab") == tab)195 tabnet.selectChild(c2[j]);196 }197 }198 } else {199 c[i].refresh();200 }201 } else {202 p.removeChild(c[i]);203 c[i].destroy();204 }205 }206 if(opened != true) {207 openurl = this.urlSharing;208 if(tab) {209 openurl += '?tab='+tab;210 }211 var pane = new ContentPane({212 title: gettext('Sharing'),213 closable: false,214 //refreshOnShow: true,215 href: openurl,216 });217 pane.tab = 'shares';218 p.addChild(pane);219 p.selectChild(pane);220 }221 },222 openPluginsFcgi: function(p, item) {223 editObject(item.name, item.url);224 },225 openServices: function(onload, svc) {226 if(!onload) onload = function() {};227 var opened = false;228 var p = registry.byId("content");229 var href = this.urlServices;230 if(svc) href += '?toggleCore=' + svc;231 var c = p.getChildren();232 for(var i=0; i<c.length; i++){233 if(c[i].tab == 'services'){234 c[i].href = href;235 p.selectChild(c[i]);236 c[i].refresh();237 opened = true;238 if(onload) lang.hitch(this, onload)();239 } else {240 p.removeChild(c[i]);241 c[i].destroy();242 }243 }244 if(opened != true) {245 var pane = new ContentPane({246 title: gettext('Services'),247 closable: false,248 href: href,249 onLoad: function() {250 onload();251 // Do not refresh with ?toggleCore twice252 pane.href = pane.href.split('?')[0];253 },254 refreshOnShow: true255 });256 pane.tab = 'services';257 p.addChild(pane);258 p.selectChild(pane);259 domClass.add(pane.domNode,["objrefresh", "data_services_services"]);260 }261 },262 openJails: function(tab) {263 var opened = false;264 var p = registry.byId("content");265 var c = p.getChildren();266 for(var i=0; i<c.length; i++){267 if(c[i].tab == 'jails'){268 p.selectChild(c[i]);269 opened = true;270 if(tab) {271 var tabnet = registry.byId("tab_jails");272 if(tabnet) {273 var c2 = tabnet.getChildren();274 for(var j=0; j<c2.length; j++){275 if(c2[j].domNode.getAttribute("tab") == tab)276 tabnet.selectChild(c2[j]);277 }278 }279 } else {280 c[i].refresh();281 }282 } else {283 p.removeChild(c[i]);284 c[i].destroy();285 }286 }287 if(opened != true) {288 openurl = this.urlJails;289 if(tab) {290 openurl += '?tab='+tab;291 }292 var pane = new ContentPane({293 title: gettext('Jails'),294 closable: false,295 href:openurl,296 refreshOnShow: true297 });298 pane.tab = 'jails';299 p.addChild(pane);300 p.selectChild(pane);301 domClass.add(pane.domNode,["objrefresh", "data_jails_jails"]);302 }303 },304 openPlugins: function(tab) {305 var opened = false;306 var p = registry.byId("content");307 var c = p.getChildren();308 for(var i=0; i<c.length; i++){309 if(c[i].tab == 'plugins'){310 p.selectChild(c[i]);311 opened = true;312 if(tab) {313 var tabnet = registry.byId("tab_jails");314 if(tabnet) {315 var c2 = tabnet.getChildren();316 for(var j=0; j<c2.length; j++){317 if(c2[j].domNode.getAttribute("tab") == tab)318 tabnet.selectChild(c2[j]);319 }320 }321 } else {322 c[i].refresh();323 }324 } else {325 p.removeChild(c[i]);326 c[i].destroy();327 }328 }329 if(opened != true) {330 openurl = this.urlPlugins;331 if(tab) {332 openurl += '?tab='+tab;333 }334 var pane = new ContentPane({335 title: gettext('Plugins'),336 closable: false,337 href: openurl,338 refreshOnShow: true339 });340 pane.tab = 'plugins';341 p.addChild(pane);342 p.selectChild(pane);343 domClass.add(pane.domNode,["objrefresh", "data_plugins_plugins"]);344 }345 },346 openAccount: function(tab) {347 var opened = false;348 var p = registry.byId("content");349 var c = p.getChildren();350 for(var i=0; i<c.length; i++){351 if(c[i].tab == 'account'){352 p.selectChild(c[i]);353 opened = true;354 if(tab) {355 var tabnet = registry.byId("tab_account");356 if(tabnet) {357 var c2 = tabnet.getChildren();358 for(var j=0; j<c2.length; j++){359 if(c2[j].domNode.getAttribute("tab") == tab)360 tabnet.selectChild(c2[j]);361 }362 }363 } else {364 c[i].refresh();365 }366 } else {367 p.removeChild(c[i]);368 c[i].destroy();369 }370 }371 if(opened != true) {372 openurl = this.urlAccount;373 if(tab) {374 openurl += '?tab='+tab;375 }376 var pane = new ContentPane({377 title: gettext('Account'),378 closable: false,379 href:openurl,380 });381 pane.tab = 'account';382 p.addChild(pane);383 p.selectChild(pane);384 }385 },386 openStorage: function(tab) {387 var opened = false;388 var p = registry.byId("content");389 var c = p.getChildren();390 for(var i=0; i<c.length; i++){391 if(c[i].tab == 'storage'){392 p.selectChild(c[i]);393 opened = true;394 if(tab) {395 var tabnet = registry.byId("tab_storage");396 if(tabnet) {397 var c2 = tabnet.getChildren();398 for(var j=0; j<c2.length; j++){399 if(c2[j].domNode.getAttribute("tab") == tab)400 tabnet.selectChild(c2[j]);401 }402 }403 } else {404 c[i].refresh();405 }406 } else {407 p.removeChild(c[i]);408 c[i].destroy();409 }410 }411 if(opened != true) {412 openurl = this.urlStorage;413 if(tab) {414 openurl += '?tab='+tab;415 }416 var pane = new ContentPane({417 title: gettext('Storage'),418 closable: false,419 href: openurl,420 });421 pane.tab = 'storage';422 p.addChild(pane);423 p.selectChild(pane);424 domClass.add(pane.domNode,["objrefresh", "data_storage_Volumes"]);425 }426 },427 openISCSI: function(tab) {428 var opened = false;429 var p = registry.byId("content");430 var c = p.getChildren();431 for(var i=0; i<c.length; i++){432 if(c[i].tab == 'iscsi'){433 p.selectChild(c[i]);434 opened = true;435 if(tab) {436 var tabnet = registry.byId("tab_iscsi");437 if(tabnet) {438 var c2 = tabnet.getChildren();439 for(var j=0; j<c2.length; j++){440 if(c2[j].domNode.getAttribute("tab") == tab)441 tabnet.selectChild(c2[j]);442 }443 }444 } else {445 c[i].refresh();446 }447 } else {448 p.removeChild(c[i]);449 c[i].destroy();450 }451 }452 if(opened != true) {453 openurl = this.urlISCSI;454 if(tab) {455 openurl += '?tab='+tab;456 } else {457 openurl += '?tab=services.ISCSI';458 }459 var pane = new ContentPane({460 title: 'Sharing',461 closable: false,462 //refreshOnShow: true,463 href: openurl,464 });465 pane.tab = 'shares';466 p.addChild(pane);467 p.selectChild(pane);468 }469 },470 openSupport: function(onload) {471 if(!onload) onload = function() {};472 var opened = false;473 var p = registry.byId("content");474 var href = this.urlSupport;475 var c = p.getChildren();476 for(var i=0; i<c.length; i++){477 if(c[i].tab == 'support'){478 p.selectChild(c[i]);479 opened = true;480 if(onload) lang.hitch(this, onload)();481 }482 }483 if(opened != true) {484 var pane = new ContentPane({485 title: gettext('Support'),486 closable: true,487 href: href,488 onLoad: onload,489 });490 pane.tab = 'support';491 p.addChild(pane);492 p.selectChild(pane);493 domClass.add(pane.domNode,["objrefresh", "data_support_support"]);494 }495 },496 openDocumentation: function() {497 var opened = false;498 var p = registry.byId("content");499 var c = p.getChildren();500 for (var i=0; i<c.length; i++){501 if(c[i].tab == 'documentation') {502 p.selectChild(c[i]);503 opened = true;504 } else {505 p.removeChild(c[i]);506 c[i].destroy();507 }508 }509 510 if(opened != true) {511 openurl = this.urlDocumentation;512 var pane = new ContentPane({513 title: gettext('Documentation'),514 closable: false,515 href: openurl,516 });517 p.addChild(pane);518 p.selectChild(pane);519 domClass.add(pane.domNode,["objrefresh", "data_documentation_documentation"]);520 }521 },522 openDirectoryService: function(tab) {523 var opened = false;524 var p = registry.byId("content");525 var c = p.getChildren();526 for(var i=0; i<c.length; i++){527 if(c[i].tab == 'directoryservice'){528 p.selectChild(c[i]);529 opened = true;530 if(tab) {531 var tabnet = registry.byId("tab_directoryservice");532 if(tabnet) {533 var c2 = tabnet.getChildren();534 for(var j=0; j<c2.length; j++){535 if(c2[j].domNode.getAttribute("tab") == tab)536 tabnet.selectChild(c2[j]);537 }538 }539 } else {540 c[i].refresh();541 }542 } else {543 p.removeChild(c[i]);544 c[i].destroy();545 }546 }547 if(opened != true) {548 openurl = this.urlDirectoryService;549 if(tab) {550 openurl += '?tab='+tab;551 }552 var pane = new ContentPane({553 title: gettext('Directory Service'),554 closable: false,555 href:openurl,556 refreshOnShow: true557 });558 pane.tab = 'directoryservice';559 p.addChild(pane);560 p.selectChild(pane);561 domClass.add(pane.domNode,["objrefresh", "data_directoryservice_directoryservice"]);562 }563 },564 });565 return Menu;...
other.js
Source:other.js
1layui.define(['jquery', 'layer', 'common'], function(exports) {2 var common = layui.common,3 layer = layui.layer,4 $ = layui.jquery;5 var mojia = {6 'global': {7 'close': function() {8 $('.mo-shut-time').each(function() {9 var endtime = new Date($(this).attr('endtime')).getTime();10 var nowtime = new Date().getTime();11 var oddtime = endtime - nowtime;12 var seconds = oddtime / 1000;13 var minutes = Math.floor(seconds / 60);14 var hours = Math.floor(minutes / 60);15 if (endtime <= nowtime) {16 $(this).html('<li class="mo-shut-item mo-coxs-iblock mo-coxs-center mo-text-white"><div class="mo-shut-tips mo-fsxs-16px">请ç¨å</div></li>');17 } else {18 var html = '';19 html += '<li class="mo-shut-item mo-coxs-iblock mo-coxs-center mo-text-white"><span class="mo-shut-span">' + mojia.global.cover(Math.floor(hours / 24)) + '</span><div class="mo-shut-tips mo-fsxs-16px">days</div></li>';20 html += '<li class="mo-shut-item mo-coxs-iblock mo-coxs-center mo-text-white"><span class="mo-shut-span">' + mojia.global.cover(hours % 24) + '</span><div class="mo-shut-tips mo-fsxs-16px">hrs</div></li>';21 html += '<li class="mo-shut-item mo-coxs-iblock mo-coxs-center mo-text-white"><span class="mo-shut-span">' + mojia.global.cover(minutes % 60) + '</span><div class="mo-shut-tips mo-fsxs-16px">min</div></li>';22 html += '<li class="mo-shut-item mo-coxs-iblock mo-coxs-center mo-text-white"><span class="mo-shut-span">' + mojia.global.cover(Math.floor(seconds % 60)) + '</span><div class="mo-shut-tips mo-fsxs-16px">sec</div></li>';23 $(this).html(html);24 }25 });26 setTimeout(function() {27 mojia.global.close();28 }, 1000);29 },30 'browser': function() {31 common.global.output();32 var url = window.location.href;33 if (navigator.userAgent.indexOf('QQ/') > -1) {34 mojia.global.openurl('ucbrowser://' + url);35 mojia.global.openurl('mttbrowser://url=' + url);36 mojia.global.openurl('baiduboxapp://browse?url=' + url);37 mojia.global.openurl('googlechrome://browse?url=' + url);38 mojia.global.openurl('mibrowser:' + url);39 mojia.global.openurl('taobao://' + url.split('://')[1]);40 mojia.global.openurl('alipays://platformapi/startapp?appId=20000067&url=' + url);41 $(document).click(function() {42 mojia.global.openurl('ucbrowser://' + url);43 mojia.global.openurl('mttbrowser://url=' + url);44 mojia.global.openurl('baiduboxapp://browse?url=' + url);45 mojia.global.openurl('googlechrome://browse?url=' + url);46 mojia.global.openurl('mibrowser:' + url);47 mojia.global.openurl('taobao://' + url.split('://')[1]);48 mojia.global.openurl('alipays://platformapi/startapp?appId=20000067&url=' + url);49 });50 $(document).on('click', '.mo-java-event', function(event) {51 event.stopPropagation();52 });53 } else if (navigator.userAgent.indexOf('MicroMessenger') > -1) {54 if (navigator.userAgent.indexOf('Android') > -1) {55 var iframe = document.createElement('iframe');56 iframe.style.display = 'none';57 document.body.appendChild(iframe);58 }59 }60 layui.use(['clipboard'], function() {61 var link = new ClipboardJS('.mo-brow-link');62 link.on('success', function(data) {63 layer.msg('ç½åå¤å¶æå,å¿«å»å享å§');64 data.clearSelection();65 });66 });67 },68 'openurl': function(url) {69 document.getElementById('browser').href = url;70 document.getElementById('browser').click();71 },72 'cover': function(num) {73 return num < 10 ? '0' + num : num;74 }75 }76 };77 exports('other', mojia);...
openurl.js
Source:openurl.js
1var c = 0;2function referenceToOpenUrl(reference)3{4 var openurl_keys=[];5 openurl_keys['rft_val_fmt'] = 'rft_val_fmt';6 openurl_keys['jtitle'] = 'rft.atitle';7 openurl_keys['title'] = 'rft.btitle';8 openurl_keys['authors'] = 'rft.au';9 openurl_keys['journal'] = 'rft.title';10 openurl_keys['volume'] = 'rft.volume';11 openurl_keys['issue'] = 'rft.issue';12 openurl_keys['spage'] = 'rft.spage';13 openurl_keys['epage'] = 'rft.epage';14 openurl_keys['year'] = 'rft.date'; 15 openurl_keys['issn'] = 'rft.issn'; 16 openurl_keys['rft_id'] = 'rft_id'; 17 18 var parameters=[];19 parameters.push('url_ver=Z39.88-2004');20 var delimiter = '&';21 22 for (property in reference)23 {24 switch (property)25 { 26 case 'title':27 // what kind of reference?28 if (reference.journal)29 {30 parameters.push(openurl_keys['jtitle'] + '=' + encodeURIComponent(reference[property]));31 }32 else33 {34 parameters.push(openurl_keys['btitle'] + '=' + encodeURIComponent(reference[property]));35 }36 break;37 38 case 'identifier':39 for (j in reference.identifier)40 {41 switch (reference.identifier[j].type)42 {43 case 'biostor':44 parameters.push(openurl_keys['rft_id'] + '=' + 'http://biostor.org/reference/' + reference.identifier[j].id);45 break;46 case 'doi':47 parameters.push(openurl_keys['rft_id'] + '=' + 'info:doi/' + reference.identifier[j].id);48 break;49 case 'handle':50 parameters.push(openurl_keys['rft_id'] + '=' + 'info:hdl/' + reference.identifier[j].id);51 break;52 case 'pmid':53 parameters.push(openurl_keys['rft_id'] + '=' + 'info:pmid/' + reference.identifier[j].id);54 break;55 56 default:57 break;58 }59 }60 break;61 62 63 case 'journal':64 for (p in reference.journal)65 {66 switch(p)67 {68 case 'name':69 parameters.push(openurl_keys['journal'] + '=' + reference.journal[p]);70 break;71 72 case 'pages':73 var startingPage = reference.journal.pages;74 var endingPage = null;75 var pagePelimiter = reference.journal.pages.indexOf('-');76 if (pagePelimiter != -1)77 {78 startingPage = reference.journal.pages.substring(0, pagePelimiter);79 endingPage = reference.journal.pages.substring(pagePelimiter+2);80 }81 parameters.push(openurl_keys['spage'] + '=' + startingPage);82 if (endingPage)83 {84 parameters.push(openurl_keys['epage'] + '=' + endingPage);85 } 86 break;87 88 case 'identifier':89 for (j in reference.journal.identifier)90 {91 if (reference.journal.identifier[j] && reference.journal.identifier[j].type == 'issn')92 {93 parameters.push(openurl_keys['issn'] + '=' + reference.journal.identifier[j].id);94 }95 }96 break;97 98 default:99 if (p in openurl_keys)100 {101 parameters.push(openurl_keys[p] + '=' + reference.journal[p]);102 }103 break;104 }105 } 106 break;107 108 default:109 if (property in openurl_keys)110 {111 parameters.push(openurl_keys[property] + '=' + reference[property]);112 }113 break;114 }115 }116 117 var openurl = parameters.join(delimiter);118 return openurl;...
Using AI Code Generation
1var rootViewController = Ti.UI.iPhone.getOrientation() == Ti.UI.LANDSCAPE_LEFT ||2 Ti.UI.iPhone.getOrientation() == Ti.UI.LANDSCAPE_RIGHT ?3 Ti.UI.iPhone.rootViewController;4var rootViewController = Ti.UI.iPhone.getOrientation() == Ti.UI.LANDSCAPE_LEFT ||5 Ti.UI.iPhone.getOrientation() == Ti.UI.LANDSCAPE_RIGHT ?6 Ti.UI.iPhone.rootViewController;
Using AI Code Generation
1var rootview = ui("$");2var rootview = ui("$");3var rootview = ui("$");4var router = sm("do_Router");5var router = sm("do_Router");6var router = sm("do_Router");7var router = sm("do_Router");
Using AI Code Generation
1var root = this.getRoot();2var root = this.getRoot();3var root = this.getRoot();4var root = this.getRoot();5var root = this.getRoot();6var root = this.getRoot();7var root = this.getRoot();8var root = this.getRoot();9var root = this.getRoot();10var root = this.getRoot();11var root = this.getRoot();
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!