How to use getSummary method in Mocha

Best JavaScript code snippet using mocha

consumption.js

Source:consumption.js Github

copy

Full Screen

1var selectAr = [];2$('#week1').hide()3$('#week2').hide()4$('#month1').hide()5$('#month2').hide()6$('#year').hide()7// '.tbl-content' consumed little space for vertical scrollbar, scrollbar width depend on browser/os/platfrom. Here calculate the scollbar width .8$(document).ready(function () {9 $.ajax({10 type: "GET",11 url: "http://127.0.0.1:8000/consumptionData/",12 dataType: "json",13 success: function (data) {14 getData = data;15 //obj = JSON.parse(getData)16 //console.log("obj ",obj)17 getValue = [];18 for (i = 0; i < getData.length; i++) {19 if (getData[i].name) {20 name = getData[i].name;21 value = getData[i].data;22 getValue.push(name, value);23 }24 // getDataList = data.data25 }26 console.log("dataaaaaaaaa", data[12])27 getDate = getData[10];28 getIndex = getData[11];29 getSummary = getData[12]30 getTotalValue = getData[13]31 console.log("index ", getIndex);32 console.log("get data ", getData);33 console.log("get name ", getValue);34 console.log("get date ", getDate);35 console.log("getTotalValue", getTotalValue)36 GetData(getData, getValue, getDate, getIndex, getSummary, getTotalValue);37 },38 });39 // get index of select choices40 $.ajax({41 type: "GET",42 url: "http://127.0.0.1:8000/SelectOption/",43 dataType: "json",44 success: function (index) {45 //console.log(index);46 //console.log("indexxxxxxx",Object.values(index["trend"][0]))47 selectAr = index;48 series = Object.values(index["trend"][0])49 console.log(series)50 date = index["date"]51 system = index["system"]52 // test = index["Slider"]["FIX CHILLER"]53 //console.log("57 ", series)54 //console.log("selectAr", selectAr["Drive"])55 for (const [key, value] of Object.entries(index)) {56 if (key == "date" || key == "system" || key == "trend" || key == "Seagate") {57 } else {58 $('.chosen-value-operation').append("<option value='" + key + "'>" + key + "</option>")59 }60 }61 checkData(series, date, system)62 },63 });64 $('.chosen-value-operation').select2({65 placeholder: 'Select Operation',66 theme: "classic"67 });68 $('.chosen-value-systems').select2({69 placeholder: 'Select System',70 theme: "classic"71 });72 $('.chosen-value-point').select2({73 placeholder: 'Select Utility',74 theme: "classic"75 });76 $('.chosen-value-fullpoint').select2({77 placeholder: 'Select Point',78 theme: "classic"79 });80 $('.chosen-date').select2({81 placeholder: 'Select Type',82 theme: "classic"83 })84 $('.month1').select2('close')85 // ({86 // placeholder: 'Select Type',87 // theme: "classic"88 // })89 $('.month2').select2({90 placeholder: 'Select Type',91 theme: "classic"92 })93});94function GetData(getData, getValue, getDate, getIndex, getSummary, getTotalValue) {95 // console.log("function ", getDate.length);96 // console.log("name ", getData[0].data);97 // console.log("function get index ", getIndex[1].index);98 // console.log("aaaa ", getIndex.length);99 percentList = [];100 len = getDate.length - 1;101 for (percent = 0; percent < len; percent++) {102 //console.log("errrrr ", getIndex[percent].index);103 indexPercent = getIndex[percent].index;104 //console.log("len percent ", len(indexPercent))105 percentList.push(indexPercent);106 }107 head_name = [];108 for (i = 0; i < getDate.length; i++) {109 //console.log(i);110 if (head_name.indexOf(getDate[i]) === -1) {111 head_name.push(getDate[i]);112 }113 }114 console.log("head name ", head_name);115 var table = document.createElement("table");116 table.setAttribute("id", "main-table");117 table.setAttribute("class", "main-table");118 var tr = table.insertRow(-1);119 for (i = 0; i < head_name.length; i++) {120 var th = document.createElement("th");121 th.innerHTML = head_name[i];122 th.colSpan = 2;123 tr.appendChild(th);124 }125 var powerList = ["Opration Name"];126 for (i = 0; i < head_name.length - 1; i++) {127 powerList.push("Used (kW)");128 powerList.push("Percent (%)");129 }130 tr = table.insertRow(1);131 for (power = 0; power < powerList.length; power++) {132 var insertPower = tr.insertCell();133 if (power == 0) {134 insertPower.colSpan = 2;135 }136 insertPower.innerHTML = powerList[power];137 }138 for (i = 0; i < getData.length; i++) {139 var name_value = getData[i].name;140 if (name_value) {141 //console.log("get data ",getData[i].name, " ",getData[i].data)142 var loop = getData[i].data;143 var sort_loop = loop.slice();144 var loop_list = [];145 loop_list.push(getData[i].name);146 //loop_list.push(" ")147 for (j = 0; j < sort_loop.length; j++) {148 if (sort_loop[j + 1] == sort_loop[j]) {149 loop_list.push(sort_loop[j]);150 } else {151 loop_list.push(sort_loop[j]);152 //loop_list.push(percentList[0][0])153 }154 loop_list.push(percentList[j][i] + "%");155 }156 tr = table.insertRow();157 for (k = 0; k < loop_list.length; k++) {158 var insertData = tr.insertCell();159 if (k == 0) {160 insertData.colSpan = 2;161 }162 insertData.innerHTML = loop_list[k];163 }164 }165 }166 var showTable = document.getElementById("table-scroll");167 showTable.innerHTML = "";168 showTable.appendChild(table);169 $("tr")170 .not(":first")171 .hover(172 function () {173 $(this).css("background", "#567ad5");174 },175 function () {176 $(this).css("background", "");177 }178 );179 console.log("summary222", getSummary)180 //plot table th181 for (i = 0; i < getDate.length; i++) {182 $("#th-date").append('<th id="header" scope="col" colspan = 2>' + getDate[i] + '</th>')183 }184 for (i = 0; i < getSummary.length; i++) {185 system = Object.keys(getSummary[i])186 $("#ul-tab").append('<li class="nav-item"><a class="nav-link" href="#" value="' + system + '">' + system + '</a></li>')187 getSummary[i][system]["pointname"] = [... new Set(getSummary[i][system]["pointname"])]188 console.log(getSummary[i][system]["pointname"])189 }190 // console.log("output value", outputValue)191 // plot power and used192 $("#sub-th").append('<th id="first-column" scope="row" colspan = 2></th>')193 for (i = 1; i < getDate.length; i++) {194 $("#sub-th").append('<td id="unit" scope="col">Used (kW)</td>')195 $("#sub-th").append('<td id="unit" scope="col">Percent (%)</td>')196 }197 //set drive Fix เป็นค่าเริ่มต้น198 $("#ul-tab li").first().addClass("active")199 for (j = 0; j < Object.keys(getTotalValue).length; j++) {200 if (Object.keys(getTotalValue)[j] == 'Drive FIX') {201 // console.log(Object.keys(getTotalValue['Drive FIX']))202 for (i = 0; i < getSummary.length; i++) {203 if (Object.keys(getSummary[i]) == 'Drive FIX') {204 getSummary[i]['Drive FIX']["pointname"].push("Other")205 getSummary[i]['Drive FIX']["pointname"].push("Total")206 getKey = Object.keys(getSummary[i]['Drive FIX'])207 getKey.shift()208 for (k = 0; k < getTotalValue['Drive FIX'].length; k++) {209 // console.log(getKey)210 if ((getKey[k]) == Object.keys(getTotalValue['Drive FIX'][k])) {211 var result = getSummary[i]['Drive FIX'][getKey[k]].map(function (x) {212 return parseInt(x, 10);213 });214 var sumValue = result.reduce((a, b) => a + b, 0)215 var other = Object.values(getTotalValue['Drive FIX'][k])[0] - sumValue216 console.log(other)217 getSummary[i]['Drive FIX'][getKey[k]] = result218 getSummary[i]['Drive FIX'][getKey[k]].push(other)219 getSummary[i]['Drive FIX'][getKey[k]].push(Object.values(getTotalValue['Drive FIX'][k])[0])220 getSummary[i]['Drive FIX'][getKey[k]] = [... new Set(getSummary[i]['Drive FIX'][getKey[k]])]221 var percent = getSummary[i]['Drive FIX'][getKey[k]].map(function (x) {222 return parseFloat(((x / Object.values(getTotalValue['Drive FIX'][k])[0]) * 100).toFixed(2)) +"%";223 });224 console.log(percent)225 getSummary[i]['Drive FIX'][getKey[k] + "Percent"] = percent226 // getSummary[i]['Drive FIX'].push([{227 // percent : percent228 // }])229 }230 }231 getSummary[i]['Drive FIX']["pointname"] = [... new Set(getSummary[i]['Drive FIX']["pointname"])]232 driveSet = getSummary[i]['Drive FIX']["pointname"]233 }234 }235 }236 }237 driveSummary = driveSet238 // console.log(getSummary)239 var valueList = []240 var pointname = []241 for (i = 0; i < getSummary.length; i++) {242 // console.log(getSummary[i])243 $.each(getSummary[i], function (key, value) {244 // console.log(key)245 // console.log("462",href)246 if ('Drive FIX' == key) {247 console.log(getSummary[i][key])248 var sortObject = Object.fromEntries(Object.entries(getSummary[i][key]).sort())249 console.log(sortObject)250 $.each(sortObject, function (key, value) {251 if (key == 'pointname') {252 pointname.push(value)253 } else {254 valueList.push(value)255 }256 })257 }258 })259 }260 var rows = valueList;261 // console.log(rows[0])262 var result = [];263 for (var i = 0; i < rows[0].length; i++) {264 result[i] = new Array(rows[0].length).fill();265 for (var j = 0; j < rows.length; j++) {266 result[i][j] = rows[j][i]; // Here is the fixed column access using the outter index i.267 }268 }269 // console.log(result.length)270 // var resultF = result.filter(x => x !== undefined)271 for (i = 0; i < result.length; i++) {272 result[i] = result[i].filter(x => x !== undefined)273 }274 // console.log(result)275 $('#pointname tr').remove()276 // console.log(result)277 var resultFinal = result278 var table = $('#pointname');279 var row, cell;280 for (var i = 0; i < pointname[0].length; i++) {281 // $('#pointname').append('<tr><td colspan=2>'+pointname[0][i]+'</td></tr>')282 row = $('<tr />');283 row.id = "contOp";284 table.append(row);285 firstChild = $('<td colspan=2>' + pointname[0][i] + '</td>')286 row.append(firstChild)287 for (var j = 0; j < resultFinal[i].length; j++) {288 //firstChild = $('<td>'+pointname[0][i]+'</td>')289 cell = $('<td>' + resultFinal[i][j] + '</td>')290 // row.append(firstChild)291 row.append(cell);292 }293 }294 // if user click295 var href;296 var driveSummary;297 var driveList;298 $('ul.nav li a').click(function (event) {299 $('#pointname tr').remove()300 //event.preventDefault();301 href = $(event.target).text();302 console.log("href", href)303 if (href == 'Drive FIX') {304 $('li a').removeClass("active");305 $(this).addClass("active");306 for (j = 0; j < Object.keys(getTotalValue).length; j++) {307 if (Object.keys(getTotalValue)[j] == 'Drive FIX') {308 // console.log(Object.keys(getTotalValue['Drive FIX']))309 for (i = 0; i < getSummary.length; i++) {310 if (Object.keys(getSummary[i]) == 'Drive FIX') {311 getSummary[i]['Drive FIX']["pointname"].push("Other")312 getSummary[i]['Drive FIX']["pointname"].push("Total")313 getKey = Object.keys(getSummary[i]['Drive FIX'])314 getKey.shift()315 for (k = 0; k < getTotalValue['Drive FIX'].length; k++) {316 // console.log(getKey)317 if ((getKey[k]) == Object.keys(getTotalValue['Drive FIX'][k])) {318 var result = getSummary[i]['Drive FIX'][getKey[k]].map(function (x) {319 return parseInt(x, 10);320 });321 var sumValue = result.reduce((a, b) => a + b, 0)322 var other = Object.values(getTotalValue['Drive FIX'][k])[0] - sumValue323 console.log(other)324 getSummary[i]['Drive FIX'][getKey[k]] = result325 getSummary[i]['Drive FIX'][getKey[k]].push(other)326 getSummary[i]['Drive FIX'][getKey[k]].push(Object.values(getTotalValue['Drive FIX'][k])[0])327 getSummary[i]['Drive FIX'][getKey[k]] = [... new Set(getSummary[i]['Drive FIX'][getKey[k]])]328 var percent = getSummary[i]['Drive FIX'][getKey[k]].map(function (x) {329 return parseFloat(((x / Object.values(getTotalValue['Drive FIX'][k])[0]) * 100).toFixed(2)) +"%";330 });331 console.log(percent)332 getSummary[i]['Drive FIX'][getKey[k] + "Percent"] = percent333 // getSummary[i]['Drive FIX'].push([{334 // percent : percent335 // }])336 }337 }338 getSummary[i]['Drive FIX']["pointname"] = [... new Set(getSummary[i]['Drive FIX']["pointname"])]339 driveSet = getSummary[i]['Drive FIX']["pointname"]340 }341 }342 }343 }344 driveSummary = driveSet345 console.log(getSummary)346 } else if (href == 'Drive VAR') {347 $('li a').removeClass("active");348 $(this).addClass("active");349 for (j = 0; j < Object.keys(getTotalValue).length; j++) {350 if (Object.keys(getTotalValue)[j] == 'Drive VAR') {351 console.log(Object.keys(getTotalValue['Drive VAR']))352 for (i = 0; i < getSummary.length; i++) {353 if (Object.keys(getSummary[i]) == 'Drive VAR') {354 getSummary[i]['Drive VAR']["pointname"].push("Other")355 getSummary[i]['Drive VAR']["pointname"].push("Total")356 getKey = Object.keys(getSummary[i]['Drive VAR'])357 getKey.shift()358 for (k = 0; k < getTotalValue['Drive VAR'].length; k++) {359 console.log(getKey)360 if ((getKey[k]) == Object.keys(getTotalValue['Drive VAR'][k])) {361 var result = getSummary[i]['Drive VAR'][getKey[k]].map(function (x) {362 return parseInt(x, 10);363 });364 var sumValue = result.reduce((a, b) => a + b, 0)365 var other = Object.values(getTotalValue['Drive VAR'][k])[0] - sumValue366 console.log(other)367 getSummary[i]['Drive VAR'][getKey[k]] = result368 getSummary[i]['Drive VAR'][getKey[k]].push(other)369 getSummary[i]['Drive VAR'][getKey[k]].push(Object.values(getTotalValue['Drive VAR'][k])[0])370 getSummary[i]['Drive VAR'][getKey[k]] = [... new Set(getSummary[i]['Drive VAR'][getKey[k]])]371 var percent = getSummary[i]['Drive VAR'][getKey[k]].map(function (x) {372 return parseFloat(((x / Object.values(getTotalValue['Drive VAR'][k])[0]) * 100).toFixed(2))+"%";373 });374 console.log(percent)375 getSummary[i]['Drive VAR'][getKey[k] + "Percent"] = percent376 }377 }378 getSummary[i]['Drive VAR']["pointname"] = [... new Set(getSummary[i]['Drive VAR']["pointname"])]379 }380 }381 }382 }383 } else if (href == 'HSA FIX') {384 $('li a').removeClass("active");385 $(this).addClass("active");386 for (j = 0; j < Object.keys(getTotalValue).length; j++) {387 if (Object.keys(getTotalValue)[j] == 'HSA FIX') {388 console.log(Object.keys(getTotalValue['HSA FIX']))389 for (i = 0; i < getSummary.length; i++) {390 if (Object.keys(getSummary[i]) == 'HSA FIX') {391 getSummary[i]['HSA FIX']["pointname"].push("Other")392 getSummary[i]['HSA FIX']["pointname"].push("Total")393 getKey = Object.keys(getSummary[i]['HSA FIX'])394 getKey.shift()395 for (k = 0; k < getTotalValue['HSA FIX'].length; k++) {396 console.log(getKey)397 if ((getKey[k]) == Object.keys(getTotalValue['HSA FIX'][k])) {398 var result = getSummary[i]['HSA FIX'][getKey[k]].map(function (x) {399 return parseInt(x, 10);400 });401 var sumValue = result.reduce((a, b) => a + b, 0)402 var other = Object.values(getTotalValue['HSA FIX'][k])[0] - sumValue403 console.log(other)404 getSummary[i]['HSA FIX'][getKey[k]] = result405 getSummary[i]['HSA FIX'][getKey[k]].push(other)406 getSummary[i]['HSA FIX'][getKey[k]].push(Object.values(getTotalValue['HSA FIX'][k])[0])407 getSummary[i]['HSA FIX'][getKey[k]] = [... new Set(getSummary[i]['HSA FIX'][getKey[k]])]408 var percent = getSummary[i]['HSA FIX'][getKey[k]].map(function (x) {409 return parseFloat(((x / Object.values(getTotalValue['HSA FIX'][k])[0]) * 100).toFixed(2)) +"%";410 });411 console.log(percent)412 getSummary[i]['HSA FIX'][getKey[k] + "Percent"] = percent413 }414 }415 getSummary[i]['HSA FIX']["pointname"] = [... new Set(getSummary[i]['HSA FIX']["pointname"])]416 }417 }418 }419 }420 } else if (href == 'HSA VAR') {421 $('li a').removeClass("active");422 $(this).addClass("active");423 hsaVarvalue = ["Total"]424 hsaVarList = ["Bldg.1A & Bldg.2A"]425 console.log("eeeee", getTotalValue['HSA VAR'])426 $.each(getTotalValue['HSA VAR'], function(key,value){427 console.log(value)428 hsaVarList.push(Object.values(value)[0], "100%")429 hsaVarvalue.push(Object.values(value)[0], "100%")430 })431 console.log("hsa var", hsaVarList)432 hsaVarList = [hsaVarList]433 hsaVarvalue = [hsaVarvalue]434 var table = document.getElementById('pointname')435 var row = {}436 var cell = {}437 hsaVarList.forEach(function(rowData){438 row = table.insertRow(-1)439 rowData.forEach(function(cellData){440 cell = row.insertCell()441 cell.textContent = cellData442 })443 })444 var row2 = {}445 var cell2 = {}446 hsaVarvalue.forEach(function(rowD){447 row2 = table.insertRow(-1)448 rowD.forEach(function(cellD){449 cell2 = row2.insertCell()450 cell2.textContent = cellD451 })452 })453 454 // $('#pointname td:first[colspan=2]')455 $('#pointname').append(row)456 $('#pointname').append(row2)457 $('#pointname td:first').attr('colspan',2)458 $('#pointname tr:last td:first').attr('colspan',2)459 460 // $('#pointname').append('<tr></tr>')461 // var row = $('tr />')462 // for (i=0; i < hsaVarList.length; i++) {463 // row.append('<td>'+hsaVarList[i]+'</td>')464 // }465 // $('#pointname').append(row)466 } else if (href == 'Slider FIX') {467 $('li a').removeClass("active");468 $(this).addClass("active");469 for (j = 0; j < Object.keys(getTotalValue).length; j++) {470 if (Object.keys(getTotalValue)[j] == 'Slider FIX') {471 console.log(Object.keys(getTotalValue['Slider FIX']))472 for (i = 0; i < getSummary.length; i++) {473 if (Object.keys(getSummary[i]) == 'Slider FIX') {474 getSummary[i]['Slider FIX']["pointname"].push("Other")475 getSummary[i]['Slider FIX']["pointname"].push("Total")476 getKey = Object.keys(getSummary[i]['Slider FIX'])477 getKey.shift()478 for (k = 0; k < getTotalValue['Slider FIX'].length; k++) {479 console.log(getKey)480 if ((getKey[k]) == Object.keys(getTotalValue['Slider FIX'][k])) {481 var result = getSummary[i]['Slider FIX'][getKey[k]].map(function (x) {482 return parseInt(x, 10);483 });484 var sumValue = result.reduce((a, b) => a + b, 0)485 var other = Object.values(getTotalValue['Slider FIX'][k])[0] - sumValue486 console.log(other)487 getSummary[i]['Slider FIX'][getKey[k]] = result488 getSummary[i]['Slider FIX'][getKey[k]].push(other)489 getSummary[i]['Slider FIX'][getKey[k]].push(Object.values(getTotalValue['Slider FIX'][k])[0])490 getSummary[i]['Slider FIX'][getKey[k]] = [... new Set(getSummary[i]['Slider FIX'][getKey[k]])]491 var percent = getSummary[i]['Slider FIX'][getKey[k]].map(function (x) {492 return parseFloat(((x / Object.values(getTotalValue['Slider FIX'][k])[0]) * 100).toFixed(2)) +"%";493 });494 console.log(percent)495 getSummary[i]['Slider FIX'][getKey[k] + "Percent"] = percent496 }497 }498 getSummary[i]['Slider FIX']["pointname"] = [... new Set(getSummary[i]['Slider FIX']["pointname"])]499 }500 }501 }502 }503 } else if (href == 'Slider VAR') {504 $('li a').removeClass("active");505 $(this).addClass("active");506 for (j = 0; j < Object.keys(getTotalValue).length; j++) {507 if (Object.keys(getTotalValue)[j] == 'Slider VAR') {508 console.log(Object.keys(getTotalValue['Slider VAR']))509 for (i = 0; i < getSummary.length; i++) {510 if (Object.keys(getSummary[i]) == 'Slider VAR') {511 getSummary[i]['Slider VAR']["pointname"].push("Bldg.1")512 getSummary[i]['Slider VAR']["pointname"].push("Total")513 getKey = Object.keys(getSummary[i]['Slider VAR'])514 getKey.shift()515 for (k = 0; k < getTotalValue['Slider VAR'].length; k++) {516 // console.log(getKey)517 if ((getKey[k]) == Object.keys(getTotalValue['Slider VAR'][k])) {518 var result = getSummary[i]['Slider VAR'][getKey[k]].map(function (x) {519 return parseInt(x, 10);520 });521 var sumValue = result.reduce((a, b) => a + b, 0)522 var other = Object.values(getTotalValue['Slider VAR'][k])[0] - sumValue523 console.log(other)524 getSummary[i]['Slider VAR'][getKey[k]] = result525 getSummary[i]['Slider VAR'][getKey[k]].push(other)526 getSummary[i]['Slider VAR'][getKey[k]].push(Object.values(getTotalValue['Slider VAR'][k])[0])527 getSummary[i]['Slider VAR'][getKey[k]] = [... new Set(getSummary[i]['Slider VAR'][getKey[k]])]528 var percent = getSummary[i]['Slider VAR'][getKey[k]].map(function (x) {529 return parseFloat(((x / Object.values(getTotalValue['Slider VAR'][k])[0]) * 100).toFixed(2)) +"%";530 });531 console.log(percent)532 getSummary[i]['Slider VAR'][getKey[k] + "Percent"] = percent533 }534 }535 getSummary[i]['Slider VAR']["pointname"] = [... new Set(getSummary[i]['Slider VAR']["pointname"])]536 }537 }538 }539 }540 }541 var valueList = []542 var pointname = []543 for (i = 0; i < getSummary.length; i++) {544 // console.log(getSummary[i])545 $.each(getSummary[i], function (key, value) {546 // console.log(key)547 // console.log("462",href)548 if (href == key) {549 console.log(getSummary[i][key])550 var sortObject = Object.fromEntries(Object.entries(getSummary[i][key]).sort())551 console.log(sortObject)552 $.each(sortObject, function (key, value) {553 if (key == 'pointname') {554 pointname.push(value)555 } else {556 valueList.push(value)557 }558 })559 }560 })561 }562 var rows = valueList;563 console.log(rows[0])564 var result = [];565 for (var i = 0; i < rows[0].length; i++) {566 result[i] = new Array(rows[0].length).fill();567 for (var j = 0; j < rows.length; j++) {568 result[i][j] = rows[j][i]; // Here is the fixed column access using the outter index i.569 }570 }571 console.log(result.length)572 // var resultF = result.filter(x => x !== undefined)573 for (i = 0; i < result.length; i++) {574 result[i] = result[i].filter(x => x !== undefined)575 }576 console.log(result)577 console.log(result)578 var resultFinal = result579 var table = $('#pointname');580 var row, cell;581 for (var i = 0; i < pointname[0].length; i++) {582 // $('#pointname').append('<tr><td colspan=2>'+pointname[0][i]+'</td></tr>')583 row = $('<tr />');584 table.append(row);585 firstChild = $('<td colspan=2>' + pointname[0][i] + '</td>')586 row.append(firstChild)587 for (var j = 0; j < resultFinal[i].length; j++) {588 //firstChild = $('<td>'+pointname[0][i]+'</td>')589 cell = $('<td>' + resultFinal[i][j] + '</td>')590 // row.append(firstChild)591 row.append(cell);592 }593 }594 })595 console.log(getSummary)596}597const inputField = document.querySelector(".chosen-value-systems");598const dropdown = document.querySelector(".value-list-systems");599const dropdownArray = document.querySelectorAll("li");600console.log(typeof dropdownArray); ``601dropdown.classList.add("open");602inputField.focus(); // Demo purposes only603let valueArray = [];604dropdownArray.forEach((item) => {605 valueArray.push(item.textContent);606});607const closeDropdown = () => {608 dropdown.classList.remove("open");609};610inputField.addEventListener("input", () => {611 dropdown.classList.add("open");612 let inputValue = inputField.value.toLowerCase();613 let valueSubstring;614 if (inputValue.length > 0) {615 for (let j = 0; j < valueArray.length; j++) {616 if (617 !(618 inputValue.substring(0, inputValue.length) ===619 valueArray[j].substring(0, inputValue.length).toLowerCase()620 )621 ) {622 dropdownArray[j].classList.add("closed");623 } else {624 dropdownArray[j].classList.remove("closed");625 }626 }627 } else {628 for (let i = 0; i < dropdownArray.length; i++) {629 dropdownArray[i].classList.remove("closed");630 }631 }632});633dropdownArray.forEach((item) => {634 item.addEventListener("click", (evt) => {635 inputField.value = item.textContent;636 dropdownArray.forEach((dropdown) => {637 dropdown.classList.add("closed");638 });639 });640});641inputField.addEventListener("focus", () => {642 inputField.placeholder = "Type to filter";643 dropdown.classList.add("open");644 dropdownArray.forEach((dropdown) => {645 dropdown.classList.remove("closed");646 });647});648inputField.addEventListener("blur", () => {649 inputField.placeholder = "Select state";650 dropdown.classList.remove("open");651});652document.addEventListener("click", (evt) => {653 const isDropdown = dropdown.contains(evt.target);654 const isInput = inputField.contains(evt.target);655 if (!isDropdown && !isInput) {656 dropdown.classList.remove("open");657 }658});659function SelectOperation(selectObject) {660 var selected = selectObject.value;661 console.log("select operation ", selected);662 $(".chosen-value-systems").empty();663 for (const [key, value] of Object.entries(selectAr[selected])) {664 console.log("TEST TEST " + key);665 $('.chosen-value-systems').append("<option value='" + key + "'>" + key + "</option>")666 }667 //checkData(selected)668}669function SelectSystem(selectObject) {670 var operation = $("select.chosen-value-operation option:checked").val();671 var systems = $("select.chosen-value-systems option:checked").val();672 var selectedOperation = selectAr[operation]673 var selected = selectObject.value;674 console.log("select system ", selected);675 //$(".chosen-value-systems").empty();676 Utility = []677 for (const [key, value] of Object.entries(selectedOperation[systems])) {678 console.log("TEST TEST " + key);679 var utility = key.slice(0, 4)680 if (Utility.indexOf(utility) === -1) {681 $('.chosen-value-point').append("<option value='" + utility + "'>" + utility + "</option>")682 Utility.push(utility)683 }684 }685}686function SelectPoint(selectObject) {687 var point = $("select.chosen-value-point").val();688 var operation = $("select.chosen-value-operation option:checked").val();689 var systems = $("select.chosen-value-systems option:checked").val();690 var selected = selectObject.value;691 console.log("selected Point ", point);692 var selectedPoint = selectAr[operation][systems]693 console.log("select point ", point)694 //Pointlist = []695 $('.chosen-value-fullpoint').find("option").remove().end()696 for (const [key, value] of Object.entries(selectedPoint)) {697 for (i = 0; i < point.length; i++) {698 if ((key.indexOf(point[i])) !== -1) {699 console.log("testttttttt ", key)700 $('.chosen-value-fullpoint').append("<option value='" + value + "'>" + key + "</option>")701 //$('.chosen-value-fullpoint').append("<option value='"+key+"'>"+key+"</option>")702 }703 }704 }705}706function SelectFullPoint(selectObject) {707 var fullpoint = $("select.chosen-value-fullpoint").val();708 var point = $("select.chosen-value-point").val();709 var operation = $("select.chosen-value-operation option:checked").val();710 var systems = $("select.chosen-value-systems option:checked").val();711 var selected = selectObject.value;712 var selectedPoint = selectAr[operation][systems]713 console.log("selected Point ", fullpoint);714 valueList = []715 //$('.chosen-value-fullpoint').find("option").remove().end()716 for (const [key, value] of Object.entries(selectedPoint)) {717 for (i = 0; i < fullpoint.length; i++) {718 if (fullpoint[i] == key) {719 console.log("key " + key + " value " + value)720 valueList.push({721 "key": key,722 "value": value723 })724 }725 }726 }727 console.log(valueList)728 CheckValue(valueList)729 //return fullpoint730}731function CheckValue(valueList) {732 var check = $(".chosen-value-fullpoint").val()733 var name = $(".chosen-value-fullpoint").option734 console.log(check)735 console.log("value list ", valueList)736 console.log(name)737 test = []738 for (value = 0; value < checkValue.length; value++) {739 //console.log(checkValue[value]["PointID"])740 for (i = 0; i < check.length; i++) {741 if (check[i] == checkValue[value]["PointID"]) {742 console.log(checkValue[value]["Value"])743 test.push({744 "name": check[i],745 "data": checkValue[value]["Value"]746 })747 }748 }749 }750 console.log(test)751}752function checkData(series, date, system) {753 console.log("series ", series);754 //console.log("system", selected_system);755 //console.log("date hhhhhhhhhhhhhhhhhhhhhh", SliderFix_utility_date[0])756 Highcharts.chart("container-chart", {757 chart: {758 type: "spline",759 },760 title: {761 text: "Consumption Analysis Graph of " + system,762 },763 yAxis: {764 title: {765 text: "Number of Used (kW)",766 },767 },768 xAxis: {769 accessibility: {770 rangeDescription: "",771 },772 categories: date,773 },774 legend: {775 layout: 'horizontal',776 align: 'center',777 verticalAlign: 'bottom',778 },779 tooltip: {780 useHTML: true,781 backgroundColor: '#ffffff',782 },783 plotOptions: {784 series: {785 label: {786 connectorAllowed: false,787 },788 },789 },790 colors: ['#FFFFFF', '#FF0000', '#FFFF00', '#00FF00', '#0000FF', '#FF00FF', '#008000', '#FE4365'],791 series: series,792 responsive: {793 rules: [794 {795 condition: {796 maxWidth: 800,797 },798 chartOptions: {799 legend: {800 layout: "horizontal",801 align: "center",802 verticalAlign: "bottom",803 },804 },805 },806 ],807 },808 });809}810function Chosen_date() {811 var chosen_date = $(".chosen-date").val()812 console.log("Choseeeeeeen ", chosen_date)813 if (chosen_date == "Daily") {814 alert(chosen_date)815 $('#date1').show()816 $('#date2').show()817 $('#week1').hide()818 $('#week2').hide()819 $('#month1').hide()820 $('#month2').hide()821 } else if (chosen_date == "Weekly") {822 alert(chosen_date)823 $('#week1').show()824 $('#week2').show()825 $('#date1').hide()826 $('#date2').hide()827 $('#month1').hide()828 $('#month2').hide()829 } else if (chosen_date == "Monthly") {830 alert(chosen_date)831 $('#month1').show()832 $('#month2').show()833 $('#year').show()834 $('#date1').hide()835 $('#date2').hide()836 $('#week1').hide()837 $('#week2').hide()838 } else {839 }...

Full Screen

Full Screen

get_channel_balance.js

Source:get_channel_balance.js Github

copy

Full Screen

1const asyncAuto = require('async/auto');2const {returnResult} = require('asyncjs-util');3const {isLnd} = require('./../../lnd_requests');4const method = 'channelBalance';5const type = 'default';6/** Get balance across channels.7 Requires `offchain:read` permission8 `channel_balance_mtokens` is not supported on LND 0.11.1 and below9 `inbound` and `inbound_mtokens` are not supported on LND 0.11.1 and below10 `pending_inbound` is not supported on LND 0.11.1 and below11 `unsettled_balance` is not supported on LND 0.11.1 and below12 `unsettled_balance_mtokens` is not supported on LND 0.11.1 and below13 {14 lnd: <Authenticated LND API Object>15 }16 @returns via cbk or Promise17 {18 channel_balance: <Channels Balance Tokens Number>19 [channel_balance_mtokens]: <Channels Balance Millitokens String>20 [inbound]: <Inbound Liquidity Tokens Number>21 [inbound_mtokens]: <Inbound Liquidity Millitokens String>22 pending_balance: <Pending On-Chain Channels Balance Tokens Number>23 [pending_inbound]: <Pending On-Chain Inbound Liquidity Tokens Number>24 [unsettled_balance]: <In-Flight Tokens Number>25 [unsettled_balance_mtokens]: <In-Flight Millitokens String>26 }27*/28module.exports = ({lnd}, cbk) => {29 return new Promise((resolve, reject) => {30 return asyncAuto({31 // Check arguments32 validate: cbk => {33 if (!isLnd({lnd, method, type})) {34 return cbk([400, 'ExpectedLndGrpcApiForChannelBalanceQuery']);35 }36 return cbk();37 },38 // Get channel balance summary39 getSummary: ['validate', ({}, cbk) => {40 return lnd[type][method]({}, (err, res) => {41 if (!!err) {42 return cbk([503, 'UnexpectedGetChannelBalanceError', {err}]);43 }44 if (!res) {45 return cbk([503, 'ExpectedGetChannelBalanceResponse']);46 }47 if (res.balance === undefined) {48 return cbk([503, 'ExpectedChannelBalance']);49 }50 if (res.pending_open_balance === undefined) {51 return cbk([503, 'ExpectedPendingOpenBalance']);52 }53 return cbk(null, res);54 });55 }],56 // Derive balances57 balances: ['getSummary', ({getSummary}, cbk) => {58 // Exit early when there is no extended balance data59 if (!getSummary.local_balance) {60 return cbk(null, {61 channel_balance: Number(getSummary.balance),62 pending_balance: Number(getSummary.pending_open_balance),63 });64 }65 if (!getSummary.local_balance.msat) {66 return cbk([503, 'ExpectedLocalChannelBalanceMSatsInResponse']);67 }68 if (!getSummary.local_balance.sat) {69 return cbk([503, 'ExpectedLocalChannelBalanceSatsInResponse']);70 }71 // Check that pending open balance is present72 if (!getSummary.pending_open_local_balance) {73 return cbk([503, 'ExpectedPendingOpenChannelBalanceInResponse']);74 }75 if (!getSummary.pending_open_local_balance.msat) {76 return cbk([503, 'ExpectedPendingOpenBalanceMSatsInResponse']);77 }78 if (!getSummary.pending_open_local_balance.sat) {79 return cbk([503, 'ExpectedPendingOpenBalanceSatsInResponse']);80 }81 // Check that pending open remote balance is present82 if (!getSummary.pending_open_remote_balance) {83 return cbk([503, 'ExpectedPendingRemoteChannelBalanceInResponse']);84 }85 if (!getSummary.pending_open_remote_balance.msat) {86 return cbk([503, 'ExpectedPendingOpenRemoteBalanceMSatsInResponse']);87 }88 if (!getSummary.pending_open_remote_balance.sat) {89 return cbk([503, 'ExpectedPendingOpenRemoteBalanceSatsInResponse']);90 }91 // Check that the remote balance details are present92 if (!getSummary.remote_balance) {93 return cbk([503, 'ExpectedRemoteChannelBalanceInResponse']);94 }95 if (!getSummary.remote_balance.msat) {96 return cbk([503, 'ExpectedRemoteChannelBalanceMSatsInResponse']);97 }98 if (!getSummary.remote_balance.sat) {99 return cbk([503, 'ExpectedRemoteChannelBalanceSatsInResponse']);100 }101 // Check that unsettled balance details are present102 if (!getSummary.unsettled_local_balance) {103 return cbk([503, 'ExpectedUnsettledLocalChannelBalanceInResponse']);104 }105 if (!getSummary.unsettled_local_balance.msat) {106 return cbk([503, 'ExpectedUnsettledLocalBalanceMSatsInResponse']);107 }108 if (!getSummary.unsettled_local_balance.sat) {109 return cbk([503, 'ExpectedUnsettledLocalBalanceSatsInResponse']);110 }111 // Check that unsettled remote balance details are present112 if (!getSummary.unsettled_remote_balance) {113 return cbk([503, 'ExpectedUnsettledRemoteChannelBalanceInResponse']);114 }115 if (!getSummary.unsettled_remote_balance.msat) {116 return cbk([503, 'ExpectedUnsettledRemoteBalanceSatsInResponse']);117 }118 if (!getSummary.unsettled_remote_balance.sat) {119 return cbk([503, 'ExpectedUnsettledRemoteBalanceSatsInResponse']);120 }121 return cbk(null, {122 channel_balance: Number(getSummary.local_balance.sat),123 channel_balance_mtokens: getSummary.local_balance.msat,124 inbound: Number(getSummary.remote_balance.sat),125 inbound_mtokens: getSummary.remote_balance.msat,126 pending_balance: Number(getSummary.pending_open_local_balance.sat),127 pending_inbound: Number(getSummary.pending_open_remote_balance.sat),128 unsettled_balance: Number(getSummary.unsettled_local_balance.sat),129 unsettled_balance_mtokens: getSummary.unsettled_local_balance.msat,130 });131 }],132 },133 returnResult({reject, resolve, of: 'balances'}, cbk));134 });...

Full Screen

Full Screen

OPP.js

Source:OPP.js Github

copy

Full Screen

...4 this.title = title;5 this.author = author;6 this.year = year;7 }8 getSummary() {9 return `${this.title} was written by ${this.author} in ${this.year}`; 10 }11}12// Magazine Subclass13class Magazine extends Book {14 constructor(title, author, year, month) {15 super(title, author, year);16 this.month = month;17 }18}19// Instantiate Magazine20const mag1 = new Magazine('Mag One', 'John Doe', '2022', 'Feb');21console.log(mag1.getSummary());22// console.log(mag1);23// // Classes24// class Book {25// constructor(title, author, year) {26// this.title = title;27// this.author = author;28// this.year = year;29// }30// getSummary() {31// return `${this.title} was written by ${this.author} in ${this.year}`; 32// }33// getAge() {34// const years = new Date().getFullYear() - this.year;35// return `${this.title} is ${years} years old`;36// } 37// revise(newYear) {38// this.year = newYear;39// this.revised = true;40// }41// static topBookStore() {42// return 'Barnes & Noble';43// }44// }45// // Instantiate Object46// const book1 = new Book('Boon One', 'John Doe', '2013');47// console.log(book1);48// book1.revise('2022');49// console.log(book1);50// console.log(Book.topBookStore());51// book1.topBookStore();52// // Object Of Protos53// const bookProtos = {54// getSummary: function() {55// return `${this.title} was written by ${this.author} in ${this.year}`; 56// },57// getAge: function() {58// const years = new Date().getFullYear() - this.year;59// return `${this.title} is ${years} years old`;60// } 61// }62// // // Create Object63// // const book1 = Object.create(bookProtos);64// // book1.title = 'Book One';65// // book1.author = 'John Doe';66// // book1.year = '2013';67// const book1 = Object.create(bookProtos, {68// title: { value: 'Book One' },69// author: { value: 'John Doe' },70// year: { value: '2013'}71// });72// console.log(book1);73// Inheritance74// function Book(title, author, year) {75// this.title = title;76// this.author = author;77// this.year = year;78// }79// getSummary80// Book.prototype.getSummary = function() {81// return `${this.title} was written by ${this.author} in ${this.year}`;82// };83// Magazine Constructor84// function Magazine(title, author, year, month) {85// Book.call(this, title, author, year);86// this.month = month;87// }88// Inherit Prototype89// Magazine.prototype = Object.create(Book.prototype);90// // Instantiate Magazine Object91// const mag1 = new Magazine('Mag One', 'John Doe', '2022', 'Feb');92// // Use Magazine Constructor93// Magazine.prototype.constructor = Magazine;94// console.log(mag1);95// console.log(mag1.getSummary());96// Prototype97// function Book(title, author, year) {98// this.title = title;99// this.author = author;100// this.year = year;101// }102// // getSummary103// Book.prototype.getSummary = function() {104// return `${this.title} was written by ${this.author} in ${this.year}`;105// };106// getAge107// Book.prototype.getAge = function() {108// const years = new Date().getFullYear() - this.year;109// return `${this.title} is ${years} years old`;110// };111// Revise / Change Year112// Book.prototype.revise = function(newYear) {113// this.year = newYear;114// this.revised = true;115// };116// Instantiate an Oject117// const book1 = new Book('Book One', 'John Doe', '2013');118// const book2 = new Book('Book Two', 'Jane Doe', '2016');119// console.log(book2);120// book2.revise('2022');121// console.log(book2);122// console.log(book2.getAge());123// console.log(book2.getSummary());124// console.log(book2.getSummary());125// Constructor126// function Book(title, author, year) {127// this.title = title;128// this.author = author;129// this.year = year;130// this.getSummary = function() {131// return `${this.title} was written by ${this.author} in ${this.year}`;132// }133// };134// // Instantiate an Oject135// const book1 = new Book('Book One', 'John Doe', '2013');136// const book2= new Book('Book Two', 'Jane Doe', '2016');137// // console.log(book2.getSummary());138// console.log(book2);139// const s1 = 'Hello';140// console.log(typeof s1);141// const s2 = new String('Hello');142// console.log(typeof s2);143// 144// console.log(window);145// alert(1);146// console.log(navigator.appVersion);147// Object Literal148// const book1 = {149// title: 'Book One',150// author: 'John Doe',151// year: '2013', 152// getSummary: function() {153// return `${this.title} was written by ${this.author} in ${this.year}`;154// }155// };156// // console.log(book1.getSummary());157// const book2 = {158// title: 'Book Two',159// author: 'Jane Doe',160// year: '2016', 161// getSummary: function() {162// return `${this.title} was written by ${this.author} in ${this.year}`;163// }164// };165// console.log(book2.getSummary());166// console.log(Object.values(book2));...

Full Screen

Full Screen

oop.js

Source:oop.js Github

copy

Full Screen

...8 return `${this.title} was written by ${this.author} in ${this.year}`;9 }10};1112console.log(book1.getSummary());13console.log(Object.values(book1));14console.log(Object.keys(book1));15*/1617/*18//2. Constructors & 3. Prototype19//Constructor20function Book(title, author, year){21 // console.log('Book Initiated..');22 this.title = title;23 this.author = author;24 this.year = year;25 this.getSummary = function() {26 return `${this.title} was written by ${this.author} in ${this.year}`;27 }28}2930// console.log(book1.getSummary());31// console.log(book2.getSummary());3233//getAge34Book.prototype.getAge = function() {35 const years = new Date().getFullYear() - this.year;36 return `${this.title} is ${years} year old`;37}3839// console.log(book2.getAge());4041//revise / change year42Book.prototype.revise = function(newYear) {43 this.year = newYear;44 this.revised = true;45}4647//Instantiate48const book1 = new Book('Book 1', 'John Doe', '2012');49const book2 = new Book('Book 2', 'Sam Dill', '2015');5051console.log(book2);52book2.revise('2018');53console.log(book2);5455*/56/*57//4.Inheritance58//Constructor59function Book(title, author, year){60 // console.log('Book Initiated..');61 this.title = title;62 this.author = author;63 this.year = year;6465}66//get Summary67Book.prototype.getSummary = function() {68 return `${this.title} was written by ${this.author} in ${this.year}`;69}7071//Magazine Constructor72function Magazine (title, author, year, month){73 Book.call(this, title, author, year);74 this.month = month;75}7677//Inherit Prototype78Magazine.prototype = Object.create(Book.prototype);7980//Instantiate Magazine Object81const mag1 = new Magazine('Mag 1', 'Peter', '2099', 'December');8283//Use Magazine Constructor84Magazine.prototype.constructor = Magazine;8586console.log(mag1.getSummary());87console.log(mag1);88*/8990/*91//5.Object Create92const bookProtos = {93 getSummary: function () {94 return `${this.title} was written by ${this.author} in ${this.year}`;95 },96 getAge : function() {97 const years = new Date().getFullYear() - this.year;98 return `${this.title} is ${years} year old`;99 }100};101102//Create Object103const book1 = Object.create(bookProtos);104book1.title = 'Book 1';105book1.author = 'Bill';106book1.year = '2222';107console.log(book1);108109*/110/*111//6.Class112class Book {113 constructor(title, author, year){114 this.title = title;115 this.author = author;116 this.year = year;117 }118 getSummary() {119 return `${this.title} was written by ${this.author} in ${this.year}`;120 }121 getAge() {122 const years = new Date().getFullYear() - this.year;123 return `${this.title} is ${years} year old`;124 }125 revise (newYear) {126 this.year = newYear;127 this.revised = true;128 }129}130*/131132//6.SubClass133class Book {134 constructor(title, author, year){135 this.title = title;136 this.author = author;137 this.year = year;138 }139 getSummary() {140 return `${this.title} was written by ${this.author} in ${this.year}`;141 }142}143144class Magazine extends Book {145 constructor(title, author, year, month) {146 super(title, author, year);147 this.month = month;148 }149}150151const mag1 = new Magazine ('Mag1', 'Will', '2022', 'Jannuary'); ...

Full Screen

Full Screen

tests.js

Source:tests.js Github

copy

Full Screen

...8 t = new tsunit_1.TestRun("self test #" + (c++), true);9 t.getLog().setQuiet(true);10});11testRun.test("no tests", function () {12 testRun.assertTrue("no tests is true", t.getSummary().noTests());13 testRun.assertTrue("no tests: all ok", t.getSummary().allOk());14 testRun.assertEqual("no successes", 0, t.getSummary().getSuccesses());15 testRun.assertEqual("no failures", 0, t.getSummary().getFailures());16 testRun.assertEqual("no error", 0, t.getSummary().getErrors());17 testRun.assertEqual("no tests", 0, t.getSummary().getTestCount());18});19testRun.test("success", function () {20 t.test("test success", function () {21 t.assertTrue("success", true);22 });23 testRun.assertEqual("one success", 1, t.getSummary().getSuccesses());24 testRun.assertEqual("no failures", 0, t.getSummary().getFailures());25 testRun.assertEqual("no error", 0, t.getSummary().getErrors());26 testRun.assertTrue("all ok", t.getSummary().allOk());27});28testRun.test("failure", function () {29 t.test("test failure", function () {30 t.assertTrue("failure", false);31 });32 testRun.assertEqual("one failure", 1, t.getSummary().getFailures());33 testRun.assertEqual("no success", 0, t.getSummary().getSuccesses());34 testRun.assertEqual("no error", 0, t.getSummary().getErrors());35 testRun.assertTrue("not all ok", !t.getSummary().allOk());36});37testRun.test("error", function () {38 t.test("test error", function () {39 throw "forced error";40 });41 var summary = t.getSummary();42 testRun.assertEqual("one error", 1, summary.getErrors());43 testRun.assertTrue("not all ok", !t.getSummary().allOk());44});45testRun.test("assertTrue", function () {46 t.test("test assertTrue", function () {47 t.assertTrue("assertTrue", true);48 });49 testRun.assertEqual("one success", 1, t.getSummary().getSuccesses());50 t.test("test assertTrue", function () {51 t.assertTrue("assertTrue", false);52 });53 testRun.assertEqual("one failure", 1, t.getSummary().getFailures());54});55testRun.test("assertEqual", function () {56 t.test("test assertEqual", function () {57 t.assertEqual("assertEqual", 10, 10);58 });59 testRun.assertEqual("one success", 1, t.getSummary().getSuccesses());60 t.test("test assertEqual", function () {61 t.assertEqual("assertEqual", 10, 11);62 });63 testRun.assertEqual("one failure", 1, t.getSummary().getFailures());64});65testRun.test("assertNull", function () {66 t.test("test assertNull", function () {67 t.assertNull("assertNull", null);68 });69 testRun.assertEqual("one success", 1, t.getSummary().getSuccesses());70 t.test("test assertNull", function () {71 t.assertNull("assertNull", "hello");72 });73 testRun.assertEqual("one failure", 1, t.getSummary().getFailures());74});75testRun.test("assertNotNull", function () {76 t.test("test assertNotNull", function () {77 t.assertNotNull("assertNotNull", "hello");78 });79 testRun.assertEqual("one success", 1, t.getSummary().getSuccesses());80 t.test("test assertNotNull", function () {81 t.assertNotNull("assertNotNull", null);82 });83 testRun.assertEqual("one failure", 1, t.getSummary().getFailures());84});...

Full Screen

Full Screen

pair169.js

Source:pair169.js Github

copy

Full Screen

1var pairs =2{3"getsummary":{"returns":1,"summaryfield":1,"set":1,"capture":1,"function":1,"total":1}4,"returns":{"value":1,"reference":1,"summary":1}5,"value":{"summaryfield":1,"use":1,"entire":1,"country":1}6,"summaryfield":{"current":1,"breakfield":1,"-field":1}7,"current":{"range":1,"charge":1}8,"range":{"records":1}9,"records":{"file":1,"grand":1,"pertaining":1,"summary":1}10,"file":{"sorted":1,"isn\u2019t":1}11,"sorted":{"by":1}12,"by":{"breakfield":1,"break":1,"country":1,"sales":1}13,"breakfield":{"getsummary":1,"summaryfield":1,"-field":1}14,"-field":{"type":1,"expression":1}15,"type":{"summary":1}16,"summary":{"expression":1,"value":1,"field":1,"values":1,"all":1,"total":1}17,"expression":{"returns":1}18,"reference":{"breakfield":1,"calculate":1}19,"calculate":{"grand":1}20,"grand":{"summary":1}21,"use":{"summary":1,"getsummary":1}22,"field":{"summary":1,"break":1,"parameters":1,"number":1,"result":1,"returns":1,"value":1,"getsummary":1,"total":1}23,"break":{"field":1}24,"parameters":{"getsummary":1}25,"set":{"up":1,"records":1}26,"up":{"table":1}27,"table":{"break":1}28,"number":{"date":1,"countries":1}29,"date":{"time":1}30,"time":{"timestamp":1}31,"timestamp":{"filemaker":1}32,"filemaker":{"pro":1}33,"pro":{"6.0":1}34,"6.0":{"earlier":1}35,"earlier":{"function":1}36,"function":{"produces":1,"unstored":1}37,"produces":{"subsummary":1,"summary":1}38,"subsummary":{"values":1}39,"values":{"if":1,"want":1,"calculation":1,"browse":1}40,"if":{"file":1,"thischarge":1,"current":1,"number":1}41,"isn\u2019t":{"sorted":1}42,"result":{"blank":1}43,"blank":{"summary":1}44,"entire":{"found":1}45,"found":{"set":1}46,"capture":{"summary":1}47,"want":{"use":1}48,"calculation":{"display":1}49,"display":{"subsummary":1}50,"browse":{"mode":1}51,"mode":{"body":1}52,"body":{"part":1}53,"part":{"calculations":1}54,"calculations":{"getsummary":1}55,"unstored":{"get":1}56,"get":{"self-join":1}57,"self-join":{"relationship":1}58,"relationship":{"aggregate":1}59,"aggregate":{"functions":1}60,"functions":{"orking":1}61,"orking":{"related":1}62,"related":{"data":1}63,"data":{"portals":1}64,"portals":{"getsummary":1}65,"total":{"sales":1,"total":1}66,"sales":{"country":1,"total":1,"produces":1,"if":1,"zone":1,"by":1}67,"country":{"returns":1,"field":1,"sales":1,"if":1}68,"all":{"records":1}69,"pertaining":{"value":1}70,"thischarge":{"*getsummary":1}71,"*getsummary":{"avgcharge":1}72,"avgcharge":{"customer":1}73,"customer":{"verify":1}74,"verify":{"charge":1}75,"charge":{"displays":1,"if":1,"greater":1,"getsummary":1}76,"displays":{"verify":1}77,"greater":{"times":1,"returns":1}78,"times":{"average":1}79,"average":{"charge":1}80,"countries":{"country":1,"greater":1}81,"zone":{"returns":1}82}...

Full Screen

Full Screen

GetContentSummary.js

Source:GetContentSummary.js Github

copy

Full Screen

1import * as anime from '@/queries/anime/Summary';2import * as manga from '@/queries/manga/Summary';3import * as lightNovel from '@/queries/light-novel/Summary';4import * as doujinshi from '@/queries/doujinshi/Summary';5import * as visualNovel from '@/queries/visual-novel/Summary';6import * as release from '@/queries/release/Summary';7// ! keep synced with first element of the url in nex.config.js8// TODO remove after dgraph resolves resolution of fragments on interfaces9// TODO using a getMetadata + on Generic fragment for every resource.10// https://discuss.dgraph.io/t/fragments-on-interface-not-resolving/11441/311const GetContentSummary = (type) => {12 const typeToQuery = {13 "anime": anime.getSummary,14 "manga": manga.getSummary,15 "light-novels": lightNovel.getSummary,16 "doujinshi": doujinshi.getSummary,17 "visual-novels": visualNovel.getSummary,18 "visual-novels": visualNovel.getSummary,19 "releases": release.getSummary,20 }21 if (typeToQuery[type] === undefined) {22 return undefined;23 }24 return typeToQuery[type]()25 };...

Full Screen

Full Screen

1_call_apply_bind.js

Source:1_call_apply_bind.js Github

copy

Full Screen

1let getSummary = function (month, revised) {2 console.log(3 `${this.title} was written ${this.author} in ${this.year} and month ${month}, is revised: ${revised}`4 );5};6let book1 = {7 title: "Book One",8 author: "John Doe",9 year: "2015",10};11let book2 = {12 title: "Book Two",13 author: "Jane Doe",14 year: "2014",15};16// call method17console.log("call method");18getSummary.call(book1, "Jan", true);19getSummary.call(book2, "Feb", false);20// apply method21console.log("apply method");22getSummary.apply(book1, ["Jan", true]);23getSummary.apply(book2, ["Feb", false]);24// bind method25console.log("bind method");26const summarize1 = getSummary.bind(book1, "Jan", true);27const summarize2 = getSummary.bind(book2, "Feb", false);28summarize1();...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var Mocha = require('mocha');2var fs = require('fs');3var path = require('path');4var mocha = new Mocha();5var testDir = 'test';6fs.readdirSync(testDir).filter(function(file){7 return file.substr(-3) === '.js';8}).forEach(function(file){9 mocha.addFile(10 path.join(testDir, file)11 );12});13mocha.run(function(failures){14 process.on('exit', function () {15 });16});17var assert = require('assert');18describe('Array', function() {19 describe('#indexOf()', function () {20 it('should return -1 when the value is not present', function () {21 assert.equal(-1, [1,2,3].indexOf(4));22 });23 });24});

Full Screen

Using AI Code Generation

copy

Full Screen

1var Mocha = require('mocha');2var mocha = new Mocha();3mocha.addFile('test.js');4mocha.run(function(failures){5 process.on('exit', function () {6 });7});

Full Screen

Using AI Code Generation

copy

Full Screen

1var Mocha = require('mocha');2var mocha = new Mocha();3mocha.addFile('test/test.js');4mocha.run(function(failures){5 process.on('exit', function () {6 });7});8var Mocha = require('mocha');9var mocha = new Mocha();10mocha.addFile('test/test.js');11mocha.reporter('json');12mocha.run(function(failures){13 process.on('exit', function () {14 });15});

Full Screen

Using AI Code Generation

copy

Full Screen

1const Mocha = require('mocha');2const mocha = new Mocha();3mocha.addFile('test.js');4mocha.run((failures) => {5 process.on('exit', () => {6 });7})8 .on('pass', (test) => {9 console.log('Test passed: ', test.fullTitle());10 })11 .on('fail', (test, err) => {12 console.log('Test failed: ', test.fullTitle(), err.message);13 })14 .on('end', () => {15 console.log('Finished running tests.');16 });17const Mocha = require('mocha');18const mocha = new Mocha();19mocha.addFile('test.js');20mocha.run((failures) => {21 process.on('exit', () => {22 });23})24 .on('pass', (test) => {25 console.log('Test passed: ', test.fullTitle());26 })27 .on('fail', (test, err) => {28 console.log('Test failed: ', test.fullTitle(), err.message);29 })30 .on('end', () => {31 console.log('Finished running tests.');32 });33const Mocha = require('mocha');34const mocha = new Mocha();35mocha.addFile('test.js');36mocha.run((failures) => {37 process.on('exit', () => {38 });39})40 .on('pass', (test) => {41 console.log('Test passed: ', test.fullTitle());42 })43 .on('fail', (test, err) => {44 console.log('Test failed: ', test.fullTitle(), err.message);45 })46 .on('end', () => {47 console.log('Finished running tests.');48 });49const Mocha = require('mocha');50const mocha = new Mocha();51mocha.addFile('test.js');52mocha.run((fail

Full Screen

Using AI Code Generation

copy

Full Screen

1const Mocha = require('mocha');2const mocha = new Mocha();3mocha.addFile('test1.js');4mocha.addFile('test2.js');5mocha.run(function(failures){6 process.on('exit', function () {7 });8});9const assert = require('assert');10describe('Array', function() {11 describe('#indexOf()', function() {12 it('should return -1 when the value is not present', function() {13 assert.equal([1,2,3].indexOf(4), -1);14 });15 });16});17const assert = require('assert');18describe('Array', function() {19 describe('#indexOf()', function() {20 it('should return -1 when the value is not present', function() {21 assert.equal([1,2,3].indexOf(4), -1);22 });23 });24});25 #indexOf()26 #indexOf()

Full Screen

Using AI Code Generation

copy

Full Screen

1var Mocha = require('mocha');2var mocha = new Mocha({3});4mocha.addFile(5);6mocha.run(function(failures) {7 process.on('exit', function() {8 });9});10 at Object.<anonymous> (/Users/xyz/Documents/xyz/node_modules/mocha/lib/mocha.js:45:23)11 at Module._compile (module.js:556:32)12 at Object.Module._extensions..js (module.js:565:10)13 at Module.load (module.js:473:32)14 at tryModuleLoad (module.js:432:12)15 at Function.Module._load (module.js:424:3)16 at Module.require (module.js:483:17)17 at require (internal/module.js:20:19)18 at Object.<anonymous> (/Users/xyz/Documents/xyz/test.js:1:15)19 at Module._compile (module.js:556:32)20 at Object.Module._extensions..js (module.js:565:10)21 at Module.load (module.js:473:32)22 at tryModuleLoad (module.js:432:12)23 at Function.Module._load (module.js:424:3)24 at Module.runMain (module.js:590:10)25 at run (bootstrap_node.js:394:7)26 at startup (bootstrap_node.js:149:9)27var Mocha = require('mocha');28var mocha = new Mocha({29});30mocha.addFile(31);32mocha.run(function(failures) {33 process.on('exit', function() {34 process.exit(failures);

Full Screen

Using AI Code Generation

copy

Full Screen

1const assert = require('assert');2const Mocha = require('mocha');3const mocha = new Mocha();4mocha.addFile('./test1.js');5mocha.run(failures => {6 console.log('Number of failures: ' + failures);7 console.log(mocha.suite.suites[0].tests[0].getSummary());8});9{10 err: {11 ' at Context.<anonymous> (test1.js:5:12)\n' +12 ' at processImmediate (internal/timers.js:456:21)'13 }14}

Full Screen

Using AI Code Generation

copy

Full Screen

1var Mocha = require('mocha');2var mocha = new Mocha();3var fs = require('fs');4var path = require('path');5var testDir = 'test';6fs.readdirSync(testDir).filter(function(file){7 return file.substr(-3) === '.js';8}).forEach(function(file){9 mocha.addFile(10 path.join(testDir, file)11 );12});13mocha.run(function(failures){14 process.on('exit', function () {15 });16});

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Mocha automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful