Best JavaScript code snippet using backstopjs
multiview.js
Source:multiview.js
1$jc = jQuery.noConflict();2function waitvisible(gridcontainer)3 {4 if ($jc(gridcontainer).width()==0)5 setTimeout("waitvisible('"+gridcontainer+"')",100);6 else7 $jc(gridcontainer).reload2(); 8 }9function fluidDialog() {10 var $visible = $jc(".ui-dialog:visible");11 // each open dialog12 $visible.each(function () {13 var $this = $jc(this);14 var dialog = $this.find(".ui-dialog-content");15 if (dialog.dialog("option","fluid")) {16 var wWidth = $jc(window).width();17 // check window width against dialog width18 if (wWidth < (parseInt(dialog.dialog("option","maxWidth")) + 50)) {19 // keep dialog from filling entire screen20 $this.css("max-width", "90%");21 } else {22 // fix maxWidth bug23 $this.css("max-width", dialog.dialog("option","maxWidth") + "px");24 }25 //reposition dialog26 dialog.dialog("option","position", dialog.dialog("option","position"));27 }28 });29 30 }31 $jc(window).resize(function () {32 fluidDialog();33 });34 $jc(document).on("dialogopen", ".ui-dialog", function (event, ui) {35 fluidDialog();36 });37window.$ = jQuery;38function initMultiViewCal(container,calendarId,config)39{40 $jc(document).ready(function($jc) {41 (function( $jc ) { 42 var def = {43 numberOfMonths:6,44 viewNew : config.edition,45 viewToday : config.btoday,46 viewDay : false,47 viewWeek : false,48 viewMonth : false,49 viewNMonth : false,50 viewNDays : false,51 viewList : false,52 numberOfDays : 10,53 list_start:"", //"","now" or string compatible with strtotime 54 list_end:"", //"","now" or string compatible with strtotime 55 list_order:"asc",//asc or desc56 list_totalEvents:0, //0 = unlimited57 list_eventsPerPage:10, 58 list_readmore_numberofwords:0, //0 = unlimited, 59 viewRefresh : config.brefresh,60 viewNavigation : config.bnavigation,61 view: config.viewdefault, //'day','week','month','nMonth','nDays'62 weekstartday:config.start_weekday,63 showtooltip:false,64 tooltipon:1,65 shownavigate:false,66 navigateurl:config.url,67 target:0,68 cssStyle:"ui-darkness",69 readonly:!config.edition,70 nmonths:12,71 dialogWidth:300,72 dialogCloseAuto:false,73 height:0,74 showtooltipdwm:false,75 viewWeekDays:[1,1,1,1,1,1,1],76 militaryTime:true,77 path:"",78 hoursStart:0,79 hoursEnd:23,80 cellheight:42,81 rowsByCategory:"",82 rowsList:"",83 dayWithColumns:"",84 dayWithTime:true,85 thecontainer:container,86 userAdd:true,87 userEdit:true,88 userDel:true,89 userEditOwner:true,90 userDelOwner:true,91 userOwner:43,92 columnsList:false,93 rowsList:false,94 palette:0,95 paletteDefault:"f00"96 }97 if (config.rowsByCategory!="" && !config.dayWithTime)98 config.dayWithTime = false;99 config = $jc.extend(def, config);100 if (!config.userAdd)101 config.viewNew = false;102 var tabs = 0;103 if (config.viewNew && !config.readonly) tabs++;104 if (config.viewToday) tabs++;105 if (config.viewDay) tabs++;106 if (config.viewWeek) tabs++;107 if (config.viewMonth) tabs++;108 if (config.viewNDays) tabs++;109 if (config.viewList) tabs++;110 if (config.viewNMonth) tabs++;111 if (config.viewRefresh) tabs++;112 if (config.viewNavigation && ((tabs==1 && config.viewList) || (tabs==1 && config.viewNMonth) || (tabs==2 && config.viewList && config.viewNMonth))) config.viewNavigation=false;113 if (config.viewNavigation) tabs++;114 var string = '<div id="calhead'+config.thecontainer+' "> '+115 116 ((tabs>1)?117 ' <div id="caltoolbar'+config.thecontainer+'" class="ctoolbar">'+118 ((config.viewNew && !config.readonly)?119 ' <div id="faddbtn'+config.thecontainer+'" class="fbutton ui-state-default">'+120 ' <div><span class="ui-icon ui-icon-new"></span><span title="'+i18n.dcmvcal.click_to_create_new_event+'" >'+i18n.dcmvcal.new_event+'</span></div>'+121 ' </div>':'')+122 ((config.viewRefresh)?123 ' <div id="showreflashbtn'+config.thecontainer+'" class="fbutton ui-state-default">'+124 ' <div><span class="ui-icon ui-icon-refresh"></span><span title="'+i18n.dcmvcal.refresh_view+'" class="showdayflash">'+i18n.dcmvcal.refresh+'</span></div>'+125 ' </div>':'')+126 ((config.viewToday)?127 ' <div class="btnseparator"></div>'+128 ' <div id="showtodaybtn'+config.thecontainer+'" class="fbutton ui-state-default">'+129 ' <div><span class="ui-icon ui-icon-today"></span><span title="'+i18n.dcmvcal.click_to_back_to_today+'" class="showtoday">'+i18n.dcmvcal.today+'</span></div>'+130 ' </div>':'')+131 ((config.viewDay)?132 ' <div class="btnseparator"></div>'+133 ' <div id="showdaybtn'+config.thecontainer+'" class="fbutton ui-state-default '+((config.view=="day")?'ui-state-active':'')+'">'+134 ' <div><span title="'+i18n.dcmvcal.sday+'" class="showdayview">'+i18n.dcmvcal.sday+'</span></div>'+135 ' </div>':'')+136 ((config.viewNDays)?137 ' <div id="shownDaysbtn'+config.thecontainer+'" class="fbutton ui-state-default '+((config.view=="nDays")?'ui-state-active':'')+'">'+138 ' <div><span title="'+i18n.dcmvcal.ndays+'" class="shownMonthview">'+i18n.dcmvcal.ndays+'</span></div>'+139 ' </div>':'')+140 ((config.viewWeek)?141 ' <div id="showweekbtn'+config.thecontainer+'" class="fbutton ui-state-default '+((config.view=="week")?'ui-state-active':'')+'">'+142 ' <div><span title="'+i18n.dcmvcal.week+'" class="showweekview">'+i18n.dcmvcal.week+'</span></div>'+143 ' </div>':'')+144 ((config.viewMonth)?145 ' <div id="showmonthbtn'+config.thecontainer+'" class="fbutton ui-state-default '+((config.view=="month")?'ui-state-active':'')+'">'+146 ' <div><span title="'+i18n.dcmvcal.month+'" class="showmonthview">'+i18n.dcmvcal.month+'</span></div>'+147 ' </div>':'')+148 ((config.viewNMonth)?149 ' <div id="shownMonthbtn'+config.thecontainer+'" class="fbutton ui-state-default '+((config.view=="nMonth")?'ui-state-active':'')+'">'+150 ' <div><span title="'+i18n.dcmvcal.nmonth+'" class="shownMonthview">'+i18n.dcmvcal.nmonth+'</span></div>'+151 ' </div>':'')+152 ((config.viewList)?153 ' <div id="shownListbtn'+config.thecontainer+'" class="fbutton ui-state-default '+((config.view=="list")?'ui-state-active':'')+'">'+154 ' <div><span title="'+i18n.dcmvcal.list+'" class="showListview">'+i18n.dcmvcal.list+'</span></div>'+155 ' </div>':'')+156 ((config.viewNavigation)?157 ' <div class="btnseparator"></div>'+158 ' <div id="sfprevbtn'+config.thecontainer+'" title="'+i18n.dcmvcal.prev+'" class="fbutton fprevbtn ">'+159 ' <span class="ui-icon ui-icon-circle-triangle-w"></span>'+160 ' </div>'+161 ' <div id="sfnextbtn'+config.thecontainer+'" title="'+i18n.dcmvcal.next+'" class="fbutton ui-state-default">'+162 ' <span class="ui-icon ui-icon-circle-triangle-e"></span>'+163 ' </div>'+164 ' <div class="fshowdatep">'+165 ' <div>'+166 ' <input type="hidden" name="txtshow" id="hdtxtshow'+config.thecontainer+'" />'+167 ' <span id="txtdatetimeshow'+config.thecontainer+'">'+i18n.dcmvcal.loading+'</span>'+168 ' </div>'+169 ' </div>':'')+170 ((config.print_button)?171 ' <div id="showprintbtn'+config.thecontainer+'" class="fbutton ui-state-default showprintbtn">'+172 ' <div><span title="Print" class="shownprintview">Print</span></div>'+173 ' </div>':'')+174 ((config.export_ical_button)?175 ' <div id="shownICALbtn'+config.thecontainer+'" class="fbutton ui-state-default ">'+176 ' <div><span title="iCal" class="showicalview">iCal</span></div>'+177 ' </div>':'')+178 ' <div style="clear:both"></div></div>':'')+179 '</div>'+180 '<div id="editEventContainer"></div>'+181 '<div>'+182 ' <div id="dvCalMain'+config.thecontainer+'" class="calmain">'+183 ' <div id="loadingpannel'+config.thecontainer+'" class="ptogtitle loadicon" style="display: none;">'+i18n.dcmvcal.loading_data+'</div>'+184 ' <div id="errorpannel'+config.thecontainer+'" class="ptogtitle loaderror" style="display: none;">'+i18n.dcmvcal.sorry_could_not_load_your_data+'</div>'+185 186 ' <div class="gridcontainercover"><div id="gridcontainer'+config.thecontainer+'" style="position:relative;overflow-y: visible;"></div></div>'+187 ' </div>'+188 '</div>';189 var $container = $jc("#"+container);190 if (tabs<=1 && config.viewList)191 $jc("#"+container).parent().addClass("mvlist");192 if (tabs<=1 && config.viewNMonth)193 $jc("#"+container).parent().addClass("mvNMonth"); 194 $container.html(string);195 var DATA_FEED_URL = pathCalendar+"&f=datafeed";196 var DATA_EDIT_URL = pathCalendar+"&f=edit&month_index="+i18n.dcmvcal.dateformat.month_index+"&delete="+((config.userDel)?"1":"0")+"&palette="+config.palette+"&paletteDefault="+config.paletteDefault+"&calid="+calendarId;197 var op = {198 numberOfMonths:config.numberOfMonths,199 view: config.view,200 readonly:config.readonly,201 weekstartday: config.weekstartday,202 showtooltip:config.showtooltip,203 tooltipon:config.tooltipon,204 shownavigate:config.shownavigate,205 navigateurl:config.navigateurl,206 target:config.target,207 showday: new Date(),208 EditCmdhandler:Edit,209 DeleteCmdhandler:Delete,210 ViewCmdhandler:View,211 onWeekOrMonthToDay:wtd,212 onBeforeRequestData: cal_beforerequest,213 onAfterRequestData: cal_afterrequest,214 onRequestDataError: cal_onerror,215 autoload:true,216 url: DATA_FEED_URL + "&method=list&calid="+calendarId,217 quickAddUrl: DATA_FEED_URL + "&month_index="+i18n.dcmvcal.dateformat.month_index+"&method=add&calid="+calendarId,218 quickUpdateUrl: DATA_FEED_URL + "&method=update&calid="+calendarId,219 quickDeleteUrl: DATA_FEED_URL + "&method=remove&calid="+calendarId,220 dialogWidth:config.dialogWidth,221 dialogCloseAuto:config.dialogCloseAuto,222 height:config.height223 224 };225 op = $jc.extend(config, op);226 if (op.startdate && (op.startdate.length>=8) && (op.startdate.length<=10))227 {228 var i = op.startdate.split("-");229 op.startdate = new Date(i[0]*1,i[1]*1-1,i[2]*1);230 op.showday = op.startdate;231 }232 else233 op.mindate = "";234 if (op.mindate && (op.mindate.length>=8) && (op.mindate.length<=10))235 {236 var i = op.mindate.split("-");237 op.mindate = new Date(i[0]*1,i[1]*1-1,i[2]*1);238 }239 else240 op.mindate = "";241 if (op.maxdate && (op.maxdate.length>=8) && (op.maxdate.length<=10))242 {243 var i = op.maxdate.split("-");244 op.maxdate = new Date(i[0]*1,i[1]*1-1,i[2]*1);245 }246 else247 op.maxdate = ""; 248 var $dv = $jc("#calhead"+op.thecontainer);249 var _MH = document.documentElement.clientHeight;250 var dvH = $dv.height() + 2;251 //op.height = _MH - dvH;252 //op.height = "100%";253 op.eventItems =[];254 setTimeout("waitvisible('#gridcontainer"+op.thecontainer+"')",100);255 var p = $jc("#gridcontainer"+op.thecontainer).bcalendar(op).BcalGetOp();256 if (p && p.datestrshow) {257 $jc("#txtdatetimeshow"+op.thecontainer).text(p.datestrshow);258 }259 $jc("#caltoolbar"+op.thecontainer).noSelect();260 try {261 $jc("#hdtxtshow"+op.thecontainer).datepicker({ picker: "#txtdatetimeshow"+op.thecontainer, showtarget: $jc("#txtdatetimeshow"+op.thecontainer),262 onReturn:function(r){263 var p = $jc("#gridcontainer"+op.thecontainer).gotoDate(r).BcalGetOp();264 if (p && p.datestrshow) {265 $jc("#txtdatetimeshow"+op.thecontainer).text(p.datestrshow);266 }267 }268 });269 } catch(e){};270 function cal_beforerequest(type)271 {272 var t=i18n.dcmvcal.loading_data;273 switch(type)274 {275 case 1:276 t=i18n.dcmvcal.loading_data;277 break;278 case 2:279 case 3:280 case 4:281 t=i18n.dcmvcal.request_processed;282 break;283 }284 $jc("#errorpannel"+op.thecontainer).hide();285 $jc("#loadingpannel"+op.thecontainer).html(t);286 $jc("#loadingpannel"+op.thecontainer).show();287 }288 function cal_afterrequest(type)289 {290 switch(type)291 {292 case 1:293 $jc("#loadingpannel"+op.thecontainer).hide();294 break;295 case 2:296 case 3:297 case 4:298 $jc("#loadingpannel"+op.thecontainer).html(i18n.dcmvcal.success);299 window.setTimeout(function(){ $jc("#loadingpannel"+op.thecontainer).hide();},2000);300 break;301 }302 303 }304 function cal_onerror(type,data)305 {306 if (type!=2)307 $jc("#errorpannel"+op.thecontainer).show();308 if (data.Msg=='OVERLAPPING')309 alert(i18n.dcmvcal.error_overlapping);310 else311 alert(data.Msg); 312 }313 function Edit(data)314 {315 var eurl=DATA_EDIT_URL+"&mt="+(config.militaryTime?"true":"false")+"&css="+config.cssStyle+"&lang="+config.language+"&weekstartday="+config.weekstartday+"&hoursStart="+config.hoursStart+"&hoursEnd="+config.hoursEnd+"&id={0}&start={2}&end={3}&isallday={4}&title={1}";316 if(data)317 {318 var url = StrFormat(eurl,data); 319 showEditEvent(url);320 }321 }322 function View(data)323 {324 var str = "";325 $jc.each(data, function(i, item){326 str += "[" + i + "]: " + item + "\n";327 });328 }329 function Delete(data,callback)330 {331 332 $jc.alerts.okButton=i18n.dcmvcal.ok;333 $jc.alerts.cancelButton=i18n.dcmvcal.cancel;334 hiConfirm(i18n.dcmvcal.are_you_sure_delete, 'Confirm',function(r){ r && callback(0,data[0]);});335 }336 function wtd(p)337 {338 if (p && p.datestrshow) {339 $jc("#txtdatetimeshow"+op.thecontainer).text(p.datestrshow);340 }341 $jc("#caltoolbar"+op.thecontainer+" div.ui-state-active").each(function() {342 $jc(this).removeClass("ui-state-active");343 })344 $jc("#showdaybtn"+op.thecontainer).addClass("ui-state-active");345 }346 //to show day view347 try {348 $jc("#showdaybtn"+op.thecontainer).click(function(e) {349 $jc("#caltoolbar"+op.thecontainer+" div.ui-state-active").each(function() {350 $jc(this).removeClass("ui-state-active");351 })352 $jc(this).addClass("ui-state-active");353 var p = $jc("#gridcontainer"+op.thecontainer).swtichView("day").BcalGetOp();354 if (p && p.datestrshow) {355 $jc("#txtdatetimeshow"+op.thecontainer).text(p.datestrshow);356 }357 });358 } catch(e){};359 //to show week view360 try {361 $jc("#showweekbtn"+op.thecontainer).click(function(e) {362 $jc("#caltoolbar"+op.thecontainer+" div.ui-state-active").each(function() {363 $jc(this).removeClass("ui-state-active");364 })365 $jc(this).addClass("ui-state-active");366 var p = $jc("#gridcontainer"+op.thecontainer).swtichView("week").BcalGetOp();367 if (p && p.datestrshow) {368 $jc("#txtdatetimeshow"+op.thecontainer).text(p.datestrshow);369 }370 371 });372 } catch(e){};373 //to show month view374 try {375 $jc("#showmonthbtn"+op.thecontainer).click(function(e) {376 $jc("#caltoolbar"+op.thecontainer+" div.ui-state-active").each(function() {377 $jc(this).removeClass("ui-state-active");378 })379 $jc(this).addClass("ui-state-active");380 var p = $jc("#gridcontainer"+op.thecontainer).swtichView("month").BcalGetOp();381 if (p && p.datestrshow) {382 $jc("#txtdatetimeshow"+op.thecontainer).text(p.datestrshow);383 }384 });385 } catch(e){};386 //to show nDays view387 try {388 $jc("#shownDaysbtn"+op.thecontainer).click(function(e) {389 $jc("#caltoolbar"+op.thecontainer+" div.ui-state-active").each(function() {390 $jc(this).removeClass("ui-state-active");391 })392 $jc(this).addClass("ui-state-active");393 var p = $jc("#gridcontainer"+op.thecontainer).swtichView("nDays").BcalGetOp();394 if (p && p.datestrshow) {395 $jc("#txtdatetimeshow"+op.thecontainer).text(p.datestrshow);396 }397 });398 } catch(e){};399 //to show List view400 try {401 $jc("#shownListbtn"+op.thecontainer).click(function(e) {402 $jc("#caltoolbar"+op.thecontainer+" div.ui-state-active").each(function() {403 $jc(this).removeClass("ui-state-active");404 })405 $jc(this).addClass("ui-state-active");406 var p = $jc("#gridcontainer"+op.thecontainer).swtichView("list").BcalGetOp();407 408 if (p && p.datestrshow) {409 $jc("#txtdatetimeshow"+op.thecontainer).text(p.datestrshow);410 }411 }); 412 } catch(e){};413 //to show nMonth view414 try {415 $jc("#shownMonthbtn"+op.thecontainer).click(function(e) {416 $jc("#caltoolbar"+op.thecontainer+" div.ui-state-active").each(function() {417 $jc(this).removeClass("ui-state-active");418 })419 $jc(this).addClass("ui-state-active");420 var p = $jc("#gridcontainer"+op.thecontainer).swtichView("nMonth").BcalGetOp();421 if (p && p.datestrshow) {422 $jc("#txtdatetimeshow"+op.thecontainer).text(p.datestrshow);423 }424 });425 } catch(e){};426 try {427 $jc("#showreflashbtn"+op.thecontainer).click(function(e){428 $jc("#gridcontainer"+op.thecontainer).reload();429 });430 } catch(e){};431 try {432 $jc("#shownICALbtn"+op.thecontainer).click(function(e){433 window.location = DATA_FEED_URL.replace("datafeed","ical")+"&id="+calendarId;434 });435 } catch(e){};436 try {437 $jc("#showprintbtn"+op.thecontainer).click(function(e){438 w=window.open();439 var code = $jc("#"+op.thecontainer).parent().html()+"";440 if ($jc("#gridcontainer"+op.thecontainer).BcalGetOp().view=="nMonth")441 code = code.replace(/width:/g,"width-");442 w.document.write('<html><head><style>#multicalendar .ctoolbar{height:22px}#multicalendar .fbutton{display:none}</style><link rel="stylesheet" href="'+config.mvcsspath+config.cssStyle+'/calendar.css" type="text/css" media="print,screen"/><link rel="stylesheet" href="'+config.mvcsspath+'main.css" type="text/css" media="print,screen"/></head><body><div id="multicalendar">'+code+'</div></body></html>');443 w.document.close();444 w.print();445 });446 } catch(e){};447 function showEditEvent(url)448 { 449 var width = 600;450 var height = 480;451 try {452 $jc("#editEvent").remove();453 var content = '<iframe id="dailog_iframe_1305934814858" frameborder="0" style="border:none;width:550px;height:'+(height-50)+'px" src="'+url+'" border="0" scrolling="no">';454 $jc("#editEventContainer").append("<div id=\"editEvent\" >"+content+"</div>"); 455 $jc("#editEvent").dialog({456 width: width,457 height: height,458 modal: true,resizable: false,maxWidth: width,459 fluid: true,460 open: function(event, ui){fluidDialog();},461 //position: 'center',462 position: {463 my: "left top",464 at: "left top",465 collision:"fit flip",466 of: $jc("#gridcontainer"+op.thecontainer)467 },468 title:i18n.dcmvcal.manage_the_calendar469 ,close: function(event, ui) {$jc("#gridcontainer"+op.thecontainer).reload(); }470 }).parent().addClass("mv_dlg").addClass("mv_dlg_editevent");471 $jc(".ui-widget-overlay").css("position","absolute");472 $jc(".ui-widget-overlay").css("top","0");473 $jc(".ui-widget-overlay").css("left","0");474 $jc(".ui-widget-overlay").css("background","#aaaaaa");475 $jc(".ui-widget-overlay").css("opacity","0.3");476 } catch(e){};477 }478 //Add a new event479 try {480 $jc("#faddbtn"+op.thecontainer).click(function(e) {481 var url =DATA_EDIT_URL+"&r="+Math.random()+"&css="+config.cssStyle+"&lang="+config.language+"&weekstartday="+config.weekstartday+"&hoursStart="+config.hoursStart+"&hoursEnd="+config.hoursEnd;482 showEditEvent(url);483 484 485 });486 } catch(e){};487 //go to today488 try {489 $jc("#showtodaybtn"+op.thecontainer).click(function(e) {490 var p = $jc("#gridcontainer"+op.thecontainer).gotoDate().BcalGetOp();491 if (p && p.datestrshow) {492 $jc("#txtdatetimeshow"+op.thecontainer).text(p.datestrshow);493 }494 495 496 });497 } catch(e){};498 //previous date range499 try {500 $jc("#sfprevbtn"+op.thecontainer).click(function(e) {501 if (!$jc("#sfprevbtn"+op.thecontainer).hasClass("non-navigate"))502 {503 504 var p = $jc("#gridcontainer"+op.thecontainer).previousRange().BcalGetOp();505 if (p && p.datestrshow) {506 $jc("#txtdatetimeshow"+op.thecontainer).text(p.datestrshow);507 }508 }509 });510 } catch(e){};511 //next date range512 try {513 $jc("#sfnextbtn"+op.thecontainer).click(function(e) {514 if (!$jc("#sfnextbtn"+op.thecontainer).hasClass("non-navigate"))515 {516 var p = $jc("#gridcontainer"+op.thecontainer).nextRange().BcalGetOp();517 if (p && p.datestrshow) {518 $jc("#txtdatetimeshow"+op.thecontainer).text(p.datestrshow);519 }520 }521 });522 } catch(e){};523 524 525 526 527 528 529 530 531 532 })($jc); 533534 });
...
jc-maintenance.js
Source:jc-maintenance.js
1jc.maint = {2 prop : { full: {} },3 start : () => { jc.maint.proc({}); },4 proc : ( params ) => {5 if ( ! jc.maint.prop.uploads ) {6 jc.progressbar({ text:'Listing uploadsâ¦'});7 jc.jdav.ls({dir:'uploads'},(x) => {8 jc.maint.prop.uploads = {};9 jc.maint.prop.uploadsOrphans = {};10 x.list.forEach( (k) => {11 jc.maint.prop.uploads[k] = true;12 jc.maint.prop.uploadsOrphans[k] = true;13 } );;14 setTimeout( ()=> { jc.maint.proc( params ) }, 10 );15 });16 return;17 }18 if ( ! jc.maint.prop.tags ) {19 jc.maint.prop.tagnames = [];20 jc.maint.prop.tags = {};21 AS.def.arr(jc.prop.site && jc.prop.site.tags).forEach( x => {22 jc.maint.prop.tagnames.push( x.name );23 jc.maint.prop.tags[x.name] = {};24 });25 }26 if ( ! (params.scanlist||params.tobescanned) ) {27 params.initial = { page: jc.page.current(), id : jc.page.data().id };28 jc.progressbar({ text:'Listing pagesâ¦'});29 jc.jdav.ls({dir:'pages'},(x) => {30 params.tobescanned = x.list;31 params.totpages = x.list.length;32 setTimeout( ()=> { jc.maint.proc( params ) }, 10 );33 });34 return;35 }36 if ( params.tobescanned ) {37 let isfirst = false;38 if ( ! params.scanlist ) {39 params.scanlist = [];40 isfirst = true;41 }42 let nxt = params.tobescanned.shift();43 jc.progressbar({ text:'Loading pageâ¦', prog: ((params.totpages - params.tobescanned.length)/params.totpages) });44 params.scanlist.push(nxt);45 if ( ! params.tobescanned.length ) delete params.tobescanned;46 let page = nxt.replace(/^([^0-9.]+).*/,"$1");47 let id = nxt.match(/^[^0-9]+[0-9]+\..*$/) ? parseInt( nxt.replace(/^[^0-9]+([0-9]+)\..*$/,"$1")) : undefined;48 console.log('Scanning:',page,id);49 if ( isfirst && (page == params.initial.page) && ( id == params.initial.id )) {50 params.tobescanned.push( params.scanlist.pop() );51 setTimeout( ()=> { jc.maint.proc( params ) }, 10 );52 } else {53 jc.maint.scan( page, id, ()=>{ jc.maint.proc( params ); } );54 }55 return;56 }57 if ( ! params.listsPurged ) {58 jc.progressbar({ text:'Deleting old listsâ¦', prog: 0 });59 if ( ! params.tbdLists ) {60 jc.jdav.ls({dir:'struct',ext:'rss'},(x) => {61 x.list.forEach( (k) => { jc.dav.rm('struct/'+k,()=>{ }); } );62 });63 jc.jdav.ls({dir:'struct',ext:'txt'},(x) => {64 x.list.forEach( (k) => { jc.dav.rm('struct/'+k,()=>{ }); } );65 });66 jc.jdav.ls({dir:'struct'},(x) => {67 params.tbdLists = x.list;68 params.tbdCount = params.tbdLists.length;69 setTimeout( ()=> { jc.maint.proc( params ) }, 10 );70 });71 return;72 }73 if ( params.tbdLists.length ) {74 jc.progressbar({ prog: ((params.tbdCount - params.tbdLists.length)/params.tbdCount) });75 jc.dav.rm('struct/'+params.tbdLists.shift(),()=>{76 setTimeout( ()=> { jc.maint.proc( params ) }, 10 );77 });78 } else {79 params.listsPurged = true;80 delete params.tbdLists;81 delete params.tbdCount;82 setTimeout( ()=> { jc.maint.proc( params ) }, 10 );83 }84 return;85 }86 if ( ! params.savedFullList ) {87 jc.progressbar({ text:'Saving full listâ¦', prog: 0 });88 jc.lists.list.set(jc.maint.prop.full,()=>{89 jc.progressbar({ prog: .3 });90 jc.page.makeLasts( jc.maint.prop.full, ()=>{91 params.savedFullList = true;92 if (jc.prop.site && jc.prop.site.norss ) {93 setTimeout( ()=> { jc.maint.proc( params ) }, 10 );94 return;95 }96 jc.lists.list.dositemap( jc.maint.prop.full, ()=>{97 setTimeout( ()=> { jc.maint.proc( params ) }, 10 );98 });99 });100 });101 return;102 }103 if ( ! params.savedTypeLists ) {104 if ( ! params.ptypes ) {105 params.ptypes = Object.keys(jc.maint.prop.full);106 params.ptypesCount = params.ptypes.length;107 }108 if ( params.ptypes.length ) {109 let k = params.ptypes.shift();110 jc.progressbar({ text: 'Saving type: '+k, prog: ((params.ptypesCount - params.ptypes.length)/params.ptypesCount) });111 jc.lists.list.set(k,jc.maint.prop.full[k],()=>{112 jc.page.makeTypeLasts( k, jc.maint.prop.full[k], ()=>{113 jc.page.makeTypeDates( k, jc.maint.prop.full[k], ()=>{114 setTimeout( ()=> { jc.maint.proc( params ) }, 10 );115 });116 });117 });118 } else {119 params.savedTypeLists = true;120 delete params.ptypes;121 delete params.ptypesCount;122 setTimeout( ()=> { jc.maint.proc( params ) }, 10 );123 }124 return;125 }126 if ( ! params.savedTagsLists ) {127 if ( ! params.tagnames ) {128 params.tagnames = jc.maint.prop.tagnames.clone();129 params.tagnamesCount = params.tagnames.length;130 }131 if ( params.tagnames.length ) {132 let k = params.tagnames.shift();133 jc.progressbar({ text: 'Saving tags: '+k, prog: ((params.tagnamesCount - params.tagnames.length)/params.tagnamesCount) });134 jc.lists.tag.set(k,jc.maint.prop.tags[k],()=>{135 setTimeout( ()=> { jc.maint.proc( params ) }, 10 );136 });137 } else {138 params.savedTagsLists = true;139 delete params.tagnames;140 delete params.tagnamesCount;141 setTimeout( ()=> { jc.maint.proc( params ) }, 10 );142 }143 return;144 }145 jc.progressbar({close:true});146 setTimeout( ()=>{147 jc.maint.prop = { full: {} };148 jc.page.open( params.initial.page, params.initial.id );149 },10);150 },151 scan : ( page, id, cb ) => {152 jc.maint.prop.afterscancb = cb;153 $(document.body).on('jc_page_open_completed', jc.maint.doscan );154 setTimeout( ()=>{ jc.page.open( page, id ); }, 10 );155 },156 doscan : ( event, edata ) => {157 $(document.body).off('jc_page_open_completed', jc.maint.doscan );158 let page = edata.page;159 let id = edata.id;160 let pd = jc.page.data().pageContent;161 let cb = jc.maint.prop.afterscancb;162 delete jc.maint.prop.afterscancb;163 if ( pd && pd.metadata ) {164 jc.progressbar({ text:'Scan: '+pd.metadata.title });165 let nm = JSON.parse(JSON.stringify(pd.metadata||{}));166 if ( pd.blogdate ) nm.date = pd.blogdate;167 if ( ! jc.maint.prop.full[page] ) jc.maint.prop.full[page] = {};168 jc.maint.prop.full[page][String((pd.id||0))] = nm;169 let pdtags = jc.objFindAll( pd, 'type', 'tags' ).clone();170 jc.maint.prop.tagnames.forEach( tagname => {171 jc.maint.prop.tags[tagname] = jc.page.parseTagsOne( pd, tagname, jc.maint.prop.tags[tagname], pdtags );172 } );173 jc.dav.rm(AS.path('jsdatastatics')+page+(pd.id||'')+'.html',()=>{ jc.page.makeStatic( cb ) });174 } else {175 let id = ( pd && AS.test.def(pd.id) ) ? String(pd.id) : '';176 console.log( 'Unknown metadata:',page,id,pd);177 jc.dav.rm(AS.path('jsdatastatics')+page+id+'.html', cb );178 }179 },...
jobcenter.js
Source:jobcenter.js
1let jobs = {};2function fetchAllAds() {3 $('#jc-jobs').html('');4 fetch(`https://${ GetParentResourceName() }/jsfour-computer:fetchAllJobAds`, {5 method: 'POST',6 body: JSON.stringify({7 type: 'fetchAllJobAds'8 })9 })10 .then( response => response.json() )11 .then( data => {12 if ( data != 'false' && data.length > 0 ) {13 $('#jc-list h6 span').text( Object.keys( data ).length );14 Object.keys( data ).forEach(( k ) => {15 if ( !data[k].title ) {16 data[k].title = 'This is a null title'17 } else {18 if ( data[k].title.length > 25 ) {19 data[k].title = data[k].title.substr(0, 25) + '..';20 }21 }22 jobs[ data[k].id ] = {23 id: data[k].id,24 image: data[k].image,25 title: data[k].title,26 group: data[k].group,27 job: data[k].name,28 text: data[k].text29 };30 let div = `<div class="jc-job" identifier="${ data[k].id }">31 <img src="${ data[k].image }" draggable="false" />32 <h5>${ data[k].title }</h5>33 <p>${ data[k].name }</p>34 </div>`;35 $('#jc-jobs').prepend( div );36 });37 } 38 });39}40function searchAds( keyword ) {41 Object.keys( jobs ).forEach(( k ) => {42 if ( jobs[k].job.toLowerCase().includes( keyword.toLowerCase() ) ) {43 $('#jc-jobs').html('');44 let div = `<div class="jc-job" identifier="${ jobs[k].id }">45 <img src="${ jobs[k].image }" draggable="false" />46 <h5>${ jobs[k].title }</h5>47 <p>${ jobs[k].job }</p>48 </div>`;49 $('#jc-jobs').append( div );50 }51 });52}53function refreshjobcenter() {54 fetchAllAds();55}56fetchAllAds();57if ( loggedInUser.job === 'all' || ( loggedInUser.group === 'admin' ) ) {58 $('#jc-add').css('display', 'block');59}60$('#jc-add').click(()=> {61 $('#jc-search span').show();62 $('#jc-search form').slideUp('fast');63 $('#jc-list').fadeOut('fast', function() {64 $('#jc-add-form').fadeIn();65 });66});67$('#jc-add-form form').submit(() => {68 fetch(`https://${ GetParentResourceName() }/jsfour-computer:addJobAd`, {69 method: 'POST',70 body: JSON.stringify({71 type: 'addJobAd',72 data: {73 '@group':$('#jc-add-group').val().toLowerCase(),74 '@name': $('#jc-add-name').val().toLowerCase(),75 '@image': $('#jc-add-image').val(),76 '@title': $('#jc-add-title').val(),77 '@text': $('#jc-add-text').val(),78 }79 })80 })81 .then(() => {82 setTimeout(() => {83 fetchAllAds();84 $('#jc-search form').slideDown('fast');85 $('#jc-search span').hide();86 $('#jc-job, #jc-add-form').fadeOut('fast', function() {87 $('#jc-list').fadeIn();88 });89 }, 500);90 });91 return false;92});93$('body').on('click', '.jc-job', function() {94 let ad = $( this ).attr('identifier');95 $('#jc-search span').show();96 $('#jc-search form').slideUp('fast');97 $('#jc-job-title').val( jobs[ad].title );98 $('#jc-job-job').val( jobs[ad].job );99 $('#jc-job-text').val( jobs[ad].text );100 $('#jc-job-image').val( jobs[ad].image );101 $('#jc-job-group').val( jobs[ad].group );102 $('#jc-job-save').attr('identifier', ad);103 $('#jc-job-delete').attr('identifier', ad);104 if ( loggedInUser.job === 'all' || ( loggedInUser.job === jobs[ad].job && loggedInUser.group === 'admin' ) ) {105 $('#jc-job-edit').css('display', 'block');106 }107 $('#jc-list').fadeOut('fast', function() {108 $('#jc-job').fadeIn();109 });110});111$('#jc-search span').click(() => {112 $('#jc-search form').slideDown('fast');113 $('#jc-search span').hide();114 $('#jc-job, #jc-add-form').fadeOut('fast', function() {115 $('#jc-list').fadeIn();116 });117});118function edit() {119 if ( $('#jc-job-save').css('display') === 'block' ) {120 $('#jc-job-save, #jc-job-image, #jc-job-group, #jc-job-delete').css('display', 'none');121 } else {122 $('#jc-job-save, #jc-job-image, #jc-job-group, #jc-job-delete').css('display', 'block');123 }124 $('#jc-job input, #jc-job textarea').attr('disabled', $('#jc-job input').attr('disabled') ? false : true);125}126$('#jc-job-delete').click( function() {127 fetch(`https://${ GetParentResourceName() }/jsfour-computer:deleteJobAd`, {128 method: 'POST',129 body: JSON.stringify({130 type: 'deleteJobAd',131 data: {132 '@id': $( this ).attr('identifier')133 }134 })135 })136 .then(() => {137 setTimeout(() => {138 fetchAllAds();139 $('#jc-search form').slideDown('fast');140 $('#jc-search span').hide();141 $('#jc-job, #jc-add-form').fadeOut('fast', function() {142 $('#jc-list').fadeIn();143 });144 }, 500);145 });146});147$('#jc-job-edit').click(() => {148 edit();149});150$('#jc-job-save').click( function() {151 fetch(`https://${ GetParentResourceName() }/jsfour-computer:updateJobAd`, {152 method: 'POST',153 body: JSON.stringify({154 type: 'updateJobAd',155 data: {156 '@name': $('#jc-job-job').val(),157 '@text': $('#jc-job-text').val(),158 '@title': $('#jc-job-title').val(),159 '@image': $('#jc-job-image').val(),160 '@group': $('#jc-job-group').val(),161 '@id': $( this ).attr('identifier')162 }163 })164 })165 .then(() => {166 edit();167 fetchAllAds();168 });169});170$('#jc-search button').click(() => {171 if ($('#jc-search input').val().length > 0 ) {172 searchAds( $('#jc-search input').val() );173 return false;174 }175})176$('#jc-search form').submit(() => {177 searchAds( $('#jc-search input').val() );178 return false;179});180$('#jc-search-clear').click(() => {181 if ($('#jc-search input').val().length > 0 ) {182 $('#jc-search input').val('');183 fetchAllAds();184 }...
Using AI Code Generation
1module.exports = {2 {3 },4 {5 },6 {7 },8 {9 },10 {11 }12 {13 }14 paths: {15 },16 engineOptions: {17 },18};
Using AI Code Generation
1module.exports = {2 {3 },4 {5 },6 {7 },8 {9 }10 {11 }12 paths: {13 },14 engineOptions: {15 },16};
Using AI Code Generation
1module.exports = async (page, scenario, vp) => {2 console.log('SCENARIO > ' + scenario.label);3 await page.waitFor(500);4 await page.waitFor(1000);5 await page.waitFor(2000);6 await page.waitFor(3000);7 await page.waitFor(4000);8 await page.waitFor(5000);9 await page.waitFor(10000);10 await page.waitFor(15000);11 await page.waitFor(20000);12 await page.waitFor(25000);13 await page.waitFor(30000);14 await page.waitFor(35000);15 await page.waitFor(40000);16 await page.waitFor(45000);17 await page.waitFor(50000);18 await page.waitFor(55000);19 await page.waitFor(60000);20 await page.waitFor(65000);21 await page.waitFor(70000);22 await page.waitFor(75000);23 await page.waitFor(80000);24 await page.waitFor(85000);25 await page.waitFor(90000);26 await page.waitFor(95000);27 await page.waitFor(100000);28 await page.waitFor(105000);29 await page.waitFor(110000);30 await page.waitFor(115000);31 await page.waitFor(120000);32 await page.waitFor(125000);33 await page.waitFor(130000);34 await page.waitFor(135000);35 await page.waitFor(140000);36 await page.waitFor(145000);37 await page.waitFor(150000);38 await page.waitFor(155000);39 await page.waitFor(160000);40 await page.waitFor(165000);41 await page.waitFor(170000);42 await page.waitFor(175000);43 await page.waitFor(180000);44 await page.waitFor(185000);45 await page.waitFor(190000);46 await page.waitFor(195000);47 await page.waitFor(200000);48 await page.waitFor(205000);49 await page.waitFor(210000);50 await page.waitFor(215000);51 await page.waitFor(220000);52 await page.waitFor(225000);53 await page.waitFor(230000);54 await page.waitFor(235000);55 await page.waitFor(240000);56 await page.waitFor(245000);57 await page.waitFor(250000);58 await page.waitFor(255000);59 await page.waitFor(260
Using AI Code Generation
1var backstop = require('backstopjs');2backstop('test', {3})4.then(function () {5 console.log('Test completed!');6})7.catch(function (err) {8 console.log(err);9});10var backstop = require('backstopjs');11backstop('reference', {12})13.then(function () {14 console.log('Reference completed!');15})16.catch(function (err) {17 console.log(err);18});
Using AI Code Generation
1var backstop = require('backstopjs');2var config = require('./backstop.json');3var fs = require('fs');4var args = process.argv.slice(2);5var scenarioName = args[0];6var scenarioName2 = args[1];7var scenarioName3 = args[2];8var scenarioName4 = args[3];9var scenarioName5 = args[4];10var scenarioName6 = args[5];11var scenarioName7 = args[6];12var scenarioName8 = args[7];13var scenarioName9 = args[8];14var scenarioName10 = args[9];15var scenarioName11 = args[10];16var scenarioName12 = args[11];17var scenarioName13 = args[12];18var scenarioName14 = args[13];19var scenarioName15 = args[14];20var scenarioName16 = args[15];21var scenarioName17 = args[16];22var scenarioName18 = args[17];23var scenarioName19 = args[18];24var scenarioName20 = args[19];25var scenarioName21 = args[20];26var scenarioName22 = args[21];27var scenarioName23 = args[22];28var scenarioName24 = args[23];29var scenarioName25 = args[24];30var scenarioName26 = args[25];31var scenarioName27 = args[26];32var scenarioName28 = args[27];33var scenarioName29 = args[28];34var scenarioName30 = args[29];35var scenarioName31 = args[30];36var scenarioName32 = args[31];37var scenarioName33 = args[32];38var scenarioName34 = args[33];39var scenarioName35 = args[34];40var scenarioName36 = args[35];41var scenarioName37 = args[36];42var scenarioName38 = args[37];43var scenarioName39 = args[38];44var scenarioName40 = args[39];45var scenarioName41 = args[40];46var scenarioName42 = args[41];47var scenarioName43 = args[42];48var scenarioName44 = args[43];49var scenarioName45 = args[44];50var scenarioName46 = args[45];51var scenarioName47 = args[46];52var scenarioName48 = args[47];53var scenarioName49 = args[48];54var scenarioName50 = args[49];55var scenarioName51 = args[50];
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!!