(function() { var script = document.currentScript || document.querySelector('script[src*="manage/renderarena"]'); if (script) { function parseSearchQuery(qstr) { qstr = qstr.replace("?", ""); var query = {}; var a = qstr.split('&'); for (var i = 0; i < a.length; i++) { var b = a[i].split('='); query[decodeURIComponent(b[0])] = decodeURIComponent(b[1] || ''); } return query; } function addClass(el, classNameToAdd) { try { if (!el) return; el.className += ' ' + classNameToAdd; } catch (er) { } } function removeClass(el, classNameToRemove) { try { if (!el) return; var elClass = ' ' + el.className + ' '; while (elClass.indexOf(' ' + classNameToRemove + ' ') !== -1) { elClass = elClass.replace(' ' + classNameToRemove + ' ', ''); } el.className = elClass; } catch (er) { } } const fullScreenClassName = "ark-fullscreen"; const bodyFullScreenClassName = "ark-body-fullscreen"; var iframe = document.createElement('iframe'); iframe.style.border = "none"; iframe.style.width = "0"; iframe.style.minWidth = "100%"; iframe.style.maxWidth = "100%"; iframe.setAttribute("height", script.parentNode.clientHeight + "px"); iframe.setAttribute("scrolling", "no"); var iframeUrl = '//games.mtairynews.com'; window.onpopstate = function(state) { var arkPath = state.state.path; var path = iframeUrl; if (arkPath) { path += arkPath; } iframe.setAttribute("src",path); }; function onMessage(msg) { var actions = { 'size-ping': function(obj) { var newSize = obj.height + "px"; if(iframe.style.height !== newSize) { iframe.style.height = newSize; } }, 'set-fullscreen': function(obj) { addClass(iframe, fullScreenClassName); addClass(document.body, bodyFullScreenClassName); }, 'out-fullscreen': function(obj) { removeClass(iframe, fullScreenClassName); removeClass(document.body, bodyFullScreenClassName); }, navigate: function(obj) { function addQueryParam(url, param, value){ var hash = {}; var parser = document.createElement('a'); parser.href = url; var parameters = parser.search.split(/\?|&/); for(var i=0; i < parameters.length; i++) { if(!parameters[i]) continue; var ary = parameters[i].split('='); hash[ary[0]] = ary[1]; } hash[param] = value; var list = []; Object.keys(hash).forEach(function (key) { list.push(key + '=' + hash[key]); }); parser.search = '?' + list.join('&'); return parser.href; } window.history.pushState({path: obj.path}, document.title, addQueryParam(window.location.href,'arkpath',obj.path)); } }; if (typeof (msg.data) === "object" && typeof (msg.data.arkAction) !== "undefined") { if (typeof(actions[msg.data.arkAction]) === 'function') { actions[msg.data.arkAction](msg.data.arkParam); } } } if (window.addEventListener) { window.addEventListener('message', onMessage, false); } else { window.attachEvent('onmessage', onMessage); } var arkPath = parseSearchQuery(document.location.search)['arkpath']; var path = iframeUrl; if (arkPath) { path += arkPath; } iframe.setAttribute("src",path); var style1 = document.createElement("style"); style1.innerHTML = "." + fullScreenClassName + "{ height:100%!important; width:100%!important; left:0!important; top:0!important; position:fixed!important; z-index:2147483647!important; background:#fff!important}"; var style2 = document.createElement("style"); style2.innerHTML = "." + bodyFullScreenClassName + "{ position:fixed!important;overflow:hidden!important; }"; script.parentNode.appendChild(style1); script.parentNode.appendChild(style2); script.parentNode.appendChild(iframe); } })();