Commit 9c3c22bf authored by Van's avatar Van

uvstat

parent 640582a9
......@@ -17,8 +17,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
<#--<script src="https://cdn.jsdelivr.net/npm/uvstat@v1.0.2/dist/index.min.js"></script>-->
<script src="/js/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/uvstat@v1.0.3/dist/index.min.js"></script>
<script>
var Label = {
servePath: "${servePath}",
......
/*!
* uvstat v1.0.2 - Statistics tool for static page.
*
* MIT License
*
* Copyright (c) 2019-present B3log 开源, b3log.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Uvstat=e():t.Uvstat=e()}(window,(function(){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(o,r,function(e){return t[e]}.bind(null,r));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";n.r(e);var o=function(t,e,n){return new Promise((function(o,r){fetch(t,{body:JSON.stringify(e),cache:"no-cache",method:"POST"}).then((function(t){return t.json()})).then((function(t){return o(t)})),n&&setTimeout((function(){r(e)}),n)}))},r=function(t,e,n,o){return new(n||(n=Promise))((function(r,i){function a(t){try{u(o.next(t))}catch(t){i(t)}}function c(t){try{u(o.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,c)}u((o=o.apply(t,e||[])).next())}))},i=function(t,e){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(r=(r=a.trys).length>0&&r[r.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},a=function(){function t(t){this.options=function(t){var e={cache:!0,cacheId:"uvstat",loading:'<svg version="1.1" style="vertical-align: bottom;" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 100 100" enable-background="new 0 0 0 0" xml:space="preserve">\n<circle fill="#3b3e43" stroke="none" cx="6" cy="50" r="6">\n<animate attributeName="opacity" dur="1s" values="0;1;0" repeatCount="indefinite" begin="0.1"></animate>\n</circle>\n<circle fill="#3b3e43" stroke="none" cx="26" cy="50" r="6">\n<animate attributeName="opacity" dur="1s" values="0;1;0" repeatCount="indefinite" begin="0.2"></animate>\n</circle>\n<circle fill="#3b3e43" stroke="none" cx="46" cy="50" r="6">\n<animate attributeName="opacity" dur="1s" values="0;1;0" repeatCount="indefinite" begin="0.3"></animate>\n</circle>\n</svg>',location:{hash:!1,pathname:!0,search:!1},renderName:"uvstaturl",timeout:2e3,url:"https://hacpai.com/uvstat"};return t&&t.location&&(t.location=Object.assign({},e.location,t.location)),Object.assign({},e,t)}(t)}return t.prototype.getStat=function(t,e){return void 0===e&&(e=0),r(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,o(this.options.url+"/get",{data:t},e)];case 1:return[2,n.sent().data]}}))}))},t.prototype.renderStat=function(){return r(this,void 0,void 0,(function(){var t,e,n=this;return i(this,(function(o){switch(o.label){case 0:if(t=[],document.querySelectorAll("[data-"+this.options.renderName+"]").forEach((function(e){t.push({count:parseInt(e.textContent.trim(),10)||0,url:e.getAttribute("data-"+n.options.renderName).toLowerCase()});var o=e.getBoundingClientRect().height;e.innerHTML=n.options.loading,e.firstElementChild.style.height=o+"px",e.firstElementChild.style.width=o+"px"})),0===t.length)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.getStat(t,this.options.timeout)];case 2:return e=o.sent(),Object.keys(e).forEach((function(t){var o=document.querySelector("[data-"+n.options.renderName+'="'+t+'" i]');o&&(o.innerText=e[t].toString())})),[3,4];case 3:return o.sent(),t.forEach((function(t){var e=document.querySelector("[data-"+n.options.renderName+'="'+t+'" i]');e&&(e.innerText="0")})),[3,4];case 4:return[2]}}))}))},t.prototype.addStat=function(){var t=location.origin;if(this.options.location.pathname&&(t+=location.pathname),this.options.location.search&&(t+=location.search),this.options.location.hash&&(t+=location.hash),t=t.toLowerCase(),this.options.cache){var e=JSON.parse(localStorage.getItem(this.options.cacheId)||"[]");if(e.includes(t))return;e.push(t),localStorage.setItem(this.options.cacheId,JSON.stringify(e)),o(this.options.url+"/inc?url="+t)}else o(this.options.url+"/inc?url="+t)},t.prototype.clearCache=function(){localStorage.removeItem(this.options.cacheId)},t}();e.default=a}]).default}));
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment