Best JavaScript code snippet using puppeteer
ClientSummary.Fact.js
Source:ClientSummary.Fact.js
1/// <reference path="../../../Assets/Liberary/angular-1.5.8/angular.min.js" />2'use strict';3angular.module('DoctorApp')4 .factory('ClientSummaryService', ['$http', 'communicationService', function ($http, communicationService) {5 var service = {};6 // Start Register Client7 service.getClientDetailByClientID = function (postData, callback) {8 9 communicationService.resultViaPost(webservices.clientDetailByClientIDUrl, headerConstants.json, postData, function (err, response) {10 callback(err, response);11 });12 };13 service.updateRegisterClient = function (postData, callback) {14 15 communicationService.resultViaPost(webservices.UpdateRegisterClientUrl, headerConstants.json, postData, function (err, response) {16 callback(err, response);17 });18 };19 // EOF Register Client20 // Start Emergency Contact Service21 service.saveEmergencyContact = function (postData, callback) {22 23 communicationService.resultViaPost(webservices.SaveEmergencyContactUrl, headerConstants.json, postData, function (err, response) {24 callback(err, response);25 });26 };27 service.isEmergencyContactExistWithSameEmail = function (postData, callback) {28 29 communicationService.resultViaPost(webservices.IsEmergencyContactExistWithSameEmailUrl, headerConstants.json, postData, function (err, response) {30 callback(err, response);31 });32 };33 service.getAllEmergencyContact = function (postData, callback) {34 35 communicationService.resultViaPost(webservices.GetAllEmergencyContactUrl, headerConstants.json, postData, function (err, response) {36 callback(err, response);37 });38 };39 service.updateEmergencyContact = function (postData, callback) {40 41 communicationService.resultViaPost(webservices.UpdateEmergencyContactUrl, headerConstants.json, postData, function (err, response) {42 callback(err, response);43 });44 };45 46 service.deleteEmergencyContact = function (postData, callback) {47 48 communicationService.resultViaPost(webservices.DeleteEmergencyContactUrl, headerConstants.json, postData, function (err, response) {49 callback(err, response);50 });51 };52 // EOF Emergency Contact Service53 // Start DropDownList54 service.getDropDownListForRelation = function (callback) {55 56 communicationService.resultViaGet(webservices.GetAllRelationShipUrl, headerConstants.json, function (err, response) {57 callback(err, response);58 });59 };60 service.getCountriesDropDownList = function (callback) {61 62 communicationService.resultViaGet(webservices.GetAllCountriesUrl, headerConstants.json, function (err, response) {63 callback(err, response);64 });65 };66 67 service.getAllStatesBaseOnCountryID = function (postData, callback) {68 69 communicationService.resultViaPost(webservices.GetAllStatesBaseOnCountryIDUrl, headerConstants.json, postData, function (err, response) {70 callback(err, response);71 });72 };73 74 service.getAllCityBaseOnStateID = function (postData, callback) {75 76 communicationService.resultViaPost(webservices.GetAllCityBaseOnStateIDUrl, headerConstants.json, postData, function (err, response) {77 callback(err, response);78 });79 };80 service.getAllBloodGroup = function (callback) {81 82 communicationService.resultViaGet(webservices.GetAllBloodGroupUrl, headerConstants.json, function (err, response) {83 callback(err, response);84 });85 };86 service.getAllUserDetail = function (callback) {87 communicationService.resultViaGet(webservices.GetAllUserDetailUrl, headerConstants.json, function (err, response) {88 callback(err, response);89 });90 };91 service.getAllPaymentType = function (callback) {92 communicationService.resultViaGet(webservices.GetAllPaymentTypeUrl, headerConstants.json, function (err, response) {93 callback(err, response);94 });95 };96 97 // EOF DropDownList98 // Start ClientContact99 service.saveClientContact = function (postData, callback) {100 101 communicationService.resultViaPost(webservices.SaveClientContactUrl, headerConstants.json, postData, function (err, response) {102 callback(err, response);103 });104 };105 service.getClientContactDetial = function (postData, callback) {106 107 communicationService.resultViaPost(webservices.GetClientContactDetialUrl, headerConstants.json, postData, function (err, response) {108 callback(err, response);109 });110 };111 // EOF ClientContact112 113 // Start ClientPersonalDetail114 service.saveClientPersonalDetail = function (postData, callback) {115 116 communicationService.resultViaPost(webservices.SaveClientPersonalDetailUrl, headerConstants.json, postData, function (err, response) {117 callback(err, response);118 });119 };120 service.getClientPersonalDetail = function (postData, callback) {121 122 communicationService.resultViaPost(webservices.GetClientPersonalDetailUrl, headerConstants.json, postData, function (err, response) {123 callback(err, response);124 });125 };126 // EOF ClientPersonalDetail127 // Start Client Insurance Detail128 service.getAllClientInsuranceDetail = function (postData, callback) {129 130 communicationService.resultViaPost(webservices.GetAllClientInsuranceDetailUrl, headerConstants.json, postData, function (err, response) {131 callback(err, response);132 });133 };134 service.saveClientInsuranceDetail = function (postData, callback) {135 136 communicationService.resultViaPost(webservices.SaveClientInsuranceDetailUrl, headerConstants.json, postData, function (err, response) {137 callback(err, response);138 });139 };140 service.updateClientInsuranceDetail = function (postData, callback) {141 142 communicationService.resultViaPost(webservices.UpdateClientInsuranceDetailUrl, headerConstants.json, postData, function (err, response) {143 callback(err, response);144 });145 };146 service.deleteClientInsuranceDetail = function (postData, callback) {147 148 communicationService.resultViaPost(webservices.DeleteClientInsuranceDetailUrl, headerConstants.json, postData, function (err, response) {149 callback(err, response);150 });151 };152 service.isClientInsuranceDetailExistWithSameCardNumber = function (postData, callback) {153 154 communicationService.resultViaPost(webservices.IsClientInsuranceDetailExistWithSameCardNumberUrl, headerConstants.json, postData, function (err, response) {155 callback(err, response);156 });157 };158 159 // EOF Client Insurance Detail Service160 // Start Client Family Health Detail161 service.getAllClientFamilyHealthDetail = function (postData, callback) {162 163 communicationService.resultViaPost(webservices.GetAllClientFamilyHealthDetailUrl, headerConstants.json, postData, function (err, response) {164 callback(err, response);165 });166 };167 service.saveClientFamilyHealthDetail = function (postData, callback) {168 169 communicationService.resultViaPost(webservices.SaveClientFamilyHealthDetailUrl, headerConstants.json, postData, function (err, response) {170 callback(err, response);171 });172 };173 service.updateClientFamilyHealthDetail = function (postData, callback) {174 175 communicationService.resultViaPost(webservices.UpdateClientFamilyHealthDetailUrl, headerConstants.json, postData, function (err, response) {176 callback(err, response);177 });178 };179 service.deleteClientFamilyHealthDetail = function (postData, callback) {180 181 communicationService.resultViaPost(webservices.DeleteClientFamilyHealthDetailUrl, headerConstants.json, postData, function (err, response) {182 callback(err, response);183 });184 };185 // EOF Client Family Health Detail186 // Start Client Vitalsign Detail187 service.getAllClientVitalSignDetail = function (postData, callback) {188 189 communicationService.resultViaPost(webservices.GetAllClientVitalSignDetailUrl, headerConstants.json, postData, function (err, response) {190 callback(err, response);191 });192 };193 service.saveClientVitalSignDetail = function (postData, callback) {194 195 communicationService.resultViaPost(webservices.SaveClientVitalSignDetailUrl, headerConstants.json, postData, function (err, response) {196 callback(err, response);197 });198 };199 service.updateClientVitalSignDetail = function (postData, callback) {200 201 communicationService.resultViaPost(webservices.UpdateClientVitalSignDetailUrl, headerConstants.json, postData, function (err, response) {202 callback(err, response);203 });204 };205 service.deleteClientVitalSignDetail = function (postData, callback) {206 207 communicationService.resultViaPost(webservices.DeleteClientVitalSignDetailUrl, headerConstants.json, postData, function (err, response) {208 callback(err, response);209 });210 };211 // EOF Client Vitalsign Detail212 // Start Client AllergyInformation Detail213 service.GetAllClientAllergyInformationDetail = function (postData, callback) {214 215 communicationService.resultViaPost(webservices.GetAllClientAllergyInformationDetailUrl, headerConstants.json, postData, function (err, response) {216 callback(err, response);217 });218 };219 service.saveClientAllergyInformationDetail = function (postData, callback) {220 221 communicationService.resultViaPost(webservices.SaveClientAllergyInformationDetailUrl, headerConstants.json, postData, function (err, response) {222 callback(err, response);223 });224 };225 service.updateClientAllergyInformationDetail = function (postData, callback) {226 227 communicationService.resultViaPost(webservices.UpdateClientAllergyInformationDetailUrl, headerConstants.json, postData, function (err, response) {228 callback(err, response);229 });230 };231 service.deleteClientAllergyInformationDetail = function (postData, callback) {232 233 communicationService.resultViaPost(webservices.DeleteClientAllergyInformationDetailUrl, headerConstants.json, postData, function (err, response) {234 callback(err, response);235 });236 };237 // EOF Client Allergy Information Detail238 // Start Client Social Information Detail239 service.getAllClientSocialInformationDetail = function (postData, callback) {240 241 communicationService.resultViaPost(webservices.GetAllClientSocialInformationDetailUrl, headerConstants.json, postData, function (err, response) {242 callback(err, response);243 });244 };245 service.saveClientSocialInformationDetail = function (postData, callback) {246 247 communicationService.resultViaPost(webservices.SaveClientSocialInformationDetailUrl, headerConstants.json, postData, function (err, response) {248 callback(err, response);249 });250 };251 service.updateClientSocialInformationDetail = function (postData, callback) {252 253 communicationService.resultViaPost(webservices.UpdateClientSocialInformationDetailUrl, headerConstants.json, postData, function (err, response) {254 callback(err, response);255 });256 };257 service.deleteClientSocialInformationDetail = function (postData, callback) {258 259 communicationService.resultViaPost(webservices.DeleteClientSocialInformationDetailUrl, headerConstants.json, postData, function (err, response) {260 callback(err, response);261 });262 };263 // EOF Client Social Information Detail264 // File265 service.saveClientProfileImage = function (postData, callback) {266 communicationService.resultViaPost(webservices.SaveClientProfileImageUrl, headerConstants.json, postData, function (err, response) {267 callback(err, response);268 });269 };270 service.getClientProfileImage = function (postData, callback) {271 communicationService.resultViaPost(webservices.GetClientProfileImageUrl, headerConstants.json, postData, function (err, response) {272 callback(err, response);273 });274 };275 // EOF File Section276 // Start Client Vaccine Detail277 service.getAllClientVaccineDetail = function (postData, callback) {278 communicationService.resultViaPost(webservices.GetAllClientVaccineDetailUrl, headerConstants.json, postData, function (err, response) {279 callback(err, response);280 });281 };282 service.saveClientVaccineDetail = function (postData, callback) {283 communicationService.resultViaPost(webservices.SaveClientVaccineDetailUrl, headerConstants.json, postData, function (err, response) {284 callback(err, response);285 });286 };287 service.updateClientVaccineDetail = function (postData, callback) {288 communicationService.resultViaPost(webservices.UpdateClientVaccineDetailUrl, headerConstants.json, postData, function (err, response) {289 callback(err, response);290 });291 };292 service.deleteClientVaccineDetail = function (postData, callback) {293 communicationService.resultViaPost(webservices.DeleteClientVaccineDetailUrl, headerConstants.json, postData, function (err, response) {294 callback(err, response);295 });296 };297 // EOF Client Vaccine Detail298 // Start Client Prescription Detail299 service.getAllClientPrescriptionDetail = function (postData, callback) {300 communicationService.resultViaPost(webservices.GetAllClientPrescriptionDetailUrl, headerConstants.json, postData, function (err, response) {301 callback(err, response);302 });303 };304 service.saveClientPrescriptionDetail = function (postData, callback) {305 communicationService.resultViaPost(webservices.SaveClientPrescriptionDetailUrl, headerConstants.json, postData, function (err, response) {306 callback(err, response);307 });308 };309 service.updateClientPrescriptionDetail = function (postData, callback) {310 communicationService.resultViaPost(webservices.UpdateClientPrescriptionDetailUrl, headerConstants.json, postData, function (err, response) {311 callback(err, response);312 });313 };314 service.deleteClientPrescriptionDetail = function (postData, callback) {315 communicationService.resultViaPost(webservices.DeleteClientPrescriptionDetailUrl, headerConstants.json, postData, function (err, response) {316 callback(err, response);317 });318 };319 service.getAllDrugList = function (callback) {320 communicationService.resultViaGet(webservices.GetAllDrugListUrl, headerConstants.json, function (err, response) {321 callback(err, response);322 });323 };324 // EOF Client Prescription Detail325 // ClientProgressNote326 service.saveClientProgressNote = function (postData, callback) {327 communicationService.resultViaPost(webservices.SaveClientProgressNoteUrl, headerConstants.json, postData, function (err, response) {328 callback(err, response);329 });330 };331 service.updateClientProgressNote = function (postData, callback) {332 communicationService.resultViaPost(webservices.UpdateClientProgressNoteUrl, headerConstants.json, postData, function (err, response) {333 callback(err, response);334 });335 };336 service.deleteClientProgressNote = function (postData, callback) {337 communicationService.resultViaPost(webservices.DeleteClientProgressNoteUrl, headerConstants.json, postData, function (err, response) {338 callback(err, response);339 });340 };341 service.getAllClientProgressNote = function (postData, callback) {342 communicationService.resultViaPost(webservices.GetAllClientProgressNoteUrl, headerConstants.json, postData, function (err, response) {343 callback(err, response);344 });345 };346 // EOF ClientProgressNote347 // ClientAppointmentDetail348 service.getClientAppointmentDetail = function (postData, callback) {349 communicationService.resultViaPost(webservices.GetClientAppointmentDetailUrl, headerConstants.json, postData, function (err, response) {350 callback(err, response);351 });352 };353 // EOF ClientAppointmentDetail354 // ClientBillingDetail355 service.saveClientBillingDetail = function (postData, callback) {356 communicationService.resultViaPost(webservices.SaveClientBillingDetailUrl, headerConstants.json, postData, function (err, response) {357 callback(err, response);358 });359 };360 service.updateClientBillingDetail = function (postData, callback) {361 communicationService.resultViaPost(webservices.UpdateClientBillingDetailUrl, headerConstants.json, postData, function (err, response) {362 callback(err, response);363 });364 };365 service.deleteClientBillingDetail = function (postData, callback) {366 communicationService.resultViaPost(webservices.DeleteClientBillingDetailUrl, headerConstants.json, postData, function (err, response) {367 callback(err, response);368 });369 };370 service.getAllClientBillingDetail = function (postData, callback) {371 communicationService.resultViaPost(webservices.GetAllClientBillingDetailUrl, headerConstants.json, postData, function (err, response) {372 callback(err, response);373 });374 };375 // EOF ClientBillingDetail376 377 // ClientPaymentDetail378 service.saveClientPaymentDetail = function (postData, callback) {379 communicationService.resultViaPost(webservices.SaveClientPaymentDetailUrl, headerConstants.json, postData, function (err, response) {380 callback(err, response);381 });382 };383 service.updateClientPaymentDetail = function (postData, callback) {384 communicationService.resultViaPost(webservices.UpdateClientPaymentDetailUrl, headerConstants.json, postData, function (err, response) {385 callback(err, response);386 });387 };388 service.deleteClientPaymentDetail = function (postData, callback) {389 communicationService.resultViaPost(webservices.DeleteClientPaymentDetailUrl, headerConstants.json, postData, function (err, response) {390 callback(err, response);391 });392 };393 service.getAllClientPaymentDetail = function (postData, callback) {394 communicationService.resultViaPost(webservices.GetAllClientPaymentDetailUrl, headerConstants.json, postData, function (err, response) {395 callback(err, response);396 });397 };398 // EOF ClientPaymentDetail399 return service;...
update.js
Source:update.js
1var Request = new Object(); 2Request = GetRequest(); 3function GetRequest() { 4 var url = location.search; 5 var theRequest = new Object(); 6 if (url.indexOf("?") != -1) { 7 var str = url.substr(1); 8 strs = str.split("&"); 9 for(var i = 0; i < strs.length; i++) { 10 theRequest[strs[i].split("=")[0]]=decodeURI(strs[i].split("=")[1]); 11 } 12 } 13 return theRequest;14}15var getcaseid= Request['caseid'];16function objectifyForm(formArray,actvalue) {//serialize data function17 var returnArray=[];18 var actObject = {};19 actObject.act=actvalue;20 var formObject = {};21 for (var i = 0; i < formArray.length; i++){22 if(formArray[i]['name']!=tmp)23 formObject[formArray[i]['name']] = formArray[i]['value'];24 else25 formObject[formArray[i]['name']] += "ï¼"+formArray[i]['value'];26 var tmp =formArray[i]['name'];27 }28 returnArray.push(actObject);29 returnArray.push(formObject);30 return returnArray;31}32$(document).ready(function() {33 //ä¿®æ¹ç
æ·è³æç¨34 if(getcaseid){35 console.log(123);36 $("#getcaseid").val(getcaseid);37 var act={};38 var updatedata=[];39 act.act="getdetailbyid";40 var obj={};41 obj.caseid=getcaseid;42 updatedata.push(act);43 updatedata.push(obj);44 console.log(updatedata);45 $.ajax({46 url:'../../midcase/controller.php',47 type: 'POST',48 data:JSON.stringify(updatedata),49 async:false,50 success:function(r){51 // console.log(r);52 result=eval(r);53 if(result[0].status==200){54 console.log(result);55 $("select[name=]")56 }else if(result[0].status==422){57 }else{58 alert("ç¼çæªé æçé¯èª¤ è«è¯çµ¡ç®¡çå¡");59 }60 },61 error:function(err){62 alert("ç¼çæªé æçé¯èª¤ è«è¯çµ¡ç®¡çå¡");63 console.log(err);64 }65 });66 }67 $(".index").click(function(event){68 event.preventDefault();69 window.location.href = "index.html";70 })71 $("input[name=datafrom]").click(function(){72 if($("#other").prop('checked')){73 $("input[name=othercontent]").attr("disabled",false);74 $("input[name=othercontent]").css("background-color", "white");75 }else{76 $("input[name=othercontent]").attr("disabled",true);77 $("input[name=othercontent]").val("");78 $("input[name=othercontent]").css("background-color", "rgb(235, 235, 228)");79 }80 });81 $('#form').submit(function(event){82 var error = 0;83 event.preventDefault();84 var serializeform = $('#form').serializeArray();85 // console.log(serializeform);86 var postdata= objectifyForm(serializeform,"addCase");87 if($("#other").prop('checked')){88 var key = 'datafrom';89 // å¤å¶åæ¥çå¼90 postdata[1][key] = postdata[1]['othercontent'];91 // å é¤åæ¥çé®92 delete postdata['othercontent'];93 // æ£æ¥ææ94 }95 // console.log(postdata);96 // console.log(serializeform);97 for (var i = 0; i < serializeform.length; i++) {98 if(serializeform[i].value==""){99 var key = serializeform[i].name;100 // console.log(key);101 // console.log($("input[name="+key+"]").val());102 $("input[name="+key+"]").css("background-color", "red");103 error++;104 }else{105 var key = serializeform[i].name;106 $("input[name="+key+"]").css("background-color", "white");107 }108 }109 if(error>0){110 alert("æªå¡«å¯«å®æ è«æª¢æ¥è¼¸å
¥è³æ");111 console.log(postdata);112 }113 else{114 // var confirm2 = "以ä¸çºæ¨å¡«å¯«çè³æ\nå§å:"+postdata[1].name+" æ§å¥:"+postdata[1].sex+" ç
æ·è碼"+postdata[1].id115 // +"\nåºçæ¥æ"+postdata[1].birthday+" è¯åé診æ¥æ"+postdata[1].date116 // +"\nç©çæ²»çè©ä¼°: å·¥å
·"+postdata[1].physical_tool+" çµæ "+postdata[1].physical_result+" ç¼å±åæ¸ "+postdata[1].physical_number+" PR "+postdata[1].physical_pr117 // +"\nè·è½æ²»çè©ä¼°: å·¥å
·"+postdata[1].function_tool+" çµæ "+postdata[1].function_result+" ç¼å±åæ¸ "+postdata[1].function_number+" PR "+postdata[1].function_pr118 // +"\nèªè¨æ²»çè©ä¼°:"119 // +"\n å£èªç解工å
· "+postdata[1].oral_comprehension_tool+" çµæ "+postdata[1].oral_comprehension_result+" è½å "+postdata[1].oral_comprehension_ability120 // +"\n å£èªè¡¨éå·¥å
· "+postdata[1].oral_expression_tool+" çµæ "+postdata[1].oral_expression_result+" è½å "+postdata[1].oral_expression_ability121 // +"\nå¿çæ²»çè©ä¼°:"122 // +"\n å·¥å
· "+postdata[1].psychotherapy_tool+" çµæ "+postdata[1].psychotherapy_result+" å
¨æºå "+postdata[1].psychotherapy_iq+" PR "+postdata[1].psychotherapy_pr123 // +"\nåæ¡è½ä»ä¾æº "+postdata[1].datafrom124 var confirm2 = "以ä¸çºæ¨å¡«å¯«çè³æ\nå§å: "+postdata[1].name+"\næ§å¥: "+postdata[1].sex+"\nç
æ·è碼: "+postdata[1].id125 +"\nåºçæ¥æ: "+postdata[1].birthday+"\nè¯åé診æ¥æ: "+postdata[1].date126 var r = confirm(confirm2);127 if(r==true){128 $.ajax({129 url:'../../midcase/controller.php',130 type: 'POST',131 data:JSON.stringify(postdata),132 async:false,133 success:function(r){134 // console.log(r);135 result=eval(r);136 if(result[0].status==200){137 // alert("æ°å¢æå");138 $("#form").empty();139 $("#form").append("<h1>æ°å¢æå</h1><button id='setup'>åæ°å¢ä¸ç</button><button id='index2'>é¦é </button>");140 $("#setup").click(function(event){141 event.preventDefault();142 // console.log(this.id);143 window.location.href = this.id+".html";144 })145 $("#index2").click(function(event){146 // console.log(this.id);147 event.preventDefault();148 window.location.href = "index.html";149 })150 }151 else if(result[0].status==422){152 alert("ç
æ·è碼éè¤ è«éæ°ç¢ºèª");153 }else{154 alert("ç¼çæªé æçé¯èª¤ è«è¯çµ¡ç®¡çå¡");155 }156 },157 error:function(err){158 alert("ç¼çæªé æçé¯èª¤ è«è¯çµ¡ç®¡çå¡");159 console.log(err);160 }161 });162 }else{163 // console.log("no")164 }165 }166 // console.log(JSON.stringify(postdata));167 // window.location.href='show.html';168 });169 $('#form2').submit(function(event){170 var error = 0;171 event.preventDefault();172 var serializeform = $('#form2').serializeArray();173 // console.log(serializeform);174 var postdata= objectifyForm(serializeform,"updateCase");175 if($("#other").prop('checked')){176 var key = 'datafrom';177 // å¤å¶åæ¥çå¼178 postdata[1][key] = postdata[1]['othercontent'];179 // å é¤åæ¥çé®180 delete postdata['othercontent'];181 // æ£æ¥ææ182 }183 // console.log(postdata);184 // console.log(serializeform);185 for (var i = 0; i < serializeform.length; i++) {186 if(serializeform[i].value==""){187 var key = serializeform[i].name;188 // console.log(key);189 // console.log($("input[name="+key+"]").val());190 $("input[name="+key+"]").css("background-color", "red");191 error++;192 }else{193 var key = serializeform[i].name;194 $("input[name="+key+"]").css("background-color", "white");195 }196 }197 if(error>0){198 alert("æªå¡«å¯«å®æ è«æª¢æ¥è¼¸å
¥è³æ");199 console.log(postdata);200 }201 else{202 console.log(JSON.stringify(postdata));203 var confirm2 = "以ä¸çºæ¨å¡«å¯«çè³æ\n ç
æ·è碼"+postdata[1].id2204 +"\nç©çæ²»çè©ä¼°: å·¥å
·"+postdata[1].physical_tool+" çµæ "+postdata[1].physical_result+" ç¼å±åæ¸ "+postdata[1].physical_number+" PR "+postdata[1].physical_pr205 +"\nè·è½æ²»çè©ä¼°: å·¥å
·"+postdata[1].function_tool+" çµæ "+postdata[1].function_result+" ç¼å±åæ¸ "+postdata[1].function_number+" PR "+postdata[1].function_pr206 +"\nèªè¨æ²»çè©ä¼°:"207 +"\n å£èªç解工å
· "+postdata[1].oral_comprehension_tool+" çµæ "+postdata[1].oral_comprehension_result+" è½å "+postdata[1].oral_comprehension_ability208 +"\n å£èªè¡¨éå·¥å
· "+postdata[1].oral_expression_tool+" çµæ "+postdata[1].oral_expression_result+" è½å "+postdata[1].oral_expression_ability209 +"\nå¿çæ²»çè©ä¼°:"210 +"\n å·¥å
· "+postdata[1].psychotherapy_tool+" çµæ "+postdata[1].psychotherapy_result+" å
¨æºå "+postdata[1].psychotherapy_iq+" PR "+postdata[1].psychotherapy_pr211 +"\nåæ¡è½ä»ä¾æº "+postdata[1].datafrom212 var r = confirm(confirm2);213 if(r==true){214 $.ajax({215 url:'../../midcase/controller.php',216 type: 'POST',217 data:JSON.stringify(postdata),218 async:false,219 success:function(r){220 // console.log(r);221 result=eval(r);222 if(result[0].status==200){223 // alert("æ°å¢æå");224 $("#form2").empty();225 $("#form2").append("<h1>ä¿®æ¹æå</h1><button id='setup'>åä¿®æ¹ä¸ç</button><button id='index2'>é¦é </button>");226 $("#setup").click(function(event){227 event.preventDefault();228 // console.log(this.id);229 window.location.href = this.id+".html";230 })231 $("#index2").click(function(event){232 // console.log(this.id);233 event.preventDefault();234 window.location.href = "index.html";235 })236 }237 else if(result[0].status==422){238 alert("ç
æ·è碼éè¤ è«éæ°ç¢ºèª");239 }else{240 alert("ç¼çæªé æçé¯èª¤ è«è¯çµ¡ç®¡çå¡");241 }242 },243 error:function(err){244 alert("ç¼çæªé æçé¯èª¤ è«è¯çµ¡ç®¡çå¡");245 console.log(err);246 }247 });248 }else{249 // console.log("no")250 }251 }252 // console.log(JSON.stringify(postdata));253 // window.location.href='show.html';254 });...
PulseFunctions.js
Source:PulseFunctions.js
1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 * 10 * http://www.apache.org/licenses/LICENSE-2.011 * 12 * Unless required by applicable law or agreed to in writing,13 * software distributed under the License is distributed on an14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY15 * KIND, either express or implied. See the License for the16 * specific language governing permissions and limitations17 * under the License.18 */19/**20 * @name PulseFunctions.js21 * @version 1.022 *23 */24/**25 @class A thin JavaScript client that accesses the pulse services. It provides an abstraction layer to communicate with the system and returns json object as a result.26 @constructor27 */28function PulseFunctions() {29}30/**31 @description get pulse version function32 @param responseBack Indicates which function to be called when a response is received. 33 @example34 var pulseVersionBack = function(r, jsonResponse) { ... // handle response };35 pf.pulseVersion(pulseVersionBack, "param1", "param2");36*/37PulseFunctions.prototype.pulseVersion = function(responseBack) {38 var po = new Object();39 po.traceNo = UUIDv4();40 ajaxPost("pulseVersion", po, responseBack);41};42PulseFunctions.prototype.CluserAlertNotificationFunc = function (funcName, postData) {43 var qp = new Object();44 qp.pageNumber = $('#pageNumber').val();45 postData["SystemAlerts"] = qp;46};47PulseFunctions.prototype.ClusterKeyStatisticsFunc = function (funcName, postData) {48 var qp = new Object();49 //postData[funcName] = qp;50 postData["ClusterKeyStatistics"] = qp;51};52PulseFunctions.prototype.ClusterMembersFunc = function (funcName, postData) {53 var qp = new Object();54 postData["ClusterMembers"] = qp;55};56PulseFunctions.prototype.ClusterJVMPAusesFunc = function (funcName, postData) {57 var qp = new Object();58 postData["ClusterJVMPauses"] = qp;59};60PulseFunctions.prototype.ClusterWanInformationFunc = function (funcName, postData) {61 var qp = new Object();62 postData["ClusterWANInfo"] = qp;63};64PulseFunctions.prototype.ClusterMemoryUsageFunc = function (funcName, postData) {65 var qp = new Object();66 postData["ClusterMemoryUsage"] = qp;67};68PulseFunctions.prototype.ClusterDiskThroughputFunc = function (funcName, postData) {69 var qp = new Object();70 postData["ClusterDiskThroughput"] = qp;71};72PulseFunctions.prototype.PulseVersionDetailsFunc = function (funcName, postData) {73 var qp = new Object();74 postData["PulseVersion"] = qp;75};76PulseFunctions.prototype.CluserBasicDetailsFunc = function (funcName, postData) {77 var qp = new Object();78 postData["ClusterDetails"] = qp;79};80PulseFunctions.prototype.ClusterMembersRGraphFunc = function (funcName, postData) {81 var qp = new Object();82 postData["ClusterMembersRGraph"] = qp;83};84PulseFunctions.prototype.ClusterRegionFunc = function (funcName, postData) {85 var qp = new Object();86 postData["ClusterRegion"] = qp;87};88PulseFunctions.prototype.ClusterRegionsFunc = function (funcName, postData) {89 var qp = new Object();90 postData["ClusterRegions"] = qp;91};92PulseFunctions.prototype.ClearAllAlertsFunc = function (funcName, postData) {93 var qp = new Object();94 qp.alertType = -1;95 postData["ClearAllAlerts"] = qp;96};97PulseFunctions.prototype.MemberGatewayHubFunc = function (funcName, postData) {98 getRequestParams();99 var qp = new Object();100 qp.memberId = memberId;101 qp.memberName = memberName;102 postData["MemberGatewayHub"] = qp;103};104PulseFunctions.prototype.MemberAsynchEventQueuesFunc = function (funcName, postData) {105 getRequestParams();106 var qp = new Object();107 qp.memberId = memberId;108 qp.memberName = memberName;109 postData["MemberAsynchEventQueues"] = qp;110};111PulseFunctions.prototype.MemberDiskThroughputFunc = function (funcName, postData) {112 getRequestParams();113 var qp = new Object();114 qp.memberId = memberId;115 qp.memberName = memberName;116 postData["MemberDiskThroughput"] = qp;117};118PulseFunctions.prototype.MemberHeapUsageFunc = function (funcName, postData) {119 getRequestParams();120 var qp = new Object();121 qp.memberId = memberId;122 qp.memberName = memberName;123 postData["MemberHeapUsage"] = qp;124};125PulseFunctions.prototype.MemberClientsFunc = function (funcName, postData) {126 getRequestParams();127 var qp = new Object();128 qp.memberId = memberId;129 qp.memberName = memberName;130 postData["MemberClients"] = qp;131};132PulseFunctions.prototype.MemberRegionSummaryFunc = function (funcName, postData) {133 getRequestParams();134 var qp = new Object();135 qp.memberId = memberId;136 qp.memberName = memberName;137 postData["MemberRegions"] = qp;138};139PulseFunctions.prototype.MemberGCPausesFunc = function (funcName, postData) {140 getRequestParams();141 var qp = new Object();142 qp.memberId = memberId;143 qp.memberName = memberName;144 postData["MemberGCPauses"] = qp;145};146PulseFunctions.prototype.MemberKeyStatisticsFunc = function (funcName, postData) {147 getRequestParams();148 var qp = new Object();149 qp.memberId = memberId;150 qp.memberName = memberName;151 postData["MemberKeyStatistics"] = qp;152};153PulseFunctions.prototype.MembersListFunc = function (funcName, postData) {154 getRequestParams();155 var qp = new Object();156 postData["MembersList"] = qp;157};158PulseFunctions.prototype.MemberDetailsFunc = function (funcName, postData) {159 getRequestParams();160 var qp = new Object();161 qp.memberId = memberId;162 qp.memberName = memberName;163 postData["MemberDetails"] = qp;164};165PulseFunctions.prototype.QueryStatisticsFunc = function (funcName, postData) {166 getRequestParams();167 var qp = new Object();168 // later send filter, page etc params here169 //qp.memberId = memberId;170 //qp.memberName = memberName;171 postData["QueryStatistics"] = qp;172};173PulseFunctions.prototype.ClusterSelectedRegionFunc = function (funcName, postData) {174 getRequestParams();175 var qp = new Object();176 qp.regionFullPath = regionFullPath;177 postData["ClusterSelectedRegion"] = qp;178};179PulseFunctions.prototype.ClusterSelectedRegionsMemberFunc = function (funcName, postData) {180 getRequestParams();181 var qp = new Object();182 qp.regionFullPath = regionFullPath;183 postData["ClusterSelectedRegionsMember"] = qp;184};185/*186PulseFunctions.prototype.ClusterMembersFunc = function (funcName, postData) {187 var qp = new Object();188 qp.param1 = "7777";189 qp.param2 = 1;190 postData["ClusterMembers"] = qp;...
comment.js
Source:comment.js
1const path = require('path');2const moment = require('moment');3console.log(__dirname);4var tools = require('./myfunction');5const { writeFile } = require('fs');6const commentRoutes = (app, fs) => {7 const dataPath = '../../data/post.json';8 const userPath = '../../data/users.json';9 var postdata = require(dataPath);10 var userdata = require(userPath);11 // read comment12 app.get("/comments/:postid/:userid", (req, res) => {13 const postid = req.params.postid;14 const userid = req.params.userid;15 for (var key in postdata.data) {16 if (postdata.data[key].id == postid) {17 if (tools.isValidUser(userid, userdata)) postdata.data[key].status = tools.findPostStatus(postdata.data[key], userid);18 else {19 console.log("non-login user");20 postdata.data[key].status = 99;21 }22 23 tools.getStatus(postdata.data[key], userid, userdata);24 for (var key2 in postdata.data[key].comment) {25 tools.getStatus(postdata.data[key].comment[key2], userid, userdata);26 }27 postdata.data[key].comment.sort((x,y) => parseInt(y.totallike) - parseInt(x.totallike));28 fs.writeFile('./data/post.json', JSON.stringify(postdata, null, '\t'), (err) => {29 if (err) {30 res.status(442).send("error when writing");31 return;32 }33 }); 34 res.status(213).send(postdata.data[key]);35 return;36 }37 }38 res.status(421).send('Wrong postid');39 return;40 });41 //add comment42 app.post("/comments/:postid/:userid", (req, res) => {43 const postid = req.params.postid;44 const userid = req.params.userid;45 const commentBody = req.body.body;46 const commentDate = moment().format();47 const validUser = tools.isValidUser(userid, userdata);48 if (!validUser) {49 res.status(408).send("permission required");50 return;51 }52 var foundPost = false;53 var idx_post = 0;54 for (var key in postdata.data) {55 if (postdata.data[key].id == postid) {56 idx_post = key;57 var lastid = postdata.data[key].lastcommentid;58 var commentBox = tools.createCommentBox(commentBody, commentDate, userid, lastid); 59 postdata.data[key].lastcommentid += 1;60 postdata.data[key].comment.push(commentBox);61 foundPost = true; break;62 }63 }64 //console.log(postdata);65 tools.getStatus(postdata.data[idx_post], userid, userdata);66 for (var key in postdata.data[idx_post].comment) {67 tools.getStatus(postdata.data[idx_post].comment[key], userid, userdata);68 }69 postdata.data[idx_post].comment.sort((x,y) => parseInt(y.totallike) - parseInt(x.totallike));70/* var len = postdata.data[idx_post].comment.length;71 var temp = postdata.data[idx_post].comment[len-1];72 for (var i = len - 1; i > 0; i--) {73 postdata.data[idx_post].comment[i] = postdata.data[idx_post].comment[i-1];74 }75 postdata.data[idx_post].comment[0] = temp; */76 if (foundPost) {77 fs.writeFile('./data/post.json', JSON.stringify(postdata, null, '\t'), (err) => {78 if (err) {79 res.status(442).send("error when writing");80 return;81 }82 }); 83 res.status(215).send(postdata.data[idx_post]);84 return;85 }86 res.status(412).send("wrong postid");87 return;88 });89 //like&dislike comment90 app.put("/comments/:userid/:postid/:commentid/:cur", (req, res) => {91 // cur : {-1,0,1} = {dislike, none, like}92 const postid = req.params.postid;93 const userid = req.params.userid;94 const commentid = req.params.commentid;95 const cur = req.params.cur;96 const validUser = tools.isValidUser(userid, userdata);97 if (!validUser) {98 res.status(408).send("permission required");99 return;100 }101 var idx_post = 0, idx_comment = 0;102 for (var key in postdata.data) {103 if (postdata.data[key].id == postid) {104 idx_post = key;105 if (commentid == -1) {106 if (cur == "1") tools.justUpLike(postdata.data[key], userid);107 else if (cur == "-1") tools.justDownLike(postdata.data[key], userid);108 else if (cur == "0") tools.justNoLike(postdata.data[key], userid);109 tools.getStatus(postdata.data[key], userid, userdata);110 break;111 }112 for (var i in postdata.data[key].comment) {113 if (postdata.data[key].comment[i].id == commentid) {114 if (cur == "1") tools.justUpLike(postdata.data[key].comment[i], userid);115 else if (cur == "-1") tools.justDownLike(postdata.data[key].comment[i], userid);116 else if (cur == "0") tools.justNoLike(postdata.data[key].comment[i], userid);117 idx_comment = i; 118 // get status119 var isFirst = true;120 if (isFirst) {121 tools.getStatus(postdata.data[key], userid, userdata);122 isFirst = false;123 }124 tools.getStatus(postdata.data[key].comment[i], userid, userdata);125 break;126 }127 }128 break;129 }130 }131 132 fs.writeFile('./data/post.json', JSON.stringify(postdata, null, '\t'), (err) => {133 if (err) {134 res.status(442).send("error when writing");135 return;136 }137 }); 138 res.status(214).send(postdata.data[idx_post]);139 });140};...
CreditCard.js
Source:CreditCard.js
1/* eslint-disable prettier/prettier */2import React from 'react';3import IMP from 'iamport-react-native';4import { createGroup, participationGroup } from '../../utils/helper';5import axiosApiInstance from '../../utils/axios';6import { Alert, View, Text } from 'react-native';7const CreditCard = ({route, navigation}) => {8 const { paymentInfo, postData } = route.params;9 let today = new Date();10 today.setHours(today.getHours() + 9);11 today = JSON.stringify(today).substr(1,10);12 const groupType = postData.deliDate === today ? 'day' : 'weekly';13 const tempDay = new Date(postData.deliDate);14 tempDay.setHours(postData.time.substr(0,2) * 1 + 9);15 tempDay.setMinutes(postData.time.substr(3,4) * 1);16 // console. test17 const test ={18 storeId: postData.storeInfo.storeId,19 // time: postData.time,20 // date: postData.deliDate,21 deliveryDateTime: tempDay,22 maxValue: postData.maxValue,23 groupType: groupType,24 latitude: postData.location.latitude,25 longitude: postData.location.longitude,26 address: postData.location.address,27 buildingName: postData.location.buildingName,28 // order Data29 menu: postData.cartItems,30 totalCost: postData.totalPrice,31 payMethod: 'card',32 promotion: postData.promotion ? 'On' : 'Off',33 };34 console.log(JSON.stringify(test,null,4))35 const paymentTermination = (response) => {36 // ì¶í ì¤ì ê²°ì ë trueë¡37 if (response.imp_success === 'false') {38 const currentTime = new Date();39 currentTime.setHours(currentTime.getHours() + 9);40 if (!postData.groupData) {41 // 그룹 ìì± ê²°ì ì±ê³µ íì´ì§ë¡ ì´ë í42 // navigation.replace('PaymentCompleted',{43 // paymentMethod: 'ì¹´ë',44 // totalCost: postData.totalPrice,45 // groupType: groupType,46 // });47 axiosApiInstance.post('/deliveryGroup', {48 // groupData49 storeId: postData.storeInfo.storeId,50 // time: postData.time,51 // date: postData.deliDate,52 deliveryDateTime: tempDay,53 maxValue: postData.maxValue,54 groupType: groupType,55 latitude: postData.location.latitude,56 longitude: postData.location.longitude,57 address: postData.location.address,58 buildingName: postData.location.buildingName,59 // order Data60 menu: postData.cartItems,61 totalCost: postData.totalPrice,62 payMethod: 'card',63 orderTime: currentTime,64 promotion: postData.promotion ? 'On' : 'Off',65 }).then( (response) => {66 console.log('ë°°ë¬ê·¸ë£¹ ìì±ìë£');67 // ê²°ì ì±ê³µ íì´ì§ë¡ ì´ë í68 navigation.replace('PaymentCompleted',{69 paymentMethod: 'ì¹´ë',70 totalCost: postData.totalPrice,71 groupType: groupType,72 });73 });74 } else {75 // 그룹 ì°¸ì¬ ê²°ì ì±ê³µ íì´ì§ë¡ ì´ë í76 // navigation.replace('PaymentCompleted',{77 // totalCost: postData.totalPrice,78 // paymentMethod: 'ì¹´ë',79 // groupType: groupType,80 // });81 let cartItems = postData.cartItems.map((item) => {82 delete item.menuId;83 return item;84 });85 axiosApiInstance.post('/deliveryGroupJoin', {86 groupId: postData.groupData.groupId,87 // order detail88 menu: cartItems,89 totalCost: postData.totalPrice,90 payMethod: 'card',91 orderTime: currentTime,92 promotion: postData.promotion ? 'On' : 'Off',93 }).then( (response) => {94 console.log('ë°°ë¬ê·¸ë£¹ ì°¸ì¬ìë£');95 // ê²°ì ì±ê³µ íì´ì§ë¡ ì´ë í96 navigation.replace('PaymentCompleted',{97 totalCost: postData.totalPrice,98 paymentMethod: 'ì¹´ë',99 groupType: groupType,100 });101 });102 }103 } else {104 Alert.alert(response.error_msg);105 navigation.goBack();106 }107 };108 const data = {109 pg: 'inicis',110 pay_method: 'card',111 name: 'Dutch Delivery',112 merchant_uid: `mid_${new Date().getTime()}`,113 amount: postData.totalPrice,114 buyer_name: paymentInfo.buyerName,115 buyer_tel: paymentInfo.buyerTel,116 buyer_email: paymentInfo.buyerEmail,117 app_scheme: 'example',118 };119 return (120 // <View>121 // <Text>hello</Text>122 // </View>123 <IMP.Payment124 userCode={'imp77640589'}125 data={data}126 callback={paymentTermination} // ê²°ì ì¢
ë£ í ì½ë°±í¨ì í¸ì¶127 />128 );129};130export default CreditCard;131// dummy Dataë¡ í
ì¤í¸ í ë,132// createGroup(creationGroupData.groupData, creationGroupData.orderData).then(() => {133// console.log("hi");134// navigation.popToTop();135// });136// participationGroup(participationGroupData.groupId, participationGroupData.orderData).then((data) => {137// console.log("hi");138// navigation.popToTop();...
delete.js
Source:delete.js
1'use strict';2const _ = require('lodash');3const db = require('../database');4const topics = require('../topics');5const categories = require('../categories');6const user = require('../user');7const groups = require('../groups');8const notifications = require('../notifications');9const plugins = require('../plugins');10module.exports = function (Posts) {11 Posts.delete = async function (pid, uid) {12 return await deleteOrRestore('delete', pid, uid);13 };14 Posts.restore = async function (pid, uid) {15 return await deleteOrRestore('restore', pid, uid);16 };17 async function deleteOrRestore(type, pid, uid) {18 const isDeleting = type === 'delete';19 await plugins.fireHook('filter:post.' + type, { pid: pid, uid: uid });20 await Posts.setPostFields(pid, {21 deleted: isDeleting ? 1 : 0,22 deleterUid: isDeleting ? uid : 0,23 });24 const postData = await Posts.getPostFields(pid, ['pid', 'tid', 'uid', 'content', 'timestamp']);25 const topicData = await topics.getTopicFields(postData.tid, ['tid', 'cid', 'pinned']);26 postData.cid = topicData.cid;27 await Promise.all([28 topics.updateLastPostTimeFromLastPid(postData.tid),29 topics.updateTeaser(postData.tid),30 isDeleting ?31 db.sortedSetRemove('cid:' + topicData.cid + ':pids', pid) :32 db.sortedSetAdd('cid:' + topicData.cid + ':pids', postData.timestamp, pid),33 ]);34 await categories.updateRecentTidForCid(postData.cid);35 plugins.fireHook('action:post.' + type, { post: _.clone(postData), uid: uid });36 return postData;37 }38 Posts.purge = async function (pid, uid) {39 const postData = await Posts.getPostData(pid);40 if (!postData) {41 return;42 }43 const topicData = await topics.getTopicFields(postData.tid, ['tid', 'cid', 'pinned']);44 postData.cid = topicData.cid;45 await plugins.fireHook('filter:post.purge', { post: postData, pid: pid, uid: uid });46 await Promise.all([47 deletePostFromTopicUserNotification(postData, topicData),48 deletePostFromCategoryRecentPosts(postData),49 deletePostFromUsersBookmarks(pid),50 deletePostFromUsersVotes(pid),51 deletePostFromReplies(postData),52 deletePostFromGroups(postData),53 db.sortedSetsRemove(['posts:pid', 'posts:votes', 'posts:flagged'], pid),54 Posts.uploads.dissociateAll(pid),55 ]);56 plugins.fireHook('action:post.purge', { post: postData, uid: uid });57 await db.delete('post:' + pid);58 };59 async function deletePostFromTopicUserNotification(postData, topicData) {60 await db.sortedSetsRemove([61 'tid:' + postData.tid + ':posts',62 'tid:' + postData.tid + ':posts:votes',63 'uid:' + postData.uid + ':posts',64 ], postData.pid);65 const tasks = [66 db.decrObjectField('global', 'postCount'),67 db.decrObjectField('category:' + topicData.cid, 'post_count'),68 db.sortedSetRemove('cid:' + topicData.cid + ':uid:' + postData.uid + ':pids', postData.pid),69 db.sortedSetRemove('cid:' + topicData.cid + ':uid:' + postData.uid + ':pids:votes', postData.pid),70 topics.decreasePostCount(postData.tid),71 topics.updateTeaser(postData.tid),72 topics.updateLastPostTimeFromLastPid(postData.tid),73 db.sortedSetIncrBy('tid:' + postData.tid + ':posters', -1, postData.uid),74 user.incrementUserPostCountBy(postData.uid, -1),75 notifications.rescind('new_post:tid:' + postData.tid + ':pid:' + postData.pid + ':uid:' + postData.uid),76 ];77 if (!topicData.pinned) {78 tasks.push(db.sortedSetIncrBy('cid:' + topicData.cid + ':tids:posts', -1, postData.tid));79 }80 await Promise.all(tasks);81 }82 async function deletePostFromCategoryRecentPosts(postData) {83 const cids = await categories.getAllCidsFromSet('categories:cid');84 const sets = cids.map(cid => 'cid:' + cid + ':pids');85 await db.sortedSetsRemove(sets, postData.pid);86 await categories.updateRecentTidForCid(postData.cid);87 }88 async function deletePostFromUsersBookmarks(pid) {89 const uids = await db.getSetMembers('pid:' + pid + ':users_bookmarked');90 const sets = uids.map(uid => 'uid:' + uid + ':bookmarks');91 await db.sortedSetsRemove(sets, pid);92 await db.delete('pid:' + pid + ':users_bookmarked');93 }94 async function deletePostFromUsersVotes(pid) {95 const [upvoters, downvoters] = await Promise.all([96 db.getSetMembers('pid:' + pid + ':upvote'),97 db.getSetMembers('pid:' + pid + ':downvote'),98 ]);99 const upvoterSets = upvoters.map(uid => 'uid:' + uid + ':upvote');100 const downvoterSets = downvoters.map(uid => 'uid:' + uid + ':downvote');101 await Promise.all([102 db.sortedSetsRemove(upvoterSets.concat(downvoterSets), pid),103 db.deleteAll(['pid:' + pid + ':upvote', 'pid:' + pid + ':downvote']),104 ]);105 }106 async function deletePostFromReplies(postData) {107 if (!parseInt(postData.toPid, 10)) {108 return;109 }110 await Promise.all([111 db.sortedSetRemove('pid:' + postData.toPid + ':replies', postData.pid),112 db.decrObjectField('post:' + postData.toPid, 'replies'),113 ]);114 }115 async function deletePostFromGroups(postData) {116 if (!parseInt(postData.uid, 10)) {117 return;118 }119 const groupNames = await groups.getUserGroupMembership('groups:visible:createtime', [postData.uid]);120 const keys = groupNames[0].map(groupName => 'group:' + groupName + ':member:pids');121 await db.sortedSetsRemove(keys, postData.pid);122 }...
har.js
Source:har.js
1'use strict'2var fs = require('fs')3var qs = require('querystring')4var validate = require('har-validator')5var extend = require('extend')6function Har (request) {7 this.request = request8}9Har.prototype.reducer = function (obj, pair) {10 // new property ?11 if (obj[pair.name] === undefined) {12 obj[pair.name] = pair.value13 return obj14 }15 // existing? convert to array16 var arr = [17 obj[pair.name],18 pair.value19 ]20 obj[pair.name] = arr21 return obj22}23Har.prototype.prep = function (data) {24 // construct utility properties25 data.queryObj = {}26 data.headersObj = {}27 data.postData.jsonObj = false28 data.postData.paramsObj = false29 // construct query objects30 if (data.queryString && data.queryString.length) {31 data.queryObj = data.queryString.reduce(this.reducer, {})32 }33 // construct headers objects34 if (data.headers && data.headers.length) {35 // loweCase header keys36 data.headersObj = data.headers.reduceRight(function (headers, header) {37 headers[header.name] = header.value38 return headers39 }, {})40 }41 // construct Cookie header42 if (data.cookies && data.cookies.length) {43 var cookies = data.cookies.map(function (cookie) {44 return cookie.name + '=' + cookie.value45 })46 if (cookies.length) {47 data.headersObj.cookie = cookies.join('; ')48 }49 }50 // prep body51 function some (arr) {52 return arr.some(function (type) {53 return data.postData.mimeType.indexOf(type) === 054 })55 }56 if (some([57 'multipart/mixed',58 'multipart/related',59 'multipart/form-data',60 'multipart/alternative'])) {61 // reset values62 data.postData.mimeType = 'multipart/form-data'63 } else if (some([64 'application/x-www-form-urlencoded'])) {65 if (!data.postData.params) {66 data.postData.text = ''67 } else {68 data.postData.paramsObj = data.postData.params.reduce(this.reducer, {})69 // always overwrite70 data.postData.text = qs.stringify(data.postData.paramsObj)71 }72 } else if (some([73 'text/json',74 'text/x-json',75 'application/json',76 'application/x-json'])) {77 data.postData.mimeType = 'application/json'78 if (data.postData.text) {79 try {80 data.postData.jsonObj = JSON.parse(data.postData.text)81 } catch (e) {82 this.request.debug(e)83 // force back to text/plain84 data.postData.mimeType = 'text/plain'85 }86 }87 }88 return data89}90Har.prototype.options = function (options) {91 // skip if no har property defined92 if (!options.har) {93 return options94 }95 var har = {}96 extend(har, options.har)97 // only process the first entry98 if (har.log && har.log.entries) {99 har = har.log.entries[0]100 }101 // add optional properties to make validation successful102 har.url = har.url || options.url || options.uri || options.baseUrl || '/'103 har.httpVersion = har.httpVersion || 'HTTP/1.1'104 har.queryString = har.queryString || []105 har.headers = har.headers || []106 har.cookies = har.cookies || []107 har.postData = har.postData || {}108 har.postData.mimeType = har.postData.mimeType || 'application/octet-stream'109 har.bodySize = 0110 har.headersSize = 0111 har.postData.size = 0112 if (!validate.request(har)) {113 return options114 }115 // clean up and get some utility properties116 var req = this.prep(har)117 // construct new options118 if (req.url) {119 options.url = req.url120 }121 if (req.method) {122 options.method = req.method123 }124 if (Object.keys(req.queryObj).length) {125 options.qs = req.queryObj126 }127 if (Object.keys(req.headersObj).length) {128 options.headers = req.headersObj129 }130 function test (type) {131 return req.postData.mimeType.indexOf(type) === 0132 }133 if (test('application/x-www-form-urlencoded')) {134 options.form = req.postData.paramsObj135 } else if (test('application/json')) {136 if (req.postData.jsonObj) {137 options.body = req.postData.jsonObj138 options.json = true139 }140 } else if (test('multipart/form-data')) {141 options.formData = {}142 req.postData.params.forEach(function (param) {143 var attachment = {}144 if (!param.fileName && !param.contentType) {145 options.formData[param.name] = param.value146 return147 }148 // attempt to read from disk!149 if (param.fileName && !param.value) {150 attachment.value = fs.createReadStream(param.fileName)151 } else if (param.value) {152 attachment.value = param.value153 }154 if (param.fileName) {155 attachment.options = {156 filename: param.fileName,157 contentType: param.contentType ? param.contentType : null158 }159 }160 options.formData[param.name] = attachment161 })162 } else {163 if (req.postData.text) {164 options.body = req.postData.text165 }166 }167 return options168}...
serverXHRSignalingChannel.js
Source:serverXHRSignalingChannel.js
1// Copyright 2013-2014 Digital Codex LLC2// You may use this code for your own education. If you use it3// largely intact, or develop something from it, don't claim4// that your code came first. You are using this code completely5// at your own risk. If you rely on it to work in any particular6// way, you're an idiot and we won't be held responsible.7var log = require("./log").log;8var connections = {},9 partner = {},10 messagesFor = {};11// queue the sending of a json response12function webrtcResponse(response, res) {13 log("replying with webrtc response " +14 JSON.stringify(response));15 res.writeHead(200, {"Content-Type":"application/json"});16 res.write(JSON.stringify(response));17 res.end();18}19// send an error as the json WebRTC response20function webrtcError(err, res) {21 log("replying with webrtc error: " + err);22 webrtcResponse({"err": err}, res);23}24// handle XML HTTP Request to connect using a given key25function connect(info) {26 var res = info.res,27 query = info.query,28 thisconnection,29 newID = function() {30 // create large random number unlikely to be repeated31 // soon in server's lifetime32 return Math.floor(Math.random()*1000000000);33 },34 connectFirstParty = function() {35 if (thisconnection.status == "connected") {36 // delete pairing and any stored messages37 delete partner[thisconnection.ids[0]];38 delete partner[thisconnection.ids[1]];39 delete messagesFor[thisconnection.ids[0]];40 delete messagesFor[thisconnection.ids[1]];41 }42 connections[query.key] = {};43 thisconnection = connections[query.key];44 thisconnection.status = "waiting";45 thisconnection.ids = [newID()];46 webrtcResponse({"id":thisconnection.ids[0],47 "status":thisconnection.status}, res);48 },49 connectSecondParty = function() {50 thisconnection.ids[1] = newID();51 partner[thisconnection.ids[0]] = thisconnection.ids[1];52 partner[thisconnection.ids[1]] = thisconnection.ids[0];53 messagesFor[thisconnection.ids[0]] = [];54 messagesFor[thisconnection.ids[1]] = [];55 thisconnection.status = "connected";56 webrtcResponse({"id":thisconnection.ids[1],57 "status":thisconnection.status}, res);58 };59 log("Request handler 'connect' was called.");60 if (query && query.key) {61 var thisconnection = connections[query.key] ||62 {status:"new"};63 if (thisconnection.status == "waiting") { // first half ready64 connectSecondParty(); return;65 } else { // must be new or status of "connected"66 connectFirstParty(); return;67 }68 } else {69 webrtcError("No recognizable query key", res);70 }71}72exports.connect = connect;73// Queues message in info.postData.message for sending to the74// partner of the id in info.postData.id75function sendMessage(info) {76 log("postData received is ***" + info.postData + "***");77 var postData = JSON.parse(info.postData),78 res = info.res;79 if (typeof postData === "undefined") {80 webrtcError("No posted data in JSON format!", res);81 return;82 }83 if (typeof (postData.message) === "undefined") {84 webrtcError("No message received", res);85 return;86 }87 if (typeof (postData.id) === "undefined") {88 webrtcError("No id received with message", res);89 return;90 }91 if (typeof (partner[postData.id]) === "undefined") {92 webrtcError("Invalid id " + postData.id, res);93 return;94 }95 if (typeof (messagesFor[partner[postData.id]]) ===96 "undefined") {97 webrtcError("Invalid id " + postData.id, res);98 return;99 }100 messagesFor[partner[postData.id]].push(postData.message);101 log("Saving message ***" + postData.message +102 "*** for delivery to id " + partner[postData.id]);103 webrtcResponse("Saving message ***" + postData.message +104 "*** for delivery to id " +105 partner[postData.id], res);106}107exports.send = sendMessage;108// Returns all messages queued for info.postData.id109function getMessages(info) {110 var postData = JSON.parse(info.postData),111 res = info.res;112 if (typeof postData === "undefined") {113 webrtcError("No posted data in JSON format!", res);114 return;115 }116 if (typeof (postData.id) === "undefined") {117 webrtcError("No id received on get", res);118 return;119 }120 if (typeof (messagesFor[postData.id]) === "undefined") {121 webrtcError("Invalid id " + postData.id, res);122 return;123 }124 log("Sending messages ***" +125 JSON.stringify(messagesFor[postData.id]) + "*** to id " +126 postData.id);127 webrtcResponse({'msgs':messagesFor[postData.id]}, res);128 messagesFor[postData.id] = [];129}...
Using AI Code Generation
1const puppeteer = require('puppeteer');2const fs = require('fs');3(async () => {4 const browser = await puppeteer.launch({headless: false});5 const page = await browser.newPage();6 await page.screenshot({path: 'google.png'});7 await browser.close();8})();
Using AI Code Generation
1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch({ headless: false });4 const page = await browser.newPage();5 await page.type('#myText', 'Hello World!');6 await page.click('#myButton');7 await page.waitForNavigation();8 await browser.close();9})();10const puppeteer = require('puppeteer');11(async () => {12 const browser = await puppeteer.launch({ headless: false });13 const page = await browser.newPage();14 await page.type('#myText', 'Hello World!');15 await page.click('#myButton');16 await page.waitForNavigation();17 await browser.close();18})();19const puppeteer = require('puppeteer');20(async () => {21 const browser = await puppeteer.launch({ headless: false });22 const page = await browser.newPage();23 await page.type('#myText', 'Hello World!');24 await page.click('#myButton');25 await page.waitForNavigation();26 await browser.close();27})();28const puppeteer = require('puppeteer');29(async () => {30 const browser = await puppeteer.launch({ headless: false });31 const page = await browser.newPage();32 await page.type('#myText', 'Hello World!');33 await page.click('#myButton');34 await page.waitForNavigation();35 await browser.close();36})();37const puppeteer = require('puppeteer');38(async () => {39 const browser = await puppeteer.launch({ headless: false });40 const page = await browser.newPage();41 await page.type('#myText', 'Hello World!');42 await page.click('#myButton');43 await page.waitForNavigation();44 await browser.close();45})();46const puppeteer = require('puppeteer');47(async () => {
Using AI Code Generation
1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch({headless: false});4 const page = await browser.newPage();5 await page.screenshot({path: 'example.png'});6 await page.screenshot({path: 'example2.png'});7 await page.screenshot({path: 'example3.png'});8 await page.screenshot({path: 'example4.png'});9 await page.screenshot({path: 'example5.png'});10 await page.screenshot({path: 'example6.png'});11 await browser.close();12})();13const puppeteer = require('puppeteer');14(async () => {15 const browser = await puppeteer.launch({headless: false});16 const page = await browser.newPage();17 await page.screenshot({path: 'example.png'});18 await page.screenshot({path: 'example2.png'});19 await page.screenshot({path: 'example3.png'});20 await page.screenshot({path: 'example4.png'});21 await page.screenshot({path: 'example5.png'});22 await page.screenshot({path: 'example6.png'});23 await browser.close();24})();25const puppeteer = require('puppeteer');26(async () => {27 const browser = await puppeteer.launch({headless: false});28 const page = await browser.newPage();29 await page.screenshot({path: 'example.png'});
Using AI Code Generation
1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch({headless: false});4 const page = await browser.newPage();5 await page.evaluate(() => {6 body: JSON.stringify({a: 1, b: 'Textual content'}),7 headers: {8 }9 }).then(res => res.json())10 .then(response => console.log('Success:', JSON.stringify(response)))11 .catch(error => console.error('Error:', error));12 });13 await browser.close();14})();15 body: JSON.stringify({a: 1, b: 'Textual content'}),16 headers: {17 }18 }).then(res => res.json())19 .then(response => console.log('Success:', JSON.stringify(response)))20 .catch(error => console.error('Error:', error));21import requests22payload = {'a': 1, 'b': 'Textual content'}23r = requests.post(url, data=payload)24print(r.text)25$data = array('a' => 1, 'b' => 'Textual content');26$options = array(27 'http' => array(28 'content' => http_build_query($data),29);30$context = stream_context_create($options);31$result = file_get_contents($url, false, $context);32if ($result === FALSE) { /* Handle error */ }33var_dump($result);
Using AI Code Generation
1const puppeteer = require('puppeteer');2const $ = require('cheerio');3 .launch()4 .then(function(browser) {5 return browser.newPage();6 })7 .then(function(page) {8 return page.goto(url).then(function() {9 return page.content();10 });11 })12 .then(function(html) {13 $('h3', html).each(function() {14 console.log($(this).text());15 });16 })17 .catch(function(err) {18 });19const puppeteer = require('puppeteer');20const $ = require('cheerio');21 .launch()22 .then(function(browser) {23 return browser.newPage();24 })25 .then(function(page) {26 return page.goto(url).then(function() {27 return page.content();28 });29 })30 .then(function(html) {31 $('h3', html).each(function() {32 console.log($(this).text());33 });34 })35 .catch(function(err) {36 });37const puppeteer = require('puppeteer');38const $ = require('cheerio');39 .launch()40 .then(function(browser) {41 return browser.newPage();42 })43 .then(function(page) {44 return page.goto(url).then(function() {45 return page.content();46 });47 })48 .then(function(html) {49 $('h3', html).each(function() {50 console.log($(this).text());51 });52 })53 .catch(function(err) {54 });55const puppeteer = require('puppeteer');56const $ = require('cheerio');57 .launch()58 .then(function(browser) {59 return browser.newPage();60 })61 .then(function(page) {62 return page.goto(url).then(function() {63 return page.content();64 });65 })66 .then(function(html) {
Using AI Code Generation
1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch({ headless: false });4 const page = await browser.newPage();5 await page.goto(url);6 await page.type('input[type="text"]', 'puppeteer');7 await page.keyboard.press('Enter');8 await page.waitForNavigation();9 await page.screenshot({ path: 'google.png' });10 await browser.close();11})();12const puppeteer = require('puppeteer');13(async () => {14 const browser = await puppeteer.launch({ headless: false });15 const page = await browser.newPage();16 await page.goto(url);17 await page.type('input[type="text"]', 'puppeteer');18 await page.keyboard.press('Enter');19 await page.waitForNavigation();20 await page.screenshot({ path: 'google.png' });21 await browser.close();22})();
Using AI Code Generation
1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch();4 const page = await browser.newPage();5 await page.evaluate(() => {6 });7 });8 await browser.close();9})();10await page.evaluate(() => {11 });12 });13await page.evaluate(() => {14 });15 });16await page.evaluate(() => {17 });18 });19await page.evaluate(() => {20 });21 });22await page.evaluate(() => {23 });24 });25await page.evaluate(() => {26 });27 });28await page.evaluate(() => {
Using AI Code Generation
1const puppeteer = require('puppeteer');2const fs = require('fs');3const path = require('path');4(async () => {5 const browser = await puppeteer.launch();6 const page = await browser.newPage();7 await page.goto(url);8 await page.screenshot({path: 'google.png'});9 await browser.close();10})();11const puppeteer = require('puppeteer');12const fs = require('fs');13const path = require('path');14(async () => {15 const browser = await puppeteer.launch();16 const page = await browser.newPage();17 await page.goto(url);18 await page.screenshot({path: 'google.png'});19 await browser.close();20})();21const puppeteer = require('puppeteer');22const fs = require('fs');23const path = require('path');24(async () => {25 const browser = await puppeteer.launch();26 const page = await browser.newPage();27 await page.goto(url);28 await page.screenshot({path: 'google.png'});29 await browser.close();30})();31const puppeteer = require('puppeteer');32const fs = require('fs');33const path = require('path');34(async () => {35 const browser = await puppeteer.launch();36 const page = await browser.newPage();37 await page.goto(url);38 await page.screenshot({path: 'google.png'});39 await browser.close();40})();41const puppeteer = require('puppeteer');42const fs = require('fs');43const path = require('path');44(async () => {45 const browser = await puppeteer.launch();46 const page = await browser.newPage();47 await page.goto(url);48 await page.screenshot({path: 'google.png'});49 await browser.close();50})();51const puppeteer = require('puppeteer');52const fs = require('fs');
Using AI Code Generation
1const puppeteer = require('puppeteer');2const fs = require('fs');3const path = require('path');4const postData = require('puppeteer-postdata');5const data = {6};7(async () => {8 const browser = await puppeteer.launch();9 const page = await browser.newPage();10 await postData(page, url, data);11 await page.screenshot({12 path: path.join(__dirname, 'example.png')13 });14 await browser.close();15})();
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!!