// Generated by Haxe 4.0.5 (function ($global) { "use strict"; var $estr = function() { return js_Boot.__string_rec(this,''); },$hxEnums = $hxEnums || {},$_; function $extend(from, fields) { var proto = Object.create(from); for (var name in fields) proto[name] = fields[name]; if( fields.toString !== Object.prototype.toString ) proto.toString = fields.toString; return proto; } var ClientGroup = $hxEnums["ClientGroup"] = { __ename__ : true, __constructs__ : ["User","Leader","Admin"] ,User: {_hx_index:0,__enum__:"ClientGroup",toString:$estr} ,Leader: {_hx_index:1,__enum__:"ClientGroup",toString:$estr} ,Admin: {_hx_index:2,__enum__:"ClientGroup",toString:$estr} }; var Client = function(name,group) { this.name = name; var i = group; if(group == null) { i = 0; } this.group = i; }; Client.__name__ = true; Client.fromData = function(data) { return new Client(data.name,data.group); }; Client.prototype = { setGroupFlag: function(type,flag) { if(flag) { this.group |= 1 << type._hx_index; } else { this.group &= -1 - (1 << type._hx_index); } return flag; } }; var ClientTools = function() { }; ClientTools.__name__ = true; ClientTools.setLeader = function(clients,name) { var _g = 0; while(_g < clients.length) { var client = clients[_g]; ++_g; if(client.name == name) { client.setGroupFlag(ClientGroup.Leader,true); } else if((client.group & 2) != 0) { client.setGroupFlag(ClientGroup.Leader,false); } } }; ClientTools.getByName = function(clients,name,def) { var _g = 0; while(_g < clients.length) { var client = clients[_g]; ++_g; if(client.name == name) { return client; } } return def; }; var EReg = function(r,opt) { this.r = new RegExp(r,opt.split("u").join("")); }; EReg.__name__ = true; EReg.prototype = { match: function(s) { if(this.r.global) { this.r.lastIndex = 0; } this.r.m = this.r.exec(s); this.r.s = s; return this.r.m != null; } ,matched: function(n) { if(this.r.m != null && n >= 0 && n < this.r.m.length) { return this.r.m[n]; } else { throw new js__$Boot_HaxeError("EReg::matched"); } } }; var HxOverrides = function() { }; HxOverrides.__name__ = true; HxOverrides.dateStr = function(date) { var m = date.getMonth() + 1; var d = date.getDate(); var h = date.getHours(); var mi = date.getMinutes(); var s = date.getSeconds(); return date.getFullYear() + "-" + (m < 10 ? "0" + m : "" + m) + "-" + (d < 10 ? "0" + d : "" + d) + " " + (h < 10 ? "0" + h : "" + h) + ":" + (mi < 10 ? "0" + mi : "" + mi) + ":" + (s < 10 ? "0" + s : "" + s); }; HxOverrides.substr = function(s,pos,len) { if(len == null) { len = s.length; } else if(len < 0) { if(pos == 0) { len = s.length + len; } else { return ""; } } return s.substr(pos,len); }; HxOverrides.remove = function(a,obj) { var i = a.indexOf(obj); if(i == -1) { return false; } a.splice(i,1); return true; }; HxOverrides.iter = function(a) { return { cur : 0, arr : a, hasNext : function() { return this.cur < this.arr.length; }, next : function() { return this.arr[this.cur++]; }}; }; var Lambda = function() { }; Lambda.__name__ = true; Lambda.exists = function(it,f) { var x = $getIterator(it); while(x.hasNext()) if(f(x.next())) { return true; } return false; }; Lambda.find = function(it,f) { var v = $getIterator(it); while(v.hasNext()) { var v1 = v.next(); if(f(v1)) { return v1; } } return null; }; var haxe_ds_StringMap = function() { this.h = { }; }; haxe_ds_StringMap.__name__ = true; haxe_ds_StringMap.prototype = { setReserved: function(key,value) { if(this.rh == null) { this.rh = { }; } this.rh["$" + key] = value; } ,getReserved: function(key) { if(this.rh == null) { return null; } else { return this.rh["$" + key]; } } }; var Lang = function() { }; Lang.__name__ = true; Lang.request = function(path,callback) { var http = new haxe_http_HttpJs(path); http.onData = callback; http.request(); }; Lang.init = function(folderPath,callback) { var _this = Lang.ids; var _g = []; var _g1 = 0; while(_g1 < _this.length) { var v = _this[_g1]; ++_g1; if(v == Lang.lang || v == "en") { _g.push(v); } } Lang.ids = _g; var _this1 = Lang.langs; _this1.h = { }; _this1.rh = null; var count = 0; var _g2 = 0; var _g11 = Lang.ids; while(_g2 < _g11.length) { var name = [_g11[_g2]]; ++_g2; Lang.request("" + folderPath + "/" + name[0] + ".json",(function(name1) { return function(data) { var data1 = JSON.parse(data); var lang = new haxe_ds_StringMap(); var _g3 = 0; var _g12 = Reflect.fields(data1); while(_g3 < _g12.length) { var key = _g12[_g3]; ++_g3; var v1 = Reflect.field(data1,key); if(__map_reserved[key] != null) { lang.setReserved(key,v1); } else { lang.h[key] = v1; } } var id = haxe_io_Path.withoutExtension(name1[0]); var _this2 = Lang.langs; if(__map_reserved[id] != null) { _this2.setReserved(id,lang); } else { _this2.h[id] = lang; } count += 1; if(count == Lang.ids.length && callback != null) { callback(); } return; }; })(name)); } }; Lang.get = function(key) { var key1 = Lang.lang; var _this = Lang.langs; if((__map_reserved[key1] != null ? _this.getReserved(key1) : _this.h[key1]) == null) { Lang.lang = "en"; } var key2 = Lang.lang; var _this1 = Lang.langs; var _this2 = __map_reserved[key2] != null ? _this1.getReserved(key2) : _this1.h[key2]; var text = __map_reserved[key] != null ? _this2.getReserved(key) : _this2.h[key]; if(text == null) { return key; } else { return text; } }; Math.__name__ = true; var Reflect = function() { }; Reflect.__name__ = true; Reflect.field = function(o,field) { try { return o[field]; } catch( e ) { return null; } }; Reflect.fields = function(o) { var a = []; if(o != null) { var hasOwnProperty = Object.prototype.hasOwnProperty; for( var f in o ) { if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) { a.push(f); } } } return a; }; Reflect.isFunction = function(f) { if(typeof(f) == "function") { return !(f.__name__ || f.__ename__); } else { return false; } }; Reflect.compareMethods = function(f1,f2) { if(f1 == f2) { return true; } if(!Reflect.isFunction(f1) || !Reflect.isFunction(f2)) { return false; } if(f1.scope == f2.scope && f1.method == f2.method) { return f1.method != null; } else { return false; } }; var Std = function() { }; Std.__name__ = true; Std.string = function(s) { return js_Boot.__string_rec(s,""); }; Std.parseInt = function(x) { if(x != null) { var _g = 0; var _g1 = x.length; while(_g < _g1) { var i = _g++; var c = x.charCodeAt(i); if(c <= 8 || c >= 14 && c != 32 && c != 45) { var v = parseInt(x, (x[(i + 1)]=="x" || x[(i + 1)]=="X") ? 16 : 10); if(isNaN(v)) { return null; } else { return v; } } } } return null; }; var StringTools = function() { }; StringTools.__name__ = true; StringTools.htmlEscape = function(s,quotes) { var buf_b = ""; var _g_offset = 0; var _g_s = s; while(_g_offset < _g_s.length) { var s1 = _g_s; var index = _g_offset++; var c = s1.charCodeAt(index); if(c >= 55296 && c <= 56319) { c = c - 55232 << 10 | s1.charCodeAt(index + 1) & 1023; } var c1 = c; if(c1 >= 65536) { ++_g_offset; } var code = c1; switch(code) { case 34: if(quotes) { buf_b += """; } else { buf_b += String.fromCodePoint(code); } break; case 38: buf_b += "&"; break; case 39: if(quotes) { buf_b += "'"; } else { buf_b += String.fromCodePoint(code); } break; case 60: buf_b += "<"; break; case 62: buf_b += ">"; break; default: buf_b += String.fromCodePoint(code); } } return buf_b; }; StringTools.startsWith = function(s,start) { if(s.length >= start.length) { return s.lastIndexOf(start,0) == 0; } else { return false; } }; StringTools.endsWith = function(s,end) { var elen = end.length; var slen = s.length; if(slen >= elen) { return s.indexOf(end,slen - elen) == slen - elen; } else { return false; } }; StringTools.replace = function(s,sub,by) { return s.split(sub).join(by); }; StringTools.hex = function(n,digits) { var s = ""; while(true) { s = "0123456789ABCDEF".charAt(n & 15) + s; n >>>= 4; if(!(n > 0)) { break; } } if(digits != null) { while(s.length < digits) s = "0" + s; } return s; }; var _$VideoList_VideoList_$Impl_$ = {}; _$VideoList_VideoList_$Impl_$.__name__ = true; _$VideoList_VideoList_$Impl_$._new = function() { return []; }; _$VideoList_VideoList_$Impl_$.findIndex = function(this1,f) { var i = 0; var _g = 0; while(_g < this1.length) { if(f(this1[_g++])) { return i; } ++i; } return -1; }; _$VideoList_VideoList_$Impl_$.addItem = function(this1,item,atEnd,itemPos) { if(atEnd) { this1.push(item); } else { this1.splice(itemPos + 1,0,item); } }; _$VideoList_VideoList_$Impl_$.setNextItem = function(this1,pos,itemPos) { var next = this1[pos]; HxOverrides.remove(this1,next); this1.splice(itemPos + 1,0,next); }; _$VideoList_VideoList_$Impl_$.toggleItemType = function(this1,pos) { this1[pos].isTemp = !this1[pos].isTemp; }; _$VideoList_VideoList_$Impl_$.removeItem = function(this1,index,itemPos) { if(index < itemPos) { --itemPos; } HxOverrides.remove(this1,this1[index]); if(itemPos >= this1.length) { itemPos = 0; } return itemPos; }; _$VideoList_VideoList_$Impl_$.skipItem = function(this1,itemPos) { var item = this1[itemPos]; if(!item.isTemp) { ++itemPos; } else { HxOverrides.remove(this1,item); } if(itemPos >= this1.length) { itemPos = 0; } return itemPos; }; var client_Buttons = function() { }; client_Buttons.__name__ = true; client_Buttons.init = function(main) { client_Buttons.settings = main.settings; window.onresize = client_Buttons.onVideoResize; client_Buttons.initSplit(); client_Buttons.initChatInput(main); client_Buttons.initNavBar(main); var passIcon = window.document.querySelector("#guestpass_icon"); passIcon.onclick = function(e) { var isOpen = passIcon.classList.toggle("glyphicon-eye-open"); passIcon.classList.toggle("glyphicon-eye-close"); var pass = window.document.querySelector("#guestpass"); if(isOpen) { return pass.type = "password"; } else { return pass.type = "text"; } }; var smilesBtn = window.document.querySelector("#smilesbtn"); smilesBtn.onclick = function(e1) { var smilesWrap = window.document.querySelector("#smileswrap"); if(smilesWrap.children.length == 0) { return; } if(smilesBtn.classList.toggle("active")) { smilesWrap.style.display = "block"; } else { smilesWrap.style.display = "none"; } if(smilesWrap.firstElementChild.dataset.src == null) { return; } var _g = 0; var _g1 = smilesWrap.children; while(_g < _g1.length) { var child = _g1[_g]; ++_g; child.src = child.dataset.src; child.removeAttribute("data-src"); } return; }; window.document.querySelector("#clearchatbtn").onclick = function(e2) { if((main.personal.group & 4) != 0) { main.send({ type : "ClearChat"}); } return; }; var userList = window.document.querySelector("#userlist"); userList.onclick = function(e3) { if((main.personal.group & 4) == 0) { return; } var el = e3.target; if(userList == el) { return; } if(!el.classList.contains("userlist_item")) { el = el.parentElement; } var name = ""; if(el.children.length == 1) { name = el.lastElementChild.innerText; } main.send({ type : "SetLeader", setLeader : { clientName : name}}); return; }; var userlistToggle = window.document.querySelector("#userlisttoggle"); userlistToggle.onclick = function(e4) { var isHidden = userlistToggle.classList.toggle("glyphicon-chevron-right"); userlistToggle.classList.toggle("glyphicon-chevron-down"); var style = window.document.querySelector("#userlist").style; if(isHidden) { style.display = "none"; } else { style.display = "block"; } client_Buttons.settings.isUserListHidden = isHidden; client_Settings.write(client_Buttons.settings); return; }; window.document.querySelector("#usercount").onclick = userlistToggle.onclick; if(client_Buttons.settings.isUserListHidden) { userlistToggle.onclick(); } var extendPlayer = window.document.querySelector("#extendplayer"); extendPlayer.onclick = function(e5) { var isExtended = extendPlayer.classList.toggle("active"); var sizes = isExtended ? [20,80] : [40,60]; window.document.querySelector("#userlist").style.width = isExtended ? "80px" : "90px"; if(client_Buttons.settings.isSwapped) { sizes.reverse(); } client_Buttons.split.setSizes(sizes); client_Buttons.settings.isExtendedPlayer = isExtended; client_Buttons.writeSplitSize(); return window.dispatchEvent(new Event("resize")); }; if(client_Buttons.settings.isExtendedPlayer) { extendPlayer.onclick(); } var toggleSynch = window.document.querySelector("#togglesynch"); toggleSynch.onclick = function(e6) { var icon = toggleSynch.firstElementChild; if(main.isSyncActive) { if(!window.confirm(Lang.get("toggleSynchConfirm"))) { return; } main.isSyncActive = false; icon.style.color = "rgba(238, 72, 67, 0.75)"; icon.classList.add("glyphicon-pause"); icon.classList.remove("glyphicon-play"); } else { main.isSyncActive = true; icon.style.color = ""; icon.classList.add("glyphicon-play"); icon.classList.remove("glyphicon-pause"); main.send({ type : "UpdatePlaylist"}); } return; }; window.document.querySelector("#mediarefresh").onclick = function(e7) { main.refreshPlayer(); return; }; window.document.querySelector("#fullscreenbtn").onclick = function(e8) { return client_Utils.toggleFullScreen(window.document.querySelector("#ytapiplayer")); }; var getPlaylist = window.document.querySelector("#getplaylist"); getPlaylist.onclick = function(e9) { client_Utils.copyToClipboard(main.getPlaylistLinks().join(",")); var icon1 = getPlaylist.firstElementChild; icon1.classList.remove("glyphicon-link"); icon1.classList.add("glyphicon-ok"); return haxe_Timer.delay(function() { icon1.classList.add("glyphicon-link"); icon1.classList.remove("glyphicon-ok"); return; },2000); }; window.document.querySelector("#clearplaylist").onclick = function(e10) { if(!window.confirm(Lang.get("clearPlaylistConfirm"))) { return; } main.send({ type : "ClearPlaylist"}); return; }; window.document.querySelector("#shuffleplaylist").onclick = function(e11) { if(!window.confirm(Lang.get("shufflePlaylistConfirm"))) { return; } main.send({ type : "ShufflePlaylist"}); return; }; window.document.querySelector("#lockplaylist").onclick = function(e12) { if((main.personal.group & 4) != 0) { main.send({ type : "TogglePlaylistLock"}); } return; }; var showMediaUrl = window.document.querySelector("#showmediaurl"); showMediaUrl.onclick = function(e13) { client_Buttons.showPlayerGroup(showMediaUrl); return; }; var showCustomEmbed = window.document.querySelector("#showcustomembed"); showCustomEmbed.onclick = function(e14) { client_Buttons.showPlayerGroup(showCustomEmbed); return; }; window.document.querySelector("#insert_template").onclick = function(e15) { var input = window.document.querySelector("#mediaurl"); input.value = main.getTemplateUrl(); input.focus(); return; }; }; client_Buttons.showPlayerGroup = function(el) { var groups = window.document.querySelectorAll("[data-target]"); var _g = 0; while(_g < groups.length) { var group = groups[_g]; ++_g; if(el == group) { continue; } group.classList.add("collapsed"); group.classList.remove("active"); window.document.querySelector(group.dataset.target).classList.add("collapse"); } el.classList.toggle("collapsed"); el.classList.toggle("active"); window.document.querySelector(el.dataset.target).classList.toggle("collapse"); }; client_Buttons.initSplit = function() { if(client_Buttons.split != null) { client_Buttons.split.destroy(); } var divs = ["#chatwrap","#videowrap"]; var sizes = [client_Buttons.settings.chatSize,client_Buttons.settings.playerSize]; if(client_Buttons.settings.isSwapped) { divs.reverse(); sizes.reverse(); } client_Buttons.split = new Split(divs,{ sizes : sizes, onDragEnd : function() { window.dispatchEvent(new Event("resize")); client_Buttons.writeSplitSize(); return; }, minSize : 185, snapOffset : 0}); window.dispatchEvent(new Event("resize")); }; client_Buttons.writeSplitSize = function() { var sizes = client_Buttons.split.getSizes(); if(client_Buttons.settings.isSwapped) { sizes.reverse(); } client_Buttons.settings.chatSize = sizes[0]; client_Buttons.settings.playerSize = sizes[1]; client_Settings.write(client_Buttons.settings); }; client_Buttons.onVideoResize = function() { var height = window.document.querySelector("#ytapiplayer").offsetHeight - window.document.querySelector("#chatline").offsetHeight; window.document.querySelector("#messagebuffer").style.height = "" + height + "px"; window.document.querySelector("#userlist").style.height = "" + height + "px"; }; client_Buttons.onClick = function(el,func) { if(!client_Utils.isTouch()) { el.onclick = func; } else { el.ontouchend = func; } }; client_Buttons.initNavBar = function(main) { var onclick = function(e) { return window.document.querySelector("#nav-collapsible").classList.toggle("in"); }; client_Buttons.onClick(window.document.querySelector("#toggleMenu"),onclick); var classes = window.document.querySelectorAll(".dropdown-toggle"); var _g = 0; while(_g < classes.length) { var klass = [classes[_g]]; ++_g; klass[0].onclick = (function(klass1) { return function(e1) { var isActive = klass1[0].classList.toggle("focus"); client_Buttons.hideMenus(); var menu = klass1[0].parentElement.querySelector(".dropdown-menu"); if(isActive) { return menu.style.display = "block"; } else { return menu.style.display = "none"; } }; })(klass); klass[0].onmouseover = klass[0].onclick; } var classes1 = window.document.querySelectorAll(".dropdown"); var _g1 = 0; while(_g1 < classes1.length) { var klass2 = [classes1[_g1]]; ++_g1; klass2[0].onmouseleave = (function(klass3) { return function(e2) { var toggle = klass3[0].querySelector(".dropdown-toggle"); toggle.classList.remove("focus"); toggle.blur(); return klass3[0].querySelector(".dropdown-menu").style.display = ""; }; })(klass2); } var exitBtn = window.document.querySelector("#exitBtn"); exitBtn.onclick = function(e3) { if((main.personal.group & 1) != 0) { main.send({ type : "Logout"}); } else { window.document.querySelector("#guestname").focus(); } exitBtn.blur(); client_Buttons.hideMenus(); return; }; var synchThresholdBtn = window.document.querySelector("#synchThresholdBtn"); synchThresholdBtn.onclick = function(e4) { var secs = main.settings.synchThreshold + 1; if(secs > 5) { secs = 1; } main.setSynchThreshold(secs); client_Buttons.updateSynchThresholdBtn(main); synchThresholdBtn.blur(); return; }; synchThresholdBtn.innerText += ": " + main.settings.synchThreshold + "s"; var swapLayoutBtn = window.document.querySelector("#swapLayoutBtn"); swapLayoutBtn.onclick = function(e5) { var p = window.document.querySelector("#main"); p.insertBefore(p.children[2],p.children[0]); p.insertBefore(p.children[2],p.children[1]); var p1 = window.document.querySelector("#controlsrow"); p1.insertBefore(p1.children[1],p1.children[0]); var p2 = window.document.querySelector("#playlistrow"); p2.insertBefore(p2.children[1],p2.children[0]); var tmp = window.document.querySelector("#main").firstElementChild; var tmp1 = window.document.querySelector("#videowrap"); client_Buttons.settings.isSwapped = tmp == tmp1; client_Settings.write(client_Buttons.settings); client_Buttons.initSplit(); swapLayoutBtn.blur(); client_Buttons.hideMenus(); return; }; if(client_Buttons.settings.isSwapped) { swapLayoutBtn.onclick(); } var removeBtn = window.document.querySelector("#removeVideoBtn"); removeBtn.onclick = function(e6) { if(main.toggleVideoElement() || main.isListEmpty()) { removeBtn.innerText = Lang.get("removeVideo"); } else { removeBtn.innerText = Lang.get("addVideo"); } removeBtn.blur(); client_Buttons.hideMenus(); return; }; }; client_Buttons.hideMenus = function() { var menus = window.document.querySelectorAll(".dropdown-menu"); var _g = 0; while(_g < menus.length) menus[_g++].style.display = ""; }; client_Buttons.updateSynchThresholdBtn = function(main) { var tmp = "" + Lang.get("synchThreshold") + ": " + main.settings.synchThreshold; window.document.querySelector("#synchThresholdBtn").innerText = tmp + "s"; }; client_Buttons.initChatInput = function(main) { var guestName = window.document.querySelector("#guestname"); guestName.onkeydown = function(e) { if(e.keyCode == 13) { main.guestLogin(guestName.value); } return; }; var guestPass = window.document.querySelector("#guestpass"); guestPass.onkeydown = function(e1) { if(e1.keyCode == 13) { main.userLogin(guestName.value,guestPass.value); guestPass.value = ""; } return; }; new client_InputWithHistory(window.document.querySelector("#chatline"),null,50,function(value) { main.send({ type : "Message", message : { clientName : "", text : value}}); return true; }); }; var client_InputWithHistory = function(element,history,maxItems,onEnter) { this.historyId = -1; this.element = element; if(history != null) { this.history = history; } else { this.history = []; } this.maxItems = maxItems; this.onEnter = onEnter; element.onkeydown = $bind(this,this.onKeyDown); }; client_InputWithHistory.__name__ = true; client_InputWithHistory.prototype = { onKeyDown: function(e) { switch(e.keyCode) { case 13: if(this.element.value.length == 0) { return; } if(this.onEnter(this.element.value)) { this.history.push(this.element.value); } if(this.history.length > this.maxItems) { this.history.shift(); } this.historyId = -1; this.element.value = ""; break; case 38: this.historyId--; if(this.historyId == -2) { this.historyId = this.history.length - 1; if(this.historyId == -1) { return; } } else if(this.historyId == -1) { this.historyId++; } this.element.value = this.history[this.historyId]; break; case 40: if(this.historyId == -1) { return; } this.historyId++; if(this.historyId > this.history.length - 1) { this.historyId = -1; this.element.value = ""; return; } this.element.value = this.history[this.historyId]; break; } } }; var client_Main = function(host,port) { this.matchNumbers = new EReg("^-?[0-9]+$",""); this.mask = new EReg("\\${([0-9]+)-([0-9]+)}","g"); this.isConnected = false; this.personal = new Client("Unknown",0); this.filters = []; this.globalIp = ""; this.pageTitle = window.document.title; this.clients = []; this.isSyncActive = true; var _gthis = this; this.player = new client_Player(this); if(host == null) { host = window.location.hostname; } if(host == "") { host = "localhost"; } this.host = host; if(port == null) { port = window.location.port; } if(port == "") { port = "80"; } client_Settings.init({ version : 1, name : "", hash : "", isExtendedPlayer : false, chatSize : 40, playerSize : 60, synchThreshold : 2, isSwapped : false, isUserListHidden : false, latestLinks : []}); this.settings = client_Settings.read(); this.initListeners(); this.onTimeGet = new haxe_Timer(this.settings.synchThreshold * 1000); this.onTimeGet.run = $bind(this,this.requestTime); window.document.onvisibilitychange = function() { if(!window.document.hidden && _gthis.onBlinkTab != null) { window.document.title = _gthis.getPageTitle(); _gthis.onBlinkTab.stop(); _gthis.onBlinkTab = null; } return; }; Lang.init("langs",function() { _gthis.openWebSocket(host,port); return; }); }; client_Main.__name__ = true; client_Main.main = function() { new client_Main(); }; client_Main.prototype = { requestTime: function() { if(!this.isSyncActive) { return; } if(this.player.isListEmpty()) { return; } this.send({ type : "GetTime"}); } ,openWebSocket: function(host,port) { var _gthis = this; var protocol = "ws:"; if(window.location.protocol == "https:") { protocol = "wss:"; } this.ws = new WebSocket("" + protocol + "//" + host + ":" + port); this.ws.onmessage = $bind(this,this.onMessage); this.ws.onopen = function() { _gthis.serverMessage(1); return _gthis.isConnected = true; }; this.ws.onclose = function() { if(_gthis.isConnected) { _gthis.serverMessage(2); } _gthis.isConnected = false; _gthis.player.pause(); return haxe_Timer.delay(function() { _gthis.openWebSocket(host,port); return; },2000); }; } ,initListeners: function() { var _gthis = this; client_Buttons.init(this); client_MobileView.init(); window.document.querySelector("#leader_btn").onclick = function(e) { _gthis.setLeaderButton((_gthis.personal.group & 2) == 0); _gthis.send({ type : "SetLeader", setLeader : { clientName : (_gthis.personal.group & 2) != 0 ? "" : _gthis.personal.name}}); return; }; window.document.querySelector("#voteskip").onclick = function(e1) { if(client_Utils.isTouch() && !window.confirm(Lang.get("skipItemConfirm"))) { return; } if(_gthis.player.isListEmpty()) { return; } _gthis.send({ type : "SkipVideo", skipVideo : { url : _gthis.player.getItems()[_gthis.player.getItemPos()].url}}); return; }; window.document.querySelector("#queue_next").onclick = function(e2) { _gthis.addVideoUrl(false); return; }; window.document.querySelector("#queue_end").onclick = function(e3) { _gthis.addVideoUrl(true); return; }; new client_InputWithHistory(window.document.querySelector("#mediaurl"),this.settings.latestLinks,10,function(value) { _gthis.addVideoUrl(true); return false; }); window.document.querySelector("#ce_queue_next").onclick = function(e4) { _gthis.addIframe(false); return; }; window.document.querySelector("#ce_queue_end").onclick = function(e5) { _gthis.addIframe(true); return; }; window.document.querySelector("#customembed-title").onkeydown = function(e6) { if(e6.keyCode == 13) { _gthis.addIframe(true); e6.preventDefault(); } return; }; window.document.querySelector("#customembed-content").onkeydown = window.document.querySelector("#customembed-title").onkeydown; } ,handleUrlMasks: function(links) { var _g = 0; while(_g < links.length) { var link = links[_g]; ++_g; if(!this.mask.match(link)) { continue; } var start = Std.parseInt(this.mask.matched(1)); var end = Std.parseInt(this.mask.matched(2)); if(Math.abs(start - end) > 100) { continue; } var step = end > start ? -1 : 1; var i = links.indexOf(link); HxOverrides.remove(links,link); while(end != start + step) { var x = link.replace(this.mask.r,"" + end); links.splice(i,0,x); end += step; } } } ,addVideoUrl: function(atEnd) { var mediaUrl = window.document.querySelector("#mediaurl"); var isTemp = window.document.querySelector("#addfromurl").querySelector(".add-temp").checked; var url = mediaUrl.value; if(url.length == 0) { return; } mediaUrl.value = ""; this.settings.latestLinks.push(url); client_Settings.write(this.settings); var _this_r = new RegExp(", ?(https?)","g".split("u").join("")); var links = url.replace(_this_r,"|$1").split("|"); this.handleUrlMasks(links); if(!atEnd) { var first = null; if(this.player.isListEmpty()) { first = links.shift(); } links.reverse(); if(this.player.isListEmpty()) { links.unshift(first); } } this.addVideoArray(links,atEnd,isTemp); } ,addVideoArray: function(links,atEnd,isTemp) { var _gthis = this; if(links.length == 0) { return; } this.addVideo(links.shift(),atEnd,isTemp,function() { _gthis.addVideoArray(links,atEnd,isTemp); return; }); } ,addVideo: function(url,atEnd,isTemp,callback) { var _gthis = this; var protocol = window.location.protocol; if(StringTools.startsWith(url,"/")) { url = "" + protocol + "//" + window.location.hostname + ":" + window.location.port + url; } if(!StringTools.startsWith(url,"http")) { url = "" + protocol + "//" + url; } this.player.getVideoData(url,function(data) { if(data.duration == 0) { var tmp = Lang.get("addVideoError"); _gthis.serverMessage(4,tmp); return; } if(data.title == null) { data.title = Lang.get("rawVideo"); } if(data.url == null) { data.url = url; } _gthis.send({ type : "AddVideo", addVideo : { item : { url : data.url, title : data.title, author : _gthis.personal.name, duration : data.duration, isTemp : isTemp, isIframe : false}, atEnd : atEnd}}); callback(); return; }); } ,addIframe: function(atEnd) { var iframeCode = window.document.querySelector("#customembed-content"); var iframe = iframeCode.value; if(iframe.length == 0) { return; } iframeCode.value = ""; var mediaName = window.document.querySelector("#customembed-title"); var name = mediaName.value.length == 0 ? "Custom Media" : mediaName.value; mediaName.value = ""; var isTemp = window.document.querySelector("#customembed").querySelector(".add-temp").checked; this.send({ type : "AddVideo", addVideo : { item : { url : iframe, title : name, author : this.personal.name, duration : 356400, isTemp : isTemp, isIframe : true}, atEnd : atEnd}}); } ,toggleVideoElement: function() { if(this.player.hasVideo()) { this.player.removeVideo(); } else if(!this.player.isListEmpty()) { this.player.setVideo(this.player.getItemPos()); } return this.player.hasVideo(); } ,isListEmpty: function() { return this.player.isListEmpty(); } ,refreshPlayer: function() { this.player.refresh(); } ,getPlaylistLinks: function() { var _g = []; var _g1 = 0; var _g2 = this.player.getItems(); while(_g1 < _g2.length) _g.push(_g2[_g1++].url); return _g; } ,tryLocalIp: function(url) { if(this.host == this.globalIp) { return url; } return StringTools.replace(url,this.globalIp,this.host); } ,onMessage: function(e) { var data = JSON.parse(e.data); var t = data.type; var t1 = t.charAt(0).toLowerCase() + HxOverrides.substr(t,1,null); haxe_Log.trace("Event: " + data.type,{ fileName : "src/client/Main.hx", lineNumber : 303, className : "client.Main", methodName : "onMessage", customParams : [data[t1]]}); switch(data.type) { case "AddVideo": this.player.addVideoItem(data.addVideo.item,data.addVideo.atEnd); if(this.player.itemsLength() == 1) { this.player.setVideo(0); } break; case "ClearChat": this.clearChat(); break; case "ClearPlaylist": this.player.clearItems(); if(this.player.isListEmpty()) { this.player.pause(); } break; case "Connected": this.onConnected(data); this.onTimeGet.run(); break; case "GetTime": if(data.getTime.paused == null) { data.getTime.paused = false; } if(data.getTime.rate == null) { data.getTime.rate = 1; } if(this.player.getPlaybackRate() != data.getTime.rate) { this.player.setPlaybackRate(data.getTime.rate); } var newTime = data.getTime.time; var time = this.player.getTime(); if((this.personal.group & 1 << ClientGroup.Leader._hx_index) != 0) { if(Math.abs(time - newTime) < this.settings.synchThreshold) { return; } this.player.setTime(time,false); return; } if(this.player.getDuration() < this.player.getTime()) { return; } if(!data.getTime.paused) { this.player.play(); } else { this.player.pause(); } if(Math.abs(time - newTime) < this.settings.synchThreshold) { return; } this.player.setTime(newTime); break; case "Login": this.onLogin(data.login.clients,data.login.clientName); break; case "LoginError": this.settings.name = ""; this.settings.hash = ""; client_Settings.write(this.settings); this.showGuestLoginPanel(); break; case "Logout": this.updateClients(data.logout.clients); this.personal = new Client(data.logout.clientName,0); this.settings.name = ""; this.settings.hash = ""; client_Settings.write(this.settings); this.showGuestLoginPanel(); break; case "Message": this.addMessage(data.message.clientName,data.message.text); break; case "PasswordRequest": this.showGuestPasswordPanel(); break; case "Pause": if((this.personal.group & 1 << ClientGroup.Leader._hx_index) != 0) { return; } this.player.pause(); this.player.setTime(data.pause.time); break; case "Play": if((this.personal.group & 1 << ClientGroup.Leader._hx_index) != 0) { return; } this.player.setTime(data.play.time); this.player.play(); break; case "PlayItem": this.player.setVideo(data.playItem.pos); break; case "RemoveVideo": this.player.removeItem(data.removeVideo.url); if(this.player.isListEmpty()) { this.player.pause(); } break; case "Rewind": this.player.setTime(data.rewind.time); break; case "ServerMessage": var id = data.serverMessage.textId; var text = id == "usernameError" ? StringTools.replace(Lang.get(id),"$MAX","" + this.config.maxLoginLength) : Lang.get(id); this.serverMessage(4,text); break; case "SetLeader": ClientTools.setLeader(this.clients,data.setLeader.clientName); this.updateUserList(); this.setLeaderButton((this.personal.group & 1 << ClientGroup.Leader._hx_index) != 0); if((this.personal.group & 1 << ClientGroup.Leader._hx_index) != 0) { this.player.setTime(this.player.getTime(),false); } break; case "SetNextItem": this.player.setNextItem(data.setNextItem.pos); break; case "SetRate": if((this.personal.group & 1 << ClientGroup.Leader._hx_index) != 0) { return; } this.player.setPlaybackRate(data.setRate.rate); break; case "SetTime": var newTime1 = data.setTime.time; var time1 = this.player.getTime(); if(Math.abs(time1 - newTime1) < this.settings.synchThreshold) { return; } this.player.setTime(newTime1); break; case "ShufflePlaylist": break; case "SkipVideo": this.player.skipItem(data.skipVideo.url); if(this.player.isListEmpty()) { this.player.pause(); } break; case "ToggleItemType": this.player.toggleItemType(data.toggleItemType.pos); break; case "TogglePlaylistLock": this.setPlaylistLock(data.togglePlaylistLock.isOpen); break; case "UpdateClients": this.updateClients(data.updateClients.clients); this.personal = ClientTools.getByName(this.clients,this.personal.name,this.personal); break; case "UpdatePlaylist": this.player.setItems(data.updatePlaylist.videoList); break; case "VideoLoaded": this.player.setTime(0); this.player.play(); break; } } ,onConnected: function(data) { var connected = data.connected; this.globalIp = connected.globalIp; this.setConfig(connected.config); if(connected.isUnknownClient) { this.updateClients(connected.clients); this.personal = ClientTools.getByName(this.clients,connected.clientName,this.personal); this.showGuestLoginPanel(); } else { this.onLogin(connected.clients,connected.clientName); } var guestName = window.document.querySelector("#guestname"); var name = this.settings.name; if(name.length == 0) { name = guestName.value; } var hash = this.settings.hash; if(hash.length > 0) { this.loginRequest(name,hash); } else { this.guestLogin(name); } this.setLeaderButton((this.personal.group & 2) != 0); this.setPlaylistLock(connected.isPlaylistOpen); this.clearChat(); this.serverMessage(1); var _g = 0; var _g1 = connected.history; while(_g < _g1.length) { var message = _g1[_g]; ++_g; this.addMessage(message.name,message.text,message.time); } this.player.setItems(connected.videoList,connected.itemPos); } ,guestLogin: function(name) { if(name.length == 0) { return; } this.send({ type : "Login", login : { clientName : name}}); this.settings.name = name; client_Settings.write(this.settings); } ,userLogin: function(name,password) { if(this.config.salt == null) { return; } if(password.length == 0) { return; } if(name.length == 0) { return; } var hash = haxe_crypto_Sha256.encode(password + this.config.salt); this.loginRequest(name,hash); this.settings.hash = hash; client_Settings.write(this.settings); } ,loginRequest: function(name,hash) { this.send({ type : "Login", login : { clientName : name, passHash : hash}}); } ,setConfig: function(config) { this.config = config; this.pageTitle = config.channelName; window.document.querySelector("#guestname").maxLength = config.maxLoginLength; window.document.querySelector("#chatline").maxLength = config.maxMessageLength; this.filters.length = 0; var _g = 0; var _g1 = config.filters; while(_g < _g1.length) { var filter = _g1[_g]; ++_g; this.filters.push({ regex : new EReg(filter.regex,filter.flags), replace : filter.replace}); } var _g2 = 0; var _g3 = config.emotes; while(_g2 < _g3.length) { var emote = _g3[_g2]; ++_g2; var tag = StringTools.endsWith(emote.image,"mp4") ? "video autoplay=\"\" loop=\"\"" : "img"; this.filters.push({ regex : new EReg("(^| )" + this.escapeRegExp(emote.name) + "(?!\\S)","g"), replace : "$1<" + tag + " class=\"channel-emote\" src=\"" + emote.image + "\" title=\"" + emote.name + "\"/>"}); } window.document.querySelector("#smilesbtn").classList.remove("active"); var smilesWrap = window.document.querySelector("#smileswrap"); smilesWrap.style.display = "none"; smilesWrap.onclick = function(e) { var el = e.target; var form = window.document.querySelector("#chatline"); form.value += " " + el.title; form.focus(); return; }; smilesWrap.textContent = ""; var _g4 = 0; var _g5 = config.emotes; while(_g4 < _g5.length) { var emote1 = _g5[_g4]; ++_g4; var tag1 = StringTools.endsWith(emote1.image,"mp4") ? "video" : "img"; var el1 = window.document.createElement(tag1); el1.className = "smile-preview"; el1.dataset.src = emote1.image; el1.title = emote1.name; smilesWrap.appendChild(el1); } } ,onLogin: function(data,clientName) { this.updateClients(data); var newPersonal = ClientTools.getByName(this.clients,clientName); if(newPersonal == null) { return; } this.personal = newPersonal; this.hideGuestLoginPanel(); } ,showGuestLoginPanel: function() { window.document.querySelector("#guestlogin").style.display = "block"; window.document.querySelector("#guestpassword").style.display = "none"; window.document.querySelector("#chatline").style.display = "none"; window.document.querySelector("#exitBtn").textContent = Lang.get("login"); window.dispatchEvent(new Event("resize")); } ,hideGuestLoginPanel: function() { window.document.querySelector("#guestlogin").style.display = "none"; window.document.querySelector("#guestpassword").style.display = "none"; window.document.querySelector("#chatline").style.display = "block"; window.document.querySelector("#exitBtn").textContent = Lang.get("exit"); if((this.personal.group & 4) != 0) { window.document.querySelector("#clearchatbtn").style.display = "inline-block"; } window.dispatchEvent(new Event("resize")); } ,showGuestPasswordPanel: function() { window.document.querySelector("#guestlogin").style.display = "none"; window.document.querySelector("#chatline").style.display = "none"; window.document.querySelector("#guestpassword").style.display = "block"; window.document.querySelector("#guestpass").type = "password"; window.document.querySelector("#guestpass_icon").classList.add("glyphicon-eye-open"); window.document.querySelector("#guestpass_icon").classList.remove("glyphicon-eye-close"); } ,updateClients: function(newClients) { this.clients.length = 0; var _g = 0; while(_g < newClients.length) this.clients.push(Client.fromData(newClients[_g++])); this.updateUserList(); } ,send: function(data) { if(!this.isConnected) { return; } this.ws.send(JSON.stringify(data)); } ,serverMessage: function(type,text,isText) { if(isText == null) { isText = true; } var msgBuf = window.document.querySelector("#messagebuffer"); var div = window.document.createElement("div"); var time = "[" + HxOverrides.dateStr(new Date()).split(" ")[1] + "] "; switch(type) { case 1: div.className = "server-msg-reconnect"; div.textContent = Lang.get("msgConnected"); break; case 2: div.className = "server-msg-disconnect"; div.textContent = Lang.get("msgDisconnected"); break; case 3: div.className = "server-whisper"; div.textContent = time + text + " " + Lang.get("entered"); break; case 4: div.className = "server-whisper"; if(isText) { div.textContent = time + text; } else { div.innerHTML = time + text; } break; default: } msgBuf.appendChild(div); msgBuf.scrollTop = msgBuf.scrollHeight; } ,updateUserList: function() { window.document.querySelector("#usercount").textContent = this.clients.length + " " + Lang.get("online"); window.document.title = this.getPageTitle(); var list_b = ""; var _g = 0; var _g1 = this.clients; while(_g < _g1.length) { var client1 = _g1[_g]; ++_g; list_b += "
"; if((client1.group & 2) != 0) { list_b += ""; } list_b += Std.string("" + client1.name + "
"); } window.document.querySelector("#userlist").innerHTML = list_b; } ,getPageTitle: function() { return "" + this.pageTitle + " (" + this.clients.length + ")"; } ,clearChat: function() { window.document.querySelector("#messagebuffer").textContent = ""; } ,addMessage: function(name,text,time) { var _gthis = this; var msgBuf = window.document.querySelector("#messagebuffer"); var userDiv = window.document.createElement("div"); userDiv.className = "chat-msg-" + name; var tstamp = window.document.createElement("span"); tstamp.className = "timestamp"; if(time == null) { time = "[" + HxOverrides.dateStr(new Date()).split(" ")[1] + "] "; } tstamp.textContent = time; var nameDiv = window.document.createElement("strong"); nameDiv.className = "username"; nameDiv.textContent = name + ": "; var textDiv = window.document.createElement("span"); text = StringTools.htmlEscape(text); if(StringTools.startsWith(text,"/")) { if(name == this.personal.name) { this.handleCommands(HxOverrides.substr(text,1,null)); } } else { var _g = 0; var _g1 = this.filters; while(_g < _g1.length) { var filter = _g1[_g]; ++_g; text = text.replace(filter.regex.r,filter.replace); } } textDiv.innerHTML = text; var isInChatEnd = msgBuf.scrollTop + msgBuf.clientHeight >= msgBuf.scrollHeight - 1; userDiv.appendChild(tstamp); userDiv.appendChild(nameDiv); userDiv.appendChild(textDiv); msgBuf.appendChild(userDiv); if(isInChatEnd) { while(msgBuf.children.length > 200) msgBuf.removeChild(msgBuf.firstChild); msgBuf.scrollTop = msgBuf.scrollHeight; } if(name == this.personal.name) { msgBuf.scrollTop = msgBuf.scrollHeight; } if(window.document.hidden && this.onBlinkTab == null) { this.onBlinkTab = new haxe_Timer(1000); this.onBlinkTab.run = function() { if(StringTools.startsWith(window.document.title,_gthis.pageTitle)) { return window.document.title = "*Chat*"; } else { return window.document.title = _gthis.getPageTitle(); } }; this.onBlinkTab.run(); } } ,handleCommands: function(text) { if(text == "clear") { if((this.personal.group & 4) != 0) { this.send({ type : "ClearChat"}); } } if(this.matchNumbers.match(text)) { this.send({ type : "Rewind", rewind : { time : Std.parseInt(text)}}); } } ,setLeaderButton: function(flag) { var leaderBtn = window.document.querySelector("#leader_btn"); if(flag) { leaderBtn.classList.add("label-success"); } else { leaderBtn.classList.remove("label-success"); } } ,setPlaylistLock: function(isOpen) { var lockPlaylist = window.document.querySelector("#lockplaylist"); var icon = lockPlaylist.firstElementChild; if(isOpen) { lockPlaylist.title = Lang.get("playlistOpen"); lockPlaylist.classList.add("btn-success"); lockPlaylist.classList.remove("btn-danger"); icon.classList.add("glyphicon-ok"); icon.classList.remove("glyphicon-lock"); } else { lockPlaylist.title = Lang.get("playlistLocked"); lockPlaylist.classList.add("btn-danger"); lockPlaylist.classList.remove("btn-success"); icon.classList.add("glyphicon-lock"); icon.classList.remove("glyphicon-ok"); } } ,setSynchThreshold: function(s) { this.onTimeGet.stop(); this.onTimeGet = new haxe_Timer(s * 1000); this.onTimeGet.run = $bind(this,this.requestTime); this.settings.synchThreshold = s; client_Settings.write(this.settings); } ,getTemplateUrl: function() { return this.config.templateUrl; } ,getYoutubeApiKey: function() { return this.config.youtubeApiKey; } ,escapeRegExp: function(regex) { var _this_r = new RegExp("([.*+?^${}()|[\\]\\\\])","g".split("u").join("")); return regex.replace(_this_r,"\\$1"); } }; var client_MobileView = function() { }; client_MobileView.__name__ = true; client_MobileView.init = function() { var mvbtn = window.document.querySelector("#mv_btn"); mvbtn.onclick = function(e) { var hasMobileView = client_Utils.toggleFullScreen(window.document.documentElement); var vwrap = window.document.querySelector("#videowrap"); if(hasMobileView) { window.document.body.classList.add("mobile-view"); mvbtn.classList.add("active"); if(vwrap.children[0].id == "currenttitle") { vwrap.appendChild(vwrap.children[0]); } } else { window.document.body.classList.remove("mobile-view"); mvbtn.classList.remove("active"); if(vwrap.children[0].id != "currenttitle") { vwrap.insertBefore(vwrap.children[1],vwrap.children[0]); } } return; }; }; var client_Player = function(main) { this.skipSetRate = false; this.skipSetTime = false; this.isLoaded = false; this.itemPos = 0; this.currentSrc = ""; this.playerEl = window.document.querySelector("#ytapiplayer"); this.videoItemsEl = window.document.querySelector("#queue"); this.items = _$VideoList_VideoList_$Impl_$._new(); this.main = main; this.players = [new client_players_Youtube(main,this)]; this.iframePlayer = new client_players_Iframe(main,this); this.rawPlayer = new client_players_Raw(main,this); this.initItemButtons(); }; client_Player.__name__ = true; client_Player.prototype = { initItemButtons: function() { var _gthis = this; window.document.querySelector("#queue").onclick = function(e) { var btn = e.target; var item = btn.parentElement.parentElement; var i = client_Utils.getIndex(item.parentElement,item); if(btn.classList.contains("qbtn-play")) { _gthis.main.send({ type : "PlayItem", playItem : { pos : i}}); } if(btn.classList.contains("qbtn-next")) { _gthis.main.send({ type : "SetNextItem", setNextItem : { pos : i}}); } if(btn.classList.contains("qbtn-tmp")) { _gthis.main.send({ type : "ToggleItemType", toggleItemType : { pos : i}}); } if(btn.classList.contains("qbtn-delete")) { _gthis.main.send({ type : "RemoveVideo", removeVideo : { url : item.querySelector(".qe_title").getAttribute("href")}}); } return; }; } ,setNextItem: function(pos) { _$VideoList_VideoList_$Impl_$.setNextItem(this.items,pos,this.itemPos); var next = this.videoItemsEl.children[pos]; this.videoItemsEl.removeChild(next); client_Utils.insertAtIndex(this.videoItemsEl,next,this.itemPos + 1); } ,toggleItemType: function(pos) { _$VideoList_VideoList_$Impl_$.toggleItemType(this.items,pos); this.setItemElementType(this.videoItemsEl.children[pos],this.items[pos].isTemp); } ,setPlayer: function(newPlayer) { if(this.player != null && this.player != newPlayer) { this.player.removeVideo(); } this.player = newPlayer; } ,getVideoData: function(url,callback) { var player = Lambda.find(this.players,function(player1) { return player1.isSupportedLink(url); }); if(player == null) { player = this.rawPlayer; } player.getVideoData(url,callback); } ,setVideo: function(i) { if(!this.main.isSyncActive) { return; } var item = this.items[i]; var currentPlayer = Lambda.find(this.players,function(p) { return p.isSupportedLink(item.url); }); if(currentPlayer != null) { this.setPlayer(currentPlayer); } else if(item.isIframe) { this.setPlayer(this.iframePlayer); } else { this.setPlayer(this.rawPlayer); } var childs = this.videoItemsEl.children; if(childs[this.itemPos] != null) { childs[this.itemPos].classList.remove("queue_active"); } this.itemPos = i; childs[this.itemPos].classList.add("queue_active"); this.currentSrc = item.url; this.isLoaded = false; this.player.loadVideo(item); window.document.querySelector("#currenttitle").textContent = item.title; } ,removeVideo: function() { this.currentSrc = ""; this.player.removeVideo(); window.document.querySelector("#currenttitle").textContent = Lang.get("nothingPlaying"); } ,onCanBePlayed: function() { if(!this.isLoaded) { this.main.send({ type : "VideoLoaded"}); } this.isLoaded = true; } ,onPlay: function() { if((this.main.personal.group & 2) == 0) { return; } this.main.send({ type : "Play", play : { time : this.getTime()}}); } ,onPause: function() { if((this.main.personal.group & 2) == 0) { return; } this.main.send({ type : "Pause", pause : { time : this.getTime()}}); } ,onSetTime: function() { if(this.skipSetTime) { this.skipSetTime = false; return; } if((this.main.personal.group & 2) == 0) { return; } this.main.send({ type : "SetTime", setTime : { time : this.getTime()}}); } ,onRateChange: function() { if(this.skipSetRate) { this.skipSetRate = false; return; } if((this.main.personal.group & 2) == 0) { return; } this.main.send({ type : "SetRate", setRate : { rate : this.getPlaybackRate()}}); } ,addVideoItem: function(item,atEnd) { var url = StringTools.htmlEscape(item.url,true); var itemEl = this.nodeFromString("
  • \n\t\t\t\t" + StringTools.htmlEscape(item.title) + "\n\t\t\t\t" + this.duration(item.duration) + "\n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
    \n\t\t\t
  • "); _$VideoList_VideoList_$Impl_$.addItem(this.items,item,atEnd,this.itemPos); this.setItemElementType(itemEl,item.isTemp); if(atEnd) { this.videoItemsEl.appendChild(itemEl); } else { client_Utils.insertAtIndex(this.videoItemsEl,itemEl,this.itemPos + 1); } this.updateCounters(); } ,setItemElementType: function(item,isTemp) { var text = isTemp ? Lang.get("makePermanent") : Lang.get("makeTemporary"); item.querySelector(".qbtn-tmp").innerHTML = "" + text; if(isTemp) { item.classList.add("queue_temp"); } else { item.classList.remove("queue_temp"); } } ,removeItem: function(url) { this.removeElementItem(url); var index = _$VideoList_VideoList_$Impl_$.findIndex(this.items,function(item) { return item.url == url; }); if(index == -1) { return; } var isCurrent = this.items[this.itemPos].url == url; this.itemPos = _$VideoList_VideoList_$Impl_$.removeItem(this.items,index,this.itemPos); this.updateCounters(); if(isCurrent && this.items.length > 0) { this.setVideo(this.itemPos); } } ,removeElementItem: function(url) { var _g = 0; var _g1 = this.videoItemsEl.children; while(_g < _g1.length) { var child = _g1[_g]; ++_g; if(child.querySelector(".qe_title").getAttribute("href") == url) { this.videoItemsEl.removeChild(child); break; } } } ,skipItem: function(url) { var index = _$VideoList_VideoList_$Impl_$.findIndex(this.items,function(item) { return item.url == url; }); if(index == -1) { return; } if(this.items[index].isTemp) { this.removeElementItem(url); } index = _$VideoList_VideoList_$Impl_$.skipItem(this.items,index); this.updateCounters(); if(this.items.length == 0) { return; } this.setVideo(index); } ,updateCounters: function() { var tmp = "" + this.items.length + " "; var tmp1 = Lang.get("videos"); window.document.querySelector("#plcount").textContent = tmp + tmp1; window.document.querySelector("#pllength").textContent = this.totalDuration(); } ,getItems: function() { return this.items; } ,setItems: function(list,pos) { this.clearItems(); if(pos != null) { this.itemPos = pos; } if(list.length == 0) { return; } var _g = 0; while(_g < list.length) this.addVideoItem(list[_g++],true); if(this.currentSrc != this.items[this.itemPos].url) { this.setVideo(this.itemPos); } else { this.videoItemsEl.children[this.itemPos].classList.add("queue_active"); } } ,clearItems: function() { this.items.length = 0; this.videoItemsEl.textContent = ""; this.updateCounters(); } ,refresh: function() { if(this.items.length == 0) { return; } this.removeVideo(); this.setVideo(this.itemPos); } ,duration: function(time) { var h = time / 60 / 60 | 0; var m = (time / 60 | 0) - h * 60; var s = time % 60 | 0; var time1 = "" + m + ":"; if(m < 10) { time1 = "0" + time1; } if(h > 0) { time1 = "" + h + ":" + time1; } if(s < 10) { time1 += "0"; } time1 += s; return time1; } ,totalDuration: function() { var time = 0.0; var _g = 0; var _g1 = this.items; while(_g < _g1.length) time += _g1[_g++].duration; return this.duration(time); } ,nodeFromString: function(div) { var wrapper = window.document.createElement("div"); wrapper.innerHTML = div; return wrapper.firstElementChild; } ,isListEmpty: function() { return this.items.length == 0; } ,itemsLength: function() { return this.items.length; } ,getItemPos: function() { return this.itemPos; } ,hasVideo: function() { return this.playerEl.children.length != 0; } ,play: function() { if(!this.main.isSyncActive) { return; } if(this.player == null) { return; } this.player.play(); } ,pause: function() { if(!this.main.isSyncActive) { return; } if(this.player == null) { return; } this.player.pause(); } ,getDuration: function() { if(this.itemPos >= this.items.length) { return 0; } return this.items[this.itemPos].duration; } ,getTime: function() { if(this.player == null) { return 0; } return this.player.getTime(); } ,setTime: function(time,isLocal) { if(isLocal == null) { isLocal = true; } if(!this.main.isSyncActive) { return; } if(this.player == null) { return; } this.skipSetTime = isLocal; this.player.setTime(time); } ,getPlaybackRate: function() { if(this.player == null) { return 1; } return this.player.getPlaybackRate(); } ,setPlaybackRate: function(rate,isLocal) { if(isLocal == null) { isLocal = true; } if(!this.main.isSyncActive) { return; } if(this.player == null) { return; } this.skipSetRate = isLocal; this.player.setPlaybackRate(rate); } }; var client_Settings = function() { }; client_Settings.__name__ = true; client_Settings.init = function(def,upd) { client_Settings.storage = js_Browser.getLocalStorage(); client_Settings.isSupported = client_Settings.storage != null; client_Settings.defaults = def; client_Settings.updater = upd; }; client_Settings.read = function() { if(!client_Settings.isSupported) { return client_Settings.defaults; } return client_Settings.checkData(JSON.parse(client_Settings.storage.getItem("data"))); }; client_Settings.checkData = function(data) { if(client_Settings.defaults == null) { throw new js__$Boot_HaxeError("read: default data is null"); } if(data == null) { return client_Settings.defaults; } if(data.version == client_Settings.defaults.version) { return data; } if(data.version > client_Settings.defaults.version) { throw new js__$Boot_HaxeError("read: current data version is larger than default data version"); } if(client_Settings.updater == null) { throw new js__$Boot_HaxeError("read: updater function is null"); } while(data.version < client_Settings.defaults.version) { data = client_Settings.updater(data,data.version); data.version++; } client_Settings.write(data); return data; }; client_Settings.write = function(data) { if(!client_Settings.isSupported) { return; } client_Settings.storage.setItem("data",JSON.stringify(data)); }; var client_Utils = function() { }; client_Utils.__name__ = true; client_Utils.isTouch = function() { return 'ontouchstart' in window; }; client_Utils.prepend = function(parent,child) { if(parent.firstChild == null) { parent.appendChild(child); } else { parent.insertBefore(child,parent.firstChild); } }; client_Utils.insertAtIndex = function(parent,child,i) { if(i >= parent.children.length) { parent.appendChild(child); } else { parent.insertBefore(child,parent.children[i]); } }; client_Utils.getIndex = function(parent,child) { var i = 0; var _g = 0; var _g1 = parent.children; while(_g < _g1.length) { if(_g1[_g++] == child) { break; } ++i; } return i; }; client_Utils.toggleFullScreen = function(el) { var state = true; var doc = window.document; var el2 = el; if(window.document.fullscreenElement == null && doc.mozFullScreenElement == null && doc.webkitFullscreenElement == null) { if(el.requestFullscreen != null) { el.requestFullscreen(); } else if(el2.mozRequestFullScreen != null) { el2.mozRequestFullScreen(); } else if(el2.webkitRequestFullscreen != null) { el2.webkitRequestFullscreen(HTMLElement.ALLOW_KEYBOARD_INPUT); } else { state = false; } } else { if(doc.cancelFullScreen != null) { doc.cancelFullScreen(); } else if(doc.mozCancelFullScreen != null) { doc.mozCancelFullScreen(); } else if(doc.webkitCancelFullScreen != null) { doc.webkitCancelFullScreen(); } state = false; } return state; }; client_Utils.copyToClipboard = function(text) { var clipboardData = window.clipboardData; if(clipboardData != null && clipboardData.setData != null) { clipboardData.setData("Text",text); return; } else if(window.document.queryCommandSupported != null) { var textarea = window.document.createElement("textarea"); textarea.textContent = text; textarea.style.position = "fixed"; window.document.body.appendChild(textarea); textarea.select(); window.document.execCommand("copy"); window.document.body.removeChild(textarea); } }; var client_players_Iframe = function(main,player) { this.playerEl = window.document.querySelector("#ytapiplayer"); this.main = main; this.player = player; }; client_players_Iframe.__name__ = true; client_players_Iframe.prototype = { isSupportedLink: function(url) { return true; } ,getVideoData: function(url,callback) { callback({ duration : 356400, title : "Custom Media"}); } ,loadVideo: function(item) { this.removeVideo(); this.video = window.document.createElement("div"); this.video.id = "videoplayer"; this.video.innerHTML = item.url; if(this.video.firstChild.nodeName != "IFRAME" && this.video.firstChild.nodeName != "OBJECT") { this.video = null; return; } if(this.video.firstChild.nodeName == "IFRAME") { this.video.setAttribute("sandbox","allow-scripts"); } this.playerEl.appendChild(this.video); } ,removeVideo: function() { if(this.video == null) { return; } this.playerEl.removeChild(this.video); this.video = null; } ,play: function() { } ,pause: function() { } ,getTime: function() { return 0; } ,setTime: function(time) { } ,getPlaybackRate: function() { return 1; } ,setPlaybackRate: function(rate) { } }; var client_players_Raw = function(main,player) { this.playAllowed = true; this.playerEl = window.document.querySelector("#ytapiplayer"); this.main = main; this.player = player; }; client_players_Raw.__name__ = true; client_players_Raw.prototype = { isSupportedLink: function(url) { return true; } ,getVideoData: function(url,callback) { var _gthis = this; var title = HxOverrides.substr(url,url.lastIndexOf("/") + 1,null); var matchName = new EReg("^(.+)\\.",""); if(matchName.match(title)) { title = matchName.matched(1); } else { title = Lang.get("rawVideo"); } var video = window.document.createElement("video"); video.src = url; video.onerror = function(e) { if(_gthis.playerEl.contains(video)) { _gthis.playerEl.removeChild(video); } callback({ duration : 0}); return; }; video.onloadedmetadata = function() { if(_gthis.playerEl.contains(video)) { _gthis.playerEl.removeChild(video); } callback({ duration : video.duration, title : title}); return; }; client_Utils.prepend(this.playerEl,video); } ,loadVideo: function(item) { var _gthis = this; var url = this.main.tryLocalIp(item.url); if(this.video != null) { this.video.src = url; return; } this.video = window.document.createElement("video"); this.video.id = "videoplayer"; this.video.src = url; this.video.controls = true; if(this.controlsHider != null) { this.controlsHider.stop(); } if(!client_Utils.isTouch()) { this.controlsHider = haxe_Timer.delay(function() { return _gthis.video.controls = false; },3000); } this.video.onmousemove = function(e) { if(_gthis.controlsHider != null) { _gthis.controlsHider.stop(); } _gthis.video.controls = true; return _gthis.video.onmousemove = null; }; this.video.oncanplaythrough = ($_=this.player,$bind($_,$_.onCanBePlayed)); this.video.onseeking = ($_=this.player,$bind($_,$_.onSetTime)); this.video.onplay = function(e1) { _gthis.playAllowed = true; _gthis.player.onPlay(); return; }; this.video.onpause = ($_=this.player,$bind($_,$_.onPause)); this.video.onratechange = ($_=this.player,$bind($_,$_.onRateChange)); this.playerEl.appendChild(this.video); } ,removeVideo: function() { if(this.video == null) { return; } this.playerEl.removeChild(this.video); this.video = null; } ,play: function() { var _gthis = this; if(this.video == null) { return; } if(!this.playAllowed) { return; } var promise = this.video.play(); if(promise == null) { return; } promise.catch(function(error) { return _gthis.playAllowed = false; }); } ,pause: function() { if(this.video == null) { return; } this.video.pause(); } ,getTime: function() { if(this.video == null) { return 0; } return this.video.currentTime; } ,setTime: function(time) { if(this.video == null) { return; } this.video.currentTime = time; } ,getPlaybackRate: function() { if(this.video == null) { return 1; } return this.video.playbackRate; } ,setPlaybackRate: function(rate) { if(this.video == null) { return; } this.video.playbackRate = rate; } }; var client_players_Youtube = function(main,player) { this.matchSeconds = new EReg("([0-9]+)S",""); this.matchMinutes = new EReg("([0-9]+)M",""); this.matchHours = new EReg("([0-9]+)H",""); this.isLoaded = false; this.playerEl = window.document.querySelector("#ytapiplayer"); this.urlVideoId = "?part=snippet&fields=items(snippet/resourceId/videoId)"; this.urlTitleDuration = "?part=snippet,contentDetails&fields=items(snippet/title,contentDetails/duration)"; this.playlistUrl = "https://www.googleapis.com/youtube/v3/playlistItems"; this.videosUrl = "https://www.googleapis.com/youtube/v3/videos"; this.matchPlaylist = new EReg("youtube\\.com.*list=([A-z0-9_-]+)",""); this.matchEmbed = new EReg("embed/([A-z0-9_-]+)",""); this.matchShort = new EReg("youtu.be/([A-z0-9_-]+)",""); this.matchId = new EReg("v=([A-z0-9_-]+)",""); this.main = main; this.player = player; }; client_players_Youtube.__name__ = true; client_players_Youtube.prototype = { isSupportedLink: function(url) { if(this.extractVideoId(url) == "") { return this.extractPlaylistId(url) != ""; } else { return true; } } ,extractVideoId: function(url) { if(url.indexOf("youtu.be/") != -1) { this.matchShort.match(url); return this.matchShort.matched(1); } if(url.indexOf("youtube.com/embed/") != -1) { this.matchEmbed.match(url); return this.matchEmbed.matched(1); } if(!this.matchId.match(url)) { return ""; } return this.matchId.matched(1); } ,extractPlaylistId: function(url) { if(!this.matchPlaylist.match(url)) { return ""; } return this.matchPlaylist.matched(1); } ,convertTime: function(duration) { var total = 0; var hours = this.matchHours.match(duration); var minutes = this.matchMinutes.match(duration); var seconds = this.matchSeconds.match(duration); if(hours) { total = Std.parseInt(this.matchHours.matched(1)) * 3600; } if(minutes) { total += Std.parseInt(this.matchMinutes.matched(1)) * 60; } if(seconds) { total += Std.parseInt(this.matchSeconds.matched(1)); } return total; } ,getVideoData: function(url,callback) { var _gthis = this; if(this.apiKey == null) { this.apiKey = this.main.getYoutubeApiKey(); } var id = this.extractVideoId(url); if(id == "") { this.getPlaylistVideoData(url,callback); return; } var http = new haxe_http_HttpJs("" + this.videosUrl + this.urlTitleDuration + "&id=" + id + "&key=" + this.apiKey); http.onData = function(data) { var json = JSON.parse(data); if(json.error != null) { _gthis.youtubeApiError(json.error); _gthis.getRemoteDataFallback(url,callback); return; } var items = json.items; if(items == null || items.length == 0) { callback({ duration : 0}); return; } var _g = 0; while(_g < items.length) { var item = items[_g]; ++_g; var title = item.snippet.title; var tmp = _gthis.convertTime(item.contentDetails.duration); callback({ duration : tmp, title : title, url : url}); } return; }; http.onError = function(msg) { _gthis.getRemoteDataFallback(url,callback); return; }; http.request(); } ,getPlaylistVideoData: function(url,callback) { var _gthis = this; var id = this.extractPlaylistId(url); var http = new haxe_http_HttpJs("" + this.playlistUrl + this.urlVideoId + "&maxResults=50&playlistId=" + id + "&key=" + this.apiKey); http.onData = function(data) { var json = JSON.parse(data); if(json.error != null) { _gthis.youtubeApiError(json.error); callback({ duration : 0}); return; } var items = json.items; if(items == null || items.length == 0) { callback({ duration : 0}); return; } var loadNextItem = null; loadNextItem = function() { var loadNextItem1 = "youtu.be/" + items.shift().snippet.resourceId.videoId; _gthis.getVideoData(loadNextItem1,function(data1) { callback(data1); if(items.length > 0) { loadNextItem(); } return; }); }; loadNextItem(); return; }; http.onError = function(msg) { callback({ duration : 0}); return; }; http.request(); } ,youtubeApiError: function(error) { this.main.serverMessage(4,"Error " + error.code + ": " + error.message,false); } ,getRemoteDataFallback: function(url,callback) { var _gthis = this; if(!js_youtube_Youtube.isLoadedAPI) { js_youtube_Youtube.init(function() { _gthis.getRemoteDataFallback(url,callback); return; }); return; } var video = window.document.createElement("div"); video.id = "temp-videoplayer"; client_Utils.prepend(this.playerEl,video); this.tempYoutube = new YT.Player(video.id,{ videoId : this.extractVideoId(url), playerVars : { modestbranding : 1, rel : 0, showinfo : 0}, events : { onReady : function(e) { if(_gthis.playerEl.contains(video)) { _gthis.playerEl.removeChild(video); } var tmp = _gthis.tempYoutube.getDuration(); callback({ duration : tmp}); return; }, onError : function(e1) { haxe_Log.trace("Error " + e1.data,{ fileName : "src/client/players/Youtube.hx", lineNumber : 171, className : "client.players.Youtube", methodName : "getRemoteDataFallback"}); if(_gthis.playerEl.contains(video)) { _gthis.playerEl.removeChild(video); } callback({ duration : 0}); return; }}}); } ,loadVideo: function(item) { var _gthis = this; if(!js_youtube_Youtube.isLoadedAPI) { js_youtube_Youtube.init(function() { _gthis.loadVideo(item); return; }); return; } if(this.youtube != null) { this.youtube.loadVideoById({ videoId : this.extractVideoId(item.url)}); return; } this.isLoaded = false; this.video = window.document.createElement("div"); this.video.id = "videoplayer"; this.playerEl.appendChild(this.video); this.youtube = new YT.Player(this.video.id,{ videoId : this.extractVideoId(item.url), playerVars : { autoplay : 1, modestbranding : 1, rel : 0, showinfo : 0}, events : { onReady : function(e) { _gthis.isLoaded = true; _gthis.youtube.pauseVideo(); return; }, onStateChange : function(e1) { switch(e1.data) { case -1: _gthis.player.onCanBePlayed(); break; case 0: break; case 1: _gthis.player.onPlay(); break; case 2: _gthis.player.onPause(); break; case 3: _gthis.player.onSetTime(); break; case 5: break; } return; }, onPlaybackRateChange : function(e2) { _gthis.player.onRateChange(); return; }}}); } ,removeVideo: function() { if(this.video == null) { return; } this.isLoaded = false; this.youtube.destroy(); this.youtube = null; if(this.playerEl.contains(this.video)) { this.playerEl.removeChild(this.video); } this.video = null; } ,play: function() { if(!this.isLoaded) { return; } this.youtube.playVideo(); } ,pause: function() { if(!this.isLoaded) { return; } this.youtube.pauseVideo(); } ,getTime: function() { if(!this.isLoaded) { return 0; } return this.youtube.getCurrentTime(); } ,setTime: function(time) { if(!this.isLoaded) { return; } this.youtube.seekTo(time,true); } ,getPlaybackRate: function() { if(!this.isLoaded) { return 1; } return this.youtube.getPlaybackRate(); } ,setPlaybackRate: function(rate) { if(!this.isLoaded) { return; } this.youtube.setPlaybackRate(rate); } }; var haxe_Log = function() { }; haxe_Log.__name__ = true; haxe_Log.formatOutput = function(v,infos) { var str = Std.string(v); if(infos == null) { return str; } var pstr = infos.fileName + ":" + infos.lineNumber; if(infos.customParams != null) { var _g = 0; var _g1 = infos.customParams; while(_g < _g1.length) str += ", " + Std.string(_g1[_g++]); } return pstr + ": " + str; }; haxe_Log.trace = function(v,infos) { var str = haxe_Log.formatOutput(v,infos); if(typeof(console) != "undefined" && console.log != null) { console.log(str); } }; var haxe_Timer = function(time_ms) { var me = this; this.id = setInterval(function() { me.run(); },time_ms); }; haxe_Timer.__name__ = true; haxe_Timer.delay = function(f,time_ms) { var t = new haxe_Timer(time_ms); t.run = function() { t.stop(); f(); }; return t; }; haxe_Timer.prototype = { stop: function() { if(this.id == null) { return; } clearInterval(this.id); this.id = null; } ,run: function() { } }; var haxe_crypto_Sha256 = function() { }; haxe_crypto_Sha256.__name__ = true; haxe_crypto_Sha256.encode = function(s) { var sh = new haxe_crypto_Sha256(); return sh.hex(sh.doEncode(haxe_crypto_Sha256.str2blks(s),s.length * 8)); }; haxe_crypto_Sha256.str2blks = function(s) { var s1 = haxe_io_Bytes.ofString(s); var nblk = (s1.length + 8 >> 6) + 1; var blks = []; var _g = 0; var _g1 = nblk * 16; while(_g < _g1) blks[_g++] = 0; var _g2 = 0; var _g3 = s1.length; while(_g2 < _g3) { var i = _g2++; blks[i >> 2] |= s1.b[i] << 24 - ((i & 3) << 3); } var i1 = s1.length; blks[i1 >> 2] |= 128 << 24 - ((i1 & 3) << 3); blks[nblk * 16 - 1] = s1.length * 8; return blks; }; haxe_crypto_Sha256.prototype = { doEncode: function(m,l) { var K = [1116352408,1899447441,-1245643825,-373957723,961987163,1508970993,-1841331548,-1424204075,-670586216,310598401,607225278,1426881987,1925078388,-2132889090,-1680079193,-1046744716,-459576895,-272742522,264347078,604807628,770255983,1249150122,1555081692,1996064986,-1740746414,-1473132947,-1341970488,-1084653625,-958395405,-710438585,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,-2117940946,-1838011259,-1564481375,-1474664885,-1035236496,-949202525,-778901479,-694614492,-200395387,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,-2067236844,-1933114872,-1866530822,-1538233109,-1090935817,-965641998]; var HASH = [1779033703,-1150833019,1013904242,-1521486534,1359893119,-1694144372,528734635,1541459225]; var W = []; W[64] = 0; var a; var b; var c; var d; var e; var f; var g; var h; var T1; var T2; m[l >> 5] |= 128 << 24 - l % 32; m[(l + 64 >> 9 << 4) + 15] = l; var i = 0; while(i < m.length) { a = HASH[0]; b = HASH[1]; c = HASH[2]; d = HASH[3]; e = HASH[4]; f = HASH[5]; g = HASH[6]; h = HASH[7]; var _g = 0; while(_g < 64) { var j = _g++; if(j < 16) { W[j] = m[j + i]; } else { var x = W[j - 2]; var x1 = (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ x >>> 10; var y = W[j - 7]; var lsw = (x1 & 65535) + (y & 65535); var x2 = (x1 >> 16) + (y >> 16) + (lsw >> 16) << 16 | lsw & 65535; var x3 = W[j - 15]; var y1 = (x3 >>> 7 | x3 << 25) ^ (x3 >>> 18 | x3 << 14) ^ x3 >>> 3; var lsw1 = (x2 & 65535) + (y1 & 65535); var x4 = (x2 >> 16) + (y1 >> 16) + (lsw1 >> 16) << 16 | lsw1 & 65535; var y2 = W[j - 16]; var lsw2 = (x4 & 65535) + (y2 & 65535); W[j] = (x4 >> 16) + (y2 >> 16) + (lsw2 >> 16) << 16 | lsw2 & 65535; } var y3 = (e >>> 6 | e << 26) ^ (e >>> 11 | e << 21) ^ (e >>> 25 | e << 7); var lsw3 = (h & 65535) + (y3 & 65535); var x5 = (h >> 16) + (y3 >> 16) + (lsw3 >> 16) << 16 | lsw3 & 65535; var y4 = e & f ^ ~e & g; var lsw4 = (x5 & 65535) + (y4 & 65535); var x6 = (x5 >> 16) + (y4 >> 16) + (lsw4 >> 16) << 16 | lsw4 & 65535; var y5 = K[j]; var lsw5 = (x6 & 65535) + (y5 & 65535); var x7 = (x6 >> 16) + (y5 >> 16) + (lsw5 >> 16) << 16 | lsw5 & 65535; var y6 = W[j]; var lsw6 = (x7 & 65535) + (y6 & 65535); T1 = (x7 >> 16) + (y6 >> 16) + (lsw6 >> 16) << 16 | lsw6 & 65535; var x8 = (a >>> 2 | a << 30) ^ (a >>> 13 | a << 19) ^ (a >>> 22 | a << 10); var y7 = a & b ^ a & c ^ b & c; var lsw7 = (x8 & 65535) + (y7 & 65535); T2 = (x8 >> 16) + (y7 >> 16) + (lsw7 >> 16) << 16 | lsw7 & 65535; h = g; g = f; f = e; var lsw8 = (d & 65535) + (T1 & 65535); e = (d >> 16) + (T1 >> 16) + (lsw8 >> 16) << 16 | lsw8 & 65535; d = c; c = b; b = a; var lsw9 = (T1 & 65535) + (T2 & 65535); a = (T1 >> 16) + (T2 >> 16) + (lsw9 >> 16) << 16 | lsw9 & 65535; } var y8 = HASH[0]; var lsw10 = (a & 65535) + (y8 & 65535); HASH[0] = (a >> 16) + (y8 >> 16) + (lsw10 >> 16) << 16 | lsw10 & 65535; var y9 = HASH[1]; var lsw11 = (b & 65535) + (y9 & 65535); HASH[1] = (b >> 16) + (y9 >> 16) + (lsw11 >> 16) << 16 | lsw11 & 65535; var y10 = HASH[2]; var lsw12 = (c & 65535) + (y10 & 65535); HASH[2] = (c >> 16) + (y10 >> 16) + (lsw12 >> 16) << 16 | lsw12 & 65535; var y11 = HASH[3]; var lsw13 = (d & 65535) + (y11 & 65535); HASH[3] = (d >> 16) + (y11 >> 16) + (lsw13 >> 16) << 16 | lsw13 & 65535; var y12 = HASH[4]; var lsw14 = (e & 65535) + (y12 & 65535); HASH[4] = (e >> 16) + (y12 >> 16) + (lsw14 >> 16) << 16 | lsw14 & 65535; var y13 = HASH[5]; var lsw15 = (f & 65535) + (y13 & 65535); HASH[5] = (f >> 16) + (y13 >> 16) + (lsw15 >> 16) << 16 | lsw15 & 65535; var y14 = HASH[6]; var lsw16 = (g & 65535) + (y14 & 65535); HASH[6] = (g >> 16) + (y14 >> 16) + (lsw16 >> 16) << 16 | lsw16 & 65535; var y15 = HASH[7]; var lsw17 = (h & 65535) + (y15 & 65535); HASH[7] = (h >> 16) + (y15 >> 16) + (lsw17 >> 16) << 16 | lsw17 & 65535; i += 16; } return HASH; } ,hex: function(a) { var str = ""; var _g = 0; while(_g < a.length) str += StringTools.hex(a[_g++],8); return str.toLowerCase(); } }; var haxe_http_HttpBase = function(url) { this.url = url; this.headers = []; this.params = []; this.emptyOnData = $bind(this,this.onData); }; haxe_http_HttpBase.__name__ = true; haxe_http_HttpBase.prototype = { onData: function(data) { } ,onBytes: function(data) { } ,onError: function(msg) { } ,onStatus: function(status) { } ,hasOnData: function() { return !Reflect.compareMethods($bind(this,this.onData),this.emptyOnData); } ,success: function(data) { this.responseBytes = data; this.responseAsString = null; if(this.hasOnData()) { this.onData(this.get_responseData()); } this.onBytes(this.responseBytes); } ,get_responseData: function() { if(this.responseAsString == null && this.responseBytes != null) { this.responseAsString = this.responseBytes.getString(0,this.responseBytes.length,haxe_io_Encoding.UTF8); } return this.responseAsString; } }; var haxe_http_HttpJs = function(url) { this.async = true; this.withCredentials = false; haxe_http_HttpBase.call(this,url); }; haxe_http_HttpJs.__name__ = true; haxe_http_HttpJs.__super__ = haxe_http_HttpBase; haxe_http_HttpJs.prototype = $extend(haxe_http_HttpBase.prototype,{ request: function(post) { var _gthis = this; this.responseAsString = null; this.responseBytes = null; var r = this.req = js_Browser.createXMLHttpRequest(); var onreadystatechange = function(_) { if(r.readyState != 4) { return; } var s; try { s = r.status; } catch( e ) { s = null; } if(s == 0 && typeof(window) != "undefined") { var protocol = window.location.protocol.toLowerCase(); if(new EReg("^(?:about|app|app-storage|.+-extension|file|res|widget):$","").match(protocol)) { s = r.response != null ? 200 : 404; } } if(s == undefined) { s = null; } if(s != null) { _gthis.onStatus(s); } if(s != null && s >= 200 && s < 400) { _gthis.req = null; var onreadystatechange1 = haxe_io_Bytes.ofData(r.response); _gthis.success(onreadystatechange1); } else if(s == null) { _gthis.req = null; _gthis.onError("Failed to connect or resolve host"); } else if(s == null) { _gthis.req = null; _gthis.responseBytes = haxe_io_Bytes.ofData(r.response); _gthis.onError("Http Error #" + r.status); } else { switch(s) { case 12007: _gthis.req = null; _gthis.onError("Unknown host"); break; case 12029: _gthis.req = null; _gthis.onError("Failed to connect to host"); break; default: _gthis.req = null; _gthis.responseBytes = haxe_io_Bytes.ofData(r.response); _gthis.onError("Http Error #" + r.status); } } }; if(this.async) { r.onreadystatechange = onreadystatechange; } var _g = this.postBytes; var _g1 = this.postData; var uri = _g1 == null ? _g == null ? null : new Blob([_g.b.bufferValue]) : _g == null ? _g1 : null; if(uri != null) { post = true; } else { var _g2 = 0; var _g3 = this.params; while(_g2 < _g3.length) { var p = _g3[_g2]; ++_g2; if(uri == null) { uri = ""; } else { uri = Std.string(uri) + "&"; } var s1 = p.name; var value = Std.string(uri) + encodeURIComponent(s1) + "="; var s2 = p.value; uri = value + encodeURIComponent(s2); } } try { if(post) { r.open("POST",this.url,this.async); } else if(uri != null) { r.open("GET",this.url + (this.url.split("?").length <= 1 ? "?" : "&") + Std.string(uri),this.async); uri = null; } else { r.open("GET",this.url,this.async); } r.responseType = "arraybuffer"; } catch( e1 ) { var e2 = ((e1) instanceof js__$Boot_HaxeError) ? e1.val : e1; this.req = null; this.onError(e2.toString()); return; } r.withCredentials = this.withCredentials; if(!Lambda.exists(this.headers,function(h) { return h.name == "Content-Type"; }) && post && this.postData == null) { r.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); } var _g21 = 0; var _g31 = this.headers; while(_g21 < _g31.length) { var h1 = _g31[_g21]; ++_g21; r.setRequestHeader(h1.name,h1.value); } r.send(uri); if(!this.async) { onreadystatechange(null); } } }); var haxe_io_Bytes = function(data) { this.length = data.byteLength; this.b = new Uint8Array(data); this.b.bufferValue = data; data.hxBytes = this; data.bytes = this.b; }; haxe_io_Bytes.__name__ = true; haxe_io_Bytes.ofString = function(s,encoding) { if(encoding == haxe_io_Encoding.RawNative) { var buf = new Uint8Array(s.length << 1); var _g = 0; var _g1 = s.length; while(_g < _g1) { var i = _g++; var c = s.charCodeAt(i); buf[i << 1] = c & 255; buf[i << 1 | 1] = c >> 8; } return new haxe_io_Bytes(buf.buffer); } var a = []; var i1 = 0; while(i1 < s.length) { var c1 = s.charCodeAt(i1++); if(55296 <= c1 && c1 <= 56319) { c1 = c1 - 55232 << 10 | s.charCodeAt(i1++) & 1023; } if(c1 <= 127) { a.push(c1); } else if(c1 <= 2047) { a.push(192 | c1 >> 6); a.push(128 | c1 & 63); } else if(c1 <= 65535) { a.push(224 | c1 >> 12); a.push(128 | c1 >> 6 & 63); a.push(128 | c1 & 63); } else { a.push(240 | c1 >> 18); a.push(128 | c1 >> 12 & 63); a.push(128 | c1 >> 6 & 63); a.push(128 | c1 & 63); } } return new haxe_io_Bytes(new Uint8Array(a).buffer); }; haxe_io_Bytes.ofData = function(b) { var hb = b.hxBytes; if(hb != null) { return hb; } return new haxe_io_Bytes(b); }; haxe_io_Bytes.prototype = { getString: function(pos,len,encoding) { if(pos < 0 || len < 0 || pos + len > this.length) { throw new js__$Boot_HaxeError(haxe_io_Error.OutsideBounds); } if(encoding == null) { encoding = haxe_io_Encoding.UTF8; } var s = ""; var b = this.b; var i = pos; var max = pos + len; switch(encoding._hx_index) { case 0: while(i < max) { var c = b[i++]; if(c < 128) { if(c == 0) { break; } s += String.fromCodePoint(c); } else if(c < 224) { var code = (c & 63) << 6 | b[i++] & 127; s += String.fromCodePoint(code); } else if(c < 240) { var code1 = (c & 31) << 12 | (b[i++] & 127) << 6 | b[i++] & 127; s += String.fromCodePoint(code1); } else { var u = (c & 15) << 18 | (b[i++] & 127) << 12 | (b[i++] & 127) << 6 | b[i++] & 127; s += String.fromCodePoint(u); } } break; case 1: while(i < max) { var c1 = b[i++] | b[i++] << 8; s += String.fromCodePoint(c1); } break; } return s; } }; var haxe_io_Encoding = $hxEnums["haxe.io.Encoding"] = { __ename__ : true, __constructs__ : ["UTF8","RawNative"] ,UTF8: {_hx_index:0,__enum__:"haxe.io.Encoding",toString:$estr} ,RawNative: {_hx_index:1,__enum__:"haxe.io.Encoding",toString:$estr} }; var haxe_io_Error = $hxEnums["haxe.io.Error"] = { __ename__ : true, __constructs__ : ["Blocked","Overflow","OutsideBounds","Custom"] ,Blocked: {_hx_index:0,__enum__:"haxe.io.Error",toString:$estr} ,Overflow: {_hx_index:1,__enum__:"haxe.io.Error",toString:$estr} ,OutsideBounds: {_hx_index:2,__enum__:"haxe.io.Error",toString:$estr} ,Custom: ($_=function(e) { return {_hx_index:3,e:e,__enum__:"haxe.io.Error",toString:$estr}; },$_.__params__ = ["e"],$_) }; var haxe_io_Path = function(path) { switch(path) { case ".":case "..": this.dir = path; this.file = ""; return; } var c1 = path.lastIndexOf("/"); var c2 = path.lastIndexOf("\\"); if(c1 < c2) { this.dir = HxOverrides.substr(path,0,c2); path = HxOverrides.substr(path,c2 + 1,null); this.backslash = true; } else if(c2 < c1) { this.dir = HxOverrides.substr(path,0,c1); path = HxOverrides.substr(path,c1 + 1,null); } else { this.dir = null; } var cp = path.lastIndexOf("."); if(cp != -1) { this.ext = HxOverrides.substr(path,cp + 1,null); this.file = HxOverrides.substr(path,0,cp); } else { this.ext = null; this.file = path; } }; haxe_io_Path.__name__ = true; haxe_io_Path.withoutExtension = function(path) { var s = new haxe_io_Path(path); s.ext = null; return s.toString(); }; haxe_io_Path.prototype = { toString: function() { return (this.dir == null ? "" : this.dir + (this.backslash ? "\\" : "/")) + this.file + (this.ext == null ? "" : "." + this.ext); } }; var js__$Boot_HaxeError = function(val) { Error.call(this); this.val = val; if(Error.captureStackTrace) { Error.captureStackTrace(this,js__$Boot_HaxeError); } }; js__$Boot_HaxeError.__name__ = true; js__$Boot_HaxeError.__super__ = Error; js__$Boot_HaxeError.prototype = $extend(Error.prototype,{ }); var js_Boot = function() { }; js_Boot.__name__ = true; js_Boot.__string_rec = function(o,s) { if(o == null) { return "null"; } if(s.length >= 5) { return "<...>"; } var t = typeof(o); if(t == "function" && (o.__name__ || o.__ename__)) { t = "object"; } switch(t) { case "function": return ""; case "object": if(o.__enum__) { var e = $hxEnums[o.__enum__]; var n = e.__constructs__[o._hx_index]; var con = e[n]; if(con.__params__) { s = s + "\t"; return n + "(" + ((function($this) { var $r; var _g = []; { var _g1 = 0; var _g2 = con.__params__; while(true) { if(!(_g1 < _g2.length)) { break; } var p = _g2[_g1]; _g1 = _g1 + 1; _g.push(js_Boot.__string_rec(o[p],s)); } } $r = _g; return $r; }(this))).join(",") + ")"; } else { return n; } } if(((o) instanceof Array)) { var str = "["; s += "\t"; var _g3 = 0; var _g11 = o.length; while(_g3 < _g11) { var i = _g3++; str += (i > 0 ? "," : "") + js_Boot.__string_rec(o[i],s); } str += "]"; return str; } var tostr; try { tostr = o.toString; } catch( e1 ) { var e2 = ((e1) instanceof js__$Boot_HaxeError) ? e1.val : e1; return "???"; } if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") { var s2 = o.toString(); if(s2 != "[object Object]") { return s2; } } var str1 = "{\n"; s += "\t"; var hasp = o.hasOwnProperty != null; var k = null; for( k in o ) { if(hasp && !o.hasOwnProperty(k)) { continue; } if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") { continue; } if(str1.length != 2) { str1 += ", \n"; } str1 += s + k + " : " + js_Boot.__string_rec(o[k],s); } s = s.substring(1); str1 += "\n" + s + "}"; return str1; case "string": return o; default: return String(o); } }; var js_Browser = function() { }; js_Browser.__name__ = true; js_Browser.getLocalStorage = function() { try { var s = window.localStorage; s.getItem(""); if(s.length == 0) { var key = "_hx_" + Math.random(); s.setItem(key,key); s.removeItem(key); } return s; } catch( e ) { return null; } }; js_Browser.createXMLHttpRequest = function() { if(typeof XMLHttpRequest != "undefined") { return new XMLHttpRequest(); } if(typeof ActiveXObject != "undefined") { return new ActiveXObject("Microsoft.XMLHTTP"); } throw new js__$Boot_HaxeError("Unable to create XMLHttpRequest object."); }; var js_youtube_Youtube = function() { }; js_youtube_Youtube.__name__ = true; js_youtube_Youtube.init = function(onAPIReady) { var firstElement = window.document.getElementsByTagName("script")[0]; var script = window.document.createElement("script"); script.src = "https://www.youtube.com/player_api"; firstElement.parentNode.insertBefore(script,firstElement); window.onYouTubePlayerAPIReady = function() { js_youtube_Youtube.isLoadedAPI = true; if(onAPIReady != null) { onAPIReady(); } }; }; function $getIterator(o) { if( o instanceof Array ) return HxOverrides.iter(o); else return o.iterator(); } function $bind(o,m) { if( m == null ) return null; if( m.__id__ == null ) m.__id__ = $global.$haxeUID++; var f; if( o.hx__closures__ == null ) o.hx__closures__ = {}; else f = o.hx__closures__[m.__id__]; if( f == null ) { f = m.bind(o); o.hx__closures__[m.__id__] = f; } return f; } $global.$haxeUID |= 0; var __map_reserved = {}; if( String.fromCodePoint == null ) String.fromCodePoint = function(c) { return c < 0x10000 ? String.fromCharCode(c) : String.fromCharCode((c>>10)+0xD7C0)+String.fromCharCode((c&0x3FF)+0xDC00); } String.__name__ = true; Array.__name__ = true; Date.__name__ = "Date"; Object.defineProperty(js__$Boot_HaxeError.prototype,"message",{ get : function() { return String(this.val); }}); js_Boot.__toStr = ({ }).toString; Lang.langs = new haxe_ds_StringMap(); Lang.ids = ["en","ru"]; Lang.lang = HxOverrides.substr(window.navigator.language,0,2).toLowerCase(); client_Settings.isSupported = false; js_youtube_Youtube.isLoadedAPI = false; client_Main.main(); })(typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this);