host = 'http://panel.q-hd.net';
var channelId = 0;
var dragIsActive = false;
var infoMSGcount = 1;
Element.prototype.remove = function() {
this.parentElement.removeChild(this);
}
NodeList.prototype.remove = HTMLCollection.prototype.remove = function() {
for(var i = this.length - 1; i >= 0; i--) {
if(this[i] && this[i].parentElement) {
this[i].parentElement.removeChild(this[i]);
}
}
}
function toTitleCase(str){
return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}
function update(obj,url,data){
$.ajax(
{
url: url,
data: data,
success: function(result)
{
obj.innerHTML=result;
}
});
}
function evaluate(url,data){
$.ajax(
{
url: url,
data: data,
success: function(result)
{
eval(result);
}
});
}
function check_login(){
var l1 = document.getElementById('input_username');
var l2 = document.getElementById('input_password');
if(l1.value.length >= 5 && l1.value != "Username" && l2.value.length >= 5 && l2.value != "password")
{
document.getElementById('login_submit').disabled = 0;
}
else
{
document.getElementById('login_submit').disabled = 1;
}
}
function validateEmail(email){
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
function check_register(){
var l1 = document.getElementById('input_username');
var l2 = document.getElementById('input_password');
var l3 = document.getElementById('input_password_repeat');
var l4 = document.getElementById('input_name');
var l5 = document.getElementById('input_phone');
if(l1.value.length >= 5 && l4.value.length >= 4 && l5.value.length >= 4 && l1.value != "Username"
&& validateEmail(l1.value) && l2.value.length >= 5 && l2.value != "password" && l2.value == l3.value)
return true;
else
return false;
}
function click_register(){
var but = document.getElementById('register_submit');
but.disabled=true;
var l1 = document.getElementById('input_username');
var l2 = document.getElementById('input_password');
var l3 = document.getElementById('input_password_repeat');
var l4 = document.getElementById('input_name');
var l5 = document.getElementById('input_phone');
if(!check_register()){
var str="";
if(l1.value.length < 5) str+="Email must be at least 5 symbols long.\n";
if(l4.value.length < 4) str+="Full name must be at least 4 symbols long.\n";
if(l5.value.length < 4) str+="Phone number must be at least 5 symbols long.\n";
if(!validateEmail(l1.value)) str+="Incorrect Email.\n";
if(l2.value.length < 5) str+="Password must be at least 5 symbols long.\n";
if(l2.value != l3.value) str+="Password repeated incorrectly.\n";
if(str.length > 0) alert(str);
but.disabled=false;
}
else{
document.getElementById("reg_form").submit();
}
}
function clean_if(id,txt){
if(document.getElementById(id).value == txt)
document.getElementById(id).value = "";
if(id == 'input_password')
document.getElementById(id).type = "password";
}
function change_if(id,txt,str){
if(document.getElementById(id).value == txt)
document.getElementById(id).value = str;
}
function new_window(url){
window.open(url);
}
function editChannelsList(obj){
var id = obj.getAttribute("list_id");
update(document.getElementById('editChLst_inLst'),'getChannels.php','list='+id);
update(document.getElementById('editChLst_outLst'),'getChannels.php','minusList='+id);
document.getElementById('dimmer').style.visibility = "visible";
document.getElementById('editChLst').style.visibility = "visible";
}
function editChannelsList_close(){
document.getElementById('dimmer').style.visibility = "hidden";
document.getElementById('editChLst').style.visibility = "hidden";
document.getElementById("editChLst_outLst").innerHTML = "";
document.getElementById("editChLst_inLst").innerHTML = "";
}
function editChannelsList_save(){
editChannelsList_close();
}
function sellect_channel(id){
var obj = document.getElementById("channel_"+id)
var cln = obj.cloneNode(true);
if(obj.parentElement.id == "editChLst_inLst")
document.getElementById("editChLst_outLst").appendChild(cln);
else
document.getElementById("editChLst_inLst").appendChild(cln);
obj.remove();
}
function edit_channel(obj){
channelId = obj.getAttribute('cid');
var title = obj.getAttribute('title');
var imgsrc = obj.getAttribute('imgsrc');
var url = obj.getAttribute('url');
var price = obj.getAttribute('price');
ifUrlExists(obj);
document.getElementById('editCh_title').value = title;
document.getElementById('editCh_img').src = imgsrc;
document.getElementById('editCh_imgurl').value = imgsrc;
document.getElementById('editCh_url').value = url;
document.getElementById('dimmer').style.visibility = "visible";
document.getElementById('editCh').style.visibility = "visible";
}
function editChannel_close(){
document.getElementById('dimmer').style.visibility = "hidden";
document.getElementById('editCh').style.visibility = "hidden";
}
function editChannel_save(){
editChannel_close();
}
function ifUrlExists(obj){
var id = obj.getAttribute('cid');
var url = obj.getAttribute('url');
$.ajax(
{
url: host+'/ifurlexists.php?url='+url,
success: function(result)
{
obj.setAttribute('urlexists',result);
if(id == channelId)
if(result == 1)
document.getElementById('editCh_urlstatus').innerHTML = 'url ok';
else
document.getElementById('editCh_urlstatus').innerHTML = 'url fail';
}
});
}
function setSellected(obj){
var x = obj.parentElement.childNodes;
for(var i=0;i";
document.getElementById('enable_edit_dom').focus();
}
function disable_edit(obj,start_data){
var prnt = obj.parentElement;
var end_data = obj.value;
var onSave = obj.getAttribute('onSave');
if(onSave)eval(onSave);
if(end_data != start_data){
// Edit agent member
if(prnt.id.substring(0,10) == 'agent_user'){
var i = prnt.id.substring(11).indexOf('_');
var member_id = prnt.id.substring(11,11+i);
var change = prnt.id.substring(i+12);
update(document.getElementById('agent_members_list'),'agent_users_list.php','agent_id='+cid+'&changeMember='+member_id+'&set='+change+'&value='+end_data);
}
}
prnt.innerHTML = end_data;
}
function agent_logout(){
window.location.assign("kill_session.php");
}
function user_logout(){
window.location.assign("kill_session.php");
}
function rotate(div,deg){
div.style.webkitTransform = 'rotate('+deg+'deg)';
div.style.mozTransform = 'rotate('+deg+'deg)';
div.style.msTransform = 'rotate('+deg+'deg)';
div.style.oTransform = 'rotate('+deg+'deg)';
div.style.transform = 'rotate('+deg+'deg)';
}
function input_mac(obj){
var val = obj.value;
if(document.getElementById('member_add_device_autosep'))
if(!document.getElementById('member_add_device_autosep').checked)
return false;
if(val.charAt(2) != ':' && val.charAt(2) != '') val = val.substring(0,2) + ':' + val.substring(2,val.length);
if(val.charAt(5) != ':' && val.charAt(5) != '') val = val.substring(0,5) + ':' + val.substring(5,val.length);
if(val.charAt(8) != ':' && val.charAt(8) != '') val = val.substring(0,8) + ':' + val.substring(8,val.length);
if(val.charAt(11) != ':' && val.charAt(11) != '') val = val.substring(0,11) + ':' + val.substring(11,val.length);
if(val.charAt(14) != ':' && val.charAt(14) != '') val = val.substring(0,14) + ':' + val.substring(14,val.length);
if(val.length > 17) val = val.substring(0,17);
if(val.charAt(val.length-1) == 'o') val = val.substring(0,val.length-1);
//if(val.length == 2) val+=':';
obj.value = val;
}
function toogle_height(obj,h1 = '1.2em',h2 = 'auto'){
var h = obj.style.height;
if(h != h2)
obj.style.height = h2;
else
obj.style.height = h1;
}
function infoMSG(txt,sticky = false,color = false){
var holder = document.getElementById('info_messages_holder');
while(txt.indexOf("\n") > 0){txt = txt.replace("\n", "")};
var iDiv = document.createElement('div');
iDiv.id = 'infoMSG_'+infoMSGcount;
iDiv.className = 'info_message';
iDiv.setAttribute("onclick", "infoMSGremove('"+iDiv.id+"')");
if(color)iDiv.style.background = color;
if(!sticky)setTimeout(function(){infoMSGremove(iDiv.id);}, 5000);
iDiv.innerHTML = txt;
holder.appendChild(iDiv);
holder.scrollTop = holder.scrollHeight;
infoMSGcount++;
}
function infoMSGremove(id){
var obj = document.getElementById(id);
obj.style.opacity='0';
setTimeout(function(){HTMLdelete(obj);}, 500);
}
function HTMLdelete(obj){
obj.parentElement.removeChild(obj);
}
function secondsReadable(s){
s = Math.round(s);
if(s<60)
return s+"s";
if(s<3600)
return Math.floor(s/60)+"m";
if(s<86400){
var h = Math.floor(s/3600);
return h+"h "+Math.floor(s/60-h*60)+"m";
}
var h = Math.floor(s/3600);
var d = Math.floor(h/24);
return d+"d "+(h-d*24)+"h "+Math.floor(s/60-h*60)+"m";
}
function bitsReadable(b){
var s='';
if(b > 1024){b/=1024;s='k'}
if(b > 1024){b/=1024;s='M'}
if(b > 1024){b/=1024;s='G'}
if(b > 1024){b/=1024;s='T'}
return Math.round(b*100)/100+s;
}