add unique uuids to permalink
introduced unique() to Array.prototype
This commit is contained in:
parent
a43f9a6744
commit
1549eb00c9
2 changed files with 23 additions and 4 deletions
|
@ -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;
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue