(function() { var take = function() { //DDP const chatform=localStorage.getItem("chatform") if(chatform){ switch (window.location.pathname) { case '/shop/cart/goodsagree.aspx': let agreeElem = document.querySelector('[name="agree.x"]') if(agreeElem) { agreeElem.click() } break; case '/shop/cart/cart.aspx': let checkEmailErrSp = document.querySelector('.error_') if(checkEmailErrSp) { errorTxt = checkEmailErrSp.innerText.trim() var param5={ event: "chatform_bindFormErrorFound", text: errorTxt, } window.parent.postMessage(param5, '*'); if(errorTxt){ clearStorage() setTimeout(() => { window.parent.location.reload() }, 3500); } } break; case '/shop/lp/refa_dryer_smart.aspx': let checkEmailErrSp1 = document.querySelector('.checktype_mail').nextElementSibling.querySelector('[src="/img/sys/input_error.gif"]') if(checkEmailErrSp1) { errorTxt = '既に登録されているメールアドレスです。' var paramtt={ event: "chatform_bindFormErrorFound", text: errorTxt, } window.parent.postMessage(paramtt, '*'); } break; case '/shop/lp/refa_dryer.aspx': let checkEmailErrSp2 = document.querySelector('.checktype_mail').nextElementSibling.querySelector('[src="/img/sys/input_error.gif"]') if(checkEmailErrSp2) { errorTxt = '既に登録されているメールアドレスです。' var paramtt1={ event: "chatform_bindFormErrorFound", text: errorTxt, } window.parent.postMessage(paramtt1, '*'); } break; case '/shop/lp/refa_hairiron_pro.aspx': let checkEmailErrSp3 = document.querySelector('.checktype_mail').nextElementSibling.querySelector('[src="/img/sys/input_error.gif"]') if(checkEmailErrSp3) { errorTxt = '既に登録されているメールアドレスです。' var paramtt2={ event: "chatform_bindFormErrorFound", text: errorTxt, } window.parent.postMessage(paramtt2, '*'); } break; case '/shop/order/estimate.aspx': let secondConfirm = localStorage.getItem("secondConfirm") //document.addEventListener("DOMContentLoaded", () => { let password = decrypt(localStorage.getItem('password'), "mtg@qur") document.querySelector('[name="pwd"]').value = password document.querySelector('[name="cpwd"]').value = password let ccInfo = localStorage.getItem('ccInfo') if(!secondConfirm){ let param = { event: "chatform_page_transition", message: "order first confrm page", totalProcess: ccInfo ? 5 : 6, pageIndex: 1 } window.parent.postMessage(param, "*") let CouponLink = document.querySelector('[href*="/shop/order/method.aspx"]'); localStorage.setItem('secondConfirm', true); const submitCopuon = () => { CouponLink.click() } setTimeout(submitCopuon, 2500) } if(secondConfirm){ var subEl = document.querySelector('[value="注文する"]'); let param1 = { event: "chatform_page_transition", message: "order second confrm page", totalProcess: ccInfo ? 5 : 6, pageIndex: 3 } window.parent.postMessage(param1, "*") if(ccInfo){ //console.log("location href=>", window.location.href) var url = "https://pr.aqur.com/track"; function track(trackingData){ fetch(url, { method:"POST", headers:{ "Content-Type" : "application/json"}, body:trackingData }) .then(response => response.json()) .then(data => { console.log("Conversion Tracked!!") localStorage.removeItem("chatform"); //localStorage.removeItem("password") localStorage.removeItem("ccInfo") localStorage.removeItem("coupon") localStorage.removeItem('pdtype') localStorage.removeItem('cEmail') let param2 = { event: "chatform_page_transition", message: "order first confrm page", totalProcess: ccInfo ? 5 : 6, pageIndex: 4 } window.parent.postMessage(param2, "*") }) } track(chatform) var param3={ event: "chatform_CreditRedirectPage", url: window.location.href, } window.parent.postMessage(param3, '*'); //console.log("coupon=>",localStorage.getItem("coupon")) }else{ const submitNext = () => { subEl.click() } setTimeout(submitNext, 2500) } } break; case '/shop/order/method.aspx': // if(localStorage.getItem('pdtype') == "hairiron"){ // document.querySelector('input[name="coupon"]').value = "" // }else{ // document.querySelector('input[name="coupon"]').value = localStorage.getItem('coupon') // } let count=0 function checkError(a, b) { var resultArr = [] //Find error then tell to Chatbot const lperror = document.querySelectorAll('.errorBox_ p'); lperror.forEach((val) => { resultArr.push(val.innerText.trim()) }) var errorTxt = "" if (resultArr.length > 0) { errorTxt = resultArr.join("
") } if (errorTxt) { var param2 = { event: "chatform_bindFormErrorFound", text: errorTxt, } window.parent.postMessage(param2, '*'); lperror.innerHTML = "" clearInterval(intervalID); } count++ if (count >= 3) { clearInterval(intervalID); } } const intervalID = setInterval(checkError, 1000); if(localStorage.getItem('coupon')){ let inputEvent = new InputEvent('change', { bubbles: true, cancelable: false }); const couponElement = document.querySelector('input[name="coupon"]'); couponElement.value = localStorage.getItem('coupon'); couponElement.dispatchEvent(inputEvent); // document.querySelector('input[name="coupon"]').value = localStorage.getItem('coupon') } if(localStorage.getItem('cEmail')){ let inputEvent1 = new InputEvent('change', { bubbles: true, cancelable: false }); const Email = document.querySelector('[name="s_mail"]'); Email.value = localStorage.getItem('cEmail') Email.dispatchEvent(inputEvent1); const Check_Email = document.querySelector('[name="s_cmail"]'); Check_Email.value = localStorage.getItem('cEmail') Check_Email.dispatchEvent(inputEvent1); } var subEl = document.querySelector('input[name="submit.x"]'); let param = { event: "chatform_page_transition", message: "order order method change page", totalProcess: localStorage.getItem('ccInfo') ? 5 : 6, pageIndex: 2 } window.parent.postMessage(param, "*") if(localStorage.getItem('ccInfo')){ document.querySelector("#method_pay input[value='D']").click(); } const submitNext = () => { //now comment subEl.click() } setTimeout(submitNext, 2500) break; case '/shop/order/order.aspx': //console.log('OrderComplete.aspx'); let param1 = { event: "chatform_page_transition", message: "order complete page", totalProcess: 6, pageIndex: 4 } window.parent.postMessage(param1, "*") //document.addEventListener("DOMContentLoaded", () => { //console.log("DOMContentLoaded OrderComplete.aspx") let checkComplete = () => { let orderId = document.querySelector(".order_id_").innerText var url = "https://pr.aqur.com/track"; function track(trackingData){ fetch(url, { method:"POST", headers:{ "Content-Type" : "application/json"}, body:trackingData }) .then(response => response.json()) .then(data => { console.log("Conversion Tracked!!") localStorage.removeItem("chatform"); localStorage.removeItem("password") localStorage.removeItem("ccInfo") localStorage.removeItem("coupon") localStorage.removeItem('pdtype') localStorage.removeItem('cEmail') let param2 = { event: "chatform_page_transition", message: "order complete conversion", totalProcess: 6, pageIndex: 5 } window.parent.postMessage(param2, "*") let param = { event: "chatform_bindFormConversion", order_id: orderId } window.parent.postMessage(param, "*") }) } track(chatform) } checkComplete() //}) break; default: console.log('do nothing'); } }else{ console.log("No Chatform") switch (window.location.pathname) { case '/shop/order/estimate.aspx': console.log(localStorage.getItem('password')) if(localStorage.getItem('password')) { let password = decrypt(localStorage.getItem('password'), "mtg@qur") document.querySelector('[name="pwd"]').value = password document.querySelector('[name="cpwd"]').value = password } break; default: console.log('chat form do nothing'); break; } } document.addEventListener("DOMContentLoaded", () => { //console.log("DOMContentLoaded") var param={ event: "chatform_DOMContentLoaded" } window.parent.postMessage(param, '*'); const lperror = document.querySelector('.lp-error.lp-confirm, .smp-lp-error.smp-lp-confirm'); if(lperror && lperror.innerHTML.trim()){ //console.log(lperror.innerHTML.trim()) const lpshoppingcolumn = document.querySelector('#lpshoppingcolumn, #smp-lpshoppingcolumn'); if(lpshoppingcolumn){ lpshoppingcolumn.style.display= "block"; } lperror.scrollIntoView({ behavior: "smooth", block: "start", inline: "nearest" }); var param={ event: "chatform_bindFormErrorFound", text:lperror.innerHTML.trim(), } window.parent.postMessage(param, '*'); } }) window.addEventListener("message", (event) => { //console.log("window message") if(event.data.event == "chatform_vframe_debug"){ //console.log("chatform_vframe_debug") const lpshoppingcolumn = document.querySelector('#lpshoppingcolumn, #smp-lpshoppingcolumn'); lpshoppingcolumn.style.display= "block"; lpshoppingcolumn.scrollIntoView({ behavior: "smooth", block: "start", inline: "nearest" }); } if(event.data.event == "chatform_bindForm"){ // console.log("1 chatform_bindForm",event.data.project) var project = event.data.project; var arr = project.data; var pdData = event.data.product; var chatform = { pid:project.pid, sid:project.sid, uuId:project.uuId, id:arr[arr.length-1].id } localStorage.setItem('chatform', JSON.stringify(chatform)); localStorage.setItem('pdtype', pdData); if(findOption(arr, 'payment') == 'D') { // const ccInfo = { // "CardNumber": findValue(arr, "dwfrm_billing_paymentMethods_creditCard_number"), // "CardExpiryYear": findValue(arr, "dwfrm_billing_paymentMethods_creditCard_year"), // "CardExpiryMonth": findValue(arr, "dwfrm_billing_paymentMethods_creditCard_month"), // "CardCVC": findValue(arr, "dwfrm_billing_paymentMethods_creditCard_cvn"), // "CardHolderName": findValue(arr, "CardHolderName") // } //localStorage.setItem('ccInfo', JSON.stringify(ccInfo)); localStorage.setItem('ccInfo', true); }else{ localStorage.removeItem("ccInfo") } let encPass = encrypt(findValue(arr, 'Password'), "mtg@qur") localStorage.setItem('password', encPass); //console.log("coupon=>", findValue(arr, "coupon")) // console.log("coupon2 => ", findValue(arr, "coupon2")) // localStorage.setItem('coupon', "dryer2000"); if(pdData == "dry2" && findValue(arr, "coupon2") !="Undefind"){ localStorage.setItem('coupon', findValue(arr, "coupon2")); }else if(pdData == "dryer" && findValue(arr, "coupon") !="Undefind"){ localStorage.setItem('coupon', findValue(arr, "coupon")); }else if(pdData == "dry2"){ //dry2のLPにdefaultする localStorage.setItem('coupon', "dryer2409"); } bindForm(arr, pdData) } if(event.data.event == "chatform_bindFormSubmit"){ //console.log("chatform_bindFormSubmit") bindFormSubmit() } if(event.data.event == "chatform_bindFormUpcell"){ //console.log("chatform_bindFormSubmit") document.getElementById("ups_button").click(); } }) function bindForm(d, productType){ // console.log("bindForm",d) // console.log("productType", productType) let selectEvent = new Event('change', { bubbles: true, composed: true }) let inputEvent = new InputEvent('change', { bubbles: true, cancelable: false }); if(productType == "dryer"){ //商品 var goods = findOption(d,"goods2"); let GoodsName = findOptionByID(d,"6de41c8").split(">")[1].split("<")[0];// console.log("GoodsName",GoodsName) let GoodsType = findOptionByID(d,"8a80123"); //console.log("GoodsType", GoodsType) var goods = "" if(/つけない/.test(GoodsType) && /ホワイト/.test(GoodsName)){ goods = "5608720301" }else if(/つける/.test(GoodsType) && /ホワイト/.test(GoodsName)){ goods = "5608720401" }else if(/つけない/.test(GoodsType) && /ブラック/.test(GoodsName)){ goods = "5609420301" }else if(/つける/.test(GoodsType) && /ブラック/.test(GoodsName)){ goods = "5609420401" }else if(/つけない/.test(GoodsType) && /ピンク/.test(GoodsName)){ goods = "1150420201" }else if(/つける/.test(GoodsType) && /ピンク/.test(GoodsName)){ goods = "1150420401" } document.querySelector("input[value='"+ goods +"']").checked = true; }else if(productType == "dry2"){ let goods = "", GoodsName = "", GoodsPrice = "", GoodType = ""; GoodsName = findOptionByID(d,"c97de4d").split(">")[1].split("<")[0]; //console.log("goods",goods) GoodType = findOptionByID(d,"10e2cd8"); //console.log("GoodsName",GoodsName) if(/リファビューテックドライヤースマート ダブル/.test(GoodsName)){ if(findOptionByID(d,"76038e5") != "Undefind"){ GoodsPrice = findOptionByID(d,"76038e5"); //console.log("GoodsPrice",GoodsPrice) } //console.log("GoodsPrice=>", GoodsPrice) if(/ホワイト/.test(GoodType) && /つける/.test(GoodsPrice)){ goods = "1382920301" }else if(/ホワイト/.test(GoodType) && /つけない/.test(GoodsPrice)){ goods = "1382920201" }else if(/ブラック/.test(GoodType) && /つける/.test(GoodsPrice)){ goods = "1383620301" }else if(/ブラック/.test(GoodType) && /つけない/.test(GoodsPrice)){ goods = "1383620201" }else if(/ピンク/.test(GoodType) && /つける/.test(GoodsPrice)){ goods = "1384320301" }else if(/ピンク/.test(GoodType) && /つけない/.test(GoodsPrice)){ goods = "1384320201" } } if(/リファビューテック ドライヤースマート/.test(GoodsName)){ if(findOptionByID(d,"c66a7d") != "Undefind"){ GoodsPrice = findOptionByID(d,"c66a7d"); //console.log("GoodsPrice",GoodsPrice) } //console.log("GoodsPrice=>", GoodsPrice) if(/ホワイト/.test(GoodType) && /つける/.test(GoodsPrice)){ goods = "5608720401" }else if(/ホワイト/.test(GoodType) && /つけない/.test(GoodsPrice)){ goods = "5608720301" }else if(/ブラック/.test(GoodType) && /つける/.test(GoodsPrice)){ goods = "5609420401" }else if(/ブラック/.test(GoodType) && /つけない/.test(GoodsPrice)){ goods = "5609420301" }else if(/ピンク/.test(GoodType) && /つける/.test(GoodsPrice)){ goods = "1150420401" }else if(/ピンク/.test(GoodType) && /つけない/.test(GoodsPrice)){ goods = "1150420201" } } if(/リファビューテック ドライヤープロ/.test(GoodsName)){ if(findOptionByID(d,"76103e") != "Undefind"){ GoodsPrice = findOptionByID(d,"76103e"); //console.log("GoodsPrice",GoodsPrice) } //console.log("GoodsPrice=>", GoodsPrice) if(/ホワイト/.test(GoodType) && /つける/.test(GoodsPrice)){ goods = "5506620601" }else if(/ホワイト/.test(GoodType) && /つけない/.test(GoodsPrice)){ goods = "5506620501" }else if(/ブラック/.test(GoodType) && /つける/.test(GoodsPrice)){ goods = "5507320601" }else if(/ブラック/.test(GoodType) && /つけない/.test(GoodsPrice)){ goods = "5507320501" }else if(/ピンク/.test(GoodType) && /つける/.test(GoodsPrice)){ goods = "5610020401" }else if(/ピンク/.test(GoodType) && /つけない/.test(GoodsPrice)){ goods = "5610020301" } } // console.log("good=>", goods) document.querySelector("input[value='"+ goods +"']").checked = true; }else if(productType == "hairiron"){ //var goods = findOption(d,"goods2"); let GoodsName2 = "", GoodsSize = "", GoodsColor1 = ""; var goods2 = ""; GoodsName2 = findOptionByID(d,"78d6737").split(">")[1].split("<")[0]; console.log("GoodsName2",GoodsName2) if(/リファカールアイロン プロ/.test(GoodsName2)){ GoodsSize = findOptionByID(d,"65d0ab5"); //console.log("GoodsSize", GoodsSize) GoodsColor1 = findOptionByID(d,"b598524"); //console.log("GoodsColor1", GoodsColor1) if(/38cm/.test(GoodsSize) && /ホワイト/.test(GoodsColor1)){ goods2 = "1195520501" }else if(/38cm/.test(GoodsSize) && /ブラック/.test(GoodsColor1)){ goods2 = "1195520601" }else if(/32cm/.test(GoodsSize) && /ホワイト/.test(GoodsColor1)){ goods2 = "1195520101" }else if(/32cm/.test(GoodsSize) && /ブラック/.test(GoodsColor1)){ goods2 = "1195520201" }else if(/26cm/.test(GoodsSize) && /ホワイト/.test(GoodsColor1)){ goods2 = "1195520301" }else if(/26cm/.test(GoodsSize) && /ブラック/.test(GoodsColor1)){ goods2 = "1195520401" }else if(/19cm/.test(GoodsSize) && /ホワイト/.test(GoodsColor1)){ goods2 = "1195520701" }else if(/19cm/.test(GoodsSize) && /ブラック/.test(GoodsColor1)){ goods2 = "1195520801" } } let GoodsColor ="" if(/リファストレートアイロン プロ/.test(GoodsName2)){ GoodsColor = findOptionByID(d,"d4880f1"); //console.log("GoodsColor", GoodsColor) if(/ホワイト/.test(GoodsColor)){ goods2 = "1191720701" }else if(/ブラック/.test(GoodsColor)){ goods2 = "1191720801" }else if(/ピンク/.test(GoodsColor)){ goods2 = "1191720301" } } if(/リファフィンガーアイロン ST/.test(GoodsName2)){ GoodsColor = findOptionByID(d, "3c6dd8"); //console.log("GoodsColor", GoodsColor) if(/ホワイト/.test(GoodsColor)){ goods2 = "5439720101" }else if(/ブラック/.test(GoodsColor)){ goods2 = "5605620101" }else if(/ピンク/.test(GoodsColor)){ goods2 = "5439720301" } } // リファカールアイロン プロ - iron2000 // リファストレートアイロン プロ - iron2000 // リファフィンガーアイロン ST - iron1000 //アイロン1000円:iron10002409 ※フィンガーアイロンのみ適用 //アイロン2000円:iron20002409 ※ストレートアイロン、カールアイロンのみ適用 if(/リファカールアイロン プロ/.test(GoodsName2) || /リファストレートアイロン プロ/.test(GoodsName2)){ localStorage.setItem('coupon', "") localStorage.setItem('coupon', "iron20002409") }else if(/リファフィンガーアイロン ST/.test(GoodsName2)){ localStorage.setItem('coupon', "") localStorage.setItem('coupon', "iron10002409") } console.log("goods2=>",goods2 ) document.querySelector("input[value='"+ goods2 +"']").checked = true; } // 宅配ボックスへ配達希望 let isAgree = findOption(d, "6b57e15_1") var agreement = 'input[name="string18"]'; const agreementEl = document.querySelector(agreement); if(isAgree) agreementEl.checked=true; else agreementEl.checked=true; const LastName = document.querySelector('[name="s_name"]'); LastName.value = findValue(d,"lastname") LastName.dispatchEvent(inputEvent); const FirstName = document.querySelector('[name="s_name2"]'); FirstName.value = findValue(d,"firstname") FirstName.dispatchEvent(inputEvent); const LastNameKana = document.querySelector('[name="s_kana"]'); LastNameKana.value = findValue(d,"furigana_firstname") LastNameKana.dispatchEvent(inputEvent); const FirstNameKana = document.querySelector('[name="s_kana2"]'); FirstNameKana.value = findValue(d,"furigana_mei") FirstNameKana.dispatchEvent(inputEvent); // 必須 let gender = findOption(d,"gender"); document.querySelector("input[name='sex-pseudo'][value='"+ gender +"']").checked = true; document.querySelector("input[name='sex-pseudo'][value='"+ gender +"']").dispatchEvent(selectEvent) var Year = findValue(d, "Year"); document.querySelector("select[name='yy_s_birth'] option[value='"+Year+"']").selected = true; const bdYear = document.querySelector("select[name='yy_s_birth']"); bdYear.dispatchEvent(new Event('change', { bubbles: true, composed: true })); var Month = findValue(d, "Month"); Month = Month > 9 ? Month : "0" + Month document.querySelector("select[name='mm_s_birth'] option[value='"+Month+"']").selected = true; const bdMonth = document.querySelector("select[name='mm_s_birth']"); bdMonth.dispatchEvent(new Event('change', { bubbles: true, composed: true })); var Day = findValue(d, "Day"); Day = Day > 9 ? Day : "0" + Day document.querySelector("select[name='dd_s_birth'] option[value='"+Day+"']").selected = true; const bdDay = document.querySelector("select[name='dd_s_birth']"); bdDay.dispatchEvent(new Event('change', { bubbles: true, composed: true })); const Tel = document.querySelector("input[name='s_tel']"); Tel.value = findValue(d,"phone") Tel.dispatchEvent(inputEvent); const Email = document.querySelector('[name="s_mail"]'); Email.value = findValue(d, "email") Email.dispatchEvent(inputEvent); const Check_Email = document.querySelector('[name="s_cmail"]'); Check_Email.value = findValue(d, "email") Check_Email.dispatchEvent(inputEvent); localStorage.setItem("cEmail", findValue(d, "email")) const Zip = document.querySelector('[name="s_zip"]'); Zip.value = findValue(d,"zip") Zip.dispatchEvent(inputEvent); var Area = findValue(d, "area"); document.querySelector("select[name='s_pref'] option[value='"+Area+"']").selected = true; const eleArea = document.querySelector("select[name='s_pref']"); eleArea.dispatchEvent(new Event('change', { bubbles: true, composed: true })); const City = document.querySelector('[name="s_addr"]'); City.value = findValue(d,"city") City.dispatchEvent(inputEvent); const Address1 = document.querySelector('[name="s_addr2"]'); Address1.value = findValue(d,"street") Address1.dispatchEvent(inputEvent); const Address2 = document.querySelector('[name="s_addr3"]'); Address2.value = findValue(d,"building") Address2.dispatchEvent(inputEvent); let payment_id = findOption(d, 'payment') if(payment_id == "D"){ payment_id = "2" } //console.log("payment_id", payment_id) if(document.querySelector("#method_radio input[type='radio'][value='"+payment_id+"']") !== null){ document.querySelector("#method_radio input[type='radio'][value='"+payment_id+"']").checked = true; }else{ document.querySelector("#method_pay input[value='"+payment_id+"']").checked = true; } // 配送希望時間: const bindDeliTime = () => { var delivery_time = findOption(d,"delivery_time"); //console.log(delivery_time) const SelectDeliTime = document.querySelector("[name='time_spec'] option[value='"+delivery_time+"']"); SelectDeliTime.selected=true; SelectDeliTime.dispatchEvent(new Event('change')); } setTimeout(bindDeliTime, 1000) } function bindFormSubmit(){ //console.log("bindFormSubmit") var setSubmit = () => { document.body.classList.remove("chat_open"); var submit = 'input[name="order"]'; const submitEl = document.querySelector(submit); submitEl.click() }; setTimeout(setSubmit, 2000); let param = { event: "chatform_page_transition", message: "order start", totalProcess: 6, pageIndex: 0 } window.parent.postMessage(param, "*") let count=0 function checkError(a, b) { var resultArr = [] //Find error then tell to Chatbot const lperror = document.querySelectorAll('.errorBox_ p'); lperror.forEach((val) => { resultArr.push(val.innerText.trim()) }) var errorTxt = "" if(resultArr.length > 0){ errorTxt = resultArr.join("
") } if(errorTxt){ var param2={ event: "chatform_bindFormErrorFound", text: errorTxt, } window.parent.postMessage(param2, '*'); lperror.innerHTML="" clearInterval(intervalID); } count++ if(count>=3){ clearInterval(intervalID); } } const intervalID = setInterval(checkError, 1000); } function clearStorage() { return new Promise((resolve, reject) => { try { // Clear localStorage and sessionStorage localStorage.clear(); sessionStorage.clear(); // Clear cookies const cookies = document.cookie.split("; "); for (const cookie of cookies) { const eqPos = cookie.indexOf("="); const name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie; document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/"; } // Clear IndexedDB const databases = indexedDB.databases(); databases.then((dbs) => { const deletePromises = []; dbs.forEach((db) => { const deletePromise = new Promise((res, rej) => { const req = indexedDB.deleteDatabase(db.name); req.onsuccess = () => res(); req.onerror = () => rej(req.error); }); deletePromises.push(deletePromise); }); return Promise.all(deletePromises); }).then(resolve).catch(reject); } catch (error) { reject(error); } }); } function bindText(d,t,n){ //console.log(t) const el = document.querySelector(t); if(el){ el.value = findValue(d,n); el.dispatchEvent(new Event('change')); } } function bindSelect(d,t,n){ //console.log(t) const el = document.querySelector(t); var value = findOption(d,n); if(el){ el.querySelector("option[value='"+value+"']").selected = true; } } function bindRadio(d,t,n){ //console.log(t) var value = findOption(d,n); var str = t +"[value='"+value+"']" const el = document.querySelector(str); if(el){ el.click() } } function bindCheckbox(d,t,n){ //console.log(t) var values = findOptions(d,n); values.forEach(function(v) { var str = t +"[value='"+v+"']" const el = document.querySelector(str); if(el){ el.checked=true el.dispatchEvent(new Event('change')); } }) } //radio return single value function findValue(d,n){ //console.log(d,n) let value="Undefind"; rtn = value; for(var i=0; i < d.length; i++){ var item = d[i]; if(item.values){ item.values.forEach(function(v) { //console.log(v.name, n) if(v.name==n){ //console.log(n, v.name) rtn = v.value } }) } } //console.log(n,rtn) return rtn } //radio return single value function findOption(d,n){ //console.log(n) let value="Undefind"; rtn = value; for(var i=0; i < d.length; i++){ var item = d[i]; //console.log(item) if(item.options){ item.options.forEach(function(v) { if(v.name==n && v.checked){ //console.log(v) rtn = v.value } }) } } return rtn } function findOptionLabel(d,n){ //console.log(n) let value="Undefind"; rtn = value; for(var i=0; i < d.length; i++){ var item = d[i]; //console.log(item) if(item.options){ item.options.forEach(function(v) { if(v.name==n && v.checked){ //console.log(v) rtn = v.label } }) } } return rtn } //radio return single value function findOptionByID(d,id){ //console.log(n) let value="Undefind"; rtn = value; for(var i=0; i < d.length; i++){ var item = d[i]; //console.log(item) if(item.options && item.id == id){ item.options.forEach(function(v) { if(v.checked){ //console.log(v) rtn = v.label } }) } } return rtn } //checkbox return array function findOptions(d,n){ rtn = []; for(var i=0; i < d.length; i++){ var item = d[i]; if(item.options){ item.options.forEach(function(v) { var reg = new RegExp(n) if(reg.test(v.name) && v.checked){ rtn.push(v.value) } }) } } return rtn } function encrypt(text, key) { return [...text].map((x, i) => (x.codePointAt() ^ key.charCodeAt(i % key.length) % 255) .toString(16) .padStart(2, "0") ).join('') } function decrypt(text, key) { return String.fromCharCode(...text.match(/.{1,2}/g) .map((e, i) => parseInt(e, 16) ^ key.charCodeAt(i % key.length) % 255) ) } //Inserted End } setTimeout(take, 0); }())