@yued/activities
Advanced tools
Comparing version 1.5.0 to 1.6.0
@@ -1,1 +0,1 @@ | ||
"use strict";function mitt(t){return t=t||Object.create(null),{on:function(e,n){(t[e]||(t[e]=[])).push(n)},off:function(e,n){t[e]&&t[e].splice(t[e].indexOf(n)>>>0,1)},emit:function(e,n){(t[e]||[]).slice().map(function(t){t(n)}),(t["*"]||[]).slice().map(function(t){t(e,n)})}}}Object.defineProperty(exports,"__esModule",{value:!0});var commonjsGlobal="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function commonjsRequire(){throw new Error("Dynamic requires are not currently supported by rollup-plugin-commonjs")}function createCommonjsModule(t,e){return t(e={exports:{}},e.exports),e.exports}var es6Promise=createCommonjsModule(function(t,e){t.exports=function(){function t(t){return"function"==typeof t}var e=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},n=0,r=void 0,i=void 0,o=function(t,e){f[n]=t,f[n+1]=e,2===(n+=2)&&(i?i(d):b())},s="undefined"!=typeof window?window:void 0,a=s||{},c=a.MutationObserver||a.WebKitMutationObserver,u="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),l="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function p(){var t=setTimeout;return function(){return t(d,1)}}var f=new Array(1e3);function d(){for(var t=0;t<n;t+=2){var e=f[t],r=f[t+1];e(r),f[t]=void 0,f[t+1]=void 0}n=0}var v,h,m,y,b=void 0;function w(t,e){var n=this,r=new this.constructor(A);void 0===r[_]&&P(r);var i=n._state;if(i){var s=arguments[i-1];o(function(){return U(i,r,s,n._result)})}else M(n,r,t,e);return r}function g(t){if(t&&"object"==typeof t&&t.constructor===this)return t;var e=new this(A);return x(e,t),e}u?b=function(){return process.nextTick(d)}:c?(h=0,m=new c(d),y=document.createTextNode(""),m.observe(y,{characterData:!0}),b=function(){y.data=h=++h%2}):l?((v=new MessageChannel).port1.onmessage=d,b=function(){return v.port2.postMessage(0)}):b=void 0===s&&"function"==typeof commonjsRequire?function(){try{var t=Function("return this")().require("vertx");return void 0!==(r=t.runOnLoop||t.runOnContext)?function(){r(d)}:p()}catch(t){return p()}}():p();var _=Math.random().toString(36).substring(2);function A(){}var D=void 0,E=1,S=2,O={error:null};function j(t){try{return t.then}catch(t){return O.error=t,O}}function T(e,n,r){n.constructor===e.constructor&&r===w&&n.constructor.resolve===g?function(t,e){e._state===E?k(t,e._result):e._state===S?C(t,e._result):M(e,void 0,function(e){return x(t,e)},function(e){return C(t,e)})}(e,n):r===O?(C(e,O.error),O.error=null):void 0===r?k(e,n):t(r)?function(t,e,n){o(function(t){var r=!1,i=function(t,e,n,r){try{t.call(e,n,r)}catch(t){return t}}(n,e,function(n){r||(r=!0,e!==n?x(t,n):k(t,n))},function(e){r||(r=!0,C(t,e))},t._label);!r&&i&&(r=!0,C(t,i))},t)}(e,n,r):k(e,n)}function x(t,e){var n,r;t===e?C(t,new TypeError("You cannot resolve a promise with itself")):(r=typeof(n=e),null===n||"object"!==r&&"function"!==r?k(t,e):T(t,e,j(e)))}function R(t){t._onerror&&t._onerror(t._result),I(t)}function k(t,e){t._state===D&&(t._result=e,t._state=E,0!==t._subscribers.length&&o(I,t))}function C(t,e){t._state===D&&(t._state=S,t._result=e,o(R,t))}function M(t,e,n,r){var i=t._subscribers,s=i.length;t._onerror=null,i[s]=e,i[s+E]=n,i[s+S]=r,0===s&&t._state&&o(I,t)}function I(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var r=void 0,i=void 0,o=t._result,s=0;s<e.length;s+=3)r=e[s],i=e[s+n],r?U(n,r,i,o):i(o);t._subscribers.length=0}}function U(e,n,r,i){var o=t(r),s=void 0,a=void 0,c=void 0,u=void 0;if(o){if((s=function(t,e){try{return t(e)}catch(t){return O.error=t,O}}(r,i))===O?(u=!0,a=s.error,s.error=null):c=!0,n===s)return void C(n,new TypeError("A promises callback cannot return that same promise."))}else s=i,c=!0;n._state!==D||(o&&c?x(n,s):u?C(n,a):e===E?k(n,s):e===S&&C(n,s))}var G=0;function P(t){t[_]=G++,t._state=void 0,t._result=void 0,t._subscribers=[]}var Z=function(){function t(t,n){this._instanceConstructor=t,this.promise=new t(A),this.promise[_]||P(this.promise),e(n)?(this.length=n.length,this._remaining=n.length,this._result=new Array(this.length),0===this.length?k(this.promise,this._result):(this.length=this.length||0,this._enumerate(n),0===this._remaining&&k(this.promise,this._result))):C(this.promise,new Error("Array Methods must be provided an Array"))}return t.prototype._enumerate=function(t){for(var e=0;this._state===D&&e<t.length;e++)this._eachEntry(t[e],e)},t.prototype._eachEntry=function(t,e){var n=this._instanceConstructor,r=n.resolve;if(r===g){var i=j(t);if(i===w&&t._state!==D)this._settledAt(t._state,e,t._result);else if("function"!=typeof i)this._remaining--,this._result[e]=t;else if(n===B){var o=new n(A);T(o,t,i),this._willSettleAt(o,e)}else this._willSettleAt(new n(function(e){return e(t)}),e)}else this._willSettleAt(r(t),e)},t.prototype._settledAt=function(t,e,n){var r=this.promise;r._state===D&&(this._remaining--,t===S?C(r,n):this._result[e]=n),0===this._remaining&&k(r,this._result)},t.prototype._willSettleAt=function(t,e){var n=this;M(t,void 0,function(t){return n._settledAt(E,e,t)},function(t){return n._settledAt(S,e,t)})},t}(),B=function(){function t(e){this[_]=G++,this._result=this._state=void 0,this._subscribers=[],A!==e&&("function"!=typeof e&&function(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}(),this instanceof t?function(t,e){try{e(function(e){x(t,e)},function(e){C(t,e)})}catch(e){C(t,e)}}(this,e):function(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}())}return t.prototype.catch=function(t){return this.then(null,t)},t.prototype.finally=function(t){var e=this.constructor;return this.then(function(n){return e.resolve(t()).then(function(){return n})},function(n){return e.resolve(t()).then(function(){throw n})})},t}();return B.prototype.then=w,B.all=function(t){return new Z(this,t).promise},B.race=function(t){var n=this;return e(t)?new n(function(e,r){for(var i=t.length,o=0;o<i;o++)n.resolve(t[o]).then(e,r)}):new n(function(t,e){return e(new TypeError("You must pass an array to race."))})},B.resolve=g,B.reject=function(t){var e=new this(A);return C(e,t),e},B._setScheduler=function(t){i=t},B._setAsap=function(t){o=t},B._asap=o,B.polyfill=function(){var t=void 0;if(void 0!==commonjsGlobal)t=commonjsGlobal;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(t){throw new Error("polyfill failed because global object is unavailable in this environment")}var e=t.Promise;if(e){var n=null;try{n=Object.prototype.toString.call(e.resolve())}catch(t){}if("[object Promise]"===n&&!e.cast)return}t.Promise=B},B.Promise=B,B}()});const Promise$1=es6Promise.Promise;function getSrvTime(t,e){var n;try{n=new XMLHttpRequest}catch(t){try{n=new ActiveXObject("Msxml2.XMLHTTP")}catch(t){try{n=new ActiveXObject("Microsoft.XMLHTTP")}catch(t){return console.error("AJAX not supported"),void(e&&e())}}}n.onreadystatechange=function(){if(n.readyState===XMLHttpRequest.DONE)if(200===n.status)try{var r=JSON.parse(n.responseText);t&&t(r.data)}catch(t){console.error("parse json error"),e&&e()}else console.error("There was a problem with the request."),e&&e()},n.open("GET","https://app.myscrm.cn/njs/time",!0),n.send()}let serverLocalTimeDiff;function getServerTime(){return new Promise$1((t,e)=>{window.GET_SERVER_TIME?t(window.GET_SERVER_TIME()):void 0===serverLocalTimeDiff?getSrvTime(function(e){serverLocalTimeDiff=e-Date.now(),t(Date.now()+serverLocalTimeDiff)},function(){serverLocalTimeDiff=0,console.error("get time fail, using local time"),t(Date.now())}):t(Date.now()+serverLocalTimeDiff)})}function styleInject(t,e){void 0===e&&(e={});var n=e.insertAt;if(t&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===n&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t))}}var css='.active_pop_mask {\n position: fixed;\n top: 0;\n bottom: 0;\n width: 100%;\n z-index: 100000000;\n background-color: rgba(34, 34, 34, 0.8);\n -webkit-box-shadow: 0px 1px 0.2rem rgba(0, 0, 0, 0.6);\n line-height: 0.36rem;\n}\n.active_pop_1ad1 {\n position: fixed;\n z-index: 100000001;\n top: 0;\n bottom: 0;\n width: 100%;\n height: 100%;\n}\n.active_pop_1ad1 .content {\n position: absolute;\n -ms-transform: translate(0, -50%);\n transform: translate(0, -50%);\n -webkit-transform: translate(0, -50%);\n top: 50%;\n left: 5%;\n right: 5%;\n margin-top: -50px;\n}\n.active_pop_1ad1 .content-inner > * {\n max-width: 100%;\n}\n.active_pop_1ad1 * {\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n position: relative;\n z-index: 100;\n}\n.active_pop_1ad1 .active_pop_close_btn {\n position: absolute;\n bottom: -100px;\n transform: translateX(-50%);\n left: 50%;\n width: 56px;\n height: 56px;\n z-index: 1;\n background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAA4CAYAAACohjseAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMDY3IDc5LjE1Nzc0NywgMjAxNS8wMy8zMC0yMzo0MDo0MiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnM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CYII=) no-repeat;\n}\n.active_pop_1ad1 .active_pop_close_btn::before {\n content: "";\n display: block;\n width: 1px;\n height: 100px;\n background: #ddd;\n position: absolute;\n bottom: 100%;\n left: 50%;\n}';styleInject(css);var classCallCheck=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},createClass=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),get=function t(e,n,r){null===e&&(e=Function.prototype);var i=Object.getOwnPropertyDescriptor(e,n);if(void 0===i){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,n,r)}if("value"in i)return i.value;var s=i.get;return void 0!==s?s.call(r):void 0},inherits=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},possibleConstructorReturn=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},slicedToArray=function(){return function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var s,a=t[Symbol.iterator]();!(r=(s=a.next()).done)&&(n.push(s.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{!r&&a.return&&a.return()}finally{if(i)throw o}}return n}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),set$1=function(t){var e=t.key,n=t.value,r=t.expires;return window.localStorage.setItem(e,JSON.stringify({value:n,expires:r}))},get$1=function(t,e){var n=JSON.parse(window.localStorage.getItem(t));if(n){var r=n.value,i=n.expires;return i&&new Date(i)<e?(window.localStorage.removeItem(t),null):r}return null},getDaysDiffBetweenDates=function(t){return function(e){return(e-t)/864e5}},paddingLeft=function(t,e,n){var r=e-t.length;if(r<=0)return t;for(var i="",o=0;o<r;o++)i+=n;return i+t},Active=function(){function t(e){var n=this;classCallCheck(this,t),this.opts=e,this.emitter=mitt(),this.emitTo=function(t){return function(e){return n.emitter(t,e)}},this.on=this.emitter.on,this.off=this.emitter.off,this.emit=this.emitter.emit}return createClass(t,[{key:"serialization",value:function(){var t=this.opts,e=t.title,n=t.id,r=t.end_date;return set$1({key:""+e+n,value:t,expires:r})}},{key:"isActive",value:function(){var t=this.opts;return!t.end_date||new Date(t.end_date)>=new Date}}]),t}(),PopupActive=function(t){function e(t,n){classCallCheck(this,e);var r=possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return r.meta=n,r.activeURL=t.activeURL,r.popupDom=r.makePopupDom(t),r.popupDom.querySelector(".active_pop_close.active_pop_close_btn").addEventListener("click",function(t){r.popupDom.remove(),r.emit("popClose",t)}),r.popupDom.querySelector(".content-inner").addEventListener("click",function(e){var n=t.urls,i=(n.length,n[Math.floor(Math.random()*n.length)]);window.location=i,r.emit("content-inner",e)}),r}return inherits(e,Active),createClass(e,[{key:"init",value:function(){(this.meta.dom||document.body).appendChild(this.popupDom)}},{key:"inRange",value:function(){var t=this.opts,e=t.start_date,n=t.end_date,r=t.time_start,i=t.time_end,o=(t.serverTime,new Date(t.serverTime));if(e&&o<e)return!1;if(n&&o>n)return!1;var s=paddingLeft(o.getHours(),2,"0")+":"+paddingLeft(o.getMinutes(),2,"0")+":"+paddingLeft(o.getSeconds(),2,"0");return!(r&&s<r)&&!(i&&s>i)}},{key:"isActive",value:function(){var t=this.opts;if(!get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"isActive",this).call(this))return!1;if(!this.inRange())return!1;if("1"===t.is_first_show){t.meta=t.meta||{},t.meta.visitCb=t.meta.visitCb||[];var n=new Date(t.serverTime),r=getDaysDiffBetweenDates(n);return t.meta.visitCb.every(function(t){return r(new Date(t.time))<-1})}return!0}},{key:"makePopupDom",value:function(t){var e=t.imageUrl,n='<div class="active_pop_1ad1_wrapper">\n <div class="active_pop_mask"></div>\n <div class="active_pop_1ad1">\n <div class="content">\n <div class="content-inner" style="max-height: '+(window.innerHeight-40)+'px;">\n <div style="text-align: center">\n <img style="max-height: 100%;max-width: 100%;" src="'+e+'">\n </div>\n </div>\n <div class="active_pop_close active_pop_close_btn" />\n </div>\n </div>\n </div>',r=document.createElement("div");return r.innerHTML=n,r}},{key:"updateStatus",value:function(t){var e=this.opts;e.meta=e.meta||{},e.meta.visitCb=e.meta.visitCb||[],e.meta.visitCb.push({type:t,time:new Date(e.serverTime)}),this.serialization()}}]),e}(),Manager=function(){function t(e){classCallCheck(this,t),this.opts=e||{}}return createClass(t,[{key:"setActiveOrigin",value:function(t){var e=this;return Promise.all([getServerTime(),t]).then(function(t){var e=slicedToArray(t,2),n=e[0],r=e[1].data,i=r.id,o=r.title,s=r.end_date,a=r.start_date,c=r.date_modified,u=r.time_end,l=r.time_start,p=r.urls,f=r.image.data.url,d=r.is_first_show;s=s&&new Date(s),a=a&&new Date(a);var v,h={id:i,date_modified:c,urls:p.data.map(function(t){return t.text}),title:o,serverTime:n,end_date:s,start_date:a,time_end:u,time_start:l,imageUrl:f,is_first_show:d},m=""+o+i,y=get$1(m,n);return y&&new Date(y.date_modified)>=new Date(h.date_modified)?((v=y).start_date=v.start_date&&new Date(v.start_date),v.end_date=v.end_date&&new Date(v.end_date),v):(set$1({key:m,value:h,expires:s}),h)}).then(function(t){var n=new PopupActive(t,{meta:e.opts.dom});n.isActive()&&(n.on("popClose",function(t){return n.updateStatus("popClose")}),n.init(),e.active=n)})}}]),t}();exports.PopupActive=PopupActive,exports.Manager=Manager; | ||
"use strict";function mitt(t){return t=t||Object.create(null),{on:function(e,n){(t[e]||(t[e]=[])).push(n)},off:function(e,n){t[e]&&t[e].splice(t[e].indexOf(n)>>>0,1)},emit:function(e,n){(t[e]||[]).slice().map(function(t){t(n)}),(t["*"]||[]).slice().map(function(t){t(e,n)})}}}Object.defineProperty(exports,"__esModule",{value:!0});var commonjsGlobal="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function commonjsRequire(){throw new Error("Dynamic requires are not currently supported by rollup-plugin-commonjs")}function createCommonjsModule(t,e){return t(e={exports:{}},e.exports),e.exports}var es6Promise=createCommonjsModule(function(t,e){t.exports=function(){function t(t){return"function"==typeof t}var e=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},n=0,r=void 0,i=void 0,o=function(t,e){f[n]=t,f[n+1]=e,2===(n+=2)&&(i?i(d):b())},s="undefined"!=typeof window?window:void 0,a=s||{},c=a.MutationObserver||a.WebKitMutationObserver,u="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),l="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function p(){var t=setTimeout;return function(){return t(d,1)}}var f=new Array(1e3);function d(){for(var t=0;t<n;t+=2){var e=f[t],r=f[t+1];e(r),f[t]=void 0,f[t+1]=void 0}n=0}var v,h,m,y,b=void 0;function w(t,e){var n=this,r=new this.constructor(A);void 0===r[_]&&P(r);var i=n._state;if(i){var s=arguments[i-1];o(function(){return U(i,r,s,n._result)})}else M(n,r,t,e);return r}function g(t){if(t&&"object"==typeof t&&t.constructor===this)return t;var e=new this(A);return x(e,t),e}u?b=function(){return process.nextTick(d)}:c?(h=0,m=new c(d),y=document.createTextNode(""),m.observe(y,{characterData:!0}),b=function(){y.data=h=++h%2}):l?((v=new MessageChannel).port1.onmessage=d,b=function(){return v.port2.postMessage(0)}):b=void 0===s&&"function"==typeof commonjsRequire?function(){try{var t=Function("return this")().require("vertx");return void 0!==(r=t.runOnLoop||t.runOnContext)?function(){r(d)}:p()}catch(t){return p()}}():p();var _=Math.random().toString(36).substring(2);function A(){}var D=void 0,E=1,S=2,O={error:null};function j(t){try{return t.then}catch(t){return O.error=t,O}}function T(e,n,r){n.constructor===e.constructor&&r===w&&n.constructor.resolve===g?function(t,e){e._state===E?R(t,e._result):e._state===S?C(t,e._result):M(e,void 0,function(e){return x(t,e)},function(e){return C(t,e)})}(e,n):r===O?(C(e,O.error),O.error=null):void 0===r?R(e,n):t(r)?function(t,e,n){o(function(t){var r=!1,i=function(t,e,n,r){try{t.call(e,n,r)}catch(t){return t}}(n,e,function(n){r||(r=!0,e!==n?x(t,n):R(t,n))},function(e){r||(r=!0,C(t,e))},t._label);!r&&i&&(r=!0,C(t,i))},t)}(e,n,r):R(e,n)}function x(t,e){var n,r;t===e?C(t,new TypeError("You cannot resolve a promise with itself")):(r=typeof(n=e),null===n||"object"!==r&&"function"!==r?R(t,e):T(t,e,j(e)))}function k(t){t._onerror&&t._onerror(t._result),I(t)}function R(t,e){t._state===D&&(t._result=e,t._state=E,0!==t._subscribers.length&&o(I,t))}function C(t,e){t._state===D&&(t._state=S,t._result=e,o(k,t))}function M(t,e,n,r){var i=t._subscribers,s=i.length;t._onerror=null,i[s]=e,i[s+E]=n,i[s+S]=r,0===s&&t._state&&o(I,t)}function I(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var r=void 0,i=void 0,o=t._result,s=0;s<e.length;s+=3)r=e[s],i=e[s+n],r?U(n,r,i,o):i(o);t._subscribers.length=0}}function U(e,n,r,i){var o=t(r),s=void 0,a=void 0,c=void 0,u=void 0;if(o){if((s=function(t,e){try{return t(e)}catch(t){return O.error=t,O}}(r,i))===O?(u=!0,a=s.error,s.error=null):c=!0,n===s)return void C(n,new TypeError("A promises callback cannot return that same promise."))}else s=i,c=!0;n._state!==D||(o&&c?x(n,s):u?C(n,a):e===E?R(n,s):e===S&&C(n,s))}var G=0;function P(t){t[_]=G++,t._state=void 0,t._result=void 0,t._subscribers=[]}var Z=function(){function t(t,n){this._instanceConstructor=t,this.promise=new t(A),this.promise[_]||P(this.promise),e(n)?(this.length=n.length,this._remaining=n.length,this._result=new Array(this.length),0===this.length?R(this.promise,this._result):(this.length=this.length||0,this._enumerate(n),0===this._remaining&&R(this.promise,this._result))):C(this.promise,new Error("Array Methods must be provided an Array"))}return t.prototype._enumerate=function(t){for(var e=0;this._state===D&&e<t.length;e++)this._eachEntry(t[e],e)},t.prototype._eachEntry=function(t,e){var n=this._instanceConstructor,r=n.resolve;if(r===g){var i=j(t);if(i===w&&t._state!==D)this._settledAt(t._state,e,t._result);else if("function"!=typeof i)this._remaining--,this._result[e]=t;else if(n===B){var o=new n(A);T(o,t,i),this._willSettleAt(o,e)}else this._willSettleAt(new n(function(e){return e(t)}),e)}else this._willSettleAt(r(t),e)},t.prototype._settledAt=function(t,e,n){var r=this.promise;r._state===D&&(this._remaining--,t===S?C(r,n):this._result[e]=n),0===this._remaining&&R(r,this._result)},t.prototype._willSettleAt=function(t,e){var n=this;M(t,void 0,function(t){return n._settledAt(E,e,t)},function(t){return n._settledAt(S,e,t)})},t}(),B=function(){function t(e){this[_]=G++,this._result=this._state=void 0,this._subscribers=[],A!==e&&("function"!=typeof e&&function(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}(),this instanceof t?function(t,e){try{e(function(e){x(t,e)},function(e){C(t,e)})}catch(e){C(t,e)}}(this,e):function(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}())}return t.prototype.catch=function(t){return this.then(null,t)},t.prototype.finally=function(t){var e=this.constructor;return this.then(function(n){return e.resolve(t()).then(function(){return n})},function(n){return e.resolve(t()).then(function(){throw n})})},t}();return B.prototype.then=w,B.all=function(t){return new Z(this,t).promise},B.race=function(t){var n=this;return e(t)?new n(function(e,r){for(var i=t.length,o=0;o<i;o++)n.resolve(t[o]).then(e,r)}):new n(function(t,e){return e(new TypeError("You must pass an array to race."))})},B.resolve=g,B.reject=function(t){var e=new this(A);return C(e,t),e},B._setScheduler=function(t){i=t},B._setAsap=function(t){o=t},B._asap=o,B.polyfill=function(){var t=void 0;if(void 0!==commonjsGlobal)t=commonjsGlobal;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(t){throw new Error("polyfill failed because global object is unavailable in this environment")}var e=t.Promise;if(e){var n=null;try{n=Object.prototype.toString.call(e.resolve())}catch(t){}if("[object Promise]"===n&&!e.cast)return}t.Promise=B},B.Promise=B,B}()});const Promise$1=es6Promise.Promise;function getSrvTime(t,e){var n;try{n=new XMLHttpRequest}catch(t){try{n=new ActiveXObject("Msxml2.XMLHTTP")}catch(t){try{n=new ActiveXObject("Microsoft.XMLHTTP")}catch(t){return console.error("AJAX not supported"),void(e&&e())}}}n.onreadystatechange=function(){if(n.readyState===XMLHttpRequest.DONE)if(200===n.status)try{var r=JSON.parse(n.responseText);t&&t(r.data)}catch(t){console.error("parse json error"),e&&e()}else console.error("There was a problem with the request."),e&&e()},n.open("GET","https://app.myscrm.cn/njs/time",!0),n.send()}let serverLocalTimeDiff;function getServerTime(){return new Promise$1((t,e)=>{window.GET_SERVER_TIME?t(window.GET_SERVER_TIME()):void 0===serverLocalTimeDiff?getSrvTime(function(e){serverLocalTimeDiff=e-Date.now(),t(Date.now()+serverLocalTimeDiff)},function(){serverLocalTimeDiff=0,console.error("get time fail, using local time"),t(Date.now())}):t(Date.now()+serverLocalTimeDiff)})}function styleInject(t,e){void 0===e&&(e={});var n=e.insertAt;if(t&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===n&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t))}}var css='.active_pop_mask {\n position: fixed;\n top: 0;\n bottom: 0;\n width: 100%;\n z-index: 100000000;\n background-color: rgba(34, 34, 34, 0.8);\n -webkit-box-shadow: 0px 1px 0.2rem rgba(0, 0, 0, 0.6);\n line-height: 0.36rem;\n}\n.active_pop_1ad1 {\n position: fixed;\n z-index: 100000001;\n top: 0;\n bottom: 0;\n width: 100%;\n height: 100%;\n}\n.active_pop_1ad1 .content {\n position: absolute;\n -ms-transform: translate(0, -50%);\n transform: translate(0, -50%);\n -webkit-transform: translate(0, -50%);\n top: 50%;\n left: 10%;\n right: 10%;\n margin-top: -50px;\n}\n.active_pop_1ad1 .content-inner > * {\n max-width: 100%;\n}\n.active_pop_1ad1 * {\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n position: relative;\n z-index: 100;\n}\n.active_pop_1ad1 .active_pop_close_btn {\n position: absolute;\n bottom: -70px;\n transform: translateX(-50%);\n left: 50%;\n width: 30px;\n height: 30px;\n z-index: 1;\n background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAA4CAYAAACohjseAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMDY3IDc5LjE1Nzc0NywgMjAxNS8wMy8zMC0yMzo0MDo0MiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6NDU3QzZBRDc0N0E0MTFFODg4ODA5REIwN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OK14RSQJyi7+LPhvARDDH4nMEANBFHdI+kX3FuK+ZWToLsdncE53F6Pk2wM90jGVSctHrwiJr+TNEKcMynU7pE6hDntmPU1DlFJd3wgUPbHPDu+52uOsVJ68+RLJQRnAwaAooLMpK6xSlqEU2TROAUcE3T6peoSBPi3FYDpjrMat3X2LFXkSbFSbsr2hy+FOs0dx5PpGlx0p6INhE4jO9AZUmkDXHS3og2EZjnbmssiOzDT9Pi3Ox5vsN0eptBQ65Ih9PGsSBOUVO2o7p369yqtXHqmAx5ZFr+BKX8NLFBD2/ZchYiAj+CfobFububr/zssCCy89ETgS+58zYtrr3LM7nSgkhJUr9yGEWUWBKnLIoUTY8dvuTHWxRnS6RkJupE4C0wx7I4GyJng5v/Rbgkx8SXwcIkiTMxkgup6ZsTHgEnQZwJkX8yFF2TTrI5ncah7XZJJ+nkgPqdOkymOB0jKRoOuv5ESvyO9xA+pXridxRo6ZpVUwyZDoE9KSDO70juBlWuuM4WdoCR090OXyJ9cXEaH58t8XoAeoS78WVpEvedYQS/5p//xKhkuptGR9j3olVCxStCkOqitSksTnx75acIIV3KSJqClJGEFwJtTiFxm+jTyHjf9VovKmVTF8EzsA58StJiksd3tWzH5oOmeBd4zapJR1Kw+o47hVlJEDeLtpvpS5OnqwKUU1bHerg1UkRbDX7KKf3kRS+A0RxNObQ5bCCn4+ZUDtGG2BpD24k1DSXNO0ALy5DXBixBLmAfNexzR9CSZl1F6bIRljPx1ep3UXo9Y7KH6t+i9J5MNOeDQUwGlzEWlVGTovSj4JKOjXyG4Z8VjOWKJ8FnX9AbfKdQSTi/581wf1ZwW2n+WcEvAQYAoGw2MqcpCH0AAAAASUVORK5CYII=);\n background-size: 100% 100%;\n}\n.active_pop_1ad1 .active_pop_close_btn::before {\n content: "";\n display: block;\n width: 1px;\n height: 100px;\n background: #ddd;\n position: absolute;\n bottom: 100%;\n left: 50%;\n}';styleInject(css);var classCallCheck=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},createClass=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),get=function t(e,n,r){null===e&&(e=Function.prototype);var i=Object.getOwnPropertyDescriptor(e,n);if(void 0===i){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,n,r)}if("value"in i)return i.value;var s=i.get;return void 0!==s?s.call(r):void 0},inherits=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},possibleConstructorReturn=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},slicedToArray=function(){return function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var s,a=t[Symbol.iterator]();!(r=(s=a.next()).done)&&(n.push(s.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{!r&&a.return&&a.return()}finally{if(i)throw o}}return n}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),set$1=function(t){var e=t.key,n=t.value,r=t.expires;return window.localStorage.setItem(e,JSON.stringify({value:n,expires:r}))},get$1=function(t,e){var n=JSON.parse(window.localStorage.getItem(t));if(n){var r=n.value,i=n.expires;return i&&new Date(i)<e?(window.localStorage.removeItem(t),null):r}return null},getDaysDiffBetweenDates=function(t){return function(e){return(e-t)/864e5}},paddingLeft=function(t,e,n){var r=e-t.length;if(r<=0)return t;for(var i="",o=0;o<r;o++)i+=n;return i+t},Active=function(){function t(e){var n=this;classCallCheck(this,t),this.opts=e,this.emitter=mitt(),this.emitTo=function(t){return function(e){return n.emitter(t,e)}},this.on=this.emitter.on,this.off=this.emitter.off,this.emit=this.emitter.emit}return createClass(t,[{key:"serialization",value:function(){var t=this.opts,e=t.title,n=t.id,r=t.end_date;return set$1({key:""+e+n,value:t,expires:r})}},{key:"isActive",value:function(){var t=this.opts;return!t.end_date||new Date(t.end_date)>=new Date}}]),t}(),PopupActive=function(t){function e(t,n){classCallCheck(this,e);var r=possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return r.meta=n,r.activeURL=t.activeURL,r.popupDom=r.makePopupDom(t),r.popupDom.querySelector(".active_pop_close.active_pop_close_btn").addEventListener("click",function(t){r.popupDom.remove(),r.emit("popClose",t)}),r.popupDom.querySelector(".content-inner").addEventListener("click",function(e){var n=t.urls,i=(n.length,n[Math.floor(Math.random()*n.length)]);window.location=i,r.emit("content-inner",e)}),r}return inherits(e,Active),createClass(e,[{key:"init",value:function(){(this.meta.dom||document.body).appendChild(this.popupDom)}},{key:"inRange",value:function(){var t=this.opts,e=t.start_date,n=t.end_date,r=t.time_start,i=t.time_end,o=(t.serverTime,new Date(t.serverTime));if(e&&o<e)return!1;if(n&&o>n)return!1;var s=paddingLeft(o.getHours(),2,"0")+":"+paddingLeft(o.getMinutes(),2,"0")+":"+paddingLeft(o.getSeconds(),2,"0");return!(r&&s<r)&&!(i&&s>i)}},{key:"isActive",value:function(){var t=this.opts;if(!get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"isActive",this).call(this))return!1;if(!this.inRange())return!1;if("1"===t.is_first_show){t.meta=t.meta||{},t.meta.visitCb=t.meta.visitCb||[];var n=new Date(t.serverTime),r=getDaysDiffBetweenDates(n);return t.meta.visitCb.every(function(t){return r(new Date(t.time))<-1})}return!0}},{key:"makePopupDom",value:function(t){var e=t.imageUrl,n='<div class="active_pop_1ad1_wrapper">\n <div class="active_pop_mask"></div>\n <div class="active_pop_1ad1">\n <div class="content">\n <div class="content-inner" style="max-height: '+(window.innerHeight-40)+'px;">\n <div style="text-align: center">\n <img style="max-height: 100%;max-width: 100%;" src="'+e+'">\n </div>\n </div>\n <div class="active_pop_close active_pop_close_btn" />\n </div>\n </div>\n </div>',r=document.createElement("div");return r.innerHTML=n,r}},{key:"updateStatus",value:function(t){var e=this.opts;e.meta=e.meta||{},e.meta.visitCb=e.meta.visitCb||[],e.meta.visitCb.push({type:t,time:new Date(e.serverTime)}),this.serialization()}}]),e}(),Manager=function(){function t(e){classCallCheck(this,t),this.opts=e||{}}return createClass(t,[{key:"setActiveOrigin",value:function(t){var e=this;return Promise.all([getServerTime(),t]).then(function(t){var e=slicedToArray(t,2),n=e[0],r=e[1].data,i=r.id,o=r.title,s=r.end_date,a=r.start_date,c=r.date_modified,u=r.time_end,l=r.time_start,p=r.urls,f=r.image.data.url,d=r.is_first_show;s=s&&new Date(s),a=a&&new Date(a);var v,h={id:i,date_modified:c,urls:p.data.map(function(t){return t.text}),title:o,serverTime:n,end_date:s,start_date:a,time_end:u,time_start:l,imageUrl:f,is_first_show:d},m=""+o+i,y=get$1(m,n);return y&&new Date(y.date_modified)>=new Date(h.date_modified)?((v=y).start_date=v.start_date&&new Date(v.start_date),v.end_date=v.end_date&&new Date(v.end_date),v):(set$1({key:m,value:h,expires:s}),h)}).then(function(t){var n=new PopupActive(t,{meta:e.opts.dom});n.isActive()&&(n.on("popClose",function(t){return n.updateStatus("popClose")}),n.init(),e.active=n)})}}]),t}();exports.PopupActive=PopupActive,exports.Manager=Manager; |
{ | ||
"name": "@yued/activities", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
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
29914
316