admin-dashboard.js
7 months ago
admin-post.js
7 months ago
admin-quick-edit.js
7 months ago
admin-settings.js
7 months ago
admin-widgets.js
7 months ago
block-editor.min.js
7 months ago
column-modal.js
7 months ago
counter.js
7 months ago
counter.min.js
7 months ago
dummy.js
7 months ago
frontend.js
7 months ago
frontend.min.js
7 months ago
frontend.min.js
1 lines
| 1 | var initPostViewsCounter=function(){(PostViewsCounter={promise:null,args:{},init:function(e){this.args=e;var t={};t.storage_type="cookies",t.storage_data=this.readCookieData("pvc_visits"+(!1!==e.multisite?"_"+parseInt(e.multisite):"")),"rest_api"===e.mode?this.promise=this.request(e.requestURL,t,"POST",{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8","X-WP-Nonce":e.nonce}):(t.action="pvc-check-post",t.pvc_nonce=e.nonce,t.id=e.postID,this.promise=this.request(e.requestURL,t,"POST",{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"}))},request:function(e,t,o,i){var n={method:o,mode:"cors",cache:"no-cache",credentials:"same-origin",headers:i,body:this.prepareRequestData(t)},a=this;return fetch(e,n).then(function(e){if(!e.ok)throw Error(e.statusText);return e.json()}).then(function(e){try{"object"==typeof e&&null!==e?"success"in e&&!1===e.success?(console.log("PVC: Request error."),console.log(e.data)):(a.saveCookieData(e.storage),a.triggerEvent("pvcCheckPost",e)):(console.log("PVC: Invalid object."),console.log(e))}catch(t){console.log("PVC: Invalid JSON data."),console.log(t)}}).catch(function(e){console.log("PVC: Invalid response."),console.log(e)})},prepareRequestData:function(e){return Object.keys(e).map(function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])}).join("&").replace(/%20/g,"+")},triggerEvent:function(e,t){var o=new CustomEvent(e,{bubbles:!0,detail:t});document.dispatchEvent(o)},saveCookieData:function(e){if(e.hasOwnProperty("name")){var t="";"https:"===document.location.protocol&&(t=";secure");for(var o=0;o<e.name.length;o++){var i=new Date,n=parseInt(e.expiry[o]);n?n*=1e3:n=i.getTime()+864e5,i.setTime(n),document.cookie=e.name[o]+"="+e.value[o]+";expires="+i.toUTCString()+";path=/"+("/"===this.args.path?"":this.args.path)+";domain="+this.args.domain+t+";SameSite=Lax"}}},readCookieData:function(e){var t=[];return document.cookie.split(";").forEach(function(o){var i=o.split("="),n=i[0],a=i[1],r=n.trim();RegExp(e+"\\[\\d+\\]").test(r)&&t.push(a)}),t.join("a")}}).init(pvcArgsFrontend)};document.addEventListener("DOMContentLoaded",initPostViewsCounter); |