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-75d572ba1ddd
master
Jeff Schiller 2011-02-03 06:45:01 +00:00
parent 67384a5a71
commit 09ab8a85fe
2 changed files with 19 additions and 5 deletions

View File

@ -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.

View File

@ -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());
}
};