@abtasty/cognitivediscountmaker
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -1,1 +0,1 @@ | ||
!function(){"use strict";var e="https://turing-engine.appspot.com/api/v1",t=function(e){return Object.keys(e).map(function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])}).join("&")},n=function(n,i,r,o){var a=n.map(function(e){return Object.assign(e,{vas:(t=e,n=t.newPrice,i=t.oldPrice,[i-n,Math.round(100*(1-n/i))])});var t,n,i});return Promise.all(a.map(function(n){var a=n.vas,c=n.newPrice,l=n.oldPrice,s=n.discountContainerElem,d=n.conversionElem;return function(n){var i=n.cid,r=n.vas,o=n.vid,a=n.caid,c=n.c;console.log("cognitiveModule :","Call Turing Engine : ",{cid:i,vas:r,vid:o,caid:a,c:c}),new Promise(function(n,l){return fetch(e+"/suggest?"+t({cid:i,vid:o,caid:a,c:c,vas:r}),{method:"GET"}).then(function(e){return n(e.json())})})}({cid:i,vid:r,vas:"perc,value",caid:o,c:l.toString().replace(".","d")+"_"+c.toString().replace(".","d")}).then(function(e){var t=e.va;return{vas:a,newPrice:c,oldPrice:l,va:t,selectedVa:"value"===t?a[0]:a[1]+"%",discountContainerElem:s,conversionElem:d}})}))},i=function(n,i,r){!function(n){var i=n.cid,r=n.vid,o=n.caid,a=n.c,c=n.a;fetch(e+"/convert?"+t({cid:i,vid:r,caid:o,c:a,a:c}),{method:"GET"})}({cid:n,vid:i,c:r,caid:"undefined"!=typeof TEST_ID?TEST_ID:n,a:0})};!function(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var i=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===n&&i.firstChild?i.insertBefore(r,i.firstChild):i.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}("abtasty-modal{display:none;z-index:1000000}abtasty-modal,abtasty-modal__underlay{position:fixed;top:0;left:0;width:100%;height:100%}abtasty-modal__underlay{background-color:rgba(0,0,0,.5);cursor:pointer}.abtasty-modal__area{top:0;left:0;right:0;width:auto;margin:10px!important;max-height:70%;z-index:100;position:relative;background-color:#fff;border:3px solid #fff;box-shadow:0 0 10px #666;-moz-box-shadow:#666 0 0 10px;-webkit-box-shadow:#666 0 0 10px;text-align:left}.abtasty-modal__close{float:right!important;font-size:44px;font-weight:300;background:transparent;border:0;color:#bbb;font-family:Helvetica Neue,Helvetica,Arial,sans-serif!important;line-height:32px!important;margin-right:5px;cursor:pointer}.abtasty-modal__text{padding:20px;font-family:Open Sans,sans-serif!important;color:#000}.abtasty-modal__title{text-align:left;width:auto;font-size:31px!important;font-weight:500;line-height:1.1;margin-bottom:10px}.abtasty-modal__text p{margin:0 0 10px!important;font-size:15px;font-weight:300}@media (min-width:630px){.abtasty-modal__area{width:600px;margin:150px auto!important}}");var r=function(e){var t=Object.prototype.hasOwnProperty;function n(e,i){return Array.isArray(e)?function(e,t){for(var i,r="",o="",c=Array.isArray(t),l=0;l<e.length;l++)(i=n(e[l]))&&(c&&t[l]&&(i=a(i)),r=r+o+i,o=" ");return r}(e,i):e&&"object"==typeof e?function(e){var n="",i="";for(var r in e)r&&e[r]&&t.call(e,r)&&(n=n+i+r,i=" ");return n}(e):e||""}function i(e){if(!e)return"";if("object"==typeof e){var n="";for(var i in e)t.call(e,i)&&(n=n+i+":"+e[i]+";");return n}return e+""}function r(e,t,n,i){if(!1===t||null==t||!t&&("class"===e||"style"===e))return"";if(!0===t)return" "+(i?e:e+'="'+e+'"');var r=typeof t;return"object"!==r&&"function"!==r||"function"!=typeof t.toJSON||(t=t.toJSON()),"string"==typeof t||(t=JSON.stringify(t),n||-1===t.indexOf('"'))?(n&&(t=a(t))," "+e+'="'+t+'"'):" "+e+"='"+t.replace(/'/g,"'")+"'"}e.merge=function e(t,n){if(1===arguments.length){for(var r=t[0],o=1;o<t.length;o++)r=e(r,t[o]);return r}for(var a in n)if("class"===a){var c=t[a]||[];t[a]=(Array.isArray(c)?c:[c]).concat(n[a]||[])}else if("style"===a){var c=i(t[a]);c=c&&";"!==c[c.length-1]?c+";":c;var l=i(n[a]);l=l&&";"!==l[l.length-1]?l+";":l,t[a]=c+l}else t[a]=n[a];return t},e.classes=n,e.style=i,e.attr=r,e.attrs=function(e,o){var a="";for(var c in e)if(t.call(e,c)){var l=e[c];if("class"===c){l=n(l),a=r(c,l,!1,o)+a;continue}"style"===c&&(l=i(l)),a+=r(c,l,!1,o)}return a};var o=/["&<>]/;function a(e){var t=""+e,n=o.exec(t);if(!n)return e;var i,r,a,c="";for(i=n.index,r=0;i<t.length;i++){switch(t.charCodeAt(i)){case 34:a=""";break;case 38:a="&";break;case 60:a="<";break;case 62:a=">";break;default:continue}r!==i&&(c+=t.substring(r,i)),r=i+1,c+=a}return r!==i?c+t.substring(r,i):c}return e.escape=a,e.rethrow=function e(t,n,i,r){if(!(t instanceof Error))throw t;if(!("undefined"==typeof window&&n||r))throw t.message+=" on line "+i,t;try{r=r||require("fs").readFileSync(n,"utf8")}catch(n){e(t,null,i)}var o=3,a=r.split("\n"),c=Math.max(i-o,0),l=Math.min(a.length,i+o);var o=a.slice(c,l).map(function(e,t){var n=t+c+1;return(n==i?" > ":" ")+n+"| "+e}).join("\n");t.path=n;t.message=(n||"Pug")+":"+i+"\n"+o+"\n\n"+t.message;throw t},e}({});function o(e){var t,n="";try{var i={},o=e||{};(function(e,i){n=(n=(n+="<div>")+'<div class="abtasty-price_tag"'+r.attr("style",r.style(i),!0,!0)+">")+r.escape(null==(t=e)?"":t)+"</div></div>"}).call(this,"price"in o?o.price:"undefined"!=typeof price?price:void 0,"style"in o?o.style:"undefined"!=typeof style?style:void 0)}catch(e){r.rethrow(e,void 0,void 0,i[void 0])}return n}var a=function(e){var t=window.document,n=e.getBoundingClientRect();return n.top>=0&&n.left>=0&&n.right<=(window.innerWidth||t.documentElement.clientWidth)&&n.bottom<=(window.innerHeight||t.documentElement.clientHeight)&&null!==e.offsetParent},c=function(e){var t=e.replace(/[^0-9,.€$£¥]+/g,"");return t=t.replace(/[€$£¥,]+/g,"."),parseFloat(t)},l=window.ABTasty&&window.ABTasty.visitor&&window.ABTasty.visitor.id||"noVisitorId",s=window.ABTasty&&window.ABTasty.accountSettings&&window.ABTasty.accountSettings.identifier||"noIdentifier",d=function(e){var t=e.target.dataset.abtastyDiscount||"";t&&i(s,l,t.indexOf("%")>-1?"perc":"value")},u=function(e){var t=e.oldPriceSelector,i=e.newPriceSelector,r=e.discountContainerSelector,u=e.conversionSelector,f=e.displayAction,p=e.styleReplace,v=e.currency,y=e.backgroundColor,g=e.textColor,m=e.fontSize,h=e.fontWeight,b=e.borderColor,w=e.borderWidth,x=e.borderRadius,S=e.DEBUG_ALGO_MODE;console.log("cognitiveModule :","oldPriceSelector : ",t),console.log("cognitiveModule :","newPriceSelector : ",i),console.log("cognitiveModule :","discountContainerSelector : ",r);var E=function(e){for(var t=e.oldPriceSelector,n=e.newPriceSelector,i=e.discountContainerSelector,r=e.conversionSelector,o=e.displayAction,l=[],s=document.querySelectorAll(t),d=0;d<s.length;d++){var u=s.item(d);a(u)&&!u.dataset.abtastyDiscountHandled&&(console.log("cognitiveModule :","isElementInViewport : ",u),l.push(u))}var f=[n,i,r],p=[];return l.forEach(function(e){for(var t=function(e,t){for(var n=e,i=!1;!i&&n.parentElement;)(i=t.every(function(e){return n.querySelector(e)}))||(n=n.parentElement);return n}(e,f),a=[],l=t.querySelectorAll(n),s=0;s<l.length;s++){var d=l.item(s);null!==d.offsetParent&&a.push(d)}if(!(a.length>1||t.querySelector(".abtasty-price_tag"))){var u=t.querySelector(r),v=t.querySelector(i);if(!u.dataset.abtastyDiscount){"replace"===o&&(v.setAttribute("data-abtasty-old-visibility",v.style.visibility),v.style.visibility="hidden"),e.setAttribute("data-abtasty-discount-handled","1");var y=c(e.textContent),g=c(a[0].textContent);Number.isNaN(y)||Number.isNaN(g)||p.push({oldPrice:y,newPrice:g,discountContainerElem:v,conversionElem:u})}}}),p}({oldPriceSelector:t,newPriceSelector:i,discountContainerSelector:r,conversionSelector:u,displayAction:f});return console.log("cognitiveModule :","Products where apply script : ",E),document.querySelectorAll(u).forEach(function(e){e.removeEventListener("click",d),e.addEventListener("click",d)}),function(e,t,i){var r="undefined"!=typeof TEST_ID?TEST_ID:e;return 0===i.length?Promise.resolve([]):n(i,e,t,r)}(s,l,E).then(function(e){return function(e){var t=e.productsArray,n=e.displayAction,i=e.styleReplace,r=e.currency,a=e.style;t.forEach(function(e){if(e.selectedVa){var t=e.selectedVa.toString(),c=t.indexOf("%")>-1?"- "+t:"- "+(Math.round(100*t)/100).toFixed(2)+r;switch(e.conversionElem.setAttribute("data-abtasty-discount",e.oldPrice+"_"+e.newPrice),n){case"replace":if(i){var l=o({price:c,style:a});e.discountContainerElem.innerHTML=l}else e.discountContainerElem.textContent=c;break;case"append":var s=o({price:c,style:a});e.discountContainerElem.innerHTML+=s}void 0!==e.discountContainerElem.dataset.abtastyOldVisibility&&(e.discountContainerElem.style.visibility=e.discountContainerElem.dataset.abtastyOldVisibility||"inherit")}})}({productsArray:e,displayAction:f,styleReplace:p,currency:v,debugDisplay:S,style:{"background-color":y,color:g,"font-size":m+"px","font-weight":h,"border-color":b,"border-width":w+"px","border-radius":x+"px","border-style":"solid",display:"inline-block",padding:"5px"}})})};console.log("cognitiveModule :","File loaded"),function e(){console.log("cognitiveModule :","Datas : ",DATA),u(DATA).then(function(){window.setTimeout(function(){e()},100)})}()}(); | ||
!function(){"use strict";var e="https://turing-engine.appspot.com/api/v1",t=function(e){return Object.keys(e).map(function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])}).join("&")},n=function(n,i,r,o){var a=n.map(function(e){return Object.assign(e,{vas:(t=e,n=t.newPrice,i=t.oldPrice,[i-n,Math.round(100*(1-n/i))])});var t,n,i});return Promise.all(a.map(function(n){var a=n.vas,c=n.newPrice,l=n.oldPrice,s=n.discountContainerElem,d=n.conversionElem;return function(n){var i=n.cid,r=n.vas,o=n.vid,a=n.caid,c=n.c;return console.log("cognitiveModule :","Call Turing Engine : ",{cid:i,vas:r,vid:o,caid:a,c:c}),new Promise(function(n,l){return fetch(e+"/suggest?"+t({cid:i,vid:o,caid:a,c:c,vas:r}),{method:"GET"}).then(function(e){return n(e.json())})})}({cid:i,vid:r,vas:"perc,value",caid:o,c:l.toString().replace(".","d")+"_"+c.toString().replace(".","d")}).then(function(e){var t=e.va;return{vas:a,newPrice:c,oldPrice:l,va:t,selectedVa:"value"===t?a[0]:a[1]+"%",discountContainerElem:s,conversionElem:d}})}))},i=function(n,i,r){!function(n){var i=n.cid,r=n.vid,o=n.caid,a=n.c,c=n.a;fetch(e+"/convert?"+t({cid:i,vid:r,caid:o,c:a,a:c}),{method:"GET"})}({cid:n,vid:i,c:r,caid:"undefined"!=typeof TEST_ID?TEST_ID:n,a:0})};!function(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var i=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===n&&i.firstChild?i.insertBefore(r,i.firstChild):i.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}("abtasty-modal{display:none;z-index:1000000}abtasty-modal,abtasty-modal__underlay{position:fixed;top:0;left:0;width:100%;height:100%}abtasty-modal__underlay{background-color:rgba(0,0,0,.5);cursor:pointer}.abtasty-modal__area{top:0;left:0;right:0;width:auto;margin:10px!important;max-height:70%;z-index:100;position:relative;background-color:#fff;border:3px solid #fff;box-shadow:0 0 10px #666;-moz-box-shadow:#666 0 0 10px;-webkit-box-shadow:#666 0 0 10px;text-align:left}.abtasty-modal__close{float:right!important;font-size:44px;font-weight:300;background:transparent;border:0;color:#bbb;font-family:Helvetica Neue,Helvetica,Arial,sans-serif!important;line-height:32px!important;margin-right:5px;cursor:pointer}.abtasty-modal__text{padding:20px;font-family:Open Sans,sans-serif!important;color:#000}.abtasty-modal__title{text-align:left;width:auto;font-size:31px!important;font-weight:500;line-height:1.1;margin-bottom:10px}.abtasty-modal__text p{margin:0 0 10px!important;font-size:15px;font-weight:300}@media (min-width:630px){.abtasty-modal__area{width:600px;margin:150px auto!important}}");var r=function(e){var t=Object.prototype.hasOwnProperty;function n(e,i){return Array.isArray(e)?function(e,t){for(var i,r="",o="",c=Array.isArray(t),l=0;l<e.length;l++)(i=n(e[l]))&&(c&&t[l]&&(i=a(i)),r=r+o+i,o=" ");return r}(e,i):e&&"object"==typeof e?function(e){var n="",i="";for(var r in e)r&&e[r]&&t.call(e,r)&&(n=n+i+r,i=" ");return n}(e):e||""}function i(e){if(!e)return"";if("object"==typeof e){var n="";for(var i in e)t.call(e,i)&&(n=n+i+":"+e[i]+";");return n}return e+""}function r(e,t,n,i){if(!1===t||null==t||!t&&("class"===e||"style"===e))return"";if(!0===t)return" "+(i?e:e+'="'+e+'"');var r=typeof t;return"object"!==r&&"function"!==r||"function"!=typeof t.toJSON||(t=t.toJSON()),"string"==typeof t||(t=JSON.stringify(t),n||-1===t.indexOf('"'))?(n&&(t=a(t))," "+e+'="'+t+'"'):" "+e+"='"+t.replace(/'/g,"'")+"'"}e.merge=function e(t,n){if(1===arguments.length){for(var r=t[0],o=1;o<t.length;o++)r=e(r,t[o]);return r}for(var a in n)if("class"===a){var c=t[a]||[];t[a]=(Array.isArray(c)?c:[c]).concat(n[a]||[])}else if("style"===a){var c=i(t[a]);c=c&&";"!==c[c.length-1]?c+";":c;var l=i(n[a]);l=l&&";"!==l[l.length-1]?l+";":l,t[a]=c+l}else t[a]=n[a];return t},e.classes=n,e.style=i,e.attr=r,e.attrs=function(e,o){var a="";for(var c in e)if(t.call(e,c)){var l=e[c];if("class"===c){l=n(l),a=r(c,l,!1,o)+a;continue}"style"===c&&(l=i(l)),a+=r(c,l,!1,o)}return a};var o=/["&<>]/;function a(e){var t=""+e,n=o.exec(t);if(!n)return e;var i,r,a,c="";for(i=n.index,r=0;i<t.length;i++){switch(t.charCodeAt(i)){case 34:a=""";break;case 38:a="&";break;case 60:a="<";break;case 62:a=">";break;default:continue}r!==i&&(c+=t.substring(r,i)),r=i+1,c+=a}return r!==i?c+t.substring(r,i):c}return e.escape=a,e.rethrow=function e(t,n,i,r){if(!(t instanceof Error))throw t;if(!("undefined"==typeof window&&n||r))throw t.message+=" on line "+i,t;try{r=r||require("fs").readFileSync(n,"utf8")}catch(n){e(t,null,i)}var o=3,a=r.split("\n"),c=Math.max(i-o,0),l=Math.min(a.length,i+o);var o=a.slice(c,l).map(function(e,t){var n=t+c+1;return(n==i?" > ":" ")+n+"| "+e}).join("\n");t.path=n;t.message=(n||"Pug")+":"+i+"\n"+o+"\n\n"+t.message;throw t},e}({});function o(e){var t,n="";try{var i={},o=e||{};(function(e,i){n=(n=(n+="<div>")+'<div class="abtasty-price_tag"'+r.attr("style",r.style(i),!0,!0)+">")+r.escape(null==(t=e)?"":t)+"</div></div>"}).call(this,"price"in o?o.price:"undefined"!=typeof price?price:void 0,"style"in o?o.style:"undefined"!=typeof style?style:void 0)}catch(e){r.rethrow(e,void 0,void 0,i[void 0])}return n}var a=function(e){var t=window.document,n=e.getBoundingClientRect();return n.top>=0&&n.left>=0&&n.right<=(window.innerWidth||t.documentElement.clientWidth)&&n.bottom<=(window.innerHeight||t.documentElement.clientHeight)&&null!==e.offsetParent},c=function(e){var t=e.replace(/[^0-9,.€$£¥]+/g,"");return t=t.replace(/[€$£¥,]+/g,"."),parseFloat(t)},l=window.ABTasty&&window.ABTasty.visitor&&window.ABTasty.visitor.id||"noVisitorId",s=window.ABTasty&&window.ABTasty.accountSettings&&window.ABTasty.accountSettings.identifier||"noIdentifier",d=function(e){var t=e.target.dataset.abtastyDiscount||"";t&&i(s,l,t.indexOf("%")>-1?"perc":"value")},u=function(e){var t=e.oldPriceSelector,i=e.newPriceSelector,r=e.discountContainerSelector,u=e.conversionSelector,f=e.displayAction,p=e.styleReplace,v=e.currency,y=e.backgroundColor,g=e.textColor,m=e.fontSize,h=e.fontWeight,b=e.borderColor,w=e.borderWidth,x=e.borderRadius,S=e.DEBUG_ALGO_MODE;console.log("cognitiveModule :","oldPriceSelector : ",t),console.log("cognitiveModule :","newPriceSelector : ",i),console.log("cognitiveModule :","discountContainerSelector : ",r);var E=function(e){for(var t=e.oldPriceSelector,n=e.newPriceSelector,i=e.discountContainerSelector,r=e.conversionSelector,o=e.displayAction,l=[],s=document.querySelectorAll(t),d=0;d<s.length;d++){var u=s.item(d);a(u)&&!u.dataset.abtastyDiscountHandled&&(console.log("cognitiveModule :","isElementInViewport : ",u),l.push(u))}var f=[n,i,r],p=[];return l.forEach(function(e){for(var t=function(e,t){for(var n=e,i=!1;!i&&n.parentElement;)(i=t.every(function(e){return n.querySelector(e)}))||(n=n.parentElement);return n}(e,f),a=[],l=t.querySelectorAll(n),s=0;s<l.length;s++){var d=l.item(s);null!==d.offsetParent&&a.push(d)}if(!(a.length>1||t.querySelector(".abtasty-price_tag"))){var u=t.querySelector(r),v=t.querySelector(i);if(!u.dataset.abtastyDiscount){"replace"===o&&(v.setAttribute("data-abtasty-old-visibility",v.style.visibility),v.style.visibility="hidden"),e.setAttribute("data-abtasty-discount-handled","1");var y=c(e.textContent),g=c(a[0].textContent);Number.isNaN(y)||Number.isNaN(g)||p.push({oldPrice:y,newPrice:g,discountContainerElem:v,conversionElem:u})}}}),p}({oldPriceSelector:t,newPriceSelector:i,discountContainerSelector:r,conversionSelector:u,displayAction:f});return console.log("cognitiveModule :","Products where apply script : ",E),document.querySelectorAll(u).forEach(function(e){e.removeEventListener("click",d),e.addEventListener("click",d)}),function(e,t,i){var r="undefined"!=typeof TEST_ID?TEST_ID:e;return 0===i.length?Promise.resolve([]):n(i,e,t,r)}(s,l,E).then(function(e){return function(e){var t=e.productsArray,n=e.displayAction,i=e.styleReplace,r=e.currency,a=e.style;t.forEach(function(e){if(e.selectedVa){var t=e.selectedVa.toString(),c=t.indexOf("%")>-1?"- "+t:"- "+(Math.round(100*t)/100).toFixed(2)+r;switch(e.conversionElem.setAttribute("data-abtasty-discount",e.oldPrice+"_"+e.newPrice),n){case"replace":if(i){var l=o({price:c,style:a});e.discountContainerElem.innerHTML=l}else e.discountContainerElem.textContent=c;break;case"append":var s=o({price:c,style:a});e.discountContainerElem.innerHTML+=s}void 0!==e.discountContainerElem.dataset.abtastyOldVisibility&&(e.discountContainerElem.style.visibility=e.discountContainerElem.dataset.abtastyOldVisibility||"inherit")}})}({productsArray:e,displayAction:f,styleReplace:p,currency:v,debugDisplay:S,style:{"background-color":y,color:g,"font-size":m+"px","font-weight":h,"border-color":b,"border-width":w+"px","border-radius":x+"px","border-style":"solid",display:"inline-block",padding:"5px"}})})};console.log("cognitiveModule :","File loaded"),function e(){console.log("cognitiveModule :","Datas : ",DATA),u(DATA).then(function(){window.setTimeout(function(){e()},100)})}()}(); |
{ | ||
"name": "@abtasty/cognitivediscountmaker", | ||
"description": "A simple widget", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"main": "dist/main.js", | ||
@@ -6,0 +6,0 @@ "form": "dist/form.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14935