From 7d6eed709b3f022959ee6251e46053cea71867d9 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 7 Nov 2012 14:21:21 -0800 Subject: [PATCH] Fix history truncation. --- guacamole/src/main/webapp/scripts/history.js | 16 ++++++++-------- guacamole/src/main/webapp/scripts/root-ui.js | 8 ++++++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/guacamole/src/main/webapp/scripts/history.js b/guacamole/src/main/webapp/scripts/history.js index 84a7a368f..f4fb4ee45 100644 --- a/guacamole/src/main/webapp/scripts/history.js +++ b/guacamole/src/main/webapp/scripts/history.js @@ -24,21 +24,21 @@ GuacamoleHistory = new (function() { function truncate() { - // Avoid history growth beyond defined number of entries - if (history.length > IDEAL_LENGTH) { + // Build list of entries + var entries = []; + for (var old_id in history) + entries.push(history[old_id]); - // Build list of entries - var entries = []; - for (var old_entry in history) - entries.push(old_entry); + // Avoid history growth beyond defined number of entries + if (entries.length > IDEAL_LENGTH) { // Sort list - entries.sort(GuacamoleHistory.Entries.compare); + entries.sort(GuacamoleHistory.Entry.compare); // Remove entries until length is ideal or all are recent var now = new Date().getTime(); while (entries.length > IDEAL_LENGTH - && entries[0].accessed - now > CUTOFF_AGE) { + && now - entries[0].accessed > CUTOFF_AGE) { // Remove entry var removed = entries.shift(); diff --git a/guacamole/src/main/webapp/scripts/root-ui.js b/guacamole/src/main/webapp/scripts/root-ui.js index a8f520aa5..c2f8d649a 100644 --- a/guacamole/src/main/webapp/scripts/root-ui.js +++ b/guacamole/src/main/webapp/scripts/root-ui.js @@ -366,6 +366,14 @@ GuacamoleHistory.onchange = function(id, old_entry, new_entry) { }; +/* + * This window has no name. We need it to have no name. If someone navigates + * to the root UI within the same window as a previous connection, we need to + * remove the name from that window such that new attempts to use that previous + * connection do not replace the contents of this very window. + */ +window.name = ""; + /* * Update session state when auto-fit checkbox is changed */