diff --git a/htdocs/frontend/javascripts/frontend.js b/htdocs/frontend/javascripts/frontend.js index e1e672c..6d0dcf6 100644 --- a/htdocs/frontend/javascripts/frontend.js +++ b/htdocs/frontend/javascripts/frontend.js @@ -38,17 +38,22 @@ vz.wui.init = function() { $('button, input[type=button],[type=image]').button(); $('button[name=options-save]').click(function() { vz.options.save(); }); $('#permalink').click(function() { + var uuids = []; var url = window.location.protocol + '//' + window.location.host + window.location.pathname + '?from=' + vz.options.plot.xaxis.min + '&to=' + vz.options.plot.xaxis.max; - + vz.entities.each(function(entity, parent) { if (entity.active) { - url += '&uuid=' + entity.uuid; + uuids.push(entity.uuid); } }); + + uuids.unique().each(function(key, value) { + url += '&uuid=' + value; + }); window.location = url; }); diff --git a/htdocs/frontend/javascripts/helper.js b/htdocs/frontend/javascripts/helper.js index b4c40a0..a5f2da1 100644 --- a/htdocs/frontend/javascripts/helper.js +++ b/htdocs/frontend/javascripts/helper.js @@ -55,8 +55,9 @@ var Exception = function(type, message, code) { * according to js language specification ECMA 1.6 */ Array.prototype.indexOf = function(n) { - for (var i = 0, l = this.length; i < l; i++) + for (var i = 0, l = this.length; i < l; i++) { if (n == this[i]) return i; + } }; Array.prototype.remove = function(n) { @@ -64,8 +65,9 @@ Array.prototype.remove = function(n) { }; Array.prototype.each = function(cb) { - for (var i = 0, l = this.length; i < l; i++) + for (var i = 0, l = this.length; i < l; i++) { cb(i, this[i]); + } }; Array.prototype.contains = function(n) { @@ -75,3 +77,15 @@ Array.prototype.contains = function(n) { Array.prototype.clear = function() { this.length = 0; } + +Array.prototype.unique = function () { + var r = new Array(); + + this.each(function(key, value) { + if (!r.contains(value)) { + r.push(value); + } + }); + + return r; +}