Fix randomizeIds() to also add a nonce to the current document if not present
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1972 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
67384a5a71
commit
09ab8a85fe
|
@ -44,10 +44,18 @@ svgedit.draw.Layer.prototype.getGroup = function() {
|
|||
};
|
||||
|
||||
|
||||
// Called to ensure that drawings will or will not have
|
||||
// randomized ids.
|
||||
svgedit.draw.randomizeIds = function(enableRandomization) {
|
||||
// Called to ensure that drawings will or will not have randomized ids.
|
||||
// The current_drawing will have its nonce set if it doesn't already.
|
||||
//
|
||||
// Params:
|
||||
// enableRandomization - flag indicating if documents should have randomized ids
|
||||
svgedit.draw.randomizeIds = function(enableRandomization, current_drawing) {
|
||||
randomize_ids = enableRandomization;
|
||||
|
||||
if (enableRandomization && !current_drawing.getNonce()) {
|
||||
current_drawing.setNonce(Math.floor(Math.random() * 100001));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -139,6 +147,12 @@ svgedit.draw.Drawing.prototype.getNonce = function() {
|
|||
return this.nonce_;
|
||||
};
|
||||
|
||||
svgedit.draw.Drawing.prototype.setNonce = function(n) {
|
||||
this.svgElem_.setAttributeNS(xmlns_ns, 'xmlns:se', se_ns);
|
||||
this.svgElem_.setAttributeNS(se_ns, 'se:nonce', n);
|
||||
this.nonce_ = n;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the latest object id as a string.
|
||||
* @return {String} The latest object Id.
|
||||
|
|
|
@ -6360,9 +6360,9 @@ this.getSvgString = function() {
|
|||
//
|
||||
this.randomizeIds = function() {
|
||||
if (arguments.length > 0 && arguments[0] == false) {
|
||||
svgedit.draw.randomizeIds(false);
|
||||
svgedit.draw.randomizeIds(false, getCurrentDrawing());
|
||||
} else {
|
||||
svgedit.draw.randomizeIds(true);
|
||||
svgedit.draw.randomizeIds(true, getCurrentDrawing());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue