function cbfunc(o){ var _id = ""; var message = o.message; var login = o.login; var id = o.id; if(message == "ok"){ _id = id; window.localStorage.setItem("hjid", _id); window.localStorage.setItem("hjlogin", login); url = "http://job.canhelpme.com/rss/"+_id+"@"+login+"/rss.xml"; var objet = document.getElementById('content'); objet.style.display = 'block'; // $("#content").show(); show(url); }else{ // alert('wrong login/password'); $("formulaire").append("wrong login/password"); } } function show(url){ var query = "SELECT * FROM feed WHERE url='"+url+"'"; // Storing the seconds since the epoch in now: var now = (new Date()).getTime()/1000; // If there is no cache set in localStorage, or the cache is older than 1 hour: //if(!localStorage.cache || now - parseInt(localStorage.time) > 1*60*60){ $.get("http://query.yahooapis.com/v1/public/yql?q="+encodeURIComponent(query)+"&format=json&callback=?", function(msg){ // msg.query.results.item is an array: var items = msg.query.results.item; var htmlString = ""; for(var i=0;i7)) color = 'orange'; if(parseInt(test[0]) > 14) color = 'red'; } // Extracting the post ID from the permalink: //var id = tut.guid.content.match(/(\d+)$/)[0]; // Looping and generating the markup of the tutorials: htmlString += '
\ \

'+tut.title+'

\

'+tut.description+'

\ Watch your application on Help Job\
'; } // Setting the cache // localStorage.cache = htmlString; localStorage.time = now; // Updating the content div: $('#content').slideDown(); $('#content').html(htmlString); $('#formulaire').slideUp(); }, 'json'); /*}else{ // The cache is fresh, use it: $('#content').slideDown(); $('#content').html(window.localStorage.cache); }*/ } $(document).ready(function(){ // Debug // window.localStorage.clear(); var now = (new Date()).getTime()/1000; var _id = window.localStorage.getItem("hjid"); var login = window.localStorage.getItem("hjlogin"); if((_id != null && login != null) || now - parseInt(localStorage.time) < 1*60*60){ var url = "http://job.canhelpme.com/rss/"+_id+"@"+login+"/rss.xml"; show(url); $('#formulaire').hide(); }else{ $('#content').html(''); $('#login').focus(); /*Action on click*/ $('#loginBtn').click(function(){ var login = $('#login').val(); var password = $('#password').val(); var script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'http://job.canhelpme.com/android/chromeLogin.php?login='+login+'&mdp='+password+'&format=json&callback=cbfunc'; document.getElementsByTagName('head')[0].appendChild(script); }); $('#login, #password').keydown(function(e){ if(e.which == 13) { $('#loginBtn').trigger('click'); } }); /*$('#password').keydown(function(e){ if(e.which == 13) { $('#loginBtn').trigger('click'); } });*/ } });