ライブラリ更新
git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@5761 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
parent
ad52f43293
commit
e3a9dfa4fe
@ -74,7 +74,7 @@
|
|||||||
http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/operationHistory.test.js
|
http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/operationHistory.test.js
|
||||||
*/
|
*/
|
||||||
(function() {
|
(function() {
|
||||||
const currentRevision = 5;
|
const currentRevision = 6;
|
||||||
|
|
||||||
if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {};
|
if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {};
|
||||||
|
|
||||||
@ -233,24 +233,26 @@
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
getWindowId : function(aWindow)
|
getWindowId : function(aWindow, aForceNewId)
|
||||||
{
|
{
|
||||||
var windowId = aWindow.document.documentElement.getAttribute(this.WINDOW_ID);
|
var root = aWindow.document.documentElement;
|
||||||
|
var windowId = root.getAttribute(this.WINDOW_ID);
|
||||||
try {
|
try {
|
||||||
if (!windowId)
|
if (!windowId)
|
||||||
windowId = this.SessionStore.getWindowValue(aWindow, this.WINDOW_ID);
|
windowId = this.SessionStore.getWindowValue(aWindow, this.WINDOW_ID);
|
||||||
}
|
}
|
||||||
catch(e) {
|
catch(e) {
|
||||||
}
|
}
|
||||||
if (!windowId) {
|
if (!windowId || aForceNewId) {
|
||||||
windowId = 'window-'+Date.now()+parseInt(Math.random() * 65000);
|
windowId = 'window-'+Date.now()+parseInt(Math.random() * 65000);
|
||||||
aWindow.document.documentElement.setAttribute(this.WINDOW_ID, windowId);
|
|
||||||
try {
|
try {
|
||||||
this.SessionStore.setWindowValue(aWindow, this.WINDOW_ID, windowId);
|
this.SessionStore.setWindowValue(aWindow, this.WINDOW_ID, windowId);
|
||||||
}
|
}
|
||||||
catch(e) {
|
catch(e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (root.getAttribute(this.WINDOW_ID) != windowId)
|
||||||
|
root.setAttribute(this.WINDOW_ID, windowId);
|
||||||
return windowId;
|
return windowId;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -331,18 +333,13 @@
|
|||||||
if (!name)
|
if (!name)
|
||||||
name = w ? 'window' : 'global' ;
|
name = w ? 'window' : 'global' ;
|
||||||
|
|
||||||
var tableName = encodeURIComponent(name);
|
|
||||||
|
|
||||||
var windowId = w ? this.getWindowId(w) : null ;
|
var windowId = w ? this.getWindowId(w) : null ;
|
||||||
if (windowId)
|
var table = this._getTable(name, w);
|
||||||
tableName += '::'+windowId;
|
|
||||||
|
|
||||||
if (!(tableName in this._tables)) {
|
// Wrongly duplicated ID, so, we have to create new ID for this window.
|
||||||
this._tables[tableName] = {
|
if (w && table.window && table.window != w) {
|
||||||
entries : [],
|
windowId = this.getWindowId(w, true);
|
||||||
index : -1,
|
table = this._getTable(name, w);
|
||||||
windowId : windowId
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -350,11 +347,31 @@
|
|||||||
window : w,
|
window : w,
|
||||||
windowId : windowId,
|
windowId : windowId,
|
||||||
data : data,
|
data : data,
|
||||||
history : this._tables[tableName],
|
history : table,
|
||||||
task : task
|
task : task
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_getTable : function(aName, aWindow)
|
||||||
|
{
|
||||||
|
aName = encodeURIComponent(aName);
|
||||||
|
|
||||||
|
var windowId = aWindow ? this.getWindowId(aWindow) : null ;
|
||||||
|
if (windowId)
|
||||||
|
aName += '::'+aName;
|
||||||
|
|
||||||
|
if (!(aName in this._tables)) {
|
||||||
|
this._tables[aName] = {
|
||||||
|
entries : [],
|
||||||
|
index : -1,
|
||||||
|
window : aWindow,
|
||||||
|
windowId : windowId
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return this._tables[aName];
|
||||||
|
},
|
||||||
|
|
||||||
_getAvailableFunction : function()
|
_getAvailableFunction : function()
|
||||||
{
|
{
|
||||||
var functions = Array.slice(arguments);
|
var functions = Array.slice(arguments);
|
||||||
@ -367,18 +384,22 @@
|
|||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
_deleteWindowTables : function()
|
_deleteWindowTables : function(aWindow)
|
||||||
{
|
{
|
||||||
var id = this.getWindowId(window);
|
var w = aWindow || window;
|
||||||
if (!id) return;
|
if (!w) return;
|
||||||
|
|
||||||
var removedTables = [];
|
var removedTables = [];
|
||||||
for (let i in this._tables)
|
for (let i in this._tables)
|
||||||
{
|
{
|
||||||
if (id == this._tables[i].windowId)
|
if (w == this._tables[i].window)
|
||||||
removedTables.push(i);
|
removedTables.push(i);
|
||||||
}
|
}
|
||||||
removedTables.forEach(function(aName) {
|
removedTables.forEach(function(aName) {
|
||||||
|
var table = this._tables[aName];
|
||||||
|
delete table.entries;
|
||||||
|
delete table.window;
|
||||||
|
delete table.windowId;
|
||||||
delete this._tables[aName];
|
delete this._tables[aName];
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
@ -419,7 +440,7 @@
|
|||||||
switch (aEvent.type)
|
switch (aEvent.type)
|
||||||
{
|
{
|
||||||
case 'unload':
|
case 'unload':
|
||||||
this._deleteWindowTables();
|
this._deleteWindowTables(window);
|
||||||
this.destroy();
|
this.destroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user