function start2() { loadHistory(); } function loadHistory() { for($i=0;$i<=50;$i++) { if($.cookie("history["+$i+"]")!=null) addToHistory($i); else break; } } function addToCookie($id) { $found = false; for($i=0;$i<=50;$i++) { if($.cookie("history["+$i+"]")!=null) if($.cookie("history["+$i+"]") == $id) { $found = true; break; } else {} else break; } if(!$found) { $.cookie("history["+$i+"]",$id, { expires: 356, path: '/', domain: 'detectinvisible.ro', secure: false }); $.cookie("cout["+$i+"]",'1', { expires: 356, path: '/', domain: 'detectinvisible.ro', secure: false }); addToHistory($i); } else { $inc = ($.cookie("cout["+$i+"]")/1)+1; $.cookie("cout["+$i+"]",$inc, { expires: 356, path: '/', domain: 'detectinvisible.ro', secure: false }); checkCounts(); } } function checkCounts() { for($i=50;$i>0;$i--) if($.cookie("cout["+$i+"]")!=null) { $j = $i-1; if(parseInt($.cookie("cout["+$i+"]"))>parseInt($.cookie("cout["+$j+"]"))) hisReverse($i,$j); } } function hisReverse($i,$j) { $.cookie("history[tmp]", $.cookie("history["+$i+"]"), { expires: 356, path: '/', domain: 'detectinvisible.ro', secure: false }); $.cookie("history["+$i+"]", $.cookie("history["+$j+"]"), { expires: 356, path: '/', domain: 'detectinvisible.ro', secure: false }); $.cookie("history["+$j+"]", $.cookie("history[tmp]"), { expires: 356, path: '/', domain: 'detectinvisible.ro', secure: false }); $.cookie("history[tmp]", null, { expires: 356, path: '/', domain: 'detectinvisible.ro', secure: false }); $.cookie("cout[tmp]", $.cookie("cout["+$i+"]"), { expires: 356, path: '/', domain: 'detectinvisible.ro', secure: false }); $.cookie("cout["+$i+"]", $.cookie("cout["+$j+"]"), { expires: 356, path: '/', domain: 'detectinvisible.ro', secure: false }); $.cookie("cout["+$j+"]", $.cookie("cout[tmp]"), { expires: 356, path: '/', domain: 'detectinvisible.ro', secure: false }); $.cookie("cout[tmp]", null, { expires: 356, path: '/', domain: 'detectinvisible.ro', secure: false }); updateHistory($i); updateHistory($j); } function addToHistory($i) { $par = ($i%2)?"odd":"even"; $("#history").append("

"+$i+""+$.cookie("history["+$i+"]")+"

"); $("#his"+$i).bind('click',hisCheck); $("#remhis"+$i).bind('click',remHis); } function remHis(par) { $id = $(this).attr('alt'); $.cookie('history['+$id+']',null); for($i=$id;$i<=50;$i++) { $j = ($i/1)+1; if($.cookie('history['+$j+']')!=null) { $.cookie('history['+$i+']',$.cookie('history['+$j+']'),{ expires: 356, path: '/', domain: 'detectinvisible.ro', secure: false }); $.cookie('cout['+$i+']',$.cookie('cout['+$j+']'),{ expires: 356, path: '/', domain: 'detectinvisible.ro', secure: false }); updateHistory($i); } else break; } $.cookie("history["+$i+"]", null, { expires: 356, path: '/', domain: 'detectinvisible.ro', secure: false }); $.cookie("cout["+$i+"]", null, { expires: 356, path: '/', domain: 'detectinvisible.ro', secure: false }); removeHistory($i); } function updateHistory($i) { $("#his"+$i).html($.cookie("history["+$i+"]")); } function removeHistory($id) { $("#phis"+$id).remove(); } function hisCheck(par) { $(".idfield").attr('value',$(this).html()); check(); } $(document).ready(start2);