(function (global) { // Check for defined globals global.az = global.az || {}; global.az.globals = global.az.globals || {} ; })(window); (function(){ // debugging zeugs: if (typeof(localStorage) !== 'undefined' && typeof(JSON) !== 'undefined'){ var suspect = ''; var getCookie = function(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for(var i=0; i 0) { last_log = my_history[my_history.length-1]; } } else{ my_history = []; } if (typeof(az.globals.user) != "undefined"){ new_log.user_info = az.globals.user; new_log.user_id = az.globals.user.id; email = az.globals.user.email; new_log.user_email = email; var found = false; for(var i=0; i < new_log.users.length; i++) { if (new_log.users[i] == email) { found = true; break; } } if (!found) { new_log.users.push(email); localStorage.setItem('users', JSON.stringify(new_log.users)); if (new_log.users.length > 1) { suspect += 'multiuser'; } } } var sid_cookie = getCookie('lsdebug'); if (sid_cookie && sid_cookie.indexOf(".")>0){ var sids = sid_cookie.split("."); new_log.auth = sids[sids.length-1]; new_log.sid = sids[0]; } var client_id = getCookie('lsdebugcid'); var initial_session = getCookie('lsdebugs'); new_log.original_sid = initial_session; if (!client_id || !initial_session){ // reset var d = new Date(); client_id = new_log.datetime; // make a nice random id with 4 chars/nums client_id += '-'+(("0000" + (Math.random()*Math.pow(36,4) << 0).toString(36)).slice(-4)); setCookie('lsdebugcid', client_id, 365); setCookie('lsdebugs', new_log.sid, 365); my_history = []; last_log = null; suspect += 'new cid'; } new_log.client_id = client_id; if (last_log) { if(last_log.sid != new_log.sid){ if (last_log.user_email != new_log.user_email) { suspect += 'sid and user change'; } else { suspect += 'unexpected sid change;'; } } } my_history.push(new_log); if (my_history.length>MAX_LEN){ my_history.splice(0,my_history.length-MAX_LEN); } localStorage.setItem(STORAGE_KEY, JSON.stringify(my_history)); if (suspect){ if (!last_log){ last_log = { 'sid': '', }; } var url = '/__api/v1/debug_uid_change?cid='+client_id+'&old='+last_log.sid+"&new="+new_log.sid+"&suspect="+escape(suspect)+"&data="+escape(JSON.stringify(my_history)); var xhttp; if (window.XMLHttpRequest) { xhttp = new XMLHttpRequest(); } else { xhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xhttp.open('GET', url, true); xhttp.send(); } } })();