@yued/activities
Advanced tools
Comparing version 1.3.0 to 1.4.0
@@ -1,1 +0,1 @@ | ||
var manage_pack=function(t){"use strict";var e,n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};const r=(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)},r=0,i=void 0,o=void 0,s=function(t,e){v[r]=t,v[r+1]=e,2===(r+=2)&&(o?o(d):w())},a="undefined"!=typeof window?window:void 0,u=a||{},c=u.MutationObserver||u.WebKitMutationObserver,l="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),f="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function p(){var t=setTimeout;return function(){return t(d,1)}}var v=new Array(1e3);function d(){for(var t=0;t<r;t+=2){var e=v[t],n=v[t+1];e(n),v[t]=void 0,v[t+1]=void 0}r=0}var h,m,_,y,w=void 0;function b(t,e){var n=this,r=new this.constructor(A);void 0===r[j]&&X(r);var i=n._state;if(i){var o=arguments[i-1];s(function(){return q(i,r,o,n._result)})}else L(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}l?w=function(){return process.nextTick(d)}:c?(m=0,_=new c(d),y=document.createTextNode(""),_.observe(y,{characterData:!0}),w=function(){y.data=m=++m%2}):f?((h=new MessageChannel).port1.onmessage=d,w=function(){return h.port2.postMessage(0)}):w=void 0===a?function(){try{var t=Function("return this")().require("vertx");return void 0!==(i=t.runOnLoop||t.runOnContext)?function(){i(d)}:p()}catch(t){return p()}}():p();var j=Math.random().toString(36).substring(2);function A(){}var O=void 0,D=1,S=2,T={error:null};function E(t){try{return t.then}catch(t){return T.error=t,T}}function k(e,n,r){n.constructor===e.constructor&&r===b&&n.constructor.resolve===g?function(t,e){e._state===D?M(t,e._result):e._state===S?P(t,e._result):L(e,void 0,function(e){return x(t,e)},function(e){return P(t,e)})}(e,n):r===T?(P(e,T.error),T.error=null):void 0===r?M(e,n):t(r)?function(t,e,n){s(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):M(t,n))},function(e){r||(r=!0,P(t,e))},t._label);!r&&i&&(r=!0,P(t,i))},t)}(e,n,r):M(e,n)}function x(t,e){var n,r;t===e?P(t,new TypeError("You cannot resolve a promise with itself")):(r=typeof(n=e),null===n||"object"!==r&&"function"!==r?M(t,e):k(t,e,E(e)))}function C(t){t._onerror&&t._onerror(t._result),R(t)}function M(t,e){t._state===O&&(t._result=e,t._state=D,0!==t._subscribers.length&&s(R,t))}function P(t,e){t._state===O&&(t._state=S,t._result=e,s(C,t))}function L(t,e,n,r){var i=t._subscribers,o=i.length;t._onerror=null,i[o]=e,i[o+D]=n,i[o+S]=r,0===o&&t._state&&s(R,t)}function R(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?q(n,r,i,o):i(o);t._subscribers.length=0}}function q(e,n,r,i){var o=t(r),s=void 0,a=void 0,u=void 0,c=void 0;if(o){if((s=function(t,e){try{return t(e)}catch(t){return T.error=t,T}}(r,i))===T?(c=!0,a=s.error,s.error=null):u=!0,n===s)return void P(n,new TypeError("A promises callback cannot return that same promise."))}else s=i,u=!0;n._state!==O||(o&&u?x(n,s):c?P(n,a):e===D?M(n,s):e===S&&P(n,s))}var H=0;function X(t){t[j]=H++,t._state=void 0,t._result=void 0,t._subscribers=[]}var I=function(){function t(t,n){this._instanceConstructor=t,this.promise=new t(A),this.promise[j]||X(this.promise),e(n)?(this.length=n.length,this._remaining=n.length,this._result=new Array(this.length),0===this.length?M(this.promise,this._result):(this.length=this.length||0,this._enumerate(n),0===this._remaining&&M(this.promise,this._result))):P(this.promise,new Error("Array Methods must be provided an Array"))}return t.prototype._enumerate=function(t){for(var e=0;this._state===O&&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=E(t);if(i===b&&t._state!==O)this._settledAt(t._state,e,t._result);else if("function"!=typeof i)this._remaining--,this._result[e]=t;else if(n===N){var o=new n(A);k(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===O&&(this._remaining--,t===S?P(r,n):this._result[e]=n),0===this._remaining&&M(r,this._result)},t.prototype._willSettleAt=function(t,e){var n=this;L(t,void 0,function(t){return n._settledAt(D,e,t)},function(t){return n._settledAt(S,e,t)})},t}(),N=function(){function t(e){this[j]=H++,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){P(t,e)})}catch(e){P(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 N.prototype.then=b,N.all=function(t){return new I(this,t).promise},N.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."))})},N.resolve=g,N.reject=function(t){var e=new this(A);return P(e,t),e},N._setScheduler=function(t){o=t},N._setAsap=function(t){s=t},N._asap=s,N.polyfill=function(){var t=void 0;if(void 0!==n)t=n;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 r=null;try{r=Object.prototype.toString.call(e.resolve())}catch(t){}if("[object Promise]"===r&&!e.cast)return}t.Promise=N},N.Promise=N,N}()}(e={exports:{}},e.exports),e.exports).Promise;let i;function o(){return new r((t,e)=>{window.GET_SERVER_TIME?t(window.GET_SERVER_TIME()):void 0===i?function(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()}(function(e){i=e-Date.now(),t(Date.now()+i)},function(){i=0,console.error("get time fail, using local time"),t(Date.now())}):t(Date.now()+i)})}var s=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=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}}(),u=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},c=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")}}(),l=function(t){var e=t.key,n=t.value,r=t.expires;return window.localStorage.setItem(e,JSON.stringify({value:n,expires:r}))},f=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},p=function(){function t(e){var n,r=this;s(this,t),this.opts=e,this.emitter=(n=n||Object.create(null),{on:function(t,e){(n[t]||(n[t]=[])).push(e)},off:function(t,e){n[t]&&n[t].splice(n[t].indexOf(e)>>>0,1)},emit:function(t,e){(n[t]||[]).slice().map(function(t){t(e)}),(n["*"]||[]).slice().map(function(n){n(t,e)})}}),this.emitTo=function(t){return function(e){return r.emitter(t,e)}},this.on=this.emitter.on,this.off=this.emitter.off,this.emit=this.emitter.emit}return a(t,[{key:"serialization",value:function(){var t=this.opts,e=t.title,n=t.id,r=t.end_date;return l({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}(),v=function(t){function e(t,n){s(this,e);var r=u(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(".js_pop_close.js_pop_close_btn").addEventListener("click",function(t){r.popupDom.remove(),r.emit("popClose",t)}),r.popupDom.querySelector(".js_pop_mask").addEventListener("click",function(t){r.popupDom.remove(),r.emit("maskClose",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 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)}(e,p),a(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=f(o.getHours(),2,"0")+":"+f(o.getMinutes(),2,"0")+":"+f(o.getSeconds(),2,"0");return!(r&&s<r)&&!(i&&s>i)}},{key:"isActive",value:function(){var t,n=this.opts;if(!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}(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"isActive",this).call(this))return!1;if(!this.inRange())return!1;if("1"===n.is_first_show){n.meta=n.meta||{},n.meta.visitCb=n.meta.visitCb||[];var r=new Date(n.serverTime),i=(t=r,function(e){return(e-t)/864e5});return n.meta.visitCb.every(function(t){return i(new Date(t.time))<-1})}return!0}},{key:"makePopupDom",value:function(t){var e=t.imageUrl,n='<div class="js_pop_1ad1_wrapper">\n <div class="js_pop_mask"></div>\n <div class="js_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="js_pop_close js_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}(),d=function(){function t(e){s(this,t),this.opts=e||{}}return a(t,[{key:"setActiveOrigin",value:function(t){var e=this;return Promise.all([o(),t]).then(function(t){var e=c(t,2),n=e[0],r=e[1].data,i=r.id,o=r.title,s=r.end_date,a=r.start_date,u=r.date_modified,f=r.time_end,p=r.time_start,v=r.urls,d=r.image.data.url,h=r.is_first_show;s=s&&new Date(s),a=a&&new Date(a);var m,_={id:i,date_modified:u,urls:v.data.map(function(t){return t.text}),title:o,serverTime:n,end_date:s,start_date:a,time_end:f,time_start:p,imageUrl:d,is_first_show:h},y=""+o+i,w=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}(y,n);return w&&new Date(w.date_modified)>=new Date(_.date_modified)?((m=w).start_date=m.start_date&&new Date(m.start_date),m.end_date=m.end_date&&new Date(m.end_date),m):(l({key:y,value:_,expires:s}),_)}).then(function(t){var n=new v(t,{meta:e.opts.dom});n.isActive()&&(n.on("popClose",function(t){return n.updateStatus("popClose")}),n.on("maskClose",function(t){return n.updateStatus("maskClose")}),n.init(),e.active=n)})}}]),t}();return t.PopupActive=v,t.Manager=d,t}({}); | ||
var manage_pack=function(t){"use strict";var e,n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};const r=(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)},r=0,i=void 0,o=void 0,s=function(t,e){v[r]=t,v[r+1]=e,2===(r+=2)&&(o?o(d):w())},a="undefined"!=typeof window?window:void 0,u=a||{},c=u.MutationObserver||u.WebKitMutationObserver,l="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),f="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function p(){var t=setTimeout;return function(){return t(d,1)}}var v=new Array(1e3);function d(){for(var t=0;t<r;t+=2){var e=v[t],n=v[t+1];e(n),v[t]=void 0,v[t+1]=void 0}r=0}var h,m,_,y,w=void 0;function b(t,e){var n=this,r=new this.constructor(j);void 0===r[A]&&H(r);var i=n._state;if(i){var o=arguments[i-1];s(function(){return X(i,r,o,n._result)})}else L(n,r,t,e);return r}function g(t){if(t&&"object"==typeof t&&t.constructor===this)return t;var e=new this(j);return x(e,t),e}l?w=function(){return process.nextTick(d)}:c?(m=0,_=new c(d),y=document.createTextNode(""),_.observe(y,{characterData:!0}),w=function(){y.data=m=++m%2}):f?((h=new MessageChannel).port1.onmessage=d,w=function(){return h.port2.postMessage(0)}):w=void 0===a?function(){try{var t=Function("return this")().require("vertx");return void 0!==(i=t.runOnLoop||t.runOnContext)?function(){i(d)}:p()}catch(t){return p()}}():p();var A=Math.random().toString(36).substring(2);function j(){}var O=void 0,D=1,S=2,T={error:null};function E(t){try{return t.then}catch(t){return T.error=t,T}}function k(e,n,r){n.constructor===e.constructor&&r===b&&n.constructor.resolve===g?function(t,e){e._state===D?M(t,e._result):e._state===S?P(t,e._result):L(e,void 0,function(e){return x(t,e)},function(e){return P(t,e)})}(e,n):r===T?(P(e,T.error),T.error=null):void 0===r?M(e,n):t(r)?function(t,e,n){s(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):M(t,n))},function(e){r||(r=!0,P(t,e))},t._label);!r&&i&&(r=!0,P(t,i))},t)}(e,n,r):M(e,n)}function x(t,e){var n,r;t===e?P(t,new TypeError("You cannot resolve a promise with itself")):(r=typeof(n=e),null===n||"object"!==r&&"function"!==r?M(t,e):k(t,e,E(e)))}function C(t){t._onerror&&t._onerror(t._result),R(t)}function M(t,e){t._state===O&&(t._result=e,t._state=D,0!==t._subscribers.length&&s(R,t))}function P(t,e){t._state===O&&(t._state=S,t._result=e,s(C,t))}function L(t,e,n,r){var i=t._subscribers,o=i.length;t._onerror=null,i[o]=e,i[o+D]=n,i[o+S]=r,0===o&&t._state&&s(R,t)}function R(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?X(n,r,i,o):i(o);t._subscribers.length=0}}function X(e,n,r,i){var o=t(r),s=void 0,a=void 0,u=void 0,c=void 0;if(o){if((s=function(t,e){try{return t(e)}catch(t){return T.error=t,T}}(r,i))===T?(c=!0,a=s.error,s.error=null):u=!0,n===s)return void P(n,new TypeError("A promises callback cannot return that same promise."))}else s=i,u=!0;n._state!==O||(o&&u?x(n,s):c?P(n,a):e===D?M(n,s):e===S&&P(n,s))}var q=0;function H(t){t[A]=q++,t._state=void 0,t._result=void 0,t._subscribers=[]}var I=function(){function t(t,n){this._instanceConstructor=t,this.promise=new t(j),this.promise[A]||H(this.promise),e(n)?(this.length=n.length,this._remaining=n.length,this._result=new Array(this.length),0===this.length?M(this.promise,this._result):(this.length=this.length||0,this._enumerate(n),0===this._remaining&&M(this.promise,this._result))):P(this.promise,new Error("Array Methods must be provided an Array"))}return t.prototype._enumerate=function(t){for(var e=0;this._state===O&&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=E(t);if(i===b&&t._state!==O)this._settledAt(t._state,e,t._result);else if("function"!=typeof i)this._remaining--,this._result[e]=t;else if(n===N){var o=new n(j);k(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===O&&(this._remaining--,t===S?P(r,n):this._result[e]=n),0===this._remaining&&M(r,this._result)},t.prototype._willSettleAt=function(t,e){var n=this;L(t,void 0,function(t){return n._settledAt(D,e,t)},function(t){return n._settledAt(S,e,t)})},t}(),N=function(){function t(e){this[A]=q++,this._result=this._state=void 0,this._subscribers=[],j!==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){P(t,e)})}catch(e){P(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 N.prototype.then=b,N.all=function(t){return new I(this,t).promise},N.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."))})},N.resolve=g,N.reject=function(t){var e=new this(j);return P(e,t),e},N._setScheduler=function(t){o=t},N._setAsap=function(t){s=t},N._asap=s,N.polyfill=function(){var t=void 0;if(void 0!==n)t=n;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 r=null;try{r=Object.prototype.toString.call(e.resolve())}catch(t){}if("[object Promise]"===r&&!e.cast)return}t.Promise=N},N.Promise=N,N}()}(e={exports:{}},e.exports),e.exports).Promise;let i;function o(){return new r((t,e)=>{window.GET_SERVER_TIME?t(window.GET_SERVER_TIME()):void 0===i?function(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()}(function(e){i=e-Date.now(),t(Date.now()+i)},function(){i=0,console.error("get time fail, using local time"),t(Date.now())}):t(Date.now()+i)})}var s=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=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}}(),u=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},c=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")}}(),l=function(t){var e=t.key,n=t.value,r=t.expires;return window.localStorage.setItem(e,JSON.stringify({value:n,expires:r}))},f=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},p=function(){function t(e){var n,r=this;s(this,t),this.opts=e,this.emitter=(n=n||Object.create(null),{on:function(t,e){(n[t]||(n[t]=[])).push(e)},off:function(t,e){n[t]&&n[t].splice(n[t].indexOf(e)>>>0,1)},emit:function(t,e){(n[t]||[]).slice().map(function(t){t(e)}),(n["*"]||[]).slice().map(function(n){n(t,e)})}}),this.emitTo=function(t){return function(e){return r.emitter(t,e)}},this.on=this.emitter.on,this.off=this.emitter.off,this.emit=this.emitter.emit}return a(t,[{key:"serialization",value:function(){var t=this.opts,e=t.title,n=t.id,r=t.end_date;return l({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}(),v=function(t){function e(t,n){s(this,e);var r=u(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(".js_pop_close.js_pop_close_btn").addEventListener("click",function(t){r.popupDom.remove(),r.emit("popClose",t)}),r.popupDom.querySelector(".js_pop_mask").addEventListener("click",function(t){r.popupDom.remove(),r.emit("maskClose",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 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)}(e,p),a(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=f(o.getHours(),2,"0")+":"+f(o.getMinutes(),2,"0")+":"+f(o.getSeconds(),2,"0");return!(r&&s<r)&&!(i&&s>i)}},{key:"isActive",value:function(){var t,n=this.opts;if(!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}(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"isActive",this).call(this))return!1;if(!this.inRange())return!1;if("1"===n.is_first_show){n.meta=n.meta||{},n.meta.visitCb=n.meta.visitCb||[];var r=new Date(n.serverTime),i=(t=r,function(e){return(e-t)/864e5});return n.meta.visitCb.every(function(t){return i(new Date(t.time))<-1})}return!0}},{key:"makePopupDom",value:function(t){var e=t.imageUrl,n='<div class="js_pop_1ad1_wrapper">\n <div class="js_pop_mask"></div>\n <div class="js_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 style="position: absolute;bottom: 0;transform: translateX(-50%);left: 50%;top: unset;width: 1rem;height: 1rem;background-image: unset;"/>\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}(),d=function(){function t(e){s(this,t),this.opts=e||{}}return a(t,[{key:"setActiveOrigin",value:function(t){var e=this;return Promise.all([o(),t]).then(function(t){var e=c(t,2),n=e[0],r=e[1].data,i=r.id,o=r.title,s=r.end_date,a=r.start_date,u=r.date_modified,f=r.time_end,p=r.time_start,v=r.urls,d=r.image.data.url,h=r.is_first_show;s=s&&new Date(s),a=a&&new Date(a);var m,_={id:i,date_modified:u,urls:v.data.map(function(t){return t.text}),title:o,serverTime:n,end_date:s,start_date:a,time_end:f,time_start:p,imageUrl:d,is_first_show:h},y=""+o+i,w=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}(y,n);return w&&new Date(w.date_modified)>=new Date(_.date_modified)?((m=w).start_date=m.start_date&&new Date(m.start_date),m.end_date=m.end_date&&new Date(m.end_date),m):(l({key:y,value:_,expires:s}),_)}).then(function(t){var n=new v(t,{meta:e.opts.dom});n.isActive()&&(n.on("popClose",function(t){return n.updateStatus("popClose")}),n.on("maskClose",function(t){return n.updateStatus("maskClose")}),n.init(),e.active=n)})}}]),t}();return t.PopupActive=v,t.Manager=d,t}({}); |
{ | ||
"name": "@yued/activities", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -123,3 +123,3 @@ import mitt from 'mitt' | ||
</div> | ||
<div class="js_pop_close js_pop_close_btn" /> | ||
<div style="position: absolute;bottom: 0;transform: translateX(-50%);left: 50%;top: unset;width: 1rem;height: 1rem;background-image: unset;"/> | ||
</div> | ||
@@ -126,0 +126,0 @@ </div> |
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
21108