diff --git a/lsp/mist.js b/lsp/mist.js index 3e207a03..3655b92c 100644 --- a/lsp/mist.js +++ b/lsp/mist.js @@ -15,7 +15,7 @@ $(function(){ //check if username and host have been stored in the url if (location.hash) { - var hash = location.hash.substring(1).split('@'); + var hash = decodeURIComponent(location.hash).substring(1).split('@'); var user = hash[0].split('&'); mist.user.name = user[0]; if (user[1]) { mist.user.host = user[1]; } @@ -30,7 +30,7 @@ $(function(){ }); $(window).on('hashchange', function(e) { - var loc = location.hash.substring(1).split('@'); + var loc = decodeURIComponent(location.hash).substring(1).split('@'); if (!loc[1]) { loc[1] = ''; } var tab = loc[1].split('&'); if (tab[0] == '') { tab[0] = 'Overview'; } @@ -1699,6 +1699,7 @@ var UI = { var hash = prevhash.split('@'); hash[0] = [mist.user.name,mist.user.host].join('&'); hash[1] = [tab,other].join('&'); + if (typeof screenlog != 'undefined') { screenlog.navto(hash[1]); } //allow logging if screenlog is active location.hash = hash.join('@'); if (location.hash == prevhash) { //manually trigger hashchange even though hash hasn't changed diff --git a/lsp/plugins/screenlog.js b/lsp/plugins/screenlog.js deleted file mode 100644 index fd9918f0..00000000 --- a/lsp/plugins/screenlog.js +++ /dev/null @@ -1,232 +0,0 @@ - -var screenlog = { - master: function(){ - function gettab() { - return location.hash.substring(1).split('@')[1]; - } - - //which field has focus - $(document).on('focus','.field',function(){ - screenlog.log.mine.push({ - type: 'focus', - time: (new Date()).getTime(), - tab: gettab(), - element: $(this).attr('name') - }); - }); - - //what is the value of this field on blur - $(document).on('blur','.field',function(){ - screenlog.log.mine.push({ - type: 'blur', - time: (new Date()).getTime(), - tab: gettab(), - element: $(this).attr('name'), - val: $(this).getval() - }); - }); - - //where is the cursor - var mouse = { - x: 0, - y: 0 - }; - var lastmouse = mouse; - $(document).on('mousemove',function(e){ - mouse = { - x: e.pageX, - y: e.pageY - }; - }); - setInterval(function(){ - if ((mouse.x != lastmouse.x) || (mouse.y != lastmouse.y)) { - lastmouse = mouse; - screenlog.log.mine.push({ - type: 'mousepos', - time: (new Date()).getTime(), - tab: gettab(), - pos: mouse - }); - } - },1e3); - - //which tab are we on - $(window).on('hashchange', function(e) { - screenlog.log.mine.push({ - type: 'tab', - time: (new Date()).getTime(), - tab: gettab() - }); - }); - - var lastsend; - function sendlog(){ - var l = []; - for (var i = screenlog.log.mine.length-1; i >= 0; i--) { - var entry = screenlog.mine.log[i]; - if (entry.time <= lastsend) { - break; - } - l.unshift(entry); - } - if (l.length == 0) { - return; - } - var obj = { - url: 'http://shop.mistserver.org/demo?store', - data: { - serverurl: mist.user.host, - data: JSON.stringify(l) - }, - method: 'POST', - error: function(){ - - }, - success: function(d){ - lastsend = d; - } - }; - log('[screenlog]','Send:',l); - var http = $.ajax(obj); - } - setInterval(sendlog,2e3) - - }, - slave: function(sid,token){ - - var lastgotten = 0; - function getlog() { - var obj = { - url: 'http://shop.mistserver.org/demo', - data: { - read: sid, - token: token, - from: lastgotten - }, - method: 'POST', - error: function(){ - - }, - success: function(d){ - var newlog = JSON.parse(d); - - if ('error' in newlog) { - log('[screenlog]','error',newlog); - return; - } - - if (newlog.length == 0) { return; } - - log('[screenlog]','Receive:',newlog); - - if (lastgotten == 0) { - var d = {blur:[]}; - var done = false; - for (var i = newlog.length-1; i>=0; i--) { - var entry = newlog[i]; - switch (entry.type) { - case 'mousepos': - case 'focus': - if (entry.type in d) { - break; - } - d[entry.type] = entry; - break; - case 'blur': - d.blur.unshift(entry); - break; - case 'tab': - d[entry.type] = entry; - done = true; - break; - } - if (done) { break; } - } - for (var i in d) { - if (i == 'blur') { - for (var j in d[i]) { - playentry(d[i][j]); - } - } - else { - playentry(d[i]); - } - } - } - else { - playlog(newlog); - } - screenlog.log.theirs = screenlog.log.theirs.concat(newlog); - - var amount = 50; //how many entries should be shown in the onscreen log - var show = newlog.slice(-1*amount); - for (var i in show) { - var entry = show[i]; - var d = $.extend({},entry); - delete d.time; delete d.type; delete d.tab; - UI.elements.screenlog.append( - $('