2009-08-25 12:16:42 +00:00
// JavaScript Document
2009-12-04 21:03:27 +00:00
var page = baseurl + '/ajax.php' ;
2010-12-28 13:56:44 +00:00
var loading _img = "<img style='vertical-align:middle' src='" + imageurl + "/ajax-loader.gif'>" ;
2010-01-16 09:19:34 +00:00
var loading = loading _img + " Loading..." ;
2010-01-20 07:58:20 +00:00
2009-08-25 12:16:42 +00:00
function Confirm _Delete ( delUrl ) {
if ( confirm ( "Are you sure you want to delete" ) ) {
document . location = delUrl ;
}
}
function Confirm _Uninstall ( delUrl ) {
if ( confirm ( "Are you sure you want to uninstall this plugin ?" ) ) {
document . location = delUrl ;
}
}
function Confirm _DelVid ( delUrl ) {
if ( confirm ( "Are you sure you want to delete this video?" ) ) {
document . location = delUrl ;
}
}
2009-12-31 11:56:47 +00:00
function confirm _it ( msg )
{
var action = confirm ( msg ) ;
if ( action )
{
return true ;
} else
return false ;
2009-08-25 12:16:42 +00:00
}
2009-12-09 13:43:19 +00:00
function reloadImage ( captcha _src , imgid )
2009-08-25 12:16:42 +00:00
{
2009-12-09 13:43:19 +00:00
img = document . getElementById ( imgid ) ;
2009-08-25 12:16:42 +00:00
img . src = captcha _src + '?' + Math . random ( ) ;
}
//Validate the Add Category Form
function validate _category _form ( thisform )
{
with ( thisform )
{
if ( validate _required ( title , "Title must be filled out!" ) == false )
{
title . focus ( ) ; return false ;
}
if ( validate _required ( description , "Description must be filled out!" ) == false )
{
description . focus ( ) ; return false ;
}
}
}
//Validate the Add Advertisment Form
function validate _ad _form ( thisform )
{
with ( thisform )
{
if ( validate _required ( name , "Name must be filled out!" ) == false )
{
name . focus ( ) ; return false ;
}
if ( validate _required ( type , "Type must be filled out!" ) == false )
{
type . focus ( ) ; return false ;
}
if ( validate _required ( syntax , "Syntax Must Be Filled Out" ) == false )
{
syntax . focus ( ) ; return false ;
}
if ( validate _required ( code , "Code Must Be Filled Out" ) == false )
{
code . focus ( ) ; return false ;
}
}
}
//CHECKK ALL FUNCTIOn
<!--
function checkAll ( wotForm , wotState ) {
for ( a = 0 ; a < wotForm . elements . length ; a ++ ) {
if ( wotForm . elements [ a ] . id . indexOf ( "delete_" ) == 0 ) {
wotForm . elements [ a ] . checked = wotState ;
}
}
}
// -->
2010-11-13 12:20:34 +00:00
2010-12-24 14:22:47 +00:00
function randomString ( )
{
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz" ;
var string _length = 8 ;
var randomstring = '' ;
for ( var i = 0 ; i < string _length ; i ++ ) {
var rnum = Math . floor ( Math . random ( ) * chars . length ) ;
randomstring += chars . substring ( rnum , rnum + 1 ) ;
}
return randomstring ;
}
2010-11-13 12:20:34 +00:00
var download = 0 ;
var total _size = 0 ;
var cur _speed = 0 ;
var status _refesh = 1 //in seconds
var result _page = baseurl + '/actions/file_results.php' ;
var download _page = baseurl + '/actions/file_downloader.php' ;
var count = 0 ;
var force _stop = false ;
2010-12-24 14:22:47 +00:00
var remoteObjID = randomString ( ) ;
2010-11-13 12:20:34 +00:00
2009-08-25 12:16:42 +00:00
function check _remote _url ( )
{
2010-12-24 14:22:47 +00:00
$ ( '#remoteUploadBttn' ) . attr ( "disabled" , "disabled" ) . hide ( ) ;
$ ( '#remoteUploadBttnStop' ) . show ( ) ;
2010-11-13 12:20:34 +00:00
var file = $ ( "#remote_file_url" ) . val ( ) ;
force _stop = false ;
if ( ! file || file == 'undefined' )
{
alert ( "Please enter file url" ) ;
2010-12-24 14:22:47 +00:00
$ ( '#remoteUploadBttn' ) . attr ( 'disabled' , '' ) . show ( ) ;
$ ( '#remoteUploadBttnStop' ) . attr ( "disabled" , "disabled" ) . hide ( ) ;
2010-11-13 12:20:34 +00:00
return false ;
}
var ajaxCall = $ . ajax ( {
url : download _page ,
type : "POST" ,
data : ( { file : file , file _name : file _name } ) ,
dataType : 'json' ,
beforeSend : function ( )
{
2010-12-24 14:22:47 +00:00
2010-11-13 12:20:34 +00:00
status _update ( ) ;
2010-12-24 14:22:47 +00:00
var remoteFileName = getName ( file ) ;
$ ( "#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">' + lang . remoteUploadFile + '</div><div class="clear"></div>' ) ;
$ ( '#remoteFileName' ) . replaceWith ( '"' + remoteFileName + '"' ) ;
2010-11-13 12:20:34 +00:00
} ,
success : function ( data )
{
if ( data . error )
{
force _stop = true ;
2010-12-24 14:22:47 +00:00
$ ( '#remoteUploadBttn' ) . attr ( 'disabled' , '' ) ;
2010-11-13 12:20:34 +00:00
alert ( data . error ) ;
}
$ ( "#loading" ) . html ( '' ) ;
}
}
) ;
2010-12-24 14:22:47 +00:00
$ ( '#remoteUploadBttnStop' ) . click ( function ( ) {
ajaxCall . abort ( ) ; force _stop = true ; $ ( "#loading" ) . html ( '' ) ; $ ( '#remoteDownloadStatus' ) . hide ( ) ; $ ( this ) . hide ( ) ; $ ( '#remoteUploadBttn' ) . attr ( 'disabled' , '' ) . show ( ) ; } ) ;
2010-11-13 12:20:34 +00:00
}
2010-12-24 14:22:47 +00:00
var hasLoaded = false ;
2010-11-13 12:20:34 +00:00
var perc _download = 0 ;
function status _update ( )
{
2009-08-25 12:16:42 +00:00
2010-11-13 12:20:34 +00:00
var ajaxCall = $ . ajax ( {
url : result _page ,
type : "POST" ,
data : ( { file _name : file _name } ) ,
dataType : "json" ,
success : function ( data ) {
2009-08-25 12:16:42 +00:00
2010-11-13 12:20:34 +00:00
if ( data )
{
var total = data . total _size ;
var download = data . downloaded ;
var total _fm = data . total _size _fm ;
var download _fm = data . downloaded _fm ;
var speed = data . speed _download ;
var eta = data . time _eta ;
var eta _fm = data . time _eta _fm ;
var time _took = data . time _took ;
var time _took _fm = data . time _took _fm ;
if ( speed / 1024 / 1024 > 1 )
{
var theSpeed = Math . round ( speed / 1024 / 1024 ) + " Mbps" ;
} else
var theSpeed = Math . round ( speed / 1024 ) + " Kbps" ;
perc _download = Math . round ( download / total * 100 ) ;
2010-12-24 14:22:47 +00:00
$ ( '#remoteDownloadStatus' ) . show ( ) ;
//$('#prog_bar').width(perc_download+'%');
$ ( '#prog_bar' ) . animate ( { width : perc _download + '%' } , 1000 ) ;
2010-11-13 12:20:34 +00:00
$ ( '#prog_bar' ) . html ( perc _download + '%' ) ;
$ ( '#dspeed' ) . html ( theSpeed ) ;
2010-12-24 14:22:47 +00:00
$ ( '#eta' ) . html ( eta _fm ) ;
2010-11-13 12:20:34 +00:00
$ ( '#status' ) . html ( download _fm + ' of ' + total _fm ) ;
}
2010-12-24 14:22:47 +00:00
var intval = status _refesh * 1000 ;
if ( perc _download < 100 && ! force _stop )
setTimeout ( function ( ) { status _update ( ) } , intval ) ;
else if ( perc _download == 100 && total > 1 )
{
$ ( '#time_took' ) . html ( 'Time Took : ' + time _took _fm ) ;
//Del the log file
$ . ajax ( {
url : result _page ,
type : "POST" ,
data : ( { del _log : 'yes' , file _name : file _name } ) ,
success : function ( data )
{
$ ( '#remoteUploadBttnStop' ) . hide ( ) ;
2010-11-13 12:20:34 +00:00
2010-12-24 14:22:47 +00:00
$ . post ( baseurl + '/actions/file_uploader.php' ,
{ "getForm" : "get_form" , "title" : $ ( "#remote_file_url" ) . val ( ) , "objId" : remoteObjID } ,
function ( data )
{
$ ( '#remoteForm' ) . append ( data ) ;
} , 'text' ) ;
$ . ajax ( {
url : baseurl + '/actions/file_uploader.php' ,
type : "POST" ,
data : ( { "insertVideo" : "yes" , "title" : $ ( "#remote_file_url" ) . val ( ) , "file_name" : file _name } ) ,
dataType : "json" ,
success : function ( data )
{
vid = data ;
$ ( '#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" />' ) ;
}
} ) ;
}
} ) ;
}
2010-11-13 12:20:34 +00:00
}
}
) ;
2009-08-25 12:16:42 +00:00
}
function upload _file ( Val , file _name )
{
var page = baseurl + '/actions/file_downloader.php' ;
$ . post ( page ,
{
file _url : Val ,
file _name : file _name
} ,
function ( data )
{
if ( ! data )
alert ( "No data" ) ;
else
2010-01-20 11:41:51 +00:00
submit _upload _form ( ) ;
2009-08-25 12:16:42 +00:00
} , 'text' ) ;
}
2009-11-04 10:27:40 +00:00
/ * *
2009-12-21 21:11:54 +00:00
* Function used to delete any item with confirm message
2009-11-04 10:27:40 +00:00
* /
2009-12-21 21:11:54 +00:00
function delete _item ( obj , id , msg , url )
2009-11-04 10:27:40 +00:00
{
2009-12-21 21:11:54 +00:00
$ ( "#" + obj + '-' + id ) . click ( function ( ) {
2009-11-04 10:27:40 +00:00
if ( confirm ( msg ) ) {
document . location = url ;
}
} ) ;
}
2009-12-21 21:11:54 +00:00
function delete _video ( obj , id , msg , url ) { return delete _item ( obj , id , msg , url ) ; }
2009-11-30 19:46:45 +00:00
/ * *
* Function used to load editor ' s pic video
* /
function get _ep _video ( vid )
{
var page = baseurl + '/plugins/editors_pick/get_ep_video.php' ;
2010-01-16 09:19:34 +00:00
$ ( "#ep_video_container" ) . html ( loading ) ;
2009-11-30 19:46:45 +00:00
$ . post ( page ,
{
2010-04-24 15:40:22 +00:00
vid : vid
2009-11-30 19:46:45 +00:00
} ,
function ( data )
{
if ( ! data )
alert ( "No data" ) ;
else
$ ( "#ep_video_container" ) . html ( data ) ;
} , 'text' ) ;
}
/ * *
* Function used to load editor ' s pic video
* /
function get _video ( type , div )
{
2010-01-16 09:19:34 +00:00
$ ( div ) . css ( "display" , "block" ) ;
$ ( div ) . html ( loading ) ;
$ ( div ) . html ( loading ) ;
2009-11-30 19:46:45 +00:00
$ . post ( page ,
{
2010-04-24 15:40:22 +00:00
mode : type
2009-11-30 19:46:45 +00:00
} ,
function ( data )
{
2009-12-01 11:51:31 +00:00
$ ( div ) . html ( data ) ;
2009-11-30 19:46:45 +00:00
} , 'text' ) ;
}
function rating _over ( msg , disable )
{
if ( disable != 'disabled' )
$ ( "#rating_result_container" ) . html ( msg ) ;
}
function rating _out ( msg , disable )
{
if ( disable != 'disabled' )
$ ( "#rating_result_container" ) . html ( msg ) ;
}
function submit _share _form ( form _id , type )
{
2009-12-04 21:03:27 +00:00
2010-01-16 09:19:34 +00:00
$ ( "#share_form_results" ) . css ( "display" , "block" ) ;
$ ( "#share_form_results" ) . html ( loading ) ;
2009-11-30 19:46:45 +00:00
$ . post ( page ,
{
mode : 'share_object' ,
type : type ,
users : $ ( "#" + form _id + " input:#users" ) . val ( ) ,
2010-07-01 07:32:56 +00:00
message : $ ( "#" + form _id + " textarea:#message" ) . val ( ) ,
2010-04-24 15:40:22 +00:00
id : $ ( "#" + form _id + " input:#objectid" ) . val ( )
2009-11-30 19:46:45 +00:00
} ,
function ( data )
{
if ( ! data )
alert ( "No data" ) ;
else
{
$ ( "#share_form_results" ) . html ( data ) ;
}
} , 'text' ) ;
}
function flag _object ( form _id , id , type )
{
2010-01-16 09:19:34 +00:00
$ ( "#flag_form_result" ) . css ( "display" , "block" ) ;
$ ( "#flag_form_result" ) . html ( loading ) ;
2009-11-30 19:46:45 +00:00
$ . post ( page ,
{
mode : 'flag_object' ,
type : type ,
2009-12-31 11:56:47 +00:00
flag _type : $ ( "#" + form _id + " select:#flag_type" ) . val ( ) ,
2010-04-24 15:40:22 +00:00
id : id
2009-11-30 19:46:45 +00:00
} ,
function ( data )
{
if ( ! data )
alert ( "No data" ) ;
else
{
$ ( "#flag_form_result" ) . css ( "display" , "block" ) ;
$ ( "#flag_form_result" ) . html ( data ) ;
}
} , 'text' ) ;
}
2010-01-16 09:19:34 +00:00
function slide _up _watch _video ( nodiv )
{
if ( $ ( '.video_action_result_boxes ' + nodiv ) . css ( "display" ) != "block" )
$ ( '.video_action_result_boxes > *' ) . slideUp ( ) ;
}
2009-11-30 19:46:45 +00:00
function add _to _fav ( type , id )
{
2010-01-16 09:19:34 +00:00
$ ( "#video_action_result_cont" ) . css ( "display" , "block" ) ;
$ ( "#video_action_result_cont" ) . html ( loading ) ;
2009-12-04 21:03:27 +00:00
2009-11-30 19:46:45 +00:00
$ . post ( page ,
{
mode : 'add_to_fav' ,
type : type ,
2010-04-24 15:40:22 +00:00
id : id
2009-11-30 19:46:45 +00:00
} ,
function ( data )
{
if ( ! data )
alert ( "No data" ) ;
else
{
$ ( "#video_action_result_cont" ) . css ( "display" , "block" ) ;
$ ( "#video_action_result_cont" ) . html ( data ) ;
}
} , 'text' ) ;
}
2009-12-01 11:51:31 +00:00
function subscriber ( user , type , result _cont )
2009-11-30 19:46:45 +00:00
{
2010-01-16 09:19:34 +00:00
$ ( "#" + result _cont ) . css ( "display" , "block" ) ;
$ ( "#" + result _cont ) . html ( loading ) ;
2009-12-04 21:03:27 +00:00
2009-11-30 19:46:45 +00:00
$ . post ( page ,
{
mode : type ,
2010-04-24 15:40:22 +00:00
subscribe _to : user
2009-11-30 19:46:45 +00:00
} ,
function ( data )
{
if ( ! data )
alert ( "No data" ) ;
else
{
2009-12-01 11:51:31 +00:00
$ ( "#" + result _cont ) . css ( "display" , "block" ) ;
$ ( "#" + result _cont ) . html ( data ) ;
2009-11-30 19:46:45 +00:00
}
} , 'text' ) ;
}
2009-12-21 21:11:54 +00:00
function add _friend ( uid , result _cont )
{
2010-01-16 09:19:34 +00:00
$ ( "#" + result _cont ) . css ( "display" , "block" ) ;
$ ( "#" + result _cont ) . html ( loading ) ;
2009-12-21 21:11:54 +00:00
$ . post ( page ,
{
mode : 'add_friend' ,
2010-04-24 15:40:22 +00:00
uid : uid
2009-12-21 21:11:54 +00:00
} ,
function ( data )
{
if ( ! data )
alert ( "No data" ) ;
else
{
$ ( "#" + result _cont ) . css ( "display" , "block" ) ;
$ ( "#" + result _cont ) . html ( data ) ;
}
} , 'text' ) ;
}
2009-11-30 19:46:45 +00:00
2010-01-16 14:28:04 +00:00
function block _user ( user , result _cont )
{
$ ( "#" + result _cont ) . css ( "display" , "block" ) ;
$ ( "#" + result _cont ) . html ( loading ) ;
$ . post ( page ,
{
mode : 'ban_user' ,
2010-04-24 15:40:22 +00:00
user : user
2010-01-16 14:28:04 +00:00
} ,
function ( data )
{
if ( ! data )
alert ( "No data" ) ;
else
{
$ ( "#" + result _cont ) . css ( "display" , "block" ) ;
$ ( "#" + result _cont ) . html ( data ) ;
}
} , 'text' ) ;
}
2009-11-30 19:46:45 +00:00
function rate _comment ( cid , thumb )
{
2010-01-16 09:19:34 +00:00
2009-11-30 19:46:45 +00:00
$ . post ( page ,
{
mode : 'rate_comment' ,
thumb : thumb ,
cid : cid
} ,
function ( data )
{
if ( ! data )
alert ( "No data" ) ;
else
{
2010-01-16 09:19:34 +00:00
2009-11-30 19:46:45 +00:00
if ( data . msg != '' )
alert ( data . msg )
if ( data . rate != '' )
$ ( "#comment_rating_" + cid ) . html ( data . rate ) ;
}
} , 'json' ) ;
}
2010-01-25 13:18:18 +00:00
function delete _comment ( cid , type )
{
$ . post ( page ,
{
mode : 'delete_comment' ,
cid : cid ,
type : type
} ,
function ( data )
{
if ( ! data )
alert ( "No data" ) ;
else
{
if ( data . msg )
{
alert ( data . msg ) ;
$ ( "#comment_" + cid ) . fadeOut ( "slow" ) ;
$ ( "#spam_comment_" + cid ) . fadeOut ( "slow" ) ; ;
}
if ( data . err )
alert ( data . err ) ;
}
} , 'json' ) ;
}
2009-11-30 19:46:45 +00:00
function add _comment _js ( form _id , type )
{
2010-01-16 09:19:34 +00:00
$ ( "#add_comment_result" ) . css ( "display" , "block" ) ;
$ ( "#add_comment_result" ) . html ( loading ) ;
2010-02-02 16:19:41 +00:00
$ ( "#add_comment_button" ) . attr ( "disabled" , "disabled" ) ;
2010-04-26 15:17:37 +00:00
var captcha _enabled = $ ( "#" + form _id + " input:#cb_captcha_enabled" ) . val ( ) ;
2009-11-30 19:46:45 +00:00
$ . post ( page ,
{
mode : 'add_comment' ,
name : $ ( "#" + form _id + " input:#name" ) . val ( ) ,
email : $ ( "#" + form _id + " input:#email" ) . val ( ) ,
comment : $ ( "#" + form _id + " textarea:#comment_box" ) . val ( ) ,
obj _id : $ ( "#" + form _id + " input:#obj_id" ) . val ( ) ,
reply _to : $ ( "#" + form _id + " input:#reply_to" ) . val ( ) ,
2010-04-26 15:17:37 +00:00
type : type ,
cb _captcha _enabled : $ ( "#" + form _id + " input:#cb_captcha_enabled" ) . val ( ) ,
cb _captcha : $ ( "#" + form _id + " input:#captcha" ) . val ( )
2009-11-30 19:46:45 +00:00
} ,
function ( data )
{
if ( ! data )
alert ( "No data" ) ;
else
{
2010-04-26 15:17:37 +00:00
2010-02-02 16:19:41 +00:00
$ ( "#add_comment_button" ) . attr ( "disabled" , "" ) ;
2009-11-30 19:46:45 +00:00
$ ( "#add_comment_result" ) . css ( "display" , "block" ) ;
if ( data . err != '' )
2010-04-26 15:17:37 +00:00
{
captcha _enabled
2009-11-30 19:46:45 +00:00
$ ( "#add_comment_result" ) . html ( data . err ) ;
2010-04-26 15:17:37 +00:00
}
2009-11-30 19:46:45 +00:00
if ( data . msg != '' )
$ ( "#add_comment_result" ) . html ( data . msg ) ;
2009-12-01 11:51:31 +00:00
if ( data . cid )
2009-11-30 19:46:45 +00:00
{
get _the _comment ( data . cid , "#latest_comment_container" ) ;
$ ( "#" + form _id ) . slideUp ( ) ;
}
}
} , 'json' ) ;
}
function get _the _comment ( id , div )
{
2010-01-16 09:19:34 +00:00
$ ( div ) . html ( loading ) ;
2009-11-30 19:46:45 +00:00
$ . post ( page ,
{
mode : 'get_comment' ,
cid : id
} ,
function ( data )
{
if ( ! data )
alert ( "No data" ) ;
else
{
$ ( div ) . css ( "display" , "none" ) ;
$ ( div ) . html ( data ) . fadeIn ( "slow" ) ;
}
} , 'text' ) ;
}
function add _playlist ( mode , vid , form _id )
{
2010-01-16 09:19:34 +00:00
$ ( "#playlist_form_result" ) . css ( "display" , "block" ) ;
$ ( "#playlist_form_result" ) . html ( loading ) ;
2009-11-30 19:46:45 +00:00
switch ( mode )
{
case 'add' :
{
$ . post ( page ,
{
mode : 'add_playlist' ,
vid : vid ,
2010-04-24 15:40:22 +00:00
pid : $ ( "#playlist_id option:selected" ) . val ( )
} ,
2009-11-30 19:46:45 +00:00
function ( data )
{
if ( ! data )
alert ( "No data" ) ;
else
{
if ( data . err != '' )
{
$ ( "#playlist_form_result" ) . css ( "display" , "block" ) ;
$ ( "#playlist_form_result" ) . html ( data . err ) ;
}
if ( data . msg != '' )
{
$ ( "#playlist_form_result" ) . css ( "display" , "block" ) ;
$ ( "#playlist_form_result" ) . html ( data . msg ) ;
$ ( "#" + form _id ) . css ( "display" , "none" ) ;
}
}
} , 'json' ) ;
}
break ;
case 'new' :
{
$ . post ( page ,
{
mode : 'add_new_playlist' ,
vid : vid ,
2010-04-24 15:40:22 +00:00
plname : $ ( "#" + form _id + " input:#playlist_name" ) . val ( )
} ,
2009-11-30 19:46:45 +00:00
function ( data )
{
if ( ! data )
alert ( "No data" ) ;
else
{
if ( data . err != '' )
{
$ ( "#playlist_form_result" ) . css ( "display" , "block" ) ;
$ ( "#playlist_form_result" ) . html ( data . err ) ;
}
if ( data . msg != '' )
{
$ ( "#playlist_form_result" ) . css ( "display" , "block" ) ;
$ ( "#playlist_form_result" ) . html ( data . msg ) ;
$ ( "#" + form _id ) . css ( "display" , "none" ) ;
}
}
} , 'json' ) ;
}
break ;
}
2009-12-04 21:03:27 +00:00
}
/ * *
* Function used to add and remove video from qucklist
* THIS FEATURE IS SPECIALLY ADDED ON REQUEST BY JAHANZEB HASSAN
* /
function add _quicklist ( obj , vid )
{
2010-01-20 12:18:53 +00:00
$ ( obj ) . attr ( 'src' , imageurl + "/ajax-loader.gif" ) ;
$ ( obj ) . css ( 'background-position' , "-200px 200px" ) ;
2009-12-04 21:03:27 +00:00
$ . post ( page ,
{
mode : 'quicklist' ,
todo : 'add' ,
vid : vid
} ,
function ( data )
{
if ( ! data )
alert ( "No data" ) ;
else
{
2010-01-20 12:18:53 +00:00
$ ( obj ) . attr ( 'src' , imageurl + "/dot.gif" ) ;
$ ( obj ) . css ( 'background-position' , "-0px -0px" ) ;
2009-12-04 21:03:27 +00:00
$ ( obj ) . removeClass ( 'add_icon' ) ;
$ ( obj ) . addClass ( 'check_icon' ) ;
$ ( obj ) . removeAttr ( 'onClick' ) ;
load _quicklist _box ( ) ;
}
} , 'text' ) ;
}
/ * *
* Function used to remove video from qucklist
* /
function remove _qucklist ( obj , vid )
{
$ . post ( page ,
{
mode : 'quicklist' ,
todo : 'remove' ,
vid : vid
} ,
function ( data )
{
if ( ! data )
alert ( "No data" ) ;
else
{
$ ( obj ) . slideUp ( ) ;
$ ( obj ) . hide ( ) ;
}
} , 'text' ) ;
}
/ * *
* Function used to load quicklist
* /
function load _quicklist _box ( )
{
$ . post ( page ,
{
2010-04-24 15:40:22 +00:00
mode : 'getquicklistbox'
2009-12-04 21:03:27 +00:00
} ,
function ( data )
{
if ( ! data )
$ ( "#quicklist_box" ) . css ( "display" , "none" ) ;
else
{
$ ( "#quicklist_box" ) . css ( "display" , "block" ) ;
$ ( "#quicklist_box" ) . html ( data ) ;
if ( $ . cookie ( "quick_list_box" ) != "hide" )
{
$ ( "#quicklist_cont" ) . css ( "display" , "block" ) ;
}
}
} , 'text' ) ;
}
function clear _quicklist ( )
{
$ . post ( page ,
{
2010-04-24 15:40:22 +00:00
mode : 'clear_quicklist'
2009-12-04 21:03:27 +00:00
} ,
function ( data )
{
load _quicklist _box ( ) ;
} , 'text' ) ;
}
function quick _show _hide _toggle ( obj )
{
$ ( obj ) . slideToggle ( )
if ( $ . cookie ( "quick_list_box" ) == "show" )
$ . cookie ( "quick_list_box" , "hide" )
else
$ . cookie ( "quick_list_box" , "show" )
}
/ * *
* Function used to set cookies
* /
function ini _cookies ( )
{
if ( ! $ . cookie ( "quick_list_box" ) )
$ . cookie ( "quick_list_box" , "show" )
2009-12-21 21:11:54 +00:00
}
function get _group _info ( Div , li )
{
if ( $ ( Div ) . css ( "display" ) == "none" )
{
$ ( "#group_info_cont > div" ) . slideUp ( ) ;
$ ( "#group_info_cont " + Div ) . slideDown ( ) ;
$ ( ".group_detail_tabs .selected" ) . removeClass ( "selected" ) ;
$ ( li ) . addClass ( "selected" ) ;
}
}
2010-01-20 15:45:31 +00:00
var current _menu = "" ;
function show _menu ( menu )
{
if ( current _menu != menu )
hide _menu ( )
2010-01-21 07:03:53 +00:00
$ ( "#" + menu ) . show ( )
2010-01-20 15:45:31 +00:00
current _menu = menu ;
$ ( "." + menu ) . addClass ( "selected" ) ;
}
function hide _menu ( )
{
if ( current _menu != '' )
{
2010-01-21 07:03:53 +00:00
$ ( "#" + current _menu ) . hide ( ) ;
2010-01-20 15:45:31 +00:00
$ ( "." + current _menu ) . removeClass ( "selected" ) ;
return true ;
}
}
2010-01-25 13:18:18 +00:00
function to _reply ( cid )
{
$ ( "#reply_to" ) . val ( cid ) ;
window . location = "#add_comment" ;
}
function spam _comment ( cid )
{
$ . post ( page ,
{
mode : 'spam_comment' ,
cid : cid
} ,
function ( data )
{
if ( ! data )
alert ( "No data" ) ;
else
{
if ( data . msg )
{
$ ( "#comment_" + cid ) . hide ( ) ;
$ ( "#spam_comment_" + cid ) . fadeIn ( "slow" ) ;
}
if ( data . err )
{
alert ( data . err )
}
}
} , 'json' ) ;
2010-02-12 16:17:17 +00:00
}
var normal _player _html = '' ;
var hq _player _html = '' ;
2010-07-14 10:58:46 +00:00
var has _hq _function = false ;
2010-02-12 16:17:17 +00:00
function hq _toggle ( nplayer _div , hq _div )
{
2010-07-14 10:58:46 +00:00
if ( has _hq _function )
{
var nplayer _div = nplayer _div ;
var hq _div = hq _div ;
hq _function ( ) ;
return false ;
}
2010-02-12 16:17:17 +00:00
if ( $ ( nplayer _div ) . css ( "display" ) == 'block' )
{
if ( normal _player _html == '' )
normal _player _html = $ ( nplayer _div ) . html ( ) ;
$ ( nplayer _div ) . html ( "" ) ;
} else
{
if ( normal _player _html != '' )
$ ( nplayer _div ) . html ( normal _player _html ) ;
}
if ( $ ( hq _div ) . css ( "display" ) == 'block' )
{
if ( hq _player _html == '' )
hq _player _html = $ ( hq _div ) . html ( ) ;
$ ( hq _div ) . html ( "" ) ;
} else
{
if ( hq _player _html != '' )
$ ( hq _div ) . html ( hq _player _html ) ;
}
$ ( nplayer _div + "," + hq _div ) . toggle ( )
2010-04-27 15:27:48 +00:00
}
/ * *
* Funcion autplay playlist
* /
function swap _auto _play ( )
{
if ( $ . cookie ( "auto_play_playlist" ) == "true" )
{
$ . cookie ( "auto_play_playlist" , "false" ) ;
2010-07-01 07:32:56 +00:00
window . location = document . location ;
2010-04-27 15:27:48 +00:00
$ ( '#ap_status' ) . html ( "off" ) ;
2010-07-01 07:32:56 +00:00
2010-04-27 15:27:48 +00:00
} else
{
$ . cookie ( "auto_play_playlist" , "true" ) ;
2010-07-01 07:32:56 +00:00
window . location = document . location ;
2010-04-27 15:27:48 +00:00
$ ( '#ap_status' ) . html ( "on" ) ;
}
2010-11-01 11:01:15 +00:00
}
function collection _actions ( form , mode , objID , result _con , type , cid )
{
$ ( result _con ) . css ( "display" , "block" ) ;
$ ( result _con ) . html ( loading ) ;
switch ( mode )
{
case 'add_new_item' :
{
$ . post ( page ,
{
mode : mode ,
cid : $ ( "#" + form + ' #collection' ) . val ( ) ,
obj _id : objID ,
type : type
} ,
function ( data )
{
if ( ! data )
alert ( "No Data returned" ) ;
else
{
if ( data . msg )
$ ( result _con ) . html ( data . msg ) ;
if ( data . err )
$ ( result _con ) . html ( data . err ) ;
}
} , 'json' )
}
break ;
case "remove_collection_item" :
{
$ ( "#" + form ) . hide ( ) ;
$ . post ( page ,
{
mode : mode ,
obj _id : objID ,
type : type ,
cid : cid
} ,
function ( data )
{
if ( ! data )
{
alert ( "No Data Returned" ) ;
$ ( result _con + "_" + objID ) . hide ( ) ;
$ ( "#" + form ) . show ( ) ;
}
else
{
if ( data . err )
{
alert ( data . err ) ;
$ ( result _con + "_" + objID ) . hide ( ) ;
$ ( "#" + form + objID ) . show ( ) ;
}
if ( data . msg )
{
$ ( result _con ) . html ( data . msg ) ;
$ ( "#" + form + "_" + objID ) . slideUp ( 350 ) ;
}
}
} , 'json' )
}
}
return false ;
2010-11-04 07:53:16 +00:00
}
2010-12-14 13:53:51 +00:00
// Simple function to open url with javascript
2010-12-24 14:22:47 +00:00
function openURL ( url ) {
document . location = url ;
2010-11-04 07:53:16 +00:00
}
2010-12-14 13:53:51 +00:00
function get _item ( obj , ci _id , cid , type , direction )
2010-11-04 07:53:16 +00:00
{
2010-12-28 13:56:44 +00:00
var btn _text = $ ( obj ) . html ( ) ;
$ ( obj ) . html ( loading ) ;
2010-12-14 13:53:51 +00:00
2010-11-04 07:53:16 +00:00
$ . post ( page ,
{
mode : 'get_item' ,
ci _id : ci _id ,
cid : cid ,
2010-12-14 13:53:51 +00:00
type : type ,
direction : direction
2010-11-04 07:53:16 +00:00
} ,
function ( data )
{
2010-12-14 13:53:51 +00:00
if ( ! data )
{
alert ( 'No ' + type + ' returned' ) ;
2010-12-24 14:22:47 +00:00
$ ( obj ) . text ( btn _text ) ;
2010-12-14 13:53:51 +00:00
} else {
var jsArray = new Array ( type , data [ 'cid' ] , data [ 'key' ] ) ;
construct _url ( jsArray ) ;
$ ( "#collectionItemView" ) . html ( data [ 'content' ] ) ;
}
} , 'json' )
}
function construct _url ( jsArr )
{
var url ;
if ( Seo == 'yes' )
{
url = '#!/item/' + jsArr [ 0 ] + '/' + jsArr [ 1 ] + '/' + jsArr [ 2 ] ;
window . location . hash = url
} else {
url = '#!?item=' + jsArr [ 2 ] + '&type=' + jsArr [ 0 ] + '&collection=' + jsArr [ 1 ] ;
window . location . hash = url
}
}
function onReload _item ( )
{
var comURL ,
regEX ;
if ( window . location . hash )
{
comURL = window . location . href ;
if ( Seo == 'yes' )
{
regEX = RegExp ( '\/item.+#!' ) ;
if ( regEX . test ( comURL ) )
{
comURL = comURL . replace ( regEX , '' ) ;
window . location . href = comURL ;
}
} else {
regEX = RegExp ( '\\\?item.+#!' ) ;
if ( regEX . test ( comURL ) )
{ comURL = comURL . replace ( regEX , '' )
window . location . href = comURL ;
}
}
}
}
function pagination ( object , cid , type , pageNumber )
{
2010-12-28 13:56:44 +00:00
var obj = $ ( object ) , objID = obj . id ,
parent = obj . parent ( ) , parentID , innerHTML = obj . html ( ) ;
2010-12-14 13:53:51 +00:00
if ( parent . attr ( 'id' ) )
parentID = parent . attr ( 'id' )
else
{ parent . attr ( 'id' , 'loadMoreParent' ) ; parentID = parent . attr ( 'id' ) ; }
newCall =
$ . ajax ( {
url : page ,
type : "post" ,
dataType : "json" ,
data : { mode : "moreItems" , page : pageNumber , cid : cid , type : type } ,
beforeSend : function ( ) { obj . removeAttr ( 'onClick' ) ; obj . html ( loading ) } ,
success : function ( data ) {
if ( ! data )
{
if ( object . tagName == "BUTTON" )
obj . attr ( 'disabled' , 'disabled' ) ;
2010-12-28 13:56:44 +00:00
obj . removeAttr ( 'onClick' ) ; obj . html ( 'No more ' + type ) ;
2010-12-14 13:53:51 +00:00
} else {
$ ( '#collectionItemsList' ) . append ( data [ 'content' ] ) ;
$ ( '#NewPagination' ) . html ( data [ 'pagination' ] ) ;
2010-12-28 13:56:44 +00:00
obj . html ( innerHTML ) ;
2010-12-14 13:53:51 +00:00
}
}
} ) ;
}
function ajax _add _collection ( obj )
{
var formID = obj . form . id , Form = $ ( '#' + formID ) ,
This = $ ( obj ) , AjaxCall , ButtonHTML = This . html ( ) ,
Result = $ ( '#CollectionResult' ) ;
AjaxCall =
$ . ajax
( {
url : page ,
type : "post" ,
dataType : "json" ,
data : "mode=add_collection&" + Form . serialize ( ) ,
beforeSend : function ( ) { if ( Result . css ( 'display' ) == 'block' ) Result . slideUp ( 'fast' ) ; This . attr ( 'disabled' , 'disabled' ) ; This . html ( loading ) } ,
success : function ( data ) {
if ( data . msg )
{
$ ( '#CollectionDIV' ) . slideUp ( 'fast' ) ;
Result . html ( data [ 'msg' ] ) . slideDown ( 'fast' ) ;
}
else
{
Result . html ( data [ 'err' ] ) . slideDown ( 'fast' ) ;
This . removeAttr ( 'disabled' ) ; This . html ( ButtonHTML ) ;
}
}
} ) ;
}
2010-12-28 13:56:44 +00:00
var AjaxIteration = 0 ;
var InputIteration = 0 ;
2010-12-15 06:53:09 +00:00
function callAjax ( obj )
{
2010-12-28 13:56:44 +00:00
var getArray = getDetails ( obj ) ,
object = $ ( obj ) ,
TotalItems = getArray . length , AjaxCall ,
inputs = getInputs ( obj , true ) ,
element = inputs [ InputIteration ++ ] ;
if ( AjaxIteration == getArray . length )
{
$ ( obj ) . html ( TotalItems + " Photos Saved." ) . removeAttr ( 'onclick' ) . hide ( ) ;
$ ( "<input />" ) . attr ( {
'type' : 'submit' ,
'name' : 'updatePhotos' ,
'id' : 'updatePhotos' ,
'value' : 'Done'
} ) . addClass ( object . attr ( 'class' ) ) . fadeIn ( 350 ) . insertAfter ( object ) . wrap ( "<form method='post' action='' name='finishForm' id='finishForm' />" ) ;
return true ;
}
else
{
AjaxCall =
$ . ajax
( {
url : page ,
type : "post" ,
dataType : "json" ,
data : getArray [ AjaxIteration ++ ] ,
cache : false ,
beforeSend : function ( ) { $ ( obj ) . html ( loading _img + " Saving " + AjaxIteration + " out of " + TotalItems ) ; $ ( obj ) . attr ( 'disabled' , 'disabled' ) ; $ ( "#" + element . id + " > div" ) . css ( 'opacity' , '0.5' ) ; } ,
success : function ( data ) {
$ ( '#' + element . id + " > div" ) . empty ( ) . css ( { 'padding' : '10px' , 'opacity' : '1' } ) . html ( "<div style='font:bold 11px Tahoma;'>" + data . photo _title + " is now saved.</div>" ) . fadeIn ( 'normal' , function ( ) { callAjax ( obj ) ; } ) ;
}
} ) ;
}
2010-12-14 13:53:51 +00:00
}
2010-12-28 13:56:44 +00:00
function getInputs ( obj , return _array )
2010-12-14 13:53:51 +00:00
{
2010-12-28 13:56:44 +00:00
var Child = $ ( obj ) . parent ( ) . children ( ) . filter ( 'form' ) , InputArray = [ ] ;
if ( return _array == true )
{
$ . each ( Child , function ( index , element ) {
InputArray [ index ] = element ;
2010-12-14 13:53:51 +00:00
} )
2010-12-28 13:56:44 +00:00
return InputArray ;
} else
return Child ;
}
function getDetails ( obj )
{
var forms = getInputs ( obj ) , ParamArray = new Array ( forms . length ) ;
$ . each ( forms , function ( index , form ) {
query = $ ( "#" + form . id + " *" ) . serialize ( ) ;
query += "&mode=ajaxPhotos" ;
ParamArray [ index ] = query ;
2010-12-14 13:53:51 +00:00
} )
2010-12-28 13:56:44 +00:00
2010-12-15 06:53:09 +00:00
return ParamArray ;
2010-12-23 16:56:33 +00:00
}
2010-12-24 14:22:47 +00:00
function getName ( File )
2010-12-23 16:56:33 +00:00
{
2010-12-24 14:22:47 +00:00
var url = File ;
var filename = url . substring ( url . lastIndexOf ( '/' ) + 1 ) ;
return filename ;
2010-12-15 06:53:09 +00:00
}