admin-dashboard.js
5 months ago
admin-post.js
5 months ago
admin-quick-edit.js
5 months ago
admin-settings.js
5 months ago
admin-widgets.js
5 months ago
block-editor.js
5 months ago
column-modal.js
5 months ago
counter.js
5 months ago
dummy.js
5 months ago
frontend.js
5 months ago
integration-gutenberg.js
5 months ago
frontend.js
2 lines
| 1 | !function($,t,e){function o(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var o=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=o){var n,r,a,c,i=[],s=!0,u=!1;try{if(a=(o=o.call(t)).next,0===e);else for(;!(s=(n=a.call(o)).done)&&(i.push(n.value),i.length!==e);s=!0);}catch(t){u=!0,r=t}finally{try{if(!s&&null!=o.return&&(c=o.return(),Object(c)!==c))return}finally{if(u)throw r}}return i}}(t,e)||function(t,e){if(t){if("string"==typeof t)return n(t,e);var o={}.toString.call(t).slice(8,-1);return"Object"===o&&t.constructor&&(o=t.constructor.name),"Map"===o||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?n(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var o=0,n=Array(e);o<e;o++)n[o]=t[o];return n}function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}t.PostViewsCounter={promise:null,args:{},init:function(t){this.args=t;var e={storage_type:"cookies",storage_data:this.readCookieData("pvc_visits".concat(!1!==t.multisite?"_".concat(parseInt(t.multisite,10)):""))};"rest_api"===t.mode?this.promise=this.request(t.requestURL,e,"POST",{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8","X-WP-Nonce":t.nonce}):(e.action="pvc-check-post",e.pvc_nonce=t.nonce,e.id=t.postID,this.promise=this.request(t.requestURL,e,"POST",{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"}))},request:function(t,e,o,n){var a=this,c={method:o,mode:"cors",cache:"no-cache",credentials:"same-origin",headers:n,body:this.prepareRequestData(e)};return fetch(t,c).then(function(t){if(!t.ok)throw Error(t.statusText);return t.json()}).then(function(t){try{"object"===r(t)&&null!==t?"success"in t&&!1===t.success?(console.log("PVC: Request error."),console.log(t.data)):(a.saveCookieData(t.storage),a.triggerEvent("pvcCheckPost",t)):(console.log("PVC: Invalid object."),console.log(t))}catch(e){console.log("PVC: Invalid JSON data."),console.log(e)}}).catch(function(t){console.log("PVC: Invalid response."),console.log(t)})},prepareRequestData:function(t){return Object.keys(t).map(function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(t[e]))}).join("&").replace(/%20/g,"+")},triggerEvent:function(t,o){var n=new CustomEvent(t,{bubbles:!0,detail:o});e.dispatchEvent(n)},saveCookieData:function(t){if(t&&Object.prototype.hasOwnProperty.call(t,"name")){var o="";"https:"===e.location.protocol&&(o=";secure");for(var n=0;n<t.name.length;n++){var r=new Date,a=parseInt(t.expiry[n],10);a?a*=1e3:a=r.getTime()+864e5,r.setTime(a),e.cookie="".concat(t.name[n],"=").concat(t.value[n],";expires=").concat(r.toUTCString(),";path=/").concat("/"===this.args.path?"":this.args.path,";domain=").concat(this.args.domain).concat(o,";SameSite=Lax")}}},readCookieData:function(t){var n=[];return e.cookie.split(";").forEach(function(e){var r=o(e.split("="),2),a=r[0],c=r[1],i=a.trim();new RegExp("".concat(t,"\\[\\d+\\]")).test(i)&&n.push(c)}),n.join("a")}};var a=function(){return t.PostViewsCounter.init(pvcArgsFrontend)};"loading"===e.readyState?e.addEventListener("DOMContentLoaded",a):a()}(jQuery,window,document); |
| 2 |