Define a unique id for each PaperScript.

This commit is contained in:
Jürg Lehni 2011-05-15 11:32:42 +01:00
parent 3cb78db5f5
commit 06f16d0c2a
2 changed files with 4 additions and 3 deletions

View file

@ -19,10 +19,11 @@
* global paper object, which simply is a pointer to the currently active scope.
*/
var PaperScope = this.PaperScope = Base.extend({
initialize: function() {
initialize: function(id) {
this.document = null;
this.documents = [];
this.tools = [];
this.id = id;
},
/**

View file

@ -207,13 +207,13 @@ var PaperScript = this.PaperScript = new function() {
var scripts = document.getElementsByTagName('script');
for (var i = 0, l = scripts.length; i < l; i++) {
var script = scripts[i];
// Only load this cript if it not loaded already.
// Only load this script if it not loaded already.
if (script.type === 'text/paperscript'
&& !script.getAttribute('loaded')) {
// Produce a new PaperScope for this script now. Scopes are
// cheap so let's not worry about the initial one that was
// already created.
var scope = new PaperScope();
var scope = new PaperScope(script.src || ('script-' + i));
// If a canvas id is provided, create a document for it now,
// so the active document is defined.
var canvas = script.getAttribute('canvas');