| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- 'use strict'
- cc.loader.downloader.loadSubpackage = function(name, progressCallback, completeCallback) {
- if (!completeCallback && progressCallback) {
- completeCallback = progressCallback;
- progressCallback = null;
- }
- if (completeCallback) {
- completeCallback(null);
- }
- }
- var AdObj = {
- load: function() {
- setTimeout(function() {
- adsdk_request_result("onLoad", this._jid);
- }.bind(this), 100);
- return this;
- },
- then: function(callback) {
- this._cb_then = callback;
- return this;
- },
- catch: function(callback) {
- this._cb_catch = callback;
- return this;
- },
- show: function() {
- setTimeout(function() {
- adsdk_request_result("onClose", this._jid, true);
- }.bind(this), 100);
- return this;
- },
- onLoad: function(callback) {
- this._cb_onLoad = callback;
- return this;
- },
- onClose: function(callback) {
- this._cb_onClose = callback;
- return this;
- },
- onError: function(callback) {
- this._cb_onError = callback;
- return this;
- },
- offClose: function(callback) {
- return this;
- },
- offError: function(callback) {
- return this;
- },
- offLoad: function(callback) {
- return this;
- },
- destroy: function() {
- return this;
- },
- hide: function() {
- return this;
- },
- onResize: function() {
- return this;
- },
-
- style: function() {
- return this._style;
- }
- }
- var _style = function(objId, left, top, width, height) {
- this._objId = objId;
- this._left = left;
- this._top = top;
- this._width = width;
- this._height = height;
- }
- _style.prototype = {
- set left(val) {
- this._left = val;
- this._update(0, val);
- },
- get left() {
- return this._left;
- },
- set top(val) {
- this._top = val;
- this._update(1, val);
- },
- get top() {
- return this._top;
- },
- set width(val) {
- this._width = val;
- this._update(2, val);
- },
- get width() {
- return this._width;
- },
- set height(val) {
- this._height = val;
- this._update(3, val);
- },
- get height() {
- return this._height;
- },
- _update(t, v) {
- }
- }
- window.AdSdk = {
- adObjectCache: new Map(),
- createRewardedVideoAd: function(params) {
- return createAdObj("reward", params);
- },
- createInterstitialAd: function(params) {
- return createAdObj("Interstitial", params);
- },
- createBannerAd: function(params) {
- let obj = createAdObj("banner", params);
- obj.style = new _style(obj._objId, params.style.left, params.style.top, params.style.width, params.style.height);
- return obj;
- },
- createFullscreenVideoAd: function(params) {
- return createAdObj("Fullscreen", params);
- },
- }
- window.createAdObj = function(type, params) {
- let adUnitId = params.adUnitId;
- for (let [key, value] of AdSdk.adObjectCache) {
- if (value._adUnitId == adUnitId) {
- return value;
- }
- }
- let adObj = Object.create(AdObj);
- adObj._type = type;
- adObj._adUnitId = adUnitId;
- adObj._jid = adsdk_createAdObj(type, params);
- AdSdk.adObjectCache.set(adObj._jid, adObj);
- return adObj;
- }
- window.adsdk_createAdObj = function(type, params) {
- if (AdSdk._adObjIndex == undefined) {
- AdSdk._adObjIndex = 0;
- } else {
- AdSdk._adObjIndex++;
- }
- return AdSdk._adObjIndex;
- }
- window.adsdk_request_result = function(cmd, objId, params) {
- let adObj = AdSdk.adObjectCache.get(objId);
- if (!adObj) {
- return;
- }
- if (cmd === "onLoad") {
- if (adObj._cb_onLoad) {
- adObj._cb_onLoad();
- }
- if (adObj._cb_then) {
- adObj._cb_then();
- }
- } else if (cmd === "onClose") {
- if (adObj._cb_onClose) {
- if (params) {
- adObj._cb_onClose({ isEnded: true });
- } else {
- adObj._cb_onClose({ isEnded: false });
- }
- }
- } else if (cmd === "onError") {
- }
- }
|