clipbucket/upload/js/clipbucket.min.js

1 line
No EOL
32 KiB
JavaScript
Executable file

!function(window){var _cb=function(){var self=this;if(this.baseurl=baseurl,this.imageurl="",this.page=this.baseurl+"/ajax.php",this.loading_img="<img allign='center' style='vertical-align:middle' src='"+imageurl+"/ajax-loader-big.gif'>",this.loading=this.loading_img+" Loading...",this.download=0,this.total_size=0,this.cur_speed=0,this.status_refesh=1,this.result_page=this.baseurl+"/actions/file_results.php",this.download_page=this.baseurl+"/actions/file_downloader.php",this.count=0,this.hasLoaded=!1,this.perc_download=0,this.force_stop=!1,this.remoteObjID="",this.current_menu="",this.normal_player_html="",this.hq_player_html="",this.has_hq_function=!1,this.collectionID=!1,this.keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",this.ua=navigator.userAgent.toLowerCase(),this.ua.indexOf(" chrome/")>=0||this.ua.indexOf(" firefox/")>=0||this.ua.indexOf(" gecko/")>=0)var StringMaker=function(){this.str="",this.length=0,this.append=function(a){this.str+=a,this.length+=a.length},this.prepend=function(a){this.str=a+this.str,this.length+=a.length},this.toString=function(){return this.str}};else var StringMaker=function(){this.parts=[],this.length=0,this.append=function(a){this.parts.push(a),this.length+=a.length},this.prepend=function(a){this.parts.unshift(a),this.length+=a.length},this.toString=function(){return this.parts.join("")}};this.setRemoteId=function(){this.remoteObjID=this.randomString()},this.Confirm_Delete=function(a){confirm("Are you sure you want to delete")&&(document.location=a)},this.Confirm_Uninstall=function(a){confirm("Are you sure you want to uninstall this plugin ?")&&(document.location=a)},this.confirm_it=function(a){return!!confirm(a)},this.reloadImage=function(a,b){img=document.getElementById(b),img.src=a+"?"+Math.random()},this.validate_category_form=function(thisform){var self=this;with(thisform){if(0==validate_required(title,"Title must be filled out!"))return title.focus(),!1;if(0==validate_required(description,"Description must be filled out!"))return description.focus(),!1}},this.validate_ad_form=function(thisform){var self=this;with(thisform){if(0==validate_required(name,"Name must be filled out!"))return name.focus(),!1;if(0==validate_required(type,"Type must be filled out!"))return type.focus(),!1;if(0==validate_required(syntax,"Syntax Must Be Filled Out"))return syntax.focus(),!1;if(0==validate_required(code,"Code Must Be Filled Out"))return code.focus(),!1}},this.randomString=function(){for(var b="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",c=8,d="",e=0;e<c;e++){var f=Math.floor(Math.random()*b.length);d+=b.substring(f,f+1)}return d},this.check_remote_url=function(){var a=this,b=$("#remote_file_url").val(),c=$("#ytUploadBttn"),d=$("#remoteUploadBttn"),e=$("#remoteUploadBttnStop");if(this.force_stop=!1,b.match(/^e.g/)||void 0===b||0===b.length)return $("#error_msgs").html('<div class="alert alert-danger" role="alert">Given URL is invalid!</div>'),!1;var f=function(a){void 0!==a?(d.attr("disabled","disabled"),c.attr("disabled","disabled")):($(".downloadStatusContainer").removeClass("hidden"),d.attr("disabled","disabled").hide(),c.attr("disabled","disabled"),e.show())},g=function(a){void 0!==a?(e.removeAttr("disabled").hide(),c.removeAttr("disabled"),d.removeAttr("disabled").show()):($(".downloadStatusContainer").addClass("hidden"),e.removeAttr("disabled").hide(),c.removeAttr("disabled"),d.removeAttr("disabled").show())};f();var h=$.ajax({url:a.download_page,type:"POST",data:{file:b,file_name:file_name},dataType:"JSON",beforeSend:function(){a.remoteUploadStatusUpdate();var c=a.getName(b);$("#loading").html("Downloading"),$("#remoteFileName").replaceWith('"'+c+'"')},success:function(b){if(a.force_stop=!0,b.error)return a.force_stop=!0,g(),$("#error_msgs").html('<div class="alert alert-danger" role="alert"> File Type Not Allowed!</div>'),!1;g(),$("#loading").html("");var c=b.vid;$.post(a.baseurl+"/actions/getVideoDetails.php",{file_name:file_name,vid:c},function(a){var b=$("#updateVideoInfoForm").clone();$(b).find("input[name=title]").val(a.title),$(b).find("textarea#desc").val(a.description),$(b).find("input[name='category[]']:first").attr("checked","checked");var d=document.createElement("input");d.name="videoid",d.type="hidden",d.value=c;var e=document.createElement("input");e.name="file_name",e.type="hidden",e.value=file_name,$(b).append(d),$(b).append(e),$("#remoteForm").html(""),$(b).removeClass("hidden").attr("id","uploadFormContainer_remote").appendTo("#remoteForm"),$(b).find("form").on({submit:function(a){a.preventDefault();var b=$(this),c=$(b).serialize();c+="&updateVideo=yes",$.ajax({url:baseurl+"/actions/file_uploader.php",type:"post",data:c}).success(function(a){msg=$.parseJSON(a),$("#uploadMessage").removeClass("hidden"),msg.error?$("#uploadMessage").html(msg.error).attr("class","alert alert-danger"):$("#uploadMessage").html(msg.msg).attr("class","alert alert-success"),setTimeout(function(){$("#uploadMessage").addClass("hidden")},5e3)})}}),$(".formSection h4").on({click:function(a){a.preventDefault(),$(this).find("i").hasClass("glyphicon-chevron-down")?($(this).find("i").removeClass("glyphicon-chevron-down").addClass("glyphicon-chevron-up"),$(this).next().toggleClass("hidden")):($(this).find("i").removeClass("glyphicon-chevron-up").addClass("glyphicon-chevron-down"),$(this).next().toggleClass("hidden"))}}),$(b).on({submit:function(a){a.preventDefault();var c=$(this).serialize();c+="&updateVideo=yes",$.ajax({url:baseurl+"/actions/file_uploader.php",type:"post",data:c,dataType:"JSON"}).success(function(a){$("#uploadMessage").removeClass("hidden"),a.error?$("#uploadMessage").html(a.error).attr("class","alert alert-danger"):$("#uploadMessage").html(a.msg).attr("class","alert alert-success"),setTimeout(function(){$("#uploadMessage").addClass("hidden")},5e3)}).fail(function(a){console.log(a)})}})},"json")}});$("#remoteUploadBttnStop").click(function(){h.abort(),this.force_stop=!0,$("#loading").html(""),$("#remoteDownloadStatus").hide(),$(this).hide(),$("#remoteUploadBttn").attr("disabled","").show()})},this.remoteUploadStatusUpdate=function(){var a=this;$.ajax({url:a.result_page,type:"POST",data:{file_name:file_name},dataType:"JSON"}).success(function(b){!1===a.force_stop&&(a.updateProgress(b),setTimeout(function(){a.remoteUploadStatusUpdate()},1e3*a.status_refesh))})},this.updateProgress=function(a){if(void 0!==a&&null!==a){var b=(a.downloaded/1048576).toFixed(2),c=(a.total_size/1048576).toFixed(2),d=a.downloaded/a.total_size*100;$("#downloadStatus").find("#downloaded").text(b+" Mb"),$("#downloadStatus").find("#totalSize").text(c+" Mb"),$("#prog_bar").css("width",d+"%")}},this.youtube_check_url=function(){var b=$("#remote_file_url").val();$("#ytUploadBttn"),$("#remoteUploadBttn"),$("#remoteUploadBttnStop");return this.force_stop=!1,!b.match(/^e.g/)&&void 0!==b&&0!==b.length||($("#error_msgs").html('<div class="alert alert-danger" role="alert"> Please enter valid URL !</div>'),!1)},this.youtube_upload=function(){if(!this.youtube_check_url())return!1;$("#remoteUploadBttn").attr("disabled","disabled"),$("#ytUploadBttn").attr("disabled","disabled");var a=$("#remote_file_url").val();if(force_stop=!1,!a||"undefined"==a)return alert("Please enter file url"),$("#remoteUploadBttn").attr("disabled",""),$("#ytUploadBttn").attr("disabled",""),!1;$.ajax({url:download_page,type:"POST",data:{file:a,file_name:file_name,youtube:"yes"},dataType:"json",beforeSend:function(){$("#loading").html('<div style="float: left; display: inline-block;"><img src="'+imageurl+'/ajax-loader.gif"></div><div style="float: left; line-height: 16px; padding-left:5px">Uploading video from youtube, please wait...</div><div class="clear"></div>')},success:function(a){a.error?(force_stop=!0,$("#remoteUploadBttn").attr("disabled",""),$("#ytUploadBttn").attr("disabled",""),alert(a.error)):a.vid&&(alert("this is checked success"),vid=a.vid,$("#remoteUploadBttn").attr("disabled","disabled").hide(),$("#ytUploadBttn").attr("disabled","disabled").hide(),$.post(baseurl+"/actions/file_uploader.php",{getForm:"get_form",title:a.title,desc:a.desc,tags:a.tags,objId:remoteObjID},function(a){$("#remoteForm").append(a),$("#cbSubmitUpload"+remoteObjID).before('<span id="updateVideoDataLoading" style="margin-right:5px"></span>').attr("disabled","").attr("value",lang.saveData).attr("onClick","doUpdateVideo('#uploadForm"+remoteObjID+"','"+remoteObjID+"')").after('<input type="hidden" name="videoid" value="'+vid+'" id="videoid" />').after('<input type="hidden" name="updateVideo" value="yes" id="updateVideo" />')},"text")),$("#loading").html("")}})},this.status_update=function(){var a=this;$.ajax({url:a.result_page,type:"POST",data:{file_name:file_name},dataType:"json",success:function(b){if(b){var c=parseFloat(b.total_size),d=parseFloat(b.downloaded),e=parseFloat(b.total_size_fm),f=parseFloat(b.downloaded_fm),g=parseFloat(b.speed_download),i=(parseFloat(b.time_eta),parseFloat(b.time_eta_fm)),k=(parseFloat(b.time_took),parseFloat(b.time_took_fm));if(g/1024/1024>1)var l=Math.round(g/1024/1024)+" Mbps";else var l=Math.round(g/1024)+" Kbps";a.perc_download=Math.round(d/c*100),isNaN(f)?($("#remoteDownloadStatus").show(),$("#prog_bar").html("Loading"),$("#dspeed").html("Loading"),$("#eta").html("Loading"),$("#status").html("Loading")):($("#remoteDownloadStatus").show(),$("#prog_bar").animate({width:a.perc_download+"%"},1e3),$("#prog_bar").html(a.perc_download+"%"),$("#dspeed").html(l),$("#eta").html(i),$("#status").html(f+" of "+e))}var m=1e3*a.status_refesh;a.perc_download>99&&(a.force_stop=!0),a.force_stop?100==a.perc_download&&c>1&&$("#time_took").html("Time Took : "+k):setTimeout(function(){a.status_update()},m)}})},this.upload_file=function(a,b){var d=this.baseurl+"/actions/file_downloader.php";$.post(d,{file_url:a,file_name:b},function(a){a?submit_upload_form():alert("No data")},"text")},this.delete_item=function(a,b,c,d){$("#"+a+"-"+b).click(function(){confirm(c)&&(document.location=d)})},this.delete_video=function(a,b,c,d){return delete_item(a,b,c,d)},this.get_video=function(a,b){$(b).css("display","block"),$(b).html(this.loading),$(b).html(this.loading),$.post(page,{mode:a},function(a){$(b).html(a)},"text")},this.getAjaxPhoto=function(a,b){var c=this;$(b).css("display","block");var d=$(b).html();$.ajax({url:c.page,type:"POST",dataType:"json",data:{mode:"loadAjaxPhotos",photosType:a},beforeSend:function(){$(b).html(this.loading)},success:function(a){a.failed&&$(b).html(d),a.completed&&$(b).html(a.photoBlocks)}})},this.rating_over=function(a,b){"disabled"!=b&&$("#rating_result_container").html(a)},this.rating_out=function(a,b){"disabled"!=b&&$("#rating_result_container").html(a)},this.submit_share_form=function(a,b){$("#share_form_results").css("display","block"),$("#share_form_results").html(this.loading),$.post(page,{mode:"share_object",type:b,users:$("#ShareUsers").val(),message:$("#message").val(),id:$("#objectid").val()},function(a){a?$("#share_form_results").html(a):alert("No data")},"text")},this.flag_object=function(a,b,c){$("#flag_form_result").css("display","block"),$("#flag_form_result").html(this.loading),$.post(page,{mode:"flag_object",type:c,flag_type:$("#"+a+" select option:selected").val(),id:b},function(a){a?($("#flag_form_result").css("display","block"),$("#flag_form_result").html(a)):alert("No data")},"text")},this.slide_up_watch_video=function(a){"block"!=$(".video_action_result_boxes "+a).css("display")&&$(".video_action_result_boxes > *").slideUp()},this.add_to_fav=function(a,b){$("#video_action_result_cont").css("display","block"),$("#video_action_result_cont").html(this.loading),$.post(page,{mode:"add_to_fav",type:a,id:b},function(a){a?($("#video_action_result_cont").css("display","block"),$("#video_action_result_cont").html(a)):alert("No data")},"text")},this.subscriber=function(a,b,c){$("#"+c).css("display","block"),$("#"+c).html(this.loading),$.post(page,{mode:b,subscribe_to:a},function(a){a?($("#"+c).css("display","block"),$("#"+c).html(a)):alert("No data")},"text")},this.add_friend=function(a,b){$("#"+b).css("display","block"),$("#"+b).html(this.loading),$.post(page,{mode:"add_friend",uid:a},function(a){a?($("#"+b).css("display","block"),$("#"+b).html(a)):alert("No data")},"text")},this.block_user=function(a,b){$("#"+b).css("display","block"),$("#"+b).html(this.loading),$.post(page,{mode:"ban_user",user:a},function(a){a?($("#"+b).css("display","block"),$("#"+b).html(a)):alert("No data")},"text")},this.rate_comment=function(a,b,c,d){$.post(page,{mode:"rate_comment",thumb:b,cid:a,type:c,typeid:d},function(b){b?(""!=b.msg&&alert(b.msg),""!=b.rate&&$("#comment_rating_"+a).html(b.rate)):alert("No data")},"json")},this.delete_comment=function(a,b){$.post(page,{mode:"delete_comment",cid:a,type:b},function(b){b?(b.msg&&(alert(b.msg),$("#comment_"+a).fadeOut("slow"),$("#spam_comment_"+a).fadeOut("slow")),b.err&&alert(b.err)):alert("No data")},"json")},this.add_comment_js=function(a,b){$("#add_comment_result").css("display","block"),$("#add_comment_result").html(this.loading),$("#add_comment_button").attr("disabled","disabled");var c=$("#"+a).serialize()+"&mode=add_comment";$.post(page,c,function(a){a?($("#add_comment_button").attr("disabled",""),$("#add_comment_result").css("display","block"),""!=a.err&&$("#add_comment_result").html(a.err),""!=a.msg&&$("#add_comment_result").html(a.msg),a.cid&&get_the_comment(a.cid,"#latest_comment_container")):alert("No data")},"json")},this.get_the_comment=function(a,b){$(b).html(this.loading),$.post(page,{mode:"get_comment",cid:a},function(a){a?($(b).css("display","none"),$(b).html(a).fadeIn("slow")):alert("No data")},"text")},this.add_playlist=function(a,b,c,d){switch($("#playlist_form_result").css("display","block"),$("#playlist_form_result").html(this.loading),a){case"add":$.post(page,{mode:"add_playlist",id:b,objtype:d,pid:$("#playlist_id option:selected").val()},function(a){a?(""!=a.err&&($("#playlist_form_result").css("display","block"),$("#playlist_form_result").html(a.err)),""!=a.msg&&($("#playlist_form_result").css("display","block"),$("#playlist_form_result").html(a.msg),$("#"+c).css("display","none"))):alert("No data")},"json");break;case"new":$.post(page,{mode:"add_new_playlist",id:b,objtype:d,plname:$("#playlist_name").val()},function(a){a?(a.err&&($("#playlist_form_result").css("display","block"),$("#playlist_form_result").html(a.err)),a.msg&&($("#playlist_form_result").css("display","block"),$("#playlist_form_result").html(a.msg),$("#"+c).css("display","none"))):alert("No data")},"json")}},this.add_quicklist=function(a,b){$(a).attr("src",this.imageurl+"/ajax-loader.gif"),$(a).css("background-position","-200px 200px"),$.post(page,{mode:"quicklist",todo:"add",vid:b},function(b){b?($(a).attr("src",this.imageurl+"/dot.gif"),$(a).css("background-position","-0px -0px"),$(a).removeClass("add_icon"),$(a).addClass("check_icon"),$(a).removeAttr("onClick"),load_quicklist_box()):alert("No data")},"text")},this.remove_qucklist=function(a,b){$.post(page,{mode:"quicklist",todo:"remove",vid:b},function(b){b?($(a).slideUp(),$(a).hide()):alert("No data")},"text")},this.load_quicklist_box=function(){$.post(page,{mode:"getquicklistbox"},function(a){a=$.trim(a),a?($("#quicklist_box").css("display","block"),$("#quicklist_box").html(a),"hide"!=$.cookie("quick_list_box")&&$("#quicklist_cont").css("display","block")):$("#quicklist_box").css("display","none")},"text")},this.clear_quicklist=function(){$.post(page,{mode:"clear_quicklist"},function(a){load_quicklist_box()},"text")},this.quick_show_hide_toggle=function(a){$(a).slideToggle(),"show"==$.cookie("quick_list_box")?$.cookie("quick_list_box","hide"):$.cookie("quick_list_box","show")},this.ini_cookies=function(){$.cookie("quick_list_box")||$.cookie("quick_list_box","show")},this.get_group_info=function(a,b){"none"==$(a).css("display")&&($("#group_info_cont > div").slideUp(),$("#group_info_cont "+a).slideDown(),$(".group_detail_tabs .selected").removeClass("selected"),$(b).addClass("selected"))},this.show_menu=function(a,b){if(window.location.hash&&b){var d=window.location.hash;return show_menu(d.substr(9),!1),!1}window.location.hash="current_"+a,this.current_menu!=a&&hide_menu(),$("#"+a).show(),this.current_menu=a,$("."+a).addClass("selected")},this.hide_menu=function(){if(""!=this.current_menu)return $("#"+this.current_menu).hide(),$("."+this.current_menu).removeClass("selected"),!0},this.to_reply=function(a){$("#reply_to").val(a),window.location="#add_comment"},this.spam_comment=function(a,b,c){$.post(page,{mode:"spam_comment",cid:a,type:b,typeid:c},function(b){b?(b.msg&&($("#comment_"+a).hide(),$("#spam_comment_"+a).fadeIn("slow")),b.err&&alert(b.err)):alert("No data")},"json")},this.hq_toggle=function(a,b){if(this.has_hq_function){var a=a,b=b;return hq_function(),!1}"block"==$(a).css("display")?(""==this.normal_player_html&&(this.normal_player_html=$(a).html()),$(a).html("")):""!=this.normal_player_html&&$(a).html(this.normal_player_html),"block"==$(b).css("display")?(""==this.hq_player_html&&(this.hq_player_html=$(b).html()),$(b).html("")):""!=this.hq_player_html&&$(b).html(this.hq_player_html),$(a+","+b).toggle()},this.swap_auto_play=function(){"true"==$.cookie("auto_play_playlist")?($.cookie("auto_play_playlist","false",{path:"/"}),window.location=document.location,$("#ap_status").html("off")):($.cookie("auto_play_playlist","true",{path:"/"}),window.location=document.location,$("#ap_status").html("on"))},this.collection_actions=function(a,b,c,d,e,f){switch($(d).css("display","block"),$(d).html(this.loading),b){case"add_new_item":$.post(page,{mode:b,cid:$("#"+a+" #collection").val(),obj_id:c,type:e},function(a){a?(a.msg&&$(d).html(a.msg),a.err&&$(d).html(a.err)):alert("No Data returned")},"json");break;case"remove_collection_item":$("#"+a).hide(),$.post(page,{mode:b,obj_id:c,type:e,cid:f},function(b){b?(b.err&&(alert(b.err),$(d+"_"+c).hide(),$("#"+a+c).show()),b.msg&&($(d).html(b.msg),$("#"+a+"_"+c).slideUp(350))):(alert("No Data Returned"),$(d+"_"+c).hide(),$("#"+a).show())},"json")}return!1},this.openURL=function(a){document.locati=a},this.get_item=function(a,b,c,d,e){var g=$(a).html();$(a).html(this.loading),$.post(page,{mode:"get_item",ci_id:b,cid:c,type:d,direction:e},function(b){if(b){var c=new Array(d,b.cid,b.key);construct_url(c),$("#collectionItemView").html(b.content)}else alert("No "+d+" returned"),$(a).text(g)},"json")},this.construct_url=function(a){var b;"yes"==Seo?(b="#!/item/"+a[0]+"/"+a[1]+"/"+a[2],window.location.hash=b):(b="#!?item="+a[2]+"&type="+a[0]+"&collection="+a[1],window.location.hash=b)},this.onReload_item=function(){var a,b;window.location.hash&&(a=window.location.href,"yes"==Seo?(b=RegExp("/item.+#!"),b.test(a)&&(a=a.replace(b,""),window.location.href=a)):(b=RegExp("\\?item.+#!"),b.test(a)&&(a=a.replace(b,""),window.location.href=a)))},this.pagination=function(a,b,c,d){var e=this,f=$(a),h=(f.id,f.parent()),j=f.html();h.attr("id")?parent.attr("id"):(h.attr("id","loadMoreParent"),h.attr("id")),newCall=$.ajax({url:e.page,type:"post",dataType:"json",data:{mode:"moreItems",page:d,cid:b,type:c},beforeSend:function(){f.removeAttr("onClick"),f.html(e.loading)},success:function(b){b.error?("BUTTON"==a.tagName&&f.attr("disabled","disabled"),f.removeAttr("onClick"),f.html("No more "+c)):($("#collectionItemsList").append(b.content),$("#NewPagination").html(b.pagination),f.html(j))}})},this.ajax_add_collection=function(a){var b=this,c=a.form.id,d=$("#"+c),e=$(a),g=e.html(),h=$("#CollectionResult");$.ajax({url:b.page,type:"post",dataType:"json",data:"mode=add_collection&"+d.serialize(),beforeSend:function(){"block"==h.css("display")&&h.slideUp("fast"),e.attr("disabled","disabled"),e.html(this.loading)},success:function(a){a.msg?($("#CollectionDIV").slideUp("fast"),h.html(a.msg).slideDown("fast"),this.collectionID=a.id):(h.html(a.err).slideDown("fast"),e.removeAttr("disabled"),e.html(g))}})},this.getDetails=function(a){var b=getInputs(a),c=new Array(b.length);return $.each(b,function(a,b){query=$("#"+b.id+" *").serialize(),query+="&mode=ajaxPhotos",c[a]=query}),c},this.getName=function(a){var c=a;return c.substring(c.lastIndexOf("/")+1)},this.viewRatings=function(a,b){var d=$(a),e=d.html();document.getElementById("RatingStatContainer")?$("#RatingStatContainer").toggle():loadAjax=$.ajax({url:page,type:"post",dataType:"text",data:{mode:"viewPhotoRating",photoid:b},beforeSend:function(){d.html(this.loading)},success:function(a){d.html(e),a?$("<div />").attr("id","RatingStatContainer").addClass("clearfix").css({padding:"8px",font:"normal 11px Tahoma",border:"1px solid #ccc",backgroundColor:"#FFF"}).html(a).fadeIn(350).insertAfter(d):(d.removeAttr("onclick"),alert("Photo has not recieved any rating yet."))}})},this.showAdvanceSearch=function(a,b,c,d){var f=($("#"+a),$("#"+b)),g=$("#SearchType").val();f.toggle(),"block"==f.css("display")&&f.children().hide().filter("#"+g).show(),$("."+c).toggleClass(d)},this.toggleCategory=function(a,b){var c=$(a),d=c.attr("alt"),e=$("#"+d),f=d.split("_"),g=f[0],h=$.browser.msie,i=$.browser.version;"none"==e.css("display")?(e.slideDown(350),h&&"7.0"==i&&e.addClass("internetExplorer7CategoryToggleFix"),$.cookie(g,"expanded",{expires:1,path:"/"}),c.removeClass("none").addClass("block")):(e.slideUp(350),h&&"7.0"==i&&e.removeClass("internetExplorer7CategoryToggleFix"),$.cookie(g,"collapsed",{expires:1,path:"/"}),c.removeClass("block").addClass("none"))},this.loadObject=function(a,b,c,d){var e=this,f=new Array(4);f.this=a,f.type=b,f.objID=c,f.container=d;var g=$(f.this);g.parent().css("position","relative"),$.ajax({url:e.page,type:"POST",dataType:"json",data:{mode:"channelFeatured",contentType:f.type,objID:f.objID},beforeSend:function(){g.find("img").animate({opacity:.5}),$("#"+f.container).animate({opacity:.5})},success:function(a){a.error?(g.find("img").animate({opacity:1}),$("#"+f.container).animate({opacity:1}),alert(a.error)):(g.parent().children(".selected").removeClass("selected"),g.addClass("selected"),g.find("img").animate({opacity:1}),$("#"+f.container).html(a.data),$("#"+f.container).animate({opacity:1}))}})},this.channelObjects=function(a,b,c,d,e){var f=this,g=$(a),h=g.attr("rel"),i=$(b),j=g.parents("ul").find("a.selected").attr("rel");if(h){if("block"==$("#"+h).css("display"))return!1;g.parents("ul").find("a.selected").removeClass("selected"),g.addClass("selected"),$("#"+j).hide(),$("#"+h).show()}else{var k=c+"DIV";g.attr("rel",k),$.ajax({url:f.page,type:"POST",dataType:"json",data:{mode:"channelObjects",content:c,user:d,assign:e},beforeSend:function(){g.append(this.loading_img)},success:function(a){g.find("img").remove(),g.parents("ul").find("a.selected").removeClass("selected"),g.addClass("selected"),$("#"+j).hide(),$("<div></div>").attr("id",k).addClass($("#"+j).attr("class")).html(a.html).appendTo(i)}})}};var comments_voting="no";this.getComments=function(a,b,c,d,e,f,g){var h=this;$("#comments").html("<div style='padding:5px 0px;'>"+this.loading+"</div>"),$.ajax({type:"POST",url:h.page,data:{mode:"getComments",page:d,type:a,type_id:b,object_type:f,last_update:c,total_comments:e,comments_voting:comments_voting,admin:g},success:function(a){$("#comments").hide(),$("#comments").html(a),$("#comments").fadeIn("slow")},dataType:"text"})},this.checkUncheckAll=function(a){var b=theElemeform,c=0;for(c=0;c<b.length;c++)"checkbox"==b[c].type&&"checkall"!=b[c].name&&(b[c].checked=a.checked)},this.rate=function(a,b,c){alert("BIEATCh");var e=this.baseurl+"/ajax.php";$.post(e,{mode:"rating",id:a,rating:b,type:c},function(a){a?$("#rating_container").html(a):alert("No data")},"text")},this.setPageHash=function(a){var c=a.replace(this.baseurl,"");window.location.hash.replace("#!","");window.location.hash="#!"+c},this.callURLParser=function(){var e,b=/(\#![\/a-zA-Z0-9=\.\&\-\_\?]*)/g,c=window.location.href,d=c.match(b);d&&(e=d[d.length-1])&&(window.location.href=this.baseurl+e.replace("#!",""))},this.groupsAjax=function(a,b,c){a.preventDefault();var e,g,h,f=!1;if(void 0==c&&(c="ajaxGroupResultContainer"),b.href?(e=b.href,f=!0,jqueryObj=$(b),javaObj=b):(e=b.childNodes[0].href,jqueryObj=$(b.childNodes[0]),javaObj=b.childNodes[0]),"undefined"==e)return alert("URL not found"),!1;g=jqueryObj.html(),setPageHash(e),1==f?(h=jqueryObj.parent().parent(),h.children().filter(".selected").removeClass("selected"),jqueryObj.parent().addClass("selected")):(h=jqueryObj.parent(),h.children().filter(".selected").removeClass("selected"),jqueryObj.addClass("selected")),jqueryObj.html(this.loading_img),$("#"+c).load(e+" #"+c,function(a,b,c){jqueryObj.html(g),document.getElementById("flag_item")&&$("#flag_item").show()})},this.encode64=function(a){for(var d,e,f,g,h,i,j,c=nStringMaker(),k=0;k<a.length;)d=a.charCodeAt(k++),e=a.charCodeAt(k++),f=a.charCodeAt(k++),g=d>>2,h=(3&d)<<4|e>>4,i=(15&e)<<2|f>>6,j=63&f,isNaN(e)?i=j=64:isNaN(f)&&(j=64),c.append(this.keyStr.charAt(g)+this.keyStr.charAt(h)+this.keyStr.charAt(i)+this.keyStr.charAt(j));return c.toString()},this.decode64=function(a){var d,e,f,g,h,i,j,c=nStringMaker(),k=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");k<a.length;)g=this.keyStr.indexOf(a.charAt(k++)),h=this.keyStr.indexOf(a.charAt(k++)),i=this.keyStr.indexOf(a.charAt(k++)),j=this.keyStr.indexOf(a.charAt(k++)),d=g<<2|h>>4,e=(15&h)<<4|i>>2,f=(3&i)<<6|j,c.append(String.fromCharCode(d)),64!=i&&c.append(String.fromCharCode(e)),64!=j&&c.append(String.fromCharCode(f));return c.toString()},this.getAllComments=function(a,b,c,d,e,f,g){$("#userCommentsList").html("<div style='padding:5px 0px;'>"+loading+"</div>"),$.ajax({type:"POST",url:page,data:{mode:"getComments",page:d,type:a,type_id:b,object_type:f,last_update:c,total_comments:e,comments_voting:comments_voting,admin:g},success:function(a){$("#userCommentsList").html(a)},dataType:"text"})},this.getCommentsNew=function(a,b,c,d,e,f,g){$.ajax({type:"POST",url:page,data:{mode:"getCommentsNew",page:d,type:a,type_id:b,object_type:f,last_update:c,total_comments:e,comments_voting:comments_voting,admin:g},beforeSend:function(){$(document).find("#load-more-comments").text("loading comments..")},success:function(a){"none"==a?($("#load-more-comments").text("End of comments list"),$("#load-more-comments").attr("disabled","disabled")):($("#userCommentsList").append(a),$(document).find("#load-more-comments").text("Load More"))},dataType:"text"})},this.addToFav=function(a,b){$("#messageFav").show(),$.post(page,{mode:"add_to_fav",type:a,id:b},function(a){a?($("#messageFav").html(a),setTimeout(function(){$("#messageFav").hide()},5e3)):alert("No data")},"text")},this.subscribeToChannel=function(a,b,c){$("#messageFav").show(),$.post(page,{mode:b,subscribe_to:a},function(a){a?($("#messageFav").html(a),setTimeout(function(){$("#messageFav").hide()},5e3)):alert("No data")},"text")},this.debounce=function(a,b,c){var d;return function(){var e=this,f=arguments,g=function(){d=null,c||a.apply(e,f)},h=c&&!d;clearTimeout(d),d=setTimeout(g,b),h&&a.apply(e,f)}},this.throwHeadMsg=function(a,b,c,d){$(document).find("#headErr").remove(),c=parseInt(c),c<10&&(c=3e3),a.length<3&&(a="info"),$('<div id="headErr" class="alert_messages_holder" style="display:none"><div class="alert alert-'+a+' alert-messages alert-ajax" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>'+b+"</div></div>").insertAfter("#header").fadeIn("slow").delay(c).fadeOut()},this.rateNew=function(a,b,c){curObj=this;var d=baseurl+"/ajax.php";$.post(d,{mode:"rating",id:a,rating:b,type:c},function(a){a?(likesSect=$(".likes").find("span:nth-child(2)").html(),dislikesSect=$(".dislikes").find("span:nth-child(2)").html(),currLikes=parseInt(likesSect),currDislikes=parseInt(dislikesSect),isError=$(a).find("span.error").html(),isOk=$(a).find("span.msg").html(),isError?isError.length>2&&curObj.throwHeadMsg("danger",isError,5e3,!0):isOk&&isOk.length>2&&(5==b?(newRating=currLikes+1,$(".likes").addClass("rated"),$(".likes").find("span:nth-child(2)").html(newRating)):(newRating=currDislikes+1,newRating<0&&(newRating=0),$(".dislikes").addClass("rated"),$(".dislikes").find("span:nth-child(2)").html(newRating)),curObj.throwHeadMsg("success",isOk,5e3,!0))):alert("No data")},"text")},this.showMeTheMsg=function(a,b){curObj=this,isOk=1==b?$(a).filter("div.msg").find("div.alert").html():$(a).filter("div.msg").html(),isError=$(a).filter("div.error").html(),isError?isError.length>2&&curObj.throwHeadMsg("danger",isError,5e3,!0):isOk&&isOk.length>2&&curObj.throwHeadMsg("success",isOk,5e3,!0)},this.subscribeToChannelNew=function(a,b){curObj=this,$.post(page,{mode:b,subscribe_to:a},function(a){a?curObj.showMeTheMsg(a):alert("No data")},"text")},this.add_friendNew=function(a,b){curObj=this,$("#"+b).css("display","block"),$("#"+b).html(this.loading),$.post(page,{mode:"add_friend",uid:a},function(a){a?($("#"+b).css("display","none"),curObj.showMeTheMsg(a)):alert("No data")},"text")},this.subscribeToChannelNew=function(a,b){var c=this;$.post(page,{mode:b,subscribe_to:a},function(a){a?c.showMeTheMsg(a):alert("No data")},"text")},this.add_to_favNew=function(a,b){var c=this;$("#video_action_result_cont").css("display","block"),$("#video_action_result_cont").html(c.loading),$.post(page,{mode:"add_to_fav",type:a,id:b},function(a){a?($("#video_action_result_cont").hide(),c.showMeTheMsg(a,!0)):alert("No data")},"text")},this.flag_objectNew=function(a,b,c){var d=this;$("#flag_form_result").css("display","block"),$("#flag_form_result").html(this.loading),$.post(page,{mode:"flag_object",type:c,flag_type:$("#"+a+" select option:selected").val(),id:b},function(a){a?($("#flag_form_result").hide(),d.showMeTheMsg(a)):alert("No data")},"text")},this.uploadSubtitle=function(a,b,c){if(c.length<5)return!1;var d=$("#captions").prop("files")[0],e=new FormData;e.append("subtitle_lang",b),e.append("file",d),e.append("videoid",a),$.ajax({type:"post",cache:!1,contentType:!1,processData:!1,url:c,data:e,beforeSend:function(){},success:function(a){}})},this.add_playlistNew=function(a,b,c,d){switch(curObj=this,$("#playlist_form_result").css("display","block"),$("#playlist_form_result").html("loading"),a){case"add":$.post(page,{mode:"add_playlist",id:b,objtype:d,pid:$("#playlist_id option:selected").val()},function(a){if($("#playlist_form_result").html(""),a){if(a.err.length>2){cleanedHtml=$.parseHTML(a.err);var b=$(cleanedHtml).html();curObj.throwHeadMsg("danger",b,5e3,!0)}if(a.msg.length>2){cleanedHtml=$.parseHTML(a.msg);var b=$(cleanedHtml).find("div.alert").html();curObj.throwHeadMsg("success",b,5e3,!0),$("#"+c).css("display","none")}}else alert("No data")},"json");break;case"new":$.post(page,{mode:"add_new_playlist",id:b,objtype:d,plname:$("#playlist_name").val()},function(a){a?(a.err&&($("#playlist_form_result").css("display","block"),$("#playlist_form_result").html(a.err)),a.msg&&($("#playlist_form_result").css("display","block"),$("#playlist_form_result").html(a.msg),$("#"+c).css("display","none"))):alert("No data")},"json")}},this.getModalVideo=function(a){this.loading_img;$.ajax({type:"post",url:baseurl+"/ajax/commonAjax.php",data:{videoid:a,mode:"get_video"},dataType:"json",beforeSend:function(a){$(".my-modal-content").html('<div align="center" style="color:#fff;font-size:25px;padding:10px 10px 10px 10px;">'+loadingImg+"</div>"),$(".my-modal-content").attr("id","")},success:function(a){if(a.success){var b=a.video_link,c=a.video_details;$(".my-modal-content").attr("id",c.videoid),$(".my-modal-content").html(a.video);var d=$(document).find("#cb_video_js_"+c.videoid+"_html5_api"),d=d[0],e=setInterval(function(){navigator.userAgent.match(/Android/i)||(d.play(),$(f).find(".uploaderName").append('<a href="'+b+'" title="Watch Video Page" style="margin:-2px 5px 0 0;"><i class="glyphicon glyphicon-log-in pull-right" style="font-size:20px;color:#fff;"></i></a>'));var a=!d.paused,f=$(document).find("#cb_video_js_"+c.videoid),g=$(document).find("video");if(g.length>0)for(var h=0;h<g.length;h++){var i=$(g[h]).attr("id"),j=i.split("_");j=j[3],c.videoid!=j&&$(g[h])[0].pause()}a&&clearInterval(e)},300)}else a.failure&&$(".my-modal-content").html('<div class="alert alert-warning">'+a.message+"</div>")}})},this.getPlayerEl=function(a){var b=a,c=$(document).find(".cb_video_js_"+b+"-dimensions");return!!c&&c[0]}};window._cb=new _cb,window._cb.setRemoteId()}(window);