123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695 |
- // SilenGames HTML5 Extension
- // Author: Vitaliy Sidorov
- // Copyright: SilenGames 2014
- function sg_nug_score(name, num) {
- try {
- var score = new NugPlayScore().init();
- score.setValue(num);
- nugPlay.api().submitScore(score, name);
- } catch(e) {}
- };
- function sg_nug_achi(name) {
- try {
- nugPlay.api().achieve(name);
- } catch(e) {}
- };
- function sg_nug_load() {
- try {
- nugPlay.gameLoaded();
- } catch(e) {}
- };
- function sg_nug_start() {
- try {
- nugPlay.newGame();
- } catch(e) {}
- };
- function sg_nug_end() {
- try {
- nugPlay.endGame();
- } catch(e) {}
- };
- function sg_nug_quit() {
- try {
- nugPlay.quitGame();
- } catch(e) {}
- };
- function sg_kong_stat(name, num) {
- try {
- parent.kongregate.stats.submit(name, num);
- } catch(e) {}
- };
- function sg_buon_start() {
- try {
- startSession();
- } catch (e) {}
- }
- function sg_buon_end(num) {
- try {
- endSession({score:num});
- } catch (e) {}
- }
- function sg_iwin_ad() {
- try {
- iConsole.ads.show({type: 'interstitial'});
- } catch(e) {};
- }
- function sg_iwin_score(num) {
- try {
- iConsole.game.postHighScore({score: num});
- } catch(e) {};
- }
- function sg_spil_score(num) {
- try {
- if (sg_spilapi_obj) {
- sg_spilapi_obj.Score.submit(num);
- }
- } catch(e) {};
- }
- function sg_spil_award(num) {
- try {
- if (sg_spilapi_obj) {
- var award = {award:'award'+num};
- sg_spilapi_obj.Award.submit(award);
- }
- } catch(e) {};
- }
- function sg_spil_ad() {
- try {
- if (sg_spilapi_obj) {
- sg_spilapi_obj.GameBreak.request(gml_Script_gmcallback_focusoff, gml_Script_gmcallback_focuson);
- }
- } catch(e) {
- gml_Script_gmcallback_focuson();
- };
- }
- function sg_spil_start() {
- try {
- return CHEATMODE;
- } catch(e) {
- return 0;
- };
- }
- function sg_spil_splash() {
- try {
- if (sg_spilapi_obj) {
- sg_spilapi_obj.Branding.displaySplashScreen(gml_Script_gmcallback_splashend);
- }
- } catch(e) {
- gml_Script_gmcallback_splashend();
- };
- }
- function sg_fgl_init() {
- function wrap(f) { return function(e) {
- var o = document.activeElement;
- if (!o || o == document.body || o.tagName == "CANVAS") f.call(this, e);
- }; };
- window.onkeydown = wrap(window.onkeydown);
- window.onkeyup = wrap(window.onkeyup);
- }
- function sg_fgl_achi(nam) {
- try {
- // if (!fgl.hasAchievement(nam)) {
- // fgl.grantAchievement(nam);
- // }
- } catch(e) {};
- }
- function sg_fgl_ad() {
- try {
- // fgl.showAd();
- } catch(e) {};
- }
- function sg_fgl_more_ok() {
- try {
- // if (fgl.crossPromotionEnabled) {
- // return true;
- // } else {
- // return false ;
- // }
- } catch(e) {
- return false;
- };
- }
- function sg_fgl_more() {
- try {
- // fgl.showMoreGames();
- } catch(e) {};
- }
- function sg_fgl_prem_ok() {
- try {
- // if (fgl.unlockEnabled) {
- // return true;
- // } else {
- // return false;
- // }
- } catch(e) {
- return false;
- };
- }
- function sg_fgl_prem() {
- try {
- // fgl.inApp.initiateUnlockFunction(
- // function(){
- // gml_Script_gmcallback_fgl_iap_ok();
- // },
- // function(){}
- // );
- } catch(e) {};
- }
- function sg_fgl_isprem() {
- try {
- // if (fgl.isPremium()) {
- // return true;
- // } else {
- // return false;
- // }
- } catch(e) {
- return false;
- };
- }
- function sg_fgl_spon_ok() {
- try {
- // if (fgl.brandingEnabled) {
- // return true;
- // } else {
- // return false;
- // }
- } catch(e) {
- return false;
- };
- }
- function sg_fgl_spon_create() {
- try {
- if (window.sg_fgl_spon_obj == undefined) {
- sg_fgl_spon_obj = document.createElement('img');
- sg_fgl_spon_obj.src = "";//fgl.getBrandingLogo();
- sg_fgl_spon_obj.onclick = "";//fgl.handleBrandingClick;
- sg_fgl_spon_obj.setAttribute('style','display: none; position: absolute; left: 0px; top: 0px; width: 0px; height: 0px; z-index: 5; border: 0px');
- document.body.appendChild(sg_fgl_spon_obj);
- return true;
- } else {
- return false;
- }
- } catch(e) {
- return false;
- };
- }
- function sg_fgl_score_send(num) {
- try {
- //fgl.submitScore(num);
- } catch(e) {};
- }
- function sg_fgl_score_show() {
- try {
- //fgl.displayScoreboard();
- } catch(e) {};
- }
- function sg_banner_create(siz) {
- try {
- if (window.bancont != undefined) {
- sg_banner_delete();
- }
- bancont = document.createElement("iframe");
- bancont.id = "sg-banner-cont";
- bancont.height = siz;
- bancont.marginHeight = "0";
- bancont.marginWidth = "0";
- bancont.srcdoc = '<script type="text/javascript" src=""></script>';
- document.body.insertBefore(bancont, document.body.firstChild);
- } catch(e) {};
- }
- function sg_banner_delete() {
- try {
- if (window.bancont != undefined) {
- document.body.removeChild(bancont);
- bancont = undefined;
- }
- } catch(e) {};
- }
- function sg_lead_create() {
- try {
- if (window.adscreen == undefined) {
- adcont = undefined;
- adscreen = document.createElement("div");
- adscreen.id = "sg-ad-screen";
- adtext = document.createElement("div");
- adtext.id = "sg-ad-text";
- adtext.innerHTML = "Advertisment";
- adbut = document.createElement("img");
- adbut.id = "sg-ad-but";
- adbut.src = "silengames/adbut.png";
- adbut.onclick = gml_Script_gmcallback_adclose;
- adbut.width = "30";
- adbut.height = "30";
- adbut.border = "0";
- adbut.alt = "Close";
- adscreen.appendChild(adtext);
- adscreen.appendChild(adbut);
- document.body.insertBefore(adscreen, document.body.firstChild);
- }
- } catch(e) {};
- }
- function sg_lead_show(siz) {
- try {
- if (window.adscreen != undefined) {
- adscreen.setAttribute('style','display: block');
- adbut.width = siz;
- adbut.height = siz;
- if (window.adcont == undefined) {
- adcont = document.createElement("iframe");
- adcont.srcdoc = '<script type="text/javascript" src="http://ad.leadboltmobile.net/show_app_ad.js?section_id=568879653"></script>';
- adcont.id = "sg-ad-cont";
- adscreen.appendChild(adcont);
- }
- }
- } catch(e) {};
- }
- function sg_lead_close() {
- try {
- if (window.adscreen != undefined) {
- adscreen.setAttribute('style','display: none');
- if (window.adcont != undefined) {
- adscreen.removeChild(adcont);
- adcont = undefined;
- }
- }
- } catch(e) {};
- }
- function sg_clay_share(txt) {
- try {
- Clay('client.share.any', {text: txt});
- } catch(e) {};
- }
- sg_guid = "";
- function sg_init(guid) {
- try {
- sg_guid = guid;
- if (window.loadingobj != undefined) {
- document.body.removeChild(loadingobj);
- }
- if (window.loadbarbackobj != undefined) {
- document.body.removeChild(loadbarbackobj);
- }
- if (window.loadintervalid != undefined) {
- clearInterval(loadintervalid);
- }
- if (window.loadingtextobj != undefined) {
- document.body.removeChild(loadingtextobj);
- }
- if (window.sg_spil_spon_obj != undefined) {
- sg_spil_spon_obj.setAttribute('style','display: none');
- }
- //sg_banner_delete();
- } catch(e) {};
- }
- function sg_canvas_resize(xpos, ypos, xsiz, ysiz) {
- canvasobj.setAttribute('style','position: absolute; left: '+xpos+'px; top: '+ypos+'px; width: '+xsiz+'px; height: '+ysiz+'px');
- }
- function sg_brand_set(type) {
- try {
- switch (type) {
- case "claycross": return claycrossbar;
- case "fgllogo": return sg_fgl_spon_obj;
- case "spillogo": return sg_spil_spon_obj;
- case "spilmore": return sg_spil_more_obj;
- case "spilcross": return sg_spil_cross_obj;
- default: return undefined;
- }
- } catch(e) {
- return undefined;
- };
- }
- function sg_brand_show(type,xpos,ypos,xsiz,ysiz) {
- try {
- var curobj = sg_brand_set(type);
- if (curobj != null && curobj != undefined) {
- if (type == "claycross") {
- curobj.setAttribute('style','display: block');
- } else {
- curobj.setAttribute('style','display: block; position: absolute; left: '+xpos+'px; top: '+ypos+'px; width:'+xsiz+'px; height:'+ysiz+'px; z-index: 5; border: 0px');
- }
- }
- } catch(e) {};
- }
- function sg_brand_hide(type) {
- try {
- var curobj = sg_brand_set(type);
- if (curobj != null && curobj != undefined) {
- curobj.setAttribute('style','display: none');
- }
- } catch(e) {};
- }
- sg_url_obj = [];
- sg_url_count = 0;
- function sg_url_add(url,blnk) {
- var oLink=document.createElement("a");
- oLink.setAttribute('href', url);
- if (blnk) {
- oLink.setAttribute('target', '_blank');
- }
- document.body.appendChild(oLink);
- var oDiv=document.createElement("div");
- oDiv.setAttribute('style','display: block; position: absolute; z-index: 5; border: 0px');
- oDiv.setAttribute("id", "sgurlobj"+sg_url_count);
- oDiv.style.left = "0px";
- oDiv.style.top = "0px";
- oDiv.style.width = "0px";
- oDiv.style.height = "0px";
- oDiv.style.cursor = "default";
- oDiv.style.backgroundColor = "rgba(0, 0, 0, 0)";
- oLink.appendChild(oDiv);
- sg_url_obj[sg_url_count] = oDiv;
- return sg_url_count++;
- }
- function sg_url_delete(num) {
- var obj = sg_url_obj[num];
- if (obj) {
- document.body.removeChild(obj.parentNode);
- sg_url_obj[num] = undefined;
- }
- }
- function sg_url_change(num, xpos, ypos, xsiz, ysiz) {
- var obj = sg_url_obj[num];
- if (obj) {
- obj.style.left = xpos + "px";
- obj.style.top = ypos + "px";
- obj.style.width = xsiz + "px";
- obj.style.height = ysiz + "px";
- }
- }
- function sg_get(url) {
- if (window.XMLHttpRequest) {
- xmlObject = new XMLHttpRequest();
- } else {
- xmlObject = new ActiveXObject("Microsoft.XMLHTTP");
- }
- xmlObject.open("GET",url,0);
- xmlObject.send(null);
- return xmlObject.responseText;
- }
- sg_focus = 1;
- sg_visible_type = "";
- sg_visible_event = "";
- try {
- if (typeof document.hidden !== "undefined") {
- sg_visible_type = "hidden";
- sg_visible_event = "visibilitychange";
- } else if (typeof document.webkitHidden !== "undefined") {
- sg_visible_type = "webkitHidden";
- sg_visible_event = "webkitvisibilitychange";
- } else if (typeof document.msHidden !== "undefined") {
- sg_visible_type = "msHidden";
- sg_visible_event = "msvisibilitychange";
- } else if (typeof document.mozHidden !== "undefined") {
- sg_visible_type = "mozHidden";
- sg_visible_event = "mozvisibilitychange";
- }
- } catch(e) {};
- if (sg_visible_event != "") {
- document.addEventListener(sg_visible_event, sg_get_visibility, false);
- }
- window.addEventListener("focus",sg_focus_on, false);
- window.addEventListener("blur",sg_focus_off, false);
- function sg_focus_on() {
- try {
- if (sg_focus == 0) {
- sg_focus = 1;
- gml_Script_gmcallback_focuson();
- }
- } catch(e) {};
- }
- function sg_focus_off() {
- try {
- if (sg_focus == 1) {
- sg_focus = 0;
- gml_Script_gmcallback_focusoff();
- }
- } catch(e) {};
- }
- function sg_get_visibility() {
- try {
- if (document[sg_visible_type] == 1) {
- sg_focus_off();
- } else if (document[sg_visible_type] == 0) {
- sg_focus_on();
- }
- } catch(e) {};
- }
- function sg_get_language() {
- try {
- var lang = window.navigator.userLanguage || window.navigator.language;
- return lang.substring(0,2).toLowerCase();
- } catch(e) {
- return "en";
- };
- }
- sg_unlock_audio = null;
- sg_play_audio = null;
- sg_is_winphone = false;
- function sg_unlock_music(num, win) {
- sg_unlock_audio = document.getElementsByTagName('audio')[num];
- if (win) {
- sg_is_winphone = true;
- }
- }
- function sg_play_music() {
- try {
- if (sg_play_audio != null) {
- sg_stop_music();
- }
- sg_play_audio = sg_unlock_audio;
- sg_play_audio.loop = true;
- sg_play_audio.addEventListener("ended", sg_play_music, false);
- if (sg_is_winphone) {
- sg_play_audio.play();
- } else {
- window.addEventListener("touchend", sg_unlock_music_event, false);
- }
- } catch(e) {};
- }
- function sg_unlock_music_event() {
- try {
- sg_play_audio.play();
- window.removeEventListener("touchend", sg_unlock_music_event, false);
- sg_is_winphone = true;
- } catch(e) {};
- }
- function sg_stop_music() {
- try {
- sg_play_audio.pause();
- sg_play_audio.removeEventListener("ended", sg_play_music, false);
- } catch(e) {};
- }
- function sg_unlock_webaudio() {
- try {
- window.addEventListener("touchstart", sg_unlock_webaudio_event, false);
- } catch(e) {};
- }
- function sg_unlock_webaudio_event(event) {
- try {
- var buffer = g_WebAudioContext.createBuffer(1, 1, 22050);
- var source = g_WebAudioContext.createBufferSource();
- source.buffer = buffer;
- source.connect(g_WebAudioContext.destination);
- source.noteOn(0);
- window.removeEventListener("touchstart", sg_unlock_webaudio_event, false);
- } catch(e) {};
- }
- function sg_no_bar() {
- if(!window.location.hash)
- {
- var divh = document.getElementById('gm4html5_div_id').style.height;
- if (divh < (window.outerHeight + 200))
- {
- document.getElementById('gm4html5_div_id').style.height = (window.outerHeight + 200) + 'px';
- }
- setTimeout ( function(){ window.scrollTo(0,1); },50);
- }
- }
- function sg_ios7_fix() {
- window.addEventListener('scroll', function () {
- if (document.activeElement === document.body && window.scrollY > 0) {
- document.body.scrollTop = 0;
- }
- }, true);
- }
- function test_browser_storage() {
- try {
- return 'localStorage' in window && window['localStorage'] !== null;
- } catch (e) {
- return false;
- }
- }
- sg_save_ok = test_browser_storage();
- function sg_save(name, numb) {
- try {
- var key = sg_guid + name;
- if (sg_save_ok) {
- window.localStorage.setItem(key, numb);
- } else {
- var date = new Date;
- date.setDate(date.getDate() + 999);
- document.cookie = key +"="+ numb +"; path=/; expires="+ date.toUTCString();
- }
- } catch(e) {};
- }
- function sg_load(name, def) {
- try {
- var key = sg_guid + name;
- if (sg_save_ok) {
- var done = window.localStorage.getItem(key);
- } else {
- var matches = document.cookie.match(new RegExp(
- "(?:^|; )" + key.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
- ))
- var done = matches ? decodeURIComponent(matches[1]) : undefined;
- }
- if (done!=null && done!="") {
- return parseInt(done);
- } else {
- return def;
- }
- } catch(e) {
- return def;
- };
- }
- function sg_orient(ok) {
- try {
- if (ok) {
- orientobj.setAttribute('style','display: block');
- } else {
- orientobj.setAttribute('style','display: none');
- }
- } catch(e) {};
- }
- function sg_test_orient() {
- try {
- if (!viewporter || !viewporter.ACTIVE) {
- alert(0)
- return false;
- } else {
- alert(1)
- return true;
- }
- } catch(e) {
- alert("not try")
- return true;
- };
- }
- sg_load_perc = 0;
- function sg_loadingbar(_graphics, _width, _height, _total, _current, _loadingscreen) {
- if (typeof(window.innerWidth)=='number') {
- browser_width = window.innerWidth;
- browser_height = window.innerHeight;
- } else if (document.documentElement&&document.documentElement.clientWidth) {
- browser_width = document.documentElement.clientWidth;
- browser_height = document.documentElement.clientHeight;
- } else if (document.body&&document.body.clientWidth) {
- browser_width = document.body.clientWidth;
- browser_height = document.body.clientHeight;
- }
- multi = (browser_height / splash_h);
- var new_width = (splash_w * multi);
- var load_perc = _current/_total*100;
- if (load_perc < 100) {
- if (sg_load_perc < load_perc) {
- sg_load_perc+=1;
- }
- } else {
- sg_load_perc = 100;
- }
- var perc = bar_img_w/100*sg_load_perc;
- var bar_x = (browser_width-new_width)/2+bar_img_x*multi;
- var bar_y = bar_img_y*multi;
- var bar_w = bar_img_w*multi;
- var bar_w2 = perc*multi;
- var bar_h = bar_img_h*multi;
- if (loadbarbackobj) {
- loadbarbackobj.setAttribute('style','left: '+bar_x+'px; top: '+bar_y+'px; width:'+bar_w+'px; height:'+bar_h+'px; background-size: '+(bar_img_w*multi)+'px');
- }
- if (loadbarobj) {
- loadbarobj.setAttribute('style','left: '+bar_x+'px; top: '+bar_y+'px; width:'+bar_w2+'px; height:'+bar_h+'px; background-size: '+(bar_img_w*multi)+'px');
- }
- }
- //create banner
- /*
- browser_width = splash_w;
- browser_height = splash_h;
- if (typeof(window.innerWidth)=='number') {
- browser_width = window.innerWidth;
- browser_height = window.innerHeight;
- } else if (document.documentElement&&document.documentElement.clientWidth) {
- browser_width = document.documentElement.clientWidth;
- browser_height = document.documentElement.clientHeight;
- } else if (document.body&&document.body.clientWidth) {
- browser_width = document.body.clientWidth;
- browser_height = document.body.clientHeight;
- }
- multi = (browser_height / splash_h);
- bancont = undefined;
- sg_banner_create(Math.round(70*multi).toString());
- */
|