function playlist() { if($.cookie('playlist') != null){ $('#playlist').html($.cookie('playlist')); } else { var postdata = { act : 'get' }; $.post('/quicklist/index.php', postdata, function( playlistdata , textStatus ) { if(playlistdata != 'none'){ $.cookie('playlist', playlistdata,{ path: '/' }); $('#playlist').html(playlistdata); } }); } $('#playlist').click(function(event) { var $tgt = $(event.target); if ($tgt.attr('class') == 'remove') { $.cookie("quick_"+$tgt.attr('id'), null); $('#'+$tgt.attr('id')).removeClass('q'); var postdata = { linkid : $tgt.attr('id'), act : 'deleteitem' }; $.post('/quicklist/index.php', postdata, function( playlistdata , textStatus ) { $.cookie('playlist', playlistdata,{ path: '/' }); $('#playlist').html(playlistdata); }); } }); } $(document).ready(function() { $('a.quicklist').click(function() { var $quicklist = $('#'+$(this).attr('id')); if($quicklist.attr('class') == 'quicklist'){ var postdata = { linkid : $(this).attr('id'), act : 'additem' }; $.post('/quicklist/index.php', postdata, function( playlistdata , textStatus ) { if(playlistdata == 'login'){ document.location='/register.php?mid=2'; } else if(playlistdata == 'inlist'){ } else{ $.cookie("quick_"+$quicklist.attr('id'), 'yes',{ path: '/' }); $quicklist.addClass('p'); $.cookie('playlist', playlistdata,{ path: '/' }); $('#playlist').html(playlistdata); } }); } else { var postdata = { linkid : $(this).attr('id'), act : 'deleteitem' }; $.post('/quicklist/index.php', postdata, function( playlistdata , textStatus ) { if(playlistdata == 'login'){ document.location='/register.php?mid=2'; } else { $quicklist.removeClass('p'); $.cookie("quick_"+$(this).attr('id'), null); $.cookie('playlist', playlistdata,{ path: '/' }); $('#playlist').html(playlistdata); } }); } }); $('a.g').click(function() { var $quicklist = $('#'+$(this).attr('id')); if($quicklist.attr('class') == 'g'){ var postdata = { linkid : $(this).attr('id'), act : 'additem' }; $.post('/quicklist/index.php', postdata, function( playlistdata , textStatus ) { if(playlistdata == 'login'){ document.location='/register.php?mid=2'; } else if(playlistdata == 'inlist'){ } else{ $.cookie("quick_"+$quicklist.attr('id'), 'yes',{ path: '/' }); $quicklist.addClass('q'); $.cookie('playlist', playlistdata,{ path: '/' }); $('#playlist').html(playlistdata); } }); } else { var postdata = { linkid : $(this).attr('id'), act : 'deleteitem' }; $.post('/quicklist/index.php', postdata, function( playlistdata , textStatus ) { if(playlistdata == 'login'){ document.location='/register.php?mid=2'; } else { $quicklist.removeClass('q'); $.cookie("quick_"+$(this).attr('id'), null); $.cookie('playlist', playlistdata,{ path: '/' }); $('#playlist').html(playlistdata); } }); } }); $('#commentbox').click(function(event) { var tgt = $(event.target); if(tgt.attr('type') == 'submit'){ var comment = $('.commenttext').val(); var linkid = $('.commenttext').attr('id'); if(comment.length < 10){ $('#commentmessage').html('please enter over 10 letters...'); } else { if($.cookie('comment_'+linkid) == null){ $("#commentbox").html(''); //check the username exists or not from ajax $.post("/comments/index.php",{ comment: comment,linkid: linkid,rand:Math.random() } ,function(data) { if(data == 'inlist'){ $.cookie("comment_"+linkid, 'yes',{ path: '/' }); $('#commentbox').html('thanks for commenting!'); } else if(data == 'login'){ $('#commentbox').html('please log in to comment!'); } else { $.cookie("comment_"+linkid, 'yes',{ path: '/' }); $('.comments').html(data); $('#commentbox').html('thanks for commenting!'); } }); } else { $('#commentbox').html('thanks for commenting!!'); } } return false; //not to post the form physically } }); $('#msgbox').click(function(event) { var tgt = $(event.target); if(tgt.attr('type') == 'submit'){ var username = $('#username').val(); var password = $('#password').val(); //remove all the class add the messagebox classes and start fading $("#msgbox").removeClass().addClass('messagebox').text('Validating....').fadeIn(1000); //check the username exists or not from ajax $.post("/login/index.php",{ username:username,password:password,rand:Math.random() } ,function(data) { if(data=='yes') //if correct login detail { $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox { //add message and change the class of the box and start fading $(this).html('Logging in.....').addClass('messageboxok').fadeTo(900,1, function() { $(this).html('Welcome (profile)(x)'); playlist(); }); $('#commentbox').html('
leave a comment ...
'); $('a.g').each(function() { if($.cookie("quick_"+$(this).attr('id')) == 'yes'){ $(this).addClass('q'); } }); }); } else { $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox { //add message and change the class of the box and start fading $(this).html('Your login detail sucks...').addClass('messageboxerror').fadeTo(900,1); $(this).html('
').fadeTo(900,1); }); } }); return false; //not to post the form physically } if(tgt.attr('id') == 'logout'){ $.get("/login/index.php", { act:"logout"},function(data){ $.cookie('playlist', null); $('#msgbox').html('
'); $('#playlist').html(''); $('#msgbox').removeClass(); $('a.g').each(function() { var $quicklist = $('#'+$(this).attr('id')); $quicklist.removeClass('q'); }); $('#commentbox').html('Sign in or register to comment'); }); } }); //now call the ajax also focus move from $("#password").blur(function() { $("#login_form").trigger('submit'); }); $('.vtleft').click(function(event) { var tgt = $(event.target); if(tgt.attr('class') == 'plus'){ var postdata = { id : tgt.attr('id'), act: 'plus' }; $('#message').html(''); $.post('/rating/index.php', postdata, function( ratingdata , textStatus ) { if(ratingdata == 'login'){ $('#message').html('please sign in').fadeIn('slow'); } else if(ratingdata == 'vote'){ $('#message').html('already rated').fadeIn('slow'); } else if(ratingdata == 'fail'){ $('#message').html('something went wrong').fadeIn('slow'); } else { $('#message').html('thanks for rating!').fadeIn('slow'); var rating = parseInt($('#ratingnumber').html())+1; $('#ratingnumber').html(rating); var amountrated = parseInt($('#amountrated').html())+1; $('#amountrated').html(amountrated); } }); } else if(tgt.attr('class') == 'minus'){ var postdata = { id : tgt.attr('id'), act: 'minus' }; $.post('/rating/index.php', postdata, function( ratingdata , textStatus ) { if(ratingdata == 'login'){ $('#message').html('please sign in').fadeIn('slow'); } else if(ratingdata == 'vote'){ $('#message').html('already rated').fadeIn('slow'); } else if(ratingdata == 'fail'){ $('#message').html('something went wrong').fadeIn('slow'); } else { $('#message').html('thanks for rating!').fadeIn('slow'); var rating = parseInt($('#ratingnumber').html())-1; $('#ratingnumber').html(rating); var amountrated = parseInt($('#amountrated').html())+1; $('#amountrated').html(amountrated); } }); } }); });