clipbucket/upload/js/clipbucket.min.js
2016-07-26 17:36:52 +05:00

1 line
No EOL
30 KiB
JavaScript
Executable file

!function(window){var _cb=function(){if(this.baseurl=baseurl,this.imageurl="",this.page=this.baseurl+"/ajax.php",this.loading_img="<img style='vertical-align:middle' src='"+this.imageurl+"/ajax-loader.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);else;this.setRemoteId=function(){this.remoteObjID=this.randomString()},this.Confirm_Delete=function(t){confirm("Are you sure you want to delete")&&(document.location=t)},this.Confirm_Uninstall=function(t){confirm("Are you sure you want to uninstall this plugin ?")&&(document.location=t)},this.confirm_it=function(t){var e=confirm(t);return e?!0:!1},this.reloadImage=function(t,e){img=document.getElementById(e),img.src=t+"?"+Math.random()},this.validate_category_form=function(thisform){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){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 t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",e=8,a="",o=0;e>o;o++){var i=Math.floor(Math.random()*t.length);a+=t.substring(i,i+1)}return a},this.check_remote_url=function(){var t=this,e=$("#remote_file_url").val(),a=$("#ytUploadBttn"),o=$("#remoteUploadBttn"),i=$("#remoteUploadBttnStop");if(this.force_stop=!1,e.match(/^e.g/)||"undefined"==typeof e||0===e.length)return $("#error_msgs").html('<div class="alert alert-danger" role="alert">Given URL is invalid!</div>'),!1;var s=function(t){"undefined"!=typeof t?(o.attr("disabled","disabled"),a.attr("disabled","disabled")):($(".downloadStatusContainer").removeClass("hidden"),o.attr("disabled","disabled").hide(),a.attr("disabled","disabled"),i.show())},n=function(t){"undefined"!=typeof t?(i.removeAttr("disabled").hide(),a.removeAttr("disabled"),o.removeAttr("disabled").show()):($(".downloadStatusContainer").addClass("hidden"),i.removeAttr("disabled").hide(),a.removeAttr("disabled"),o.removeAttr("disabled").show())};s();var l=$.ajax({url:t.download_page,type:"POST",data:{file:e,file_name:file_name},dataType:"JSON",beforeSend:function(){t.remoteUploadStatusUpdate();var a=t.getName(e);$("#loading").html("Downloading"),$("#remoteFileName").replaceWith('"'+a+'"')},success:function(e){if(t.force_stop=!0,e.error)return t.force_stop=!0,n(),$("#error_msgs").html('<div class="alert alert-danger" role="alert"> File Type Not Allowed!</div>'),!1;n(),$("#loading").html("");var a=e.vid;$.post(t.baseurl+"/actions/getVideoDetails.php",{file_name:file_name,vid:a},function(t){var e=$("#updateVideoInfoForm").clone();$(e).find("input[name=title]").val(t.title),$(e).find("textarea#desc").val(t.description),$(e).find("input[name='category[]']:first").attr("checked","checked");var o=document.createElement("input");o.name="videoid",o.type="hidden",o.value=a;var i=document.createElement("input");i.name="file_name",i.type="hidden",i.value=file_name,$(e).append(o),$(e).append(i),$("#remoteForm").html(""),$(e).removeClass("hidden").attr("id","uploadFormContainer_remote").appendTo("#remoteForm"),$(e).find("form").on({submit:function(t){t.preventDefault();var e=$(this),a=$(e).serialize();a+="&updateVideo=yes",$.ajax({url:baseurl+"/actions/file_uploader.php",type:"post",data:a}).success(function(t){msg=$.parseJSON(t),$("#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(t){t.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"))}}),$(e).on({submit:function(t){t.preventDefault();var e=$(this).serialize();e+="&updateVideo=yes",$.ajax({url:baseurl+"/actions/file_uploader.php",type:"post",data:e,dataType:"JSON"}).success(function(t){$("#uploadMessage").removeClass("hidden"),t.error?$("#uploadMessage").html(t.error).attr("class","alert alert-danger"):$("#uploadMessage").html(t.msg).attr("class","alert alert-success"),setTimeout(function(){$("#uploadMessage").addClass("hidden")},5e3)}).fail(function(t){console.log(t)})}})},"json")}});$("#remoteUploadBttnStop").click(function(){l.abort(),this.force_stop=!0,$("#loading").html(""),$("#remoteDownloadStatus").hide(),$(this).hide(),$("#remoteUploadBttn").attr("disabled","").show()})},this.remoteUploadStatusUpdate=function(){var t=this,e=$.ajax({url:t.result_page,type:"POST",data:{file_name:file_name},dataType:"JSON"});e.success(function(e){!1===t.force_stop&&(t.updateProgress(e),setTimeout(function(){t.remoteUploadStatusUpdate()},1e3*t.status_refesh))})},this.updateProgress=function(t){if("undefined"!=typeof t&&null!==t){var e=(t.downloaded/1048576).toFixed(2),a=(t.total_size/1048576).toFixed(2),o=t.downloaded/t.total_size*100;$("#downloadStatus").find("#downloaded").text(e+" Mb"),$("#downloadStatus").find("#totalSize").text(a+" Mb"),$("#prog_bar").css("width",o+"%")}},this.youtube_check_url=function(){var t=$("#remote_file_url").val();$("#ytUploadBttn"),$("#remoteUploadBttn"),$("#remoteUploadBttnStop");return this.force_stop=!1,t.match(/^e.g/)||"undefined"==typeof t||0===t.length?($("#error_msgs").html('<div class="alert alert-danger" role="alert"> Please enter valid URL !</div>'),!1):!0},this.youtube_upload=function(){if(!this.youtube_check_url())return!1;$("#remoteUploadBttn").attr("disabled","disabled"),$("#ytUploadBttn").attr("disabled","disabled");var t=$("#remote_file_url").val();if(force_stop=!1,!t||"undefined"==t)return alert("Please enter file url"),$("#remoteUploadBttn").attr("disabled",""),$("#ytUploadBttn").attr("disabled",""),!1;$.ajax({url:download_page,type:"POST",data:{file:t,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(t){t.error?(force_stop=!0,$("#remoteUploadBttn").attr("disabled",""),$("#ytUploadBttn").attr("disabled",""),alert(t.error)):t.vid&&(alert("this is checked success"),vid=t.vid,$("#remoteUploadBttn").attr("disabled","disabled").hide(),$("#ytUploadBttn").attr("disabled","disabled").hide(),$.post(baseurl+"/actions/file_uploader.php",{getForm:"get_form",title:t.title,desc:t.desc,tags:t.tags,objId:remoteObjID},function(t){$("#remoteForm").append(t),$("#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 t=this;$.ajax({url:t.result_page,type:"POST",data:{file_name:file_name},dataType:"json",success:function(e){if(e){var a=parseFloat(e.total_size),o=parseFloat(e.downloaded),i=parseFloat(e.total_size_fm),s=parseFloat(e.downloaded_fm),n=parseFloat(e.speed_download),l=(parseFloat(e.time_eta),parseFloat(e.time_eta_fm)),d=(parseFloat(e.time_took),parseFloat(e.time_took_fm));if(n/1024/1024>1)var r=Math.round(n/1024/1024)+" Mbps";else var r=Math.round(n/1024)+" Kbps";t.perc_download=Math.round(o/a*100),isNaN(s)?($("#remoteDownloadStatus").show(),$("#prog_bar").html("Loading"),$("#dspeed").html("Loading"),$("#eta").html("Loading"),$("#status").html("Loading")):($("#remoteDownloadStatus").show(),$("#prog_bar").animate({width:t.perc_download+"%"},1e3),$("#prog_bar").html(t.perc_download+"%"),$("#dspeed").html(r),$("#eta").html(l),$("#status").html(s+" of "+i))}var c=1e3*t.status_refesh;t.perc_download>99&&(t.force_stop=!0),t.force_stop?100==t.perc_download&&a>1&&$("#time_took").html("Time Took : "+d):setTimeout(function(){t.status_update()},c)}})},this.upload_file=function(t,e){var a=this.baseurl+"/actions/file_downloader.php";$.post(a,{file_url:t,file_name:e},function(t){t?submit_upload_form():alert("No data")},"text")},this.delete_item=function(t,e,a,o){$("#"+t+"-"+e).click(function(){confirm(a)&&(document.location=o)})},this.delete_video=function(t,e,a,o){return delete_item(t,e,a,o)},this.get_video=function(t,e){$(e).css("display","block"),$(e).html(this.loading),$(e).html(this.loading),$.post(page,{mode:t},function(t){$(e).html(t)},"text")},this.getAjaxPhoto=function(t,e){var a=this;$(e).css("display","block");var o=$(e).html();$.ajax({url:a.page,type:"POST",dataType:"json",data:{mode:"loadAjaxPhotos",photosType:t},beforeSend:function(){$(e).html(this.loading)},success:function(t){t.failed&&$(e).html(o),t.completed&&$(e).html(t.photoBlocks)}})},this.rating_over=function(t,e){"disabled"!=e&&$("#rating_result_container").html(t)},this.rating_out=function(t,e){"disabled"!=e&&$("#rating_result_container").html(t)},this.submit_share_form=function(t,e){$("#share_form_results").css("display","block"),$("#share_form_results").html(this.loading),$.post(page,{mode:"share_object",type:e,users:$("#ShareUsers").val(),message:$("#message").val(),id:$("#objectid").val()},function(t){t?$("#share_form_results").html(t):alert("No data")},"text")},this.flag_object=function(t,e,a){$("#flag_form_result").css("display","block"),$("#flag_form_result").html(this.loading),$.post(page,{mode:"flag_object",type:a,flag_type:$("#"+t+" select option:selected").val(),id:e},function(t){t?($("#flag_form_result").css("display","block"),$("#flag_form_result").html(t)):alert("No data")},"text")},this.slide_up_watch_video=function(t){"block"!=$(".video_action_result_boxes "+t).css("display")&&$(".video_action_result_boxes > *").slideUp()},this.add_to_fav=function(t,e){$("#video_action_result_cont").css("display","block"),$("#video_action_result_cont").html(this.loading),$.post(page,{mode:"add_to_fav",type:t,id:e},function(t){t?($("#video_action_result_cont").css("display","block"),$("#video_action_result_cont").html(t)):alert("No data")},"text")},this.subscriber=function(t,e,a){$("#"+a).css("display","block"),$("#"+a).html(this.loading),$.post(page,{mode:e,subscribe_to:t},function(t){t?($("#"+a).css("display","block"),$("#"+a).html(t)):alert("No data")},"text")},this.add_friend=function(t,e){$("#"+e).css("display","block"),$("#"+e).html(this.loading),$.post(page,{mode:"add_friend",uid:t},function(t){t?($("#"+e).css("display","block"),$("#"+e).html(t)):alert("No data")},"text")},this.block_user=function(t,e){$("#"+e).css("display","block"),$("#"+e).html(this.loading),$.post(page,{mode:"ban_user",user:t},function(t){t?($("#"+e).css("display","block"),$("#"+e).html(t)):alert("No data")},"text")},this.rate_comment=function(t,e,a,o){$.post(page,{mode:"rate_comment",thumb:e,cid:t,type:a,typeid:o},function(e){e?(""!=e.msg&&alert(e.msg),""!=e.rate&&$("#comment_rating_"+t).html(e.rate)):alert("No data")},"json")},this.delete_comment=function(t,e){$.post(page,{mode:"delete_comment",cid:t,type:e},function(e){e?(e.msg&&(alert(e.msg),$("#comment_"+t).fadeOut("slow"),$("#spam_comment_"+t).fadeOut("slow")),e.err&&alert(e.err)):alert("No data")},"json")},this.add_comment_js=function(t,e){$("#add_comment_result").css("display","block"),$("#add_comment_result").html(this.loading),$("#add_comment_button").attr("disabled","disabled");var a=$("#"+t).serialize()+"&mode=add_comment";$.post(page,a,function(t){t?($("#add_comment_button").attr("disabled",""),$("#add_comment_result").css("display","block"),""!=t.err&&$("#add_comment_result").html(t.err),""!=t.msg&&$("#add_comment_result").html(t.msg),t.cid&&get_the_comment(t.cid,"#latest_comment_container")):alert("No data")},"json")},this.get_the_comment=function(t,e){$(e).html(this.loading),$.post(page,{mode:"get_comment",cid:t},function(t){t?($(e).css("display","none"),$(e).html(t).fadeIn("slow")):alert("No data")},"text")},this.add_playlist=function(t,e,a,o){switch($("#playlist_form_result").css("display","block"),$("#playlist_form_result").html(this.loading),t){case"add":$.post(page,{mode:"add_playlist",id:e,objtype:o,pid:$("#playlist_id option:selected").val()},function(t){t?(""!=t.err&&($("#playlist_form_result").css("display","block"),$("#playlist_form_result").html(t.err)),""!=t.msg&&($("#playlist_form_result").css("display","block"),$("#playlist_form_result").html(t.msg),$("#"+a).css("display","none"))):alert("No data")},"json");break;case"new":$.post(page,{mode:"add_new_playlist",id:e,objtype:o,plname:$("#playlist_name").val()},function(t){t?(t.err&&($("#playlist_form_result").css("display","block"),$("#playlist_form_result").html(t.err)),t.msg&&($("#playlist_form_result").css("display","block"),$("#playlist_form_result").html(t.msg),$("#"+a).css("display","none"))):alert("No data")},"json")}},this.add_quicklist=function(t,e){$(t).attr("src",this.imageurl+"/ajax-loader.gif"),$(t).css("background-position","-200px 200px"),$.post(page,{mode:"quicklist",todo:"add",vid:e},function(e){e?($(t).attr("src",this.imageurl+"/dot.gif"),$(t).css("background-position","-0px -0px"),$(t).removeClass("add_icon"),$(t).addClass("check_icon"),$(t).removeAttr("onClick"),load_quicklist_box()):alert("No data")},"text")},this.remove_qucklist=function(t,e){$.post(page,{mode:"quicklist",todo:"remove",vid:e},function(e){e?($(t).slideUp(),$(t).hide()):alert("No data")},"text")},this.load_quicklist_box=function(){$.post(page,{mode:"getquicklistbox"},function(t){t=$.trim(t),t?($("#quicklist_box").css("display","block"),$("#quicklist_box").html(t),"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(t){load_quicklist_box()},"text")},this.quick_show_hide_toggle=function(t){$(t).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(t,e){"none"==$(t).css("display")&&($("#group_info_cont > div").slideUp(),$("#group_info_cont "+t).slideDown(),$(".group_detail_tabs .selected").removeClass("selected"),$(e).addClass("selected"))},this.show_menu=function(t,e){if(window.location.hash&&e){var a=window.location.hash;return show_menu(a.substr(9),!1),!1}window.location.hash="current_"+t,this.current_menu!=t&&hide_menu(),$("#"+t).show(),this.current_menu=t,$("."+t).addClass("selected")},this.hide_menu=function(){return""!=this.current_menu?($("#"+this.current_menu).hide(),$("."+this.current_menu).removeClass("selected"),!0):void 0},this.to_reply=function(t){$("#reply_to").val(t),window.location="#add_comment"},this.spam_comment=function(t,e,a){$.post(page,{mode:"spam_comment",cid:t,type:e,typeid:a},function(e){e?(e.msg&&($("#comment_"+t).hide(),$("#spam_comment_"+t).fadeIn("slow")),e.err&&alert(e.err)):alert("No data")},"json")},this.hq_toggle=function(t,e){if(this.has_hq_function){var t=t,e=e;return hq_function(),!1}"block"==$(t).css("display")?(""==this.normal_player_html&&(this.normal_player_html=$(t).html()),$(t).html("")):""!=this.normal_player_html&&$(t).html(this.normal_player_html),"block"==$(e).css("display")?(""==this.hq_player_html&&(this.hq_player_html=$(e).html()),$(e).html("")):""!=this.hq_player_html&&$(e).html(this.hq_player_html),$(t+","+e).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(t,e,a,o,i,s){switch($(o).css("display","block"),$(o).html(this.loading),e){case"add_new_item":$.post(page,{mode:e,cid:$("#"+t+" #collection").val(),obj_id:a,type:i},function(t){t?(t.msg&&$(o).html(t.msg),t.err&&$(o).html(t.err)):alert("No Data returned")},"json");break;case"remove_collection_item":$("#"+t).hide(),$.post(page,{mode:e,obj_id:a,type:i,cid:s},function(e){e?(e.err&&(alert(e.err),$(o+"_"+a).hide(),$("#"+t+a).show()),e.msg&&($(o).html(e.msg),$("#"+t+"_"+a).slideUp(350))):(alert("No Data Returned"),$(o+"_"+a).hide(),$("#"+t).show())},"json")}return!1},this.openURL=function(t){document.locati=t},this.get_item=function(t,e,a,o,i){var s=$(t).html();$(t).html(this.loading),$.post(page,{mode:"get_item",ci_id:e,cid:a,type:o,direction:i},function(e){if(e){var a=new Array(o,e.cid,e.key);construct_url(a),$("#collectionItemView").html(e.content)}else alert("No "+o+" returned"),$(t).text(s)},"json")},this.construct_url=function(t){var e;"yes"==Seo?(e="#!/item/"+t[0]+"/"+t[1]+"/"+t[2],window.location.hash=e):(e="#!?item="+t[2]+"&type="+t[0]+"&collection="+t[1],window.location.hash=e)},this.onReload_item=function(){var t,e;window.location.hash&&(t=window.location.href,"yes"==Seo?(e=RegExp("/item.+#!"),e.test(t)&&(t=t.replace(e,""),window.location.href=t)):(e=RegExp("\\?item.+#!"),e.test(t)&&(t=t.replace(e,""),window.location.href=t)))},this.pagination=function(t,e,a,o){var i,s=this,n=$(t),l=(n.id,n.parent()),d=n.html();l.attr("id")?i=parent.attr("id"):(l.attr("id","loadMoreParent"),i=l.attr("id")),newCall=$.ajax({url:s.page,type:"post",dataType:"json",data:{mode:"moreItems",page:o,cid:e,type:a},beforeSend:function(){n.removeAttr("onClick"),n.html(s.loading)},success:function(e){e.error?("BUTTON"==t.tagName&&n.attr("disabled","disabled"),n.removeAttr("onClick"),n.html("No more "+a)):($("#collectionItemsList").append(e.content),$("#NewPagination").html(e.pagination),n.html(d))}})},this.ajax_add_collection=function(t){var e,a=this,o=t.form.id,i=$("#"+o),s=$(t),n=s.html(),l=$("#CollectionResult");e=$.ajax({url:a.page,type:"post",dataType:"json",data:"mode=add_collection&"+i.serialize(),beforeSend:function(){"block"==l.css("display")&&l.slideUp("fast"),s.attr("disabled","disabled"),s.html(this.loading)},success:function(t){t.msg?($("#CollectionDIV").slideUp("fast"),l.html(t.msg).slideDown("fast"),this.collectionID=t.id):(l.html(t.err).slideDown("fast"),s.removeAttr("disabled"),s.html(n))}})},this.getDetails=function(t){var e=getInputs(t),a=new Array(e.length);return $.each(e,function(t,e){query=$("#"+e.id+" *").serialize(),query+="&mode=ajaxPhotos",a[t]=query}),a},this.getName=function(t){var e=t,a=e.substring(e.lastIndexOf("/")+1);return a},this.viewRatings=function(t,e){var a=$(t),o=a.html();document.getElementById("RatingStatContainer")?$("#RatingStatContainer").toggle():loadAjax=$.ajax({url:page,type:"post",dataType:"text",data:{mode:"viewPhotoRating",photoid:e},beforeSend:function(){a.html(this.loading)},success:function(t){a.html(o),t?$("<div />").attr("id","RatingStatContainer").addClass("clearfix").css({padding:"8px",font:"normal 11px Tahoma",border:"1px solid #ccc",backgroundColor:"#FFF"}).html(t).fadeIn(350).insertAfter(a):(a.removeAttr("onclick"),alert("Photo has not recieved any rating yet."))}})},this.showAdvanceSearch=function(t,e,a,o){var i=($("#"+t),$("#"+e)),s=$("#SearchType").val();i.toggle(),"block"==i.css("display")&&i.children().hide().filter("#"+s).show(),$("."+a).toggleClass(o)},this.toggleCategory=function(t,e){var a=$(t),o=a.attr("alt"),i=$("#"+o),s=o.split("_"),n=s[0],l=$.browser.msie,d=$.browser.version;"none"==i.css("display")?(i.slideDown(350),l&&"7.0"==d&&i.addClass("internetExplorer7CategoryToggleFix"),$.cookie(n,"expanded",{expires:1,path:"/"}),a.removeClass("none").addClass("block")):(i.slideUp(350),l&&"7.0"==d&&i.removeClass("internetExplorer7CategoryToggleFix"),$.cookie(n,"collapsed",{expires:1,path:"/"}),a.removeClass("block").addClass("none"))},this.loadObject=function(t,e,a,o){var i=this,s=new Array(4);s["this"]=t,s.type=e,s.objID=a,s.container=o;var n=$(s["this"]);n.parent().css("position","relative"),$.ajax({url:i.page,type:"POST",dataType:"json",data:{mode:"channelFeatured",contentType:s.type,objID:s.objID},beforeSend:function(){n.find("img").animate({opacity:.5}),$("#"+s.container).animate({opacity:.5})},success:function(t){t.error?(n.find("img").animate({opacity:1}),$("#"+s.container).animate({opacity:1}),alert(t.error)):(n.parent().children(".selected").removeClass("selected"),n.addClass("selected"),n.find("img").animate({opacity:1}),$("#"+s.container).html(t.data),$("#"+s.container).animate({opacity:1}))}})},this.channelObjects=function(t,e,a,o,i){var s=this,n=$(t),l=n.attr("rel"),d=$(e),r=n.parents("ul").find("a.selected").attr("rel");if(l){if("block"==$("#"+l).css("display"))return!1;n.parents("ul").find("a.selected").removeClass("selected"),n.addClass("selected"),$("#"+r).hide(),$("#"+l).show()}else{var c=a+"DIV";n.attr("rel",c),$.ajax({url:s.page,type:"POST",dataType:"json",data:{mode:"channelObjects",content:a,user:o,assign:i},beforeSend:function(){n.append(this.loading_img)},success:function(t){n.find("img").remove(),n.parents("ul").find("a.selected").removeClass("selected"),n.addClass("selected"),$("#"+r).hide(),$("<div></div>").attr("id",c).addClass($("#"+r).attr("class")).html(t.html).appendTo(d)}})}};var comments_voting="no";this.getComments=function(t,e,a,o,i,s,n){var l=this;$("#comments").html("<div style='padding:5px 0px;'>"+this.loading+"</div>"),$.ajax({type:"POST",url:l.page,data:{mode:"getComments",page:o,type:t,type_id:e,object_type:s,last_update:a,total_comments:i,comments_voting:comments_voting,admin:n},success:function(t){$("#comments").hide(),$("#comments").html(t),$("#comments").fadeIn("slow")},dataType:"text"})},this.checkUncheckAll=function(t){var e=theElemeform,a=0;for(a=0;a<e.length;a++)"checkbox"==e[a].type&&"checkall"!=e[a].name&&(e[a].checked=t.checked)},this.rate=function(t,e,a){alert("BIEATCh");var o=this.baseurl+"/ajax.php";$.post(o,{mode:"rating",id:t,rating:e,type:a},function(t){t?$("#rating_container").html(t):alert("No data")},"text")},this.setPageHash=function(t){var e=t.replace(this.baseurl,"");window.location.hash.replace("#!","");window.location.hash="#!"+e},this.callURLParser=function(){var t,e=/(\#![\/a-zA-Z0-9=\.\&\-\_\?]*)/g,a=window.location.href,o=a.match(e);o&&(t=o[o.length-1],t&&(window.location.href=this.baseurl+t.replace("#!","")))},this.groupsAjax=function(t,e,a){t.preventDefault();var o,i,s,n=!1;return void 0==a&&(a="ajaxGroupResultContainer"),e.href?(o=e.href,n=!0,jqueryObj=$(e),javaObj=e):(o=e.childNodes[0].href,jqueryObj=$(e.childNodes[0]),javaObj=e.childNodes[0]),"undefined"==o?(alert("URL not found"),!1):(i=jqueryObj.html(),setPageHash(o),1==n?(s=jqueryObj.parent().parent(),s.children().filter(".selected").removeClass("selected"),jqueryObj.parent().addClass("selected")):(s=jqueryObj.parent(),s.children().filter(".selected").removeClass("selected"),jqueryObj.addClass("selected")),jqueryObj.html(this.loading_img),$("#"+a).load(o+" #"+a,function(t,e,a){jqueryObj.html(i),document.getElementById("flag_item")&&$("#flag_item").show()}),void 0)},this.encode64=function(t){for(var e,a,o,i,s,n,l,d=nStringMaker(),r=0;r<t.length;)e=t.charCodeAt(r++),a=t.charCodeAt(r++),o=t.charCodeAt(r++),i=e>>2,s=(3&e)<<4|a>>4,n=(15&a)<<2|o>>6,l=63&o,isNaN(a)?n=l=64:isNaN(o)&&(l=64),d.append(this.keyStr.charAt(i)+this.keyStr.charAt(s)+this.keyStr.charAt(n)+this.keyStr.charAt(l));return d.toString()},this.decode64=function(t){var e,a,o,i,s,n,l,d=nStringMaker(),r=0;for(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");r<t.length;)i=this.keyStr.indexOf(t.charAt(r++)),s=this.keyStr.indexOf(t.charAt(r++)),n=this.keyStr.indexOf(t.charAt(r++)),l=this.keyStr.indexOf(t.charAt(r++)),e=i<<2|s>>4,a=(15&s)<<4|n>>2,o=(3&n)<<6|l,d.append(String.fromCharCode(e)),64!=n&&d.append(String.fromCharCode(a)),64!=l&&d.append(String.fromCharCode(o));return d.toString()},this.getAllComments=function(t,e,a,o,i,s,n){$("#userCommentsList").html("<div style='padding:5px 0px;'>"+loading+"</div>"),$.ajax({type:"POST",url:page,data:{mode:"getComments",page:o,type:t,type_id:e,object_type:s,last_update:a,total_comments:i,comments_voting:comments_voting,admin:n},success:function(t){$("#userCommentsList").html(t)},dataType:"text"})},this.getCommentsNew=function(t,e,a,o,i,s,n){$.ajax({type:"POST",url:page,data:{mode:"getCommentsNew",page:o,type:t,type_id:e,object_type:s,last_update:a,total_comments:i,comments_voting:comments_voting,admin:n},beforeSend:function(){$(document).find("#load-more-comments").text("loading comments..")},success:function(t){"none"==t?($("#load-more-comments").text("End of comments list"),$("#load-more-comments").attr("disabled","disabled")):($("#userCommentsList").append(t),$(document).find("#load-more-comments").text("Load More"))},dataType:"text"})},this.addToFav=function(t,e){$("#messageFav").show(),$.post(page,{mode:"add_to_fav",type:t,id:e},function(t){t?($("#messageFav").html(t),setTimeout(function(){$("#messageFav").hide()},5e3)):alert("No data")},"text")},this.subscribeToChannel=function(t,e,a){$("#messageFav").show(),$.post(page,{mode:e,subscribe_to:t},function(t){t?($("#messageFav").html(t),setTimeout(function(){$("#messageFav").hide()},5e3)):alert("No data")},"text")},this.debounce=function(t,e,a){var o;return function(){var i=this,s=arguments,n=function(){o=null,a||t.apply(i,s)},l=a&&!o;clearTimeout(o),o=setTimeout(n,e),l&&t.apply(i,s)}},this.throwHeadMsg=function(t,e,a,o){$(document).find("#headErr").remove(),a=parseInt(a),1==o&&$("html, body").animate({scrollTop:0},"slow"),10>a&&(a=3e3),t.length<3&&(t="info"),$('<div id="headErr" style="display:none" class="alert-msg-holder"><div class="alert alert-'+t+' alert-dismissible alert-ajax" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>'+e+"</div></div>").insertAfter("#header").fadeIn("slow").delay(a).fadeOut()},this.rateNew=function(t,e,a){curObj=this;var o=baseurl+"/ajax.php";$.post(o,{mode:"rating",id:t,rating:e,type:a},function(t){t?(likesSect=$(".likes").find("span:nth-child(2)").html(),dislikesSect=$(".dislikes").find("span:nth-child(2)").html(),currLikes=parseInt(likesSect),currDislikes=parseInt(dislikesSect),isError=$(t).find("span.error").html(),isOk=$(t).find("span.msg").html(),isError?isError.length>2&&curObj.throwHeadMsg("danger",isError,5e3,!0):isOk&&isOk.length>2&&(5==e?(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(t,e){curObj=this,1==e?isOk=$(t).filter("div.msg").find("div.alert").html():isOk=$(t).filter("div.msg").html(),isError=$(t).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(t,e){curObj=this,$.post(page,{mode:e,subscribe_to:t},function(t){t?curObj.showMeTheMsg(t):alert("No data")},"text")},this.add_friendNew=function(t,e){curObj=this,$("#"+e).css("display","block"),$("#"+e).html(this.loading),$.post(page,{mode:"add_friend",uid:t},function(t){t?($("#"+e).css("display","none"),curObj.showMeTheMsg(t)):alert("No data")},"text")},this.subscribeToChannelNew=function(t,e){var a=this;$.post(page,{mode:e,subscribe_to:t},function(t){t?a.showMeTheMsg(t):alert("No data")},"text")},this.add_to_favNew=function(t,e){var a=this;$("#video_action_result_cont").css("display","block"),$("#video_action_result_cont").html(a.loading),$.post(page,{mode:"add_to_fav",type:t,id:e},function(t){t?($("#video_action_result_cont").hide(),a.showMeTheMsg(t,!0)):alert("No data")},"text")},this.flag_objectNew=function(t,e,a){var o=this;$("#flag_form_result").css("display","block"),$("#flag_form_result").html(this.loading),$.post(page,{mode:"flag_object",type:a,flag_type:$("#"+t+" select option:selected").val(),id:e},function(t){t?($("#flag_form_result").hide(),o.showMeTheMsg(t)):alert("No data")},"text")},this.uploadSubtitle=function(t,e,a){if(a.length<5)return!1;var o=$("#captions").prop("files")[0],i=new FormData;i.append("subtitle_lang",e),i.append("file",o),i.append("videoid",t),$.ajax({type:"post",cache:!1,contentType:!1,processData:!1,url:a,data:i,beforeSend:function(){},success:function(t){}})},this.add_playlistNew=function(t,e,a,o){switch(curObj=this,$("#playlist_form_result").css("display","block"),$("#playlist_form_result").html("loading"),t){case"add":$.post(page,{mode:"add_playlist",id:e,objtype:o,pid:$("#playlist_id option:selected").val()},function(t){if($("#playlist_form_result").html(""),t){if(t.err.length>2){cleanedHtml=$.parseHTML(t.err);var e=$(cleanedHtml).html();curObj.throwHeadMsg("danger",e,5e3,!0)}if(t.msg.length>2){cleanedHtml=$.parseHTML(t.msg);var e=$(cleanedHtml).find("div.alert").html();curObj.throwHeadMsg("success",e,5e3,!0),$("#"+a).css("display","none")}}else alert("No data")},"json");break;case"new":$.post(page,{mode:"add_new_playlist",id:e,objtype:o,plname:$("#playlist_name").val()},function(t){t?(t.err&&($("#playlist_form_result").css("display","block"),$("#playlist_form_result").html(t.err)),t.msg&&($("#playlist_form_result").css("display","block"),$("#playlist_form_result").html(t.msg),$("#"+a).css("display","none"))):alert("No data")},"json")}}};window._cb=new _cb,window._cb.setRemoteId()}(window);