79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
--------------------------------------------------------------------------------
/chrome/content/dendzones/utils.js:
--------------------------------------------------------------------------------
1 | /* ***** BEGIN LICENSE BLOCK *****
2 | Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 |
4 | The contents of this file are subject to the Mozilla Public License Version
5 | 1.1 (the "License"); you may not use this file except in compliance with
6 | the License. You may obtain a copy of the License at
7 | http://www.mozilla.org/MPL/
8 |
9 | Software distributed under the License is distributed on an "AS IS" basis,
10 | WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 | for the specific language governing rights and limitations under the
12 | License.
13 |
14 | The Original Code is Drag & DropZones code.
15 |
16 | The Initial Developer of the Original Code is Martijn Kooij a.k.a. Captain Caveman.
17 |
18 | Alternatively, the contents of this file may be used under the terms of
19 | either the GNU General Public License Version 2 or later (the "GPL"), or
20 | the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
21 | in which case the provisions of the GPL or the LGPL are applicable instead
22 | of those above. If you wish to allow use of your version of this file only
23 | under the terms of either the GPL or the LGPL, and not to allow others to
24 | use your version of this file under the terms of the MPL, indicate your
25 | decision by deleting the provisions above and replace them with the notice
26 | and other provisions required by the GPL or the LGPL. If you do not delete
27 | the provisions above, a recipient may use your version of this file under
28 | the terms of any one of the MPL, the GPL or the LGPL.
29 |
30 | ***** END LICENSE BLOCK ***** */
31 | function DenDUtils()
32 | {
33 | this.Init();
34 | }
35 |
36 | DenDUtils.prototype=
37 | {
38 | oPref:null,
39 | oStringBundle:null,
40 |
41 | Init:function()
42 | {
43 | var sbService = Components.classes["@mozilla.org/intl/stringbundle;1"].getService(Components.interfaces.nsIStringBundleService);
44 | this.oStringBundle = sbService.createBundle("chrome://dendzones/locale/dendzones.properties");
45 |
46 | this.oPref = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
47 | this.oPref = this.oPref.getBranch("extensions.dendzones.");
48 | this.CheckDefaultPreferences();
49 | this.GetVersion();
50 | },
51 |
52 | TranslateString: function(sName, sVar1, sVar2, sVar3)
53 | {
54 | var sResult = "";
55 | if(this.oStringBundle)
56 | {
57 | sResult = this.oStringBundle.GetStringFromName(sName);
58 | if (sVar1) sResult = sResult.replace(/%1/g, sVar1);
59 | if (sVar2) sResult = sResult.replace(/%2/g, sVar2);
60 | if (sVar3) sResult = sResult.replace(/%3/g, sVar3);
61 | sResult = sResult.replace(/\\/g, ''); //Temporary fix babelzilla escaping bug.
62 | }
63 | return sResult;
64 | },
65 |
66 | CheckDefaultPreferences: function()
67 | {
68 | if (!this.HasUserValue("dropzones"))
69 | {
70 | this.SetString("dropzones", "");
71 | this.InitializeDefaultDropZones();
72 | }
73 |
74 | /*Convert any pref based dropzones to SQLite*/
75 | if (this.GetString("dropzones") != "")
76 | {
77 | this.ConvertPrefDropZones();
78 | this.SetString("dropzones", "");
79 | }
80 | },
81 |
82 | HasUserValue: function(sName)
83 | {
84 | return this.oPref.prefHasUserValue(sName);
85 | },
86 |
87 | GetString :function(sName)
88 | {
89 | try {return this.oPref.getCharPref(sName);}
90 | catch (e) {return "";}
91 | },
92 |
93 | SetString :function(sName, sValue)
94 | {
95 | this.oPref.setCharPref(sName, sValue);
96 | },
97 |
98 | GetBool :function(sName)
99 | {
100 | return this.oPref.getBoolPref(sName);
101 | },
102 |
103 | SetBool :function(sName, bValue)
104 | {
105 | this.oPref.setBoolPref(sName, bValue);
106 | },
107 |
108 | GetInt :function(sName)
109 | {
110 | try {return this.oPref.getIntPref(sName);}
111 | catch (e) {return 0;}
112 | },
113 |
114 | SetInt :function(sName, iValue)
115 | {
116 | this.oPref.setIntPref(sName, iValue);
117 | },
118 |
119 | GetLocalizedString: function(sName)
120 | {
121 | try {return this.oPref.getComplexValue(sName, Components.interfaces.nsIPrefLocalizedString).data;}
122 | catch (e) {}
123 | try {return this.oPref.getCharPref(sName);}
124 | catch (e) {return "";}
125 | },
126 |
127 | SetLocalizedString: function(sName, sData)
128 | {
129 | var oPLS = Components.classes["@mozilla.org/pref-localizedstring;1"].createInstance(Components.interfaces.nsIPrefLocalizedString);
130 | oPLS.data = sData;
131 | this.oPref.setComplexValue(sName, Components.interfaces.nsIPrefLocalizedString, oPLS);
132 | },
133 |
134 | WriteDebugMessage: function(aMsg)
135 | {
136 | var oConsole = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces["nsIConsoleService"]);
137 | oConsole.logStringMessage(aMsg);
138 | },
139 |
140 | FindTopParent: function(oElement)
141 | {
142 | if (oElement.parentNode)
143 | {
144 | while (oElement.parentNode)
145 | {
146 | oElement = oElement.parentNode;
147 | }
148 | }
149 | return oElement;
150 | },
151 |
152 | FindPosX: function(oElement)
153 | {
154 | var iX = 0;
155 | if (oElement.offsetParent)
156 | {
157 | while (oElement.offsetParent)
158 | {
159 | iX += oElement.offsetLeft;
160 | oElement = oElement.offsetParent;
161 | }
162 | }
163 | else if (oElement.boxObject.screenX) iX = oElement.boxObject.screenX;
164 | return iX;
165 | },
166 |
167 | FindPosY: function(oElement)
168 | {
169 | var iY = 0;
170 | if (oElement.offsetParent)
171 | {
172 | while (oElement.offsetParent)
173 | {
174 | iY += oElement.offsetTop;
175 | oElement = oElement.offsetParent;
176 | }
177 | }
178 | else if (oElement.boxObject.screenY) iY = oElement.boxObject.screenY;
179 | return iY;
180 | },
181 |
182 | Alltrim: function(sText)
183 | {
184 | while (sText.charAt(0) == ' ' || sText.charCodeAt(0) == 13 || sText.charCodeAt(0) == 10 || sText.charCodeAt(0) == 9) sText = sText.substring(1);
185 | while (sText.charAt(sText.length-1) == ' ' || sText.charCodeAt(sText.length-1) == 13 || sText.charCodeAt(sText.length-1) == 10 || sText.charCodeAt(sText.length-1) == 9) sText = sText.substring(0, sText.length-1);
186 | return sText;
187 | },
188 |
189 | PadLeft: function(sString,iLength,sPadChar)
190 | {
191 | var iIndex, iPLen, iSLen;
192 |
193 | sString = sString.toString();
194 | iSLen = sString.length;
195 | if(iLength <= iSLen) return sString;
196 | iPLen = iLength - iSLen;
197 | for(iIndex = 0; iIndex < iPLen; iIndex++) sString = sPadChar + sString;
198 | return sString;
199 | },
200 |
201 | RemoveAllChildren: function(oItem, sDontRemoveIDs)
202 | {
203 | var sID;
204 | var iIndex, iLen;
205 |
206 | iLen = oItem.childNodes.length - 1;
207 |
208 | for (iIndex = iLen; iIndex >= 0; iIndex --)
209 | {
210 | sID = oItem.childNodes[iIndex].id;
211 | if ((!sDontRemoveIDs || sDontRemoveIDs.indexOf(sID) == -1) && sID && sID != "")
212 | {
213 | oItem.removeChild(oItem.childNodes[iIndex]);
214 | }
215 | else
216 | {
217 | if (oItem.childNodes[iIndex].childNodes.length > 0) this.RemoveAllChildren(oItem.childNodes[iIndex], sDontRemoveIDs)
218 | }
219 | }
220 | },
221 |
222 | GetTopContentWindow: function()
223 | {
224 | return window.top.getBrowser().browsers[window.top.getBrowser().mTabBox.selectedIndex].contentWindow;
225 | },
226 |
227 | GetTopContentDocument: function()
228 | {
229 | return window.top.getBrowser().browsers[window.top.getBrowser().mTabBox.selectedIndex].contentDocument;
230 | },
231 |
232 | GetIndex: function(aArray, sItem)
233 | {
234 | var iIndex, iLen = aArray.length;
235 | for (iIndex = 0; iIndex < iLen; iIndex ++)
236 | {
237 | if (aArray[iIndex][0] == sItem) return iIndex;
238 | }
239 | return -1;
240 | },
241 |
242 | GetVersion: function()
243 | {
244 | try
245 | {
246 | var oEM = Components.classes["@mozilla.org/extensions/manager;1"].getService(Components.interfaces.nsIExtensionManager);
247 | if (oEM.getItemForID) {return oEM.getItemForID("dendzones@captaincaveman.nl").version;}
248 | else {return oEM.getItemList("dendzones@captaincaveman.nl", null, {})[0].version;}
249 | }
250 | catch (e)
251 | {
252 | Components.utils.import("resource://gre/modules/AddonManager.jsm");
253 | var oUtils = this;
254 | AddonManager.getAddonByID("dendzones@captaincaveman.nl", function(oAddon) {
255 | oUtils.SetVersion(oAddon.version);
256 | });
257 | return this.sCurrentVersion; //Stupid async calls... Just hope it's already there...
258 | }
259 | },
260 |
261 | SetVersion: function(sVersion)
262 | {
263 | this.sCurrentVersion = sVersion;
264 | },
265 |
266 | InitializeDefaultDropZones: function()
267 | {
268 | if ("nsIBrowserSearchService" in Components.interfaces)
269 | {
270 | var oSS = Components.classes["@mozilla.org/browser/search-service;1"].getService(Components.interfaces.nsIBrowserSearchService);
271 | var oEngines = oSS.getVisibleEngines({});
272 | var sDropZones = "";
273 | var iIndex, iLen = oEngines.length;
274 |
275 | var iX = 0; iY = 0, iMaxAxis = 3;
276 |
277 | if (iLen <= 16) iMaxAxis = 3;
278 | else if (iLen <= 36) iMaxAxis = 5;
279 | else iMaxAxis = 7;
280 |
281 | for (iIndex = 0; iIndex < iLen; iIndex ++)
282 | {
283 | if (iIndex <= 64)
284 | {
285 | //Assign DropZones.
286 | sDropZones += 'd_z' + iX + 'd_v' + iY + 'd_v' + oEngines[iIndex].name;
287 | iX++;
288 | if (iX > iMaxAxis)
289 | {
290 | iX = 0;
291 | iY++;
292 | }
293 | if (iY > iMaxAxis) iY = 0;
294 | }
295 | }
296 | sDropZones = sDropZones.substr(3);
297 | this.SetLocalizedString("dropzones", sDropZones);
298 | }
299 | },
300 |
301 | ConvertPrefDropZones: function()
302 | {
303 | var aTemp = new Array();
304 | var aDropZones = new Array(10);
305 | var aDropZone;
306 | var sColor = this.GetString("dropzonecolor");
307 |
308 | var iIndex, iLen, iX, iY;
309 |
310 | for (iIndex = 0; iIndex < 10; iIndex ++) aDropZones[iIndex] = new Array(10);
311 |
312 | aTemp = this.GetLocalizedString("dropzones").split('d_z');
313 | iLen = aTemp.length
314 |
315 | for (iIndex = 0; iIndex < iLen; iIndex ++)
316 | {
317 | if (aTemp[iIndex] != "")
318 | {
319 | aDropZone = new Array();
320 | aDropZone = aTemp[iIndex].split('d_v');
321 |
322 | iX = aDropZone[0];
323 | iY = aDropZone[1];
324 |
325 | aDropZones[iX][iY] = new Array(aDropZone[2], aDropZone[3], aDropZone[4], '', sColor);
326 | }
327 | }
328 | this.SetDropZones(aDropZones);
329 | },
330 |
331 | GetDropZones: function()
332 | {
333 | var oDatabase = new DenDZonesDatabase();
334 | var aResult = oDatabase.GetDropZones();
335 | oDatabase.DeInitDatabase();
336 |
337 | return aResult;
338 | },
339 |
340 | SetDropZones: function(aDropZones)
341 | {
342 | var oDatabase = new DenDZonesDatabase();
343 |
344 | var iX, iY;
345 | for (iX = 0; iX < 10; iX ++)
346 | {
347 | for (iY = 0; iY < 10; iY ++)
348 | {
349 | if (aDropZones[iX][iY])
350 | {
351 | if (!aDropZones[iX][iY][3] || aDropZones[iX][iY][3] == "")
352 | {
353 | aDropZones[iX][iY][3] = this.GetImageForZoneID(aDropZones[iX][iY][0]);
354 | }
355 | if (aDropZones[iX][iY][3].indexOf("base64") < 0)
356 | {
357 | aDropZones[iX][iY][3] = this.RemoteImage2B64(aDropZones[iX][iY][3]);
358 | }
359 | }
360 | }
361 | }
362 | oDatabase.StoreDropZones(aDropZones);
363 | oDatabase.DeInitDatabase();
364 | },
365 |
366 | GetImageForZoneID: function(sID)
367 | {
368 | if (!sID || sID == "") return "";
369 |
370 | var oSS = Components.classes["@mozilla.org/browser/search-service;1"].getService(Components.interfaces.nsIBrowserSearchService);
371 | var oEngine = oSS.getEngineByName(sID);
372 |
373 | if (oEngine)
374 | {
375 | if (oEngine.iconURI) return oEngine.iconURI.spec;
376 | }
377 | return "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACpElEQVQ4jYXRXUhTYRzH8UHldja3VaRlQVDUXWo4FU1STC3LjOkyI4uSMKwbJRQjKb0JCiLoRS2sYXdR1NTMmaVb05npXt37bOqcm6ZQx6SZds5+3ayjy8I/PJffz/Pwf1is4HwuFZLDFwRwFgvgOMOH/SQfNkk4rMfCYT7MgymLi6F0Loz7CRiTCWhELCFr+QyXCEjKO4jAjBmBaQMCU1rQvk+gJ9SgPSrQbgWosfegRjvhvVEEXTxHORi7LpEBnMUCkvL0rxpTIx2gXHLMPKmELo5NMoCjiE9SbjUTt3dfRs3TvahpioW693pI7JIQIGU3oRNx3AxgP8EnqVEVc/OvcSUaXuZgj5aP4rt8qFXVoFxyBrDk7IA2LiyPAaz54eQPZwekrQWQthyHtFmCxzIxzt8TYqstLIhcBeWSB2P2rpAlWnJ55HdbM87Wr0eefBsy2oVIeMeG0L0WUd8icUSzG5fqNmPOIYMpdePKXzAd4pHz9tfo/lCFLmUluhQVaOu8iJL7G3BQsxOldREY1j4ANdoJU/qmlcBQBpdctLUx255zvEJtUywyB7aHxNRYF8yZ/wCMqVxywdrCbFuhqIBUJoZUJg6JabcSluy/gOcs1hpjCmdu0dbKfBVzRt6GxLSnB5ajEdBkBgFDKlFoSCbIL7f2Yfr2AfiqE+Apj4anbM+yEw1PWQw85TGgvX2wiiOXAGMyMTn75g4WjE34OdiI+Y8P4e+ph19VD39PA/y9jzCvbsTsi2q4JAToiX7YCpYBhkRi8uuz2lWf7a1Kgu9aGgJTWthPbYGmIAjo49lZehFbP35F/N+Y9vaB9g0gMKVFYNoI57moJeDP6OLYpF7EgSGBA0MSAWMKgaE0LkyZXJizebDk8mDLD4e9kA/HaT4D/AYOtmDz3+Wg3QAAAABJRU5ErkJggg==";
378 | },
379 |
380 | RemoteImage2B64: function(sImageURI)
381 | {
382 | if (sImageURI && sImageURI != "")
383 | {
384 | try
385 | {
386 | var oImage = new Image();
387 | oImage.src = sImageURI;
388 | var oCanvas = document.createElementNS("http://www.w3.org/1999/xhtml", "html:canvas");
389 | oCanvas.width = 16;
390 | oCanvas.height = 16;
391 | var oContext = oCanvas.getContext('2d');
392 | oContext.drawImage(oImage, 0, 0, 16, 16);
393 | var sDataURL = oCanvas.toDataURL();
394 | return sDataURL;
395 | }
396 | catch (e) {return "";}
397 | }
398 | return "";
399 | },
400 |
401 | };
402 |
403 | function DenDZonesDatabase()
404 | {
405 | this.Init();
406 | }
407 |
408 | DenDZonesDatabase.prototype =
409 | {
410 | oDabatase: null,
411 |
412 | Init: function()
413 | {
414 | var oFile = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile);
415 | oFile.append("dendzones.sqlite");
416 | var oStorageService = Components.classes["@mozilla.org/storage/service;1"].getService(Components.interfaces.mozIStorageService);
417 | this.oDabatase = oStorageService.openDatabase(oFile);
418 |
419 | this.InitDatabase();
420 | },
421 |
422 | InitDatabase: function()
423 | {
424 | if (!this.oDabatase.tableExists("zones"))
425 | {
426 | this.oDabatase.executeSimpleSQL("CREATE TABLE zones (x INTEGER, y INTEGER, id TEXT, label TEXT, action TEXT, color TEXT, image TEXT)");
427 | }
428 | },
429 |
430 | DeInitDatabase: function()
431 | {
432 | if (typeof(this.oDabatase.close) == "function") this.oDabatase.close();
433 | this.oDabatase = null;
434 | },
435 |
436 | DeleteAllData: function(sTable)
437 | {
438 | this.oDabatase.executeSimpleSQL("DELETE FROM zones");
439 | },
440 |
441 | GetDropZones: function()
442 | {
443 | var oStatement;
444 | var aResult = new Array(10);
445 | var iIndex;
446 |
447 | for (iIndex = 0; iIndex < 10; iIndex ++) aResult[iIndex] = new Array(10);
448 |
449 | var sID, sLabel, sAction, sColor, sImage;
450 | var iX, iY;
451 | oStatement = this.oDabatase.createStatement("SELECT x, y, id, label, action, color, image FROM zones");
452 |
453 | while (oStatement.executeStep())
454 | {
455 | iX = oStatement.getInt32(0);
456 | iY = oStatement.getInt32(1);
457 | sID = oStatement.getUTF8String(2);
458 | sLabel = oStatement.getUTF8String(3);
459 | sAction = oStatement.getUTF8String(4);
460 | sColor = oStatement.getUTF8String(5);
461 | sImage = oStatement.getUTF8String(6);
462 |
463 | aResult[iX][iY] = new Array(sID, sLabel, sAction, sImage, sColor);
464 | }
465 | oStatement.reset();
466 | if (typeof(oStatement.finalize) == "function") oStatement.finalize();
467 |
468 | for (iX = 0; iX < 10; iX ++)
469 | {
470 | for (iY = 0; iY < 10; iY ++)
471 | {
472 | if (!aResult[iX][iY]) aResult[iX][iY] = new Array('', '', '', '', '');
473 | }
474 | }
475 |
476 | return aResult;
477 | },
478 |
479 | StoreDropZones: function(aDropZones)
480 | {
481 | var iX, iY = aDropZones.length;
482 |
483 | this.DeleteAllData();
484 | for (iX = 0; iX < 10; iX ++)
485 | {
486 | for (iY = 0; iY < 10; iY ++)
487 | {
488 | if (aDropZones[iX][iY]) this.AddDropZone(iX, iY, aDropZones[iX][iY]);
489 | }
490 | }
491 | },
492 |
493 | AddDropZone: function(iX, iY, aDropZone)
494 | {
495 | var oStatement;
496 |
497 | oStatement = this.oDabatase.createStatement("INSERT INTO zones VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7)");
498 | oStatement.bindInt32Parameter(0, iX);
499 | oStatement.bindInt32Parameter(1, iY);
500 | oStatement.bindUTF8StringParameter(2, aDropZone[0]);//ID
501 | oStatement.bindUTF8StringParameter(3, aDropZone[1]);//Label
502 | oStatement.bindUTF8StringParameter(4, aDropZone[2]);//Action
503 | oStatement.bindUTF8StringParameter(5, aDropZone[4]);//Color
504 | oStatement.bindUTF8StringParameter(6, aDropZone[3]);//Image
505 | oStatement.execute();
506 | oStatement.reset();
507 | if (typeof(oStatement.finalize) == "function") oStatement.finalize();
508 | }
509 | };
510 |
511 |
--------------------------------------------------------------------------------
/chrome/content/dendzones/nsDragAndDrop.js:
--------------------------------------------------------------------------------
1 | /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 | /* ***** BEGIN LICENSE BLOCK *****
3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | * http://www.mozilla.org/MPL/
9 | *
10 | * Software distributed under the License is distributed on an "AS IS" basis,
11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 | * for the specific language governing rights and limitations under the
13 | * License.
14 | *
15 | * The Original Code is mozilla.org code.
16 | *
17 | * The Initial Developer of the Original Code is
18 | * Netscape Communications Corporation.
19 | * Portions created by the Initial Developer are Copyright (C) 1998
20 | * the Initial Developer. All Rights Reserved.
21 | *
22 | * Contributor(s):
23 | * Ben Goodger (Original Author)
24 | * Pierre Chanial
25 | *
26 | * Alternatively, the contents of this file may be used under the terms of
27 | * either of the GNU General Public License Version 2 or later (the "GPL"),
28 | * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 | * in which case the provisions of the GPL or the LGPL are applicable instead
30 | * of those above. If you wish to allow use of your version of this file only
31 | * under the terms of either the GPL or the LGPL, and not to allow others to
32 | * use your version of this file under the terms of the MPL, indicate your
33 | * decision by deleting the provisions above and replace them with the notice
34 | * and other provisions required by the GPL or the LGPL. If you do not delete
35 | * the provisions above, a recipient may use your version of this file under
36 | * the terms of any one of the MPL, the GPL or the LGPL.
37 | *
38 | * ***** END LICENSE BLOCK ***** */
39 |
40 | /**
41 | * nsTransferable - a wrapper for nsITransferable that simplifies
42 | * javascript clipboard and drag&drop. for use in
43 | * these situations you should use the nsClipboard
44 | * and nsDragAndDrop wrappers for more convenience
45 | **/
46 |
47 | var nsTransferable = {
48 | /**
49 | * nsITransferable set (TransferData aTransferData) ;
50 | *
51 | * Creates a transferable with data for a list of supported types ("flavours")
52 | *
53 | * @param TransferData aTransferData
54 | * a javascript object in the format described above
55 | **/
56 | set: function (aTransferDataSet)
57 | {
58 | var trans = this.createTransferable();
59 | for (var i = 0; i < aTransferDataSet.dataList.length; ++i)
60 | {
61 | var currData = aTransferDataSet.dataList[i];
62 | var currFlavour = currData.flavour.contentType;
63 | trans.addDataFlavor(currFlavour);
64 | var supports = null; // nsISupports data
65 | var length = 0;
66 | if (currData.flavour.dataIIDKey == "nsISupportsString")
67 | {
68 | supports = Components.classes["@mozilla.org/supports-string;1"]
69 | .createInstance(Components.interfaces.nsISupportsString);
70 |
71 | supports.data = currData.supports;
72 | length = supports.data.length;
73 | }
74 | else
75 | {
76 | // non-string data.
77 | supports = currData.supports;
78 | length = 0; // kFlavorHasDataProvider
79 | }
80 | trans.setTransferData(currFlavour, supports, length * 2);
81 | }
82 | return trans;
83 | },
84 |
85 | /**
86 | * TransferData/TransferDataSet get (FlavourSet aFlavourSet,
87 | * Function aRetrievalFunc, Boolean aAnyFlag) ;
88 | *
89 | * Retrieves data from the transferable provided in aRetrievalFunc, formatted
90 | * for more convenient access.
91 | *
92 | * @param FlavourSet aFlavourSet
93 | * a FlavourSet object that contains a list of supported flavours.
94 | * @param Function aRetrievalFunc
95 | * a reference to a function that returns a nsISupportsArray of nsITransferables
96 | * for each item from the specified source (clipboard/drag&drop etc)
97 | * @param Boolean aAnyFlag
98 | * a flag specifying whether or not a specific flavour is requested. If false,
99 | * data of the type of the first flavour in the flavourlist parameter is returned,
100 | * otherwise the best flavour supported will be returned.
101 | **/
102 | get: function (aFlavourSet, aRetrievalFunc, aAnyFlag)
103 | {
104 | if (!aRetrievalFunc)
105 | throw "No data retrieval handler provided!";
106 |
107 | var supportsArray = aRetrievalFunc(aFlavourSet);
108 | var dataArray = [];
109 | var count = supportsArray.Count();
110 |
111 | // Iterate over the number of items returned from aRetrievalFunc. For
112 | // clipboard operations, this is 1, for drag and drop (where multiple
113 | // items may have been dragged) this could be >1.
114 | for (var i = 0; i < count; i++)
115 | {
116 | var trans = supportsArray.GetElementAt(i);
117 | if (!trans) continue;
118 | trans = trans.QueryInterface(Components.interfaces.nsITransferable);
119 |
120 | var data = { };
121 | var length = { };
122 |
123 | var currData = null;
124 | if (aAnyFlag)
125 | {
126 | var flavour = { };
127 | trans.getAnyTransferData(flavour, data, length);
128 | if (data && flavour)
129 | {
130 | var selectedFlavour = aFlavourSet.flavourTable[flavour.value];
131 | if (selectedFlavour)
132 | dataArray[i] = FlavourToXfer(data.value, length.value, selectedFlavour);
133 | }
134 | }
135 | else
136 | {
137 | var firstFlavour = aFlavourSet.flavours[0];
138 | trans.getTransferData(firstFlavour, data, length);
139 | if (data && firstFlavour)
140 | dataArray[i] = FlavourToXfer(data.value, length.value, firstFlavour);
141 | }
142 | }
143 | return new TransferDataSet(dataArray);
144 | },
145 |
146 | /**
147 | * nsITransferable createTransferable (void) ;
148 | *
149 | * Creates and returns a transferable object.
150 | **/
151 | createTransferable: function ()
152 | {
153 | const kXferableContractID = "@mozilla.org/widget/transferable;1";
154 | const kXferableIID = Components.interfaces.nsITransferable;
155 | return Components.classes[kXferableContractID].createInstance(kXferableIID);
156 | }
157 | };
158 |
159 | /**
160 | * A FlavourSet is a simple type that represents a collection of Flavour objects.
161 | * FlavourSet is constructed from an array of Flavours, and stores this list as
162 | * an array and a hashtable. The rationale for the dual storage is as follows:
163 | *
164 | * Array: Ordering is important when adding data flavours to a transferable.
165 | * Flavours added first are deemed to be 'preferred' by the client.
166 | * Hash: Convenient lookup of flavour data using the content type (MIME type)
167 | * of data as a key.
168 | */
169 | function FlavourSet(aFlavourList)
170 | {
171 | this.flavours = aFlavourList || [];
172 | this.flavourTable = { };
173 |
174 | this._XferID = "FlavourSet";
175 |
176 | for (var i = 0; i < this.flavours.length; ++i)
177 | this.flavourTable[this.flavours[i].contentType] = this.flavours[i];
178 | }
179 |
180 | FlavourSet.prototype = {
181 | appendFlavour: function (aFlavour, aFlavourIIDKey)
182 | {
183 | var flavour = new Flavour (aFlavour, aFlavourIIDKey);
184 | this.flavours.push(flavour);
185 | this.flavourTable[flavour.contentType] = flavour;
186 | }
187 | };
188 |
189 | /**
190 | * A Flavour is a simple type that represents a data type that can be handled.
191 | * It takes a content type (MIME type) which is used when storing data on the
192 | * system clipboard/drag and drop, and an IIDKey (string interface name
193 | * which is used to QI data to an appropriate form. The default interface is
194 | * assumed to be wide-string.
195 | */
196 | function Flavour(aContentType, aDataIIDKey)
197 | {
198 | this.contentType = aContentType;
199 | this.dataIIDKey = aDataIIDKey || "nsISupportsString";
200 |
201 | this._XferID = "Flavour";
202 | }
203 |
204 | function TransferDataBase() {}
205 | TransferDataBase.prototype = {
206 | push: function (aItems)
207 | {
208 | this.dataList.push(aItems);
209 | },
210 |
211 | get first ()
212 | {
213 | return "dataList" in this && this.dataList.length ? this.dataList[0] : null;
214 | }
215 | };
216 |
217 | /**
218 | * TransferDataSet is a list (array) of TransferData objects, which represents
219 | * data dragged from one or more elements.
220 | */
221 | function TransferDataSet(aTransferDataList)
222 | {
223 | this.dataList = aTransferDataList || [];
224 |
225 | this._XferID = "TransferDataSet";
226 | }
227 | TransferDataSet.prototype = TransferDataBase.prototype;
228 |
229 | /**
230 | * TransferData is a list (array) of FlavourData for all the applicable content
231 | * types associated with a drag from a single item.
232 | */
233 | function TransferData(aFlavourDataList)
234 | {
235 | this.dataList = aFlavourDataList || [];
236 |
237 | this._XferID = "TransferData";
238 | }
239 | TransferData.prototype = {
240 | __proto__: TransferDataBase.prototype,
241 |
242 | addDataForFlavour: function (aFlavourString, aData, aLength, aDataIIDKey)
243 | {
244 | this.dataList.push(new FlavourData(aData, aLength,
245 | new Flavour(aFlavourString, aDataIIDKey)));
246 | }
247 | };
248 |
249 | /**
250 | * FlavourData is a type that represents data retrieved from the system
251 | * clipboard or drag and drop. It is constructed internally by the Transferable
252 | * using the raw (nsISupports) data from the clipboard, the length of the data,
253 | * and an object of type Flavour representing the type. Clients implementing
254 | * IDragDropObserver receive an object of this type in their implementation of
255 | * onDrop. They access the 'data' property to retrieve data, which is either data
256 | * QI'ed to a usable form, or unicode string.
257 | */
258 | function FlavourData(aData, aLength, aFlavour)
259 | {
260 | this.supports = aData;
261 | this.contentLength = aLength;
262 | this.flavour = aFlavour || null;
263 |
264 | this._XferID = "FlavourData";
265 | }
266 |
267 | FlavourData.prototype = {
268 | get data ()
269 | {
270 | if (this.flavour &&
271 | this.flavour.dataIIDKey != "nsISupportsString" )
272 | return this.supports.QueryInterface(Components.interfaces[this.flavour.dataIIDKey]);
273 | else {
274 | var unicode = this.supports.QueryInterface(Components.interfaces.nsISupportsString);
275 | if (unicode)
276 | return unicode.data.substring(0, this.contentLength/2);
277 |
278 | return this.supports;
279 | }
280 | return "";
281 | }
282 | }
283 |
284 | /**
285 | * Create a TransferData object with a single FlavourData entry. Used when
286 | * unwrapping data of a specific flavour from the drag service.
287 | */
288 | function FlavourToXfer(aData, aLength, aFlavour)
289 | {
290 | return new TransferData([new FlavourData(aData, aLength, aFlavour)]);
291 | }
292 |
293 | var transferUtils = {
294 |
295 | retrieveURLFromData: function (aData, flavour)
296 | {
297 | switch (flavour) {
298 | case "text/unicode":
299 | return aData;
300 | case "text/x-moz-url":
301 | return aData.toString().split("\n")[0];
302 | case "application/x-moz-file":
303 | var ioService = Components.classes["@mozilla.org/network/io-service;1"]
304 | .getService(Components.interfaces.nsIIOService);
305 | var fileHandler = ioService.getProtocolHandler("file")
306 | .QueryInterface(Components.interfaces.nsIFileProtocolHandler);
307 | return fileHandler.getURLSpecFromFile(aData);
308 | }
309 | return null;
310 | }
311 |
312 | }
313 |
314 | /**
315 | * nsDragAndDrop - a convenience wrapper for nsTransferable, nsITransferable
316 | * and nsIDragService/nsIDragSession.
317 | *
318 | * Use: map the handler functions to the 'ondraggesture', 'ondragover' and
319 | * 'ondragdrop' event handlers on your XML element, e.g.
320 | *
323 | *
324 | * You need to create an observer js object with the following member
325 | * functions:
326 | * Object onDragStart (event) // called when drag initiated,
327 | * // returns flavour list with data
328 | * // to stuff into transferable
329 | * void onDragOver (Object flavour) // called when element is dragged
330 | * // over, so that it can perform
331 | * // any drag-over feedback for provided
332 | * // flavour
333 | * void onDrop (Object data) // formatted data object dropped.
334 | * Object getSupportedFlavours () // returns a flavour list so that
335 | * // nsTransferable can determine
336 | * // whether or not to accept drop.
337 | **/
338 |
339 | var nsDragAndDrop = {
340 |
341 | _mDS: null,
342 | get mDragService()
343 | {
344 | if (!this._mDS)
345 | {
346 | const kDSContractID = "@mozilla.org/widget/dragservice;1";
347 | const kDSIID = Components.interfaces.nsIDragService;
348 | this._mDS = Components.classes[kDSContractID].getService(kDSIID);
349 | }
350 | return this._mDS;
351 | },
352 |
353 | /**
354 | * void startDrag (DOMEvent aEvent, Object aDragDropObserver) ;
355 | *
356 | * called when a drag on an element is started.
357 | *
358 | * @param DOMEvent aEvent
359 | * the DOM event fired by the drag init
360 | * @param Object aDragDropObserver
361 | * javascript object of format described above that specifies
362 | * the way in which the element responds to drag events.
363 | **/
364 | startDrag: function (aEvent, aDragDropObserver)
365 | {
366 | if (!("onDragStart" in aDragDropObserver))
367 | return;
368 |
369 | const kDSIID = Components.interfaces.nsIDragService;
370 | var dragAction = { action: kDSIID.DRAGDROP_ACTION_COPY + kDSIID.DRAGDROP_ACTION_MOVE + kDSIID.DRAGDROP_ACTION_LINK };
371 |
372 | var transferData = { data: null };
373 | try
374 | {
375 | aDragDropObserver.onDragStart(aEvent, transferData, dragAction);
376 | }
377 | catch (e)
378 | {
379 | return; // not a draggable item, bail!
380 | }
381 |
382 | if (!transferData.data) return;
383 | transferData = transferData.data;
384 |
385 | var transArray = Components.classes["@mozilla.org/supports-array;1"]
386 | .createInstance(Components.interfaces.nsISupportsArray);
387 |
388 | var region = null;
389 | if (aEvent.originalTarget.localName == "treechildren") {
390 | // let's build the drag region
391 | var tree = aEvent.originalTarget.parentNode;
392 | try {
393 | region = Components.classes["@mozilla.org/gfx/region;1"].createInstance(Components.interfaces.nsIScriptableRegion);
394 | region.init();
395 | var obo = tree.treeBoxObject;
396 | var bo = obo.treeBody.boxObject;
397 | var sel= tree.view.selection;
398 |
399 | var rowX = bo.x;
400 | var rowY = bo.y;
401 | var rowHeight = obo.rowHeight;
402 | var rowWidth = bo.width;
403 |
404 | //add a rectangle for each visible selected row
405 | for (var i = obo.getFirstVisibleRow(); i <= obo.getLastVisibleRow(); i ++)
406 | {
407 | if (sel.isSelected(i))
408 | region.unionRect(rowX, rowY, rowWidth, rowHeight);
409 | rowY = rowY + rowHeight;
410 | }
411 |
412 | //and finally, clip the result to be sure we don't spill over...
413 | region.intersectRect(bo.x, bo.y, bo.width, bo.height);
414 | } catch(ex) {
415 | dump("Error while building selection region: " + ex + "\n");
416 | region = null;
417 | }
418 | }
419 |
420 | var count = 0;
421 | do
422 | {
423 | var trans = nsTransferable.set(transferData._XferID == "TransferData"
424 | ? transferData
425 | : transferData.dataList[count++]);
426 | transArray.AppendElement(trans.QueryInterface(Components.interfaces.nsISupports));
427 | }
428 | while (transferData._XferID == "TransferDataSet" &&
429 | count < transferData.dataList.length);
430 |
431 | try {
432 | this.mDragService.invokeDragSessionWithImage(aEvent.target, transArray,
433 | region, dragAction.action,
434 | null, 0, 0, aEvent);
435 | }
436 | catch(ex) {
437 | // this could be because the user pressed escape to
438 | // cancel the drag. even if it's not, there's not much
439 | // we can do, so be silent.
440 | }
441 | aEvent.stopPropagation();
442 | },
443 |
444 | /**
445 | * void dragOver (DOMEvent aEvent, Object aDragDropObserver) ;
446 | *
447 | * called when a drag passes over this element
448 | *
449 | * @param DOMEvent aEvent
450 | * the DOM event fired by passing over the element
451 | * @param Object aDragDropObserver
452 | * javascript object of format described above that specifies
453 | * the way in which the element responds to drag events.
454 | **/
455 | dragOver: function (aEvent, aDragDropObserver)
456 | {
457 | if (!("onDragOver" in aDragDropObserver))
458 | return;
459 | if (!this.checkCanDrop(aEvent, aDragDropObserver))
460 | return;
461 | var flavourSet = aDragDropObserver.getSupportedFlavours();
462 | for (var flavour in flavourSet.flavourTable)
463 | {
464 | if (this.mDragSession.isDataFlavorSupported(flavour))
465 | {
466 | aDragDropObserver.onDragOver(aEvent,
467 | flavourSet.flavourTable[flavour],
468 | this.mDragSession);
469 | aEvent.stopPropagation();
470 | break;
471 | }
472 | }
473 | },
474 |
475 | mDragSession: null,
476 |
477 | /**
478 | * void drop (DOMEvent aEvent, Object aDragDropObserver) ;
479 | *
480 | * called when the user drops on the element
481 | *
482 | * @param DOMEvent aEvent
483 | * the DOM event fired by the drop
484 | * @param Object aDragDropObserver
485 | * javascript object of format described above that specifies
486 | * the way in which the element responds to drag events.
487 | **/
488 | drop: function (aEvent, aDragDropObserver)
489 | {
490 | if (!("onDrop" in aDragDropObserver))
491 | return;
492 | if (!this.checkCanDrop(aEvent, aDragDropObserver))
493 | return;
494 | if (this.mDragSession.canDrop) {
495 | var flavourSet = aDragDropObserver.getSupportedFlavours();
496 | var transferData = nsTransferable.get(flavourSet, this.getDragData, true);
497 | // hand over to the client to respond to dropped data
498 | var multiple = "canHandleMultipleItems" in aDragDropObserver && aDragDropObserver.canHandleMultipleItems;
499 | var dropData = multiple ? transferData : transferData.first.first;
500 | aDragDropObserver.onDrop(aEvent, dropData, this.mDragSession);
501 | }
502 | aEvent.stopPropagation();
503 | },
504 |
505 | /**
506 | * void dragExit (DOMEvent aEvent, Object aDragDropObserver) ;
507 | *
508 | * called when a drag leaves this element
509 | *
510 | * @param DOMEvent aEvent
511 | * the DOM event fired by leaving the element
512 | * @param Object aDragDropObserver
513 | * javascript object of format described above that specifies
514 | * the way in which the element responds to drag events.
515 | **/
516 | dragExit: function (aEvent, aDragDropObserver)
517 | {
518 | if (!this.checkCanDrop(aEvent, aDragDropObserver))
519 | return;
520 | if ("onDragExit" in aDragDropObserver)
521 | aDragDropObserver.onDragExit(aEvent, this.mDragSession);
522 | },
523 |
524 | /**
525 | * void dragEnter (DOMEvent aEvent, Object aDragDropObserver) ;
526 | *
527 | * called when a drag enters in this element
528 | *
529 | * @param DOMEvent aEvent
530 | * the DOM event fired by entering in the element
531 | * @param Object aDragDropObserver
532 | * javascript object of format described above that specifies
533 | * the way in which the element responds to drag events.
534 | **/
535 | dragEnter: function (aEvent, aDragDropObserver)
536 | {
537 | if (!this.checkCanDrop(aEvent, aDragDropObserver))
538 | return;
539 | if ("onDragEnter" in aDragDropObserver)
540 | aDragDropObserver.onDragEnter(aEvent, this.mDragSession);
541 | },
542 |
543 | /**
544 | * nsISupportsArray getDragData (Object aFlavourList)
545 | *
546 | * Creates a nsISupportsArray of all droppable items for the given
547 | * set of supported flavours.
548 | *
549 | * @param FlavourSet aFlavourSet
550 | * formatted flavour list.
551 | **/
552 | getDragData: function (aFlavourSet)
553 | {
554 | var supportsArray = Components.classes["@mozilla.org/supports-array;1"]
555 | .createInstance(Components.interfaces.nsISupportsArray);
556 |
557 | for (var i = 0; i < nsDragAndDrop.mDragSession.numDropItems; ++i)
558 | {
559 | var trans = nsTransferable.createTransferable();
560 | for (var j = 0; j < aFlavourSet.flavours.length; ++j)
561 | trans.addDataFlavor(aFlavourSet.flavours[j].contentType);
562 | nsDragAndDrop.mDragSession.getData(trans, i);
563 | supportsArray.AppendElement(trans);
564 | }
565 | return supportsArray;
566 | },
567 |
568 | /**
569 | * Boolean checkCanDrop (DOMEvent aEvent, Object aDragDropObserver) ;
570 | *
571 | * Sets the canDrop attribute for the drag session.
572 | * returns false if there is no current drag session.
573 | *
574 | * @param DOMEvent aEvent
575 | * the DOM event fired by the drop
576 | * @param Object aDragDropObserver
577 | * javascript object of format described above that specifies
578 | * the way in which the element responds to drag events.
579 | **/
580 | checkCanDrop: function (aEvent, aDragDropObserver)
581 | {
582 | if (!this.mDragSession)
583 | this.mDragSession = this.mDragService.getCurrentSession();
584 | if (!this.mDragSession)
585 | return false;
586 | this.mDragSession.canDrop = this.mDragSession.sourceNode != aEvent.target;
587 | if ("canDrop" in aDragDropObserver)
588 | this.mDragSession.canDrop &= aDragDropObserver.canDrop(aEvent, this.mDragSession);
589 | return true;
590 | },
591 |
592 | /**
593 | * Do a security check for drag n' drop. Make sure the source document
594 | * can load the dragged link.
595 | *
596 | * @param DOMEvent aEvent
597 | * the DOM event fired by leaving the element
598 | * @param Object aDragDropObserver
599 | * javascript object of format described above that specifies
600 | * the way in which the element responds to drag events.
601 | * @param String aUri
602 | * the uri being dragged
603 | **/
604 | dragDropSecurityCheck: function (aEvent, aDragSession, aUri)
605 | {
606 | var sourceDoc = aDragSession.sourceDocument;
607 |
608 | if (sourceDoc) {
609 | // Strip leading and trailing whitespace, then try to create a
610 | // URI from the dropped string. If that succeeds, we're
611 | // dropping a URI and we need to do a security check to make
612 | // sure the source document can load the dropped URI. We don't
613 | // so much care about creating the real URI here
614 | // (i.e. encoding differences etc don't matter), we just want
615 | // to know if aUri really is a URI.
616 |
617 | var uriStr = aUri.replace(/^\s*|\s*$/g, '');
618 | var uri = null;
619 |
620 | try {
621 | uri = Components.classes["@mozilla.org/network/io-service;1"]
622 | .getService(Components.interfaces.nsIIOService)
623 | .newURI(uriStr, null, null);
624 | } catch (e) {
625 | }
626 |
627 | if (uri) {
628 | // aUri is a URI, do the security check.
629 | var sourceURI = sourceDoc.documentURI;
630 |
631 | const nsIScriptSecurityManager =
632 | Components.interfaces.nsIScriptSecurityManager;
633 | var secMan =
634 | Components.classes["@mozilla.org/scriptsecuritymanager;1"]
635 | .getService(nsIScriptSecurityManager);
636 |
637 | try {
638 | secMan.checkLoadURIStr(sourceURI, uriStr,
639 | nsIScriptSecurityManager.STANDARD);
640 | } catch (e) {
641 | // Stop event propagation right here.
642 | aEvent.stopPropagation();
643 |
644 | throw "Drop of " + aUri + " denied.";
645 | }
646 | }
647 | }
648 | }
649 | };
650 |
--------------------------------------------------------------------------------
/license.txt:
--------------------------------------------------------------------------------
1 | MOZILLA PUBLIC LICENSE
2 | Version 1.1
3 |
4 | ---------------
5 |
6 | 1. Definitions.
7 |
8 | 1.0.1. "Commercial Use" means distribution or otherwise making the
9 | Covered Code available to a third party.
10 |
11 | 1.1. "Contributor" means each entity that creates or contributes to
12 | the creation of Modifications.
13 |
14 | 1.2. "Contributor Version" means the combination of the Original
15 | Code, prior Modifications used by a Contributor, and the Modifications
16 | made by that particular Contributor.
17 |
18 | 1.3. "Covered Code" means the Original Code or Modifications or the
19 | combination of the Original Code and Modifications, in each case
20 | including portions thereof.
21 |
22 | 1.4. "Electronic Distribution Mechanism" means a mechanism generally
23 | accepted in the software development community for the electronic
24 | transfer of data.
25 |
26 | 1.5. "Executable" means Covered Code in any form other than Source
27 | Code.
28 |
29 | 1.6. "Initial Developer" means the individual or entity identified
30 | as the Initial Developer in the Source Code notice required by Exhibit
31 | A.
32 |
33 | 1.7. "Larger Work" means a work which combines Covered Code or
34 | portions thereof with code not governed by the terms of this License.
35 |
36 | 1.8. "License" means this document.
37 |
38 | 1.8.1. "Licensable" means having the right to grant, to the maximum
39 | extent possible, whether at the time of the initial grant or
40 | subsequently acquired, any and all of the rights conveyed herein.
41 |
42 | 1.9. "Modifications" means any addition to or deletion from the
43 | substance or structure of either the Original Code or any previous
44 | Modifications. When Covered Code is released as a series of files, a
45 | Modification is:
46 | A. Any addition to or deletion from the contents of a file
47 | containing Original Code or previous Modifications.
48 |
49 | B. Any new file that contains any part of the Original Code or
50 | previous Modifications.
51 |
52 | 1.10. "Original Code" means Source Code of computer software code
53 | which is described in the Source Code notice required by Exhibit A as
54 | Original Code, and which, at the time of its release under this
55 | License is not already Covered Code governed by this License.
56 |
57 | 1.10.1. "Patent Claims" means any patent claim(s), now owned or
58 | hereafter acquired, including without limitation, method, process,
59 | and apparatus claims, in any patent Licensable by grantor.
60 |
61 | 1.11. "Source Code" means the preferred form of the Covered Code for
62 | making modifications to it, including all modules it contains, plus
63 | any associated interface definition files, scripts used to control
64 | compilation and installation of an Executable, or source code
65 | differential comparisons against either the Original Code or another
66 | well known, available Covered Code of the Contributor's choice. The
67 | Source Code can be in a compressed or archival form, provided the
68 | appropriate decompression or de-archiving software is widely available
69 | for no charge.
70 |
71 | 1.12. "You" (or "Your") means an individual or a legal entity
72 | exercising rights under, and complying with all of the terms of, this
73 | License or a future version of this License issued under Section 6.1.
74 | For legal entities, "You" includes any entity which controls, is
75 | controlled by, or is under common control with You. For purposes of
76 | this definition, "control" means (a) the power, direct or indirect,
77 | to cause the direction or management of such entity, whether by
78 | contract or otherwise, or (b) ownership of more than fifty percent
79 | (50%) of the outstanding shares or beneficial ownership of such
80 | entity.
81 |
82 | 2. Source Code License.
83 |
84 | 2.1. The Initial Developer Grant.
85 | The Initial Developer hereby grants You a world-wide, royalty-free,
86 | non-exclusive license, subject to third party intellectual property
87 | claims:
88 | (a) under intellectual property rights (other than patent or
89 | trademark) Licensable by Initial Developer to use, reproduce,
90 | modify, display, perform, sublicense and distribute the Original
91 | Code (or portions thereof) with or without Modifications, and/or
92 | as part of a Larger Work; and
93 |
94 | (b) under Patents Claims infringed by the making, using or
95 | selling of Original Code, to make, have made, use, practice,
96 | sell, and offer for sale, and/or otherwise dispose of the
97 | Original Code (or portions thereof).
98 |
99 | (c) the licenses granted in this Section 2.1(a) and (b) are
100 | effective on the date Initial Developer first distributes
101 | Original Code under the terms of this License.
102 |
103 | (d) Notwithstanding Section 2.1(b) above, no patent license is
104 | granted: 1) for code that You delete from the Original Code; 2)
105 | separate from the Original Code; or 3) for infringements caused
106 | by: i) the modification of the Original Code or ii) the
107 | combination of the Original Code with other software or devices.
108 |
109 | 2.2. Contributor Grant.
110 | Subject to third party intellectual property claims, each Contributor
111 | hereby grants You a world-wide, royalty-free, non-exclusive license
112 |
113 | (a) under intellectual property rights (other than patent or
114 | trademark) Licensable by Contributor, to use, reproduce, modify,
115 | display, perform, sublicense and distribute the Modifications
116 | created by such Contributor (or portions thereof) either on an
117 | unmodified basis, with other Modifications, as Covered Code
118 | and/or as part of a Larger Work; and
119 |
120 | (b) under Patent Claims infringed by the making, using, or
121 | selling of Modifications made by that Contributor either alone
122 | and/or in combination with its Contributor Version (or portions
123 | of such combination), to make, use, sell, offer for sale, have
124 | made, and/or otherwise dispose of: 1) Modifications made by that
125 | Contributor (or portions thereof); and 2) the combination of
126 | Modifications made by that Contributor with its Contributor
127 | Version (or portions of such combination).
128 |
129 | (c) the licenses granted in Sections 2.2(a) and 2.2(b) are
130 | effective on the date Contributor first makes Commercial Use of
131 | the Covered Code.
132 |
133 | (d) Notwithstanding Section 2.2(b) above, no patent license is
134 | granted: 1) for any code that Contributor has deleted from the
135 | Contributor Version; 2) separate from the Contributor Version;
136 | 3) for infringements caused by: i) third party modifications of
137 | Contributor Version or ii) the combination of Modifications made
138 | by that Contributor with other software (except as part of the
139 | Contributor Version) or other devices; or 4) under Patent Claims
140 | infringed by Covered Code in the absence of Modifications made by
141 | that Contributor.
142 |
143 | 3. Distribution Obligations.
144 |
145 | 3.1. Application of License.
146 | The Modifications which You create or to which You contribute are
147 | governed by the terms of this License, including without limitation
148 | Section 2.2. The Source Code version of Covered Code may be
149 | distributed only under the terms of this License or a future version
150 | of this License released under Section 6.1, and You must include a
151 | copy of this License with every copy of the Source Code You
152 | distribute. You may not offer or impose any terms on any Source Code
153 | version that alters or restricts the applicable version of this
154 | License or the recipients' rights hereunder. However, You may include
155 | an additional document offering the additional rights described in
156 | Section 3.5.
157 |
158 | 3.2. Availability of Source Code.
159 | Any Modification which You create or to which You contribute must be
160 | made available in Source Code form under the terms of this License
161 | either on the same media as an Executable version or via an accepted
162 | Electronic Distribution Mechanism to anyone to whom you made an
163 | Executable version available; and if made available via Electronic
164 | Distribution Mechanism, must remain available for at least twelve (12)
165 | months after the date it initially became available, or at least six
166 | (6) months after a subsequent version of that particular Modification
167 | has been made available to such recipients. You are responsible for
168 | ensuring that the Source Code version remains available even if the
169 | Electronic Distribution Mechanism is maintained by a third party.
170 |
171 | 3.3. Description of Modifications.
172 | You must cause all Covered Code to which You contribute to contain a
173 | file documenting the changes You made to create that Covered Code and
174 | the date of any change. You must include a prominent statement that
175 | the Modification is derived, directly or indirectly, from Original
176 | Code provided by the Initial Developer and including the name of the
177 | Initial Developer in (a) the Source Code, and (b) in any notice in an
178 | Executable version or related documentation in which You describe the
179 | origin or ownership of the Covered Code.
180 |
181 | 3.4. Intellectual Property Matters
182 | (a) Third Party Claims.
183 | If Contributor has knowledge that a license under a third party's
184 | intellectual property rights is required to exercise the rights
185 | granted by such Contributor under Sections 2.1 or 2.2,
186 | Contributor must include a text file with the Source Code
187 | distribution titled "LEGAL" which describes the claim and the
188 | party making the claim in sufficient detail that a recipient will
189 | know whom to contact. If Contributor obtains such knowledge after
190 | the Modification is made available as described in Section 3.2,
191 | Contributor shall promptly modify the LEGAL file in all copies
192 | Contributor makes available thereafter and shall take other steps
193 | (such as notifying appropriate mailing lists or newsgroups)
194 | reasonably calculated to inform those who received the Covered
195 | Code that new knowledge has been obtained.
196 |
197 | (b) Contributor APIs.
198 | If Contributor's Modifications include an application programming
199 | interface and Contributor has knowledge of patent licenses which
200 | are reasonably necessary to implement that API, Contributor must
201 | also include this information in the LEGAL file.
202 |
203 | (c) Representations.
204 | Contributor represents that, except as disclosed pursuant to
205 | Section 3.4(a) above, Contributor believes that Contributor's
206 | Modifications are Contributor's original creation(s) and/or
207 | Contributor has sufficient rights to grant the rights conveyed by
208 | this License.
209 |
210 | 3.5. Required Notices.
211 | You must duplicate the notice in Exhibit A in each file of the Source
212 | Code. If it is not possible to put such notice in a particular Source
213 | Code file due to its structure, then You must include such notice in a
214 | location (such as a relevant directory) where a user would be likely
215 | to look for such a notice. If You created one or more Modification(s)
216 | You may add your name as a Contributor to the notice described in
217 | Exhibit A. You must also duplicate this License in any documentation
218 | for the Source Code where You describe recipients' rights or ownership
219 | rights relating to Covered Code. You may choose to offer, and to
220 | charge a fee for, warranty, support, indemnity or liability
221 | obligations to one or more recipients of Covered Code. However, You
222 | may do so only on Your own behalf, and not on behalf of the Initial
223 | Developer or any Contributor. You must make it absolutely clear than
224 | any such warranty, support, indemnity or liability obligation is
225 | offered by You alone, and You hereby agree to indemnify the Initial
226 | Developer and every Contributor for any liability incurred by the
227 | Initial Developer or such Contributor as a result of warranty,
228 | support, indemnity or liability terms You offer.
229 |
230 | 3.6. Distribution of Executable Versions.
231 | You may distribute Covered Code in Executable form only if the
232 | requirements of Section 3.1-3.5 have been met for that Covered Code,
233 | and if You include a notice stating that the Source Code version of
234 | the Covered Code is available under the terms of this License,
235 | including a description of how and where You have fulfilled the
236 | obligations of Section 3.2. The notice must be conspicuously included
237 | in any notice in an Executable version, related documentation or
238 | collateral in which You describe recipients' rights relating to the
239 | Covered Code. You may distribute the Executable version of Covered
240 | Code or ownership rights under a license of Your choice, which may
241 | contain terms different from this License, provided that You are in
242 | compliance with the terms of this License and that the license for the
243 | Executable version does not attempt to limit or alter the recipient's
244 | rights in the Source Code version from the rights set forth in this
245 | License. If You distribute the Executable version under a different
246 | license You must make it absolutely clear that any terms which differ
247 | from this License are offered by You alone, not by the Initial
248 | Developer or any Contributor. You hereby agree to indemnify the
249 | Initial Developer and every Contributor for any liability incurred by
250 | the Initial Developer or such Contributor as a result of any such
251 | terms You offer.
252 |
253 | 3.7. Larger Works.
254 | You may create a Larger Work by combining Covered Code with other code
255 | not governed by the terms of this License and distribute the Larger
256 | Work as a single product. In such a case, You must make sure the
257 | requirements of this License are fulfilled for the Covered Code.
258 |
259 | 4. Inability to Comply Due to Statute or Regulation.
260 |
261 | If it is impossible for You to comply with any of the terms of this
262 | License with respect to some or all of the Covered Code due to
263 | statute, judicial order, or regulation then You must: (a) comply with
264 | the terms of this License to the maximum extent possible; and (b)
265 | describe the limitations and the code they affect. Such description
266 | must be included in the LEGAL file described in Section 3.4 and must
267 | be included with all distributions of the Source Code. Except to the
268 | extent prohibited by statute or regulation, such description must be
269 | sufficiently detailed for a recipient of ordinary skill to be able to
270 | understand it.
271 |
272 | 5. Application of this License.
273 |
274 | This License applies to code to which the Initial Developer has
275 | attached the notice in Exhibit A and to related Covered Code.
276 |
277 | 6. Versions of the License.
278 |
279 | 6.1. New Versions.
280 | Netscape Communications Corporation ("Netscape") may publish revised
281 | and/or new versions of the License from time to time. Each version
282 | will be given a distinguishing version number.
283 |
284 | 6.2. Effect of New Versions.
285 | Once Covered Code has been published under a particular version of the
286 | License, You may always continue to use it under the terms of that
287 | version. You may also choose to use such Covered Code under the terms
288 | of any subsequent version of the License published by Netscape. No one
289 | other than Netscape has the right to modify the terms applicable to
290 | Covered Code created under this License.
291 |
292 | 6.3. Derivative Works.
293 | If You create or use a modified version of this License (which you may
294 | only do in order to apply it to code which is not already Covered Code
295 | governed by this License), You must (a) rename Your license so that
296 | the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape",
297 | "MPL", "NPL" or any confusingly similar phrase do not appear in your
298 | license (except to note that your license differs from this License)
299 | and (b) otherwise make it clear that Your version of the license
300 | contains terms which differ from the Mozilla Public License and
301 | Netscape Public License. (Filling in the name of the Initial
302 | Developer, Original Code or Contributor in the notice described in
303 | Exhibit A shall not of themselves be deemed to be modifications of
304 | this License.)
305 |
306 | 7. DISCLAIMER OF WARRANTY.
307 |
308 | COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
309 | WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
310 | WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
311 | DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
312 | THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
313 | IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
314 | YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
315 | COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
316 | OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
317 | ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
318 |
319 | 8. TERMINATION.
320 |
321 | 8.1. This License and the rights granted hereunder will terminate
322 | automatically if You fail to comply with terms herein and fail to cure
323 | such breach within 30 days of becoming aware of the breach. All
324 | sublicenses to the Covered Code which are properly granted shall
325 | survive any termination of this License. Provisions which, by their
326 | nature, must remain in effect beyond the termination of this License
327 | shall survive.
328 |
329 | 8.2. If You initiate litigation by asserting a patent infringement
330 | claim (excluding declatory judgment actions) against Initial Developer
331 | or a Contributor (the Initial Developer or Contributor against whom
332 | You file such action is referred to as "Participant") alleging that:
333 |
334 | (a) such Participant's Contributor Version directly or indirectly
335 | infringes any patent, then any and all rights granted by such
336 | Participant to You under Sections 2.1 and/or 2.2 of this License
337 | shall, upon 60 days notice from Participant terminate prospectively,
338 | unless if within 60 days after receipt of notice You either: (i)
339 | agree in writing to pay Participant a mutually agreeable reasonable
340 | royalty for Your past and future use of Modifications made by such
341 | Participant, or (ii) withdraw Your litigation claim with respect to
342 | the Contributor Version against such Participant. If within 60 days
343 | of notice, a reasonable royalty and payment arrangement are not
344 | mutually agreed upon in writing by the parties or the litigation claim
345 | is not withdrawn, the rights granted by Participant to You under
346 | Sections 2.1 and/or 2.2 automatically terminate at the expiration of
347 | the 60 day notice period specified above.
348 |
349 | (b) any software, hardware, or device, other than such Participant's
350 | Contributor Version, directly or indirectly infringes any patent, then
351 | any rights granted to You by such Participant under Sections 2.1(b)
352 | and 2.2(b) are revoked effective as of the date You first made, used,
353 | sold, distributed, or had made, Modifications made by that
354 | Participant.
355 |
356 | 8.3. If You assert a patent infringement claim against Participant
357 | alleging that such Participant's Contributor Version directly or
358 | indirectly infringes any patent where such claim is resolved (such as
359 | by license or settlement) prior to the initiation of patent
360 | infringement litigation, then the reasonable value of the licenses
361 | granted by such Participant under Sections 2.1 or 2.2 shall be taken
362 | into account in determining the amount or value of any payment or
363 | license.
364 |
365 | 8.4. In the event of termination under Sections 8.1 or 8.2 above,
366 | all end user license agreements (excluding distributors and resellers)
367 | which have been validly granted by You or any distributor hereunder
368 | prior to termination shall survive termination.
369 |
370 | 9. LIMITATION OF LIABILITY.
371 |
372 | UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
373 | (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
374 | DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
375 | OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR
376 | ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY
377 | CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL,
378 | WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
379 | COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
380 | INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
381 | LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
382 | RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
383 | PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
384 | EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO
385 | THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
386 |
387 | 10. U.S. GOVERNMENT END USERS.
388 |
389 | The Covered Code is a "commercial item," as that term is defined in
390 | 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer
391 | software" and "commercial computer software documentation," as such
392 | terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
393 | C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
394 | all U.S. Government End Users acquire Covered Code with only those
395 | rights set forth herein.
396 |
397 | 11. MISCELLANEOUS.
398 |
399 | This License represents the complete agreement concerning subject
400 | matter hereof. If any provision of this License is held to be
401 | unenforceable, such provision shall be reformed only to the extent
402 | necessary to make it enforceable. This License shall be governed by
403 | California law provisions (except to the extent applicable law, if
404 | any, provides otherwise), excluding its conflict-of-law provisions.
405 | With respect to disputes in which at least one party is a citizen of,
406 | or an entity chartered or registered to do business in the United
407 | States of America, any litigation relating to this License shall be
408 | subject to the jurisdiction of the Federal Courts of the Northern
409 | District of California, with venue lying in Santa Clara County,
410 | California, with the losing party responsible for costs, including
411 | without limitation, court costs and reasonable attorneys' fees and
412 | expenses. The application of the United Nations Convention on
413 | Contracts for the International Sale of Goods is expressly excluded.
414 | Any law or regulation which provides that the language of a contract
415 | shall be construed against the drafter shall not apply to this
416 | License.
417 |
418 | 12. RESPONSIBILITY FOR CLAIMS.
419 |
420 | As between Initial Developer and the Contributors, each party is
421 | responsible for claims and damages arising, directly or indirectly,
422 | out of its utilization of rights under this License and You agree to
423 | work with Initial Developer and Contributors to distribute such
424 | responsibility on an equitable basis. Nothing herein is intended or
425 | shall be deemed to constitute any admission of liability.
426 |
427 | 13. MULTIPLE-LICENSED CODE.
428 |
429 | Initial Developer may designate portions of the Covered Code as
430 | "Multiple-Licensed". "Multiple-Licensed" means that the Initial
431 | Developer permits you to utilize portions of the Covered Code under
432 | Your choice of the NPL or the alternative licenses, if any, specified
433 | by the Initial Developer in the file described in Exhibit A.
434 |
435 | EXHIBIT A -Mozilla Public License.
436 |
437 | The contents of this file are subject to the Mozilla Public License
438 | Version 1.1 (the "License"); you may not use this file except in
439 | compliance with the License. You may obtain a copy of the License at
440 | http://www.mozilla.org/MPL/
441 |
442 | Software distributed under the License is distributed on an "AS IS"
443 | basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
444 | License for the specific language governing rights and limitations
445 | under the License.
446 |
447 | The Original Code is Drah & DropZone Searching.
448 |
449 | The Initial Developer of the Original Code is Martijn Kooij a.k.a. Captain Caveman.
450 |
451 | Alternatively, the contents of this file may be used under the terms of
452 | either the GNU General Public License Version 2 or later (the "GPL"), or
453 | the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
454 | in which case the provisions of the GPL or the LGPL are applicable instead
455 | of those above. If you wish to allow use of your version of this file only
456 | under the terms of either the GPL or the LGPL, and not to allow others to
457 | use your version of this file under the terms of the MPL, indicate your
458 | decision by deleting the provisions above and replace them with the notice
459 | and other provisions required by the GPL or the LGPL. If you do not delete
460 | the provisions above, a recipient may use your version of this file under
461 | the terms of any one of the MPL, the GPL or the LGPL.
462 |
463 |
--------------------------------------------------------------------------------
/chrome/content/dendzones/settings.js:
--------------------------------------------------------------------------------
1 | /* ***** BEGIN LICENSE BLOCK *****
2 | Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 |
4 | The contents of this file are subject to the Mozilla Public License Version
5 | 1.1 (the "License"); you may not use this file except in compliance with
6 | the License. You may obtain a copy of the License at
7 | http://www.mozilla.org/MPL/
8 |
9 | Software distributed under the License is distributed on an "AS IS" basis,
10 | WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 | for the specific language governing rights and limitations under the
12 | License.
13 |
14 | The Original Code is Web Search Pro code.
15 |
16 | The Initial Developer of the Original Code is Martijn Kooij a.k.a. Captain Caveman.
17 |
18 | Alternatively, the contents of this file may be used under the terms of
19 | either the GNU General Public License Version 2 or later (the "GPL"), or
20 | the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
21 | in which case the provisions of the GPL or the LGPL are applicable instead
22 | of those above. If you wish to allow use of your version of this file only
23 | under the terms of either the GPL or the LGPL, and not to allow others to
24 | use your version of this file under the terms of the MPL, indicate your
25 | decision by deleting the provisions above and replace them with the notice
26 | and other provisions required by the GPL or the LGPL. If you do not delete
27 | the provisions above, a recipient may use your version of this file under
28 | the terms of any one of the MPL, the GPL or the LGPL.
29 |
30 | ***** END LICENSE BLOCK ***** */
31 |
32 | var {Services} = Components.utils.import('resource://gre/modules/Services.jsm');
33 |
34 | var ENGINE_FLAVOR = ENGINE_FLAVOR || 'text/x-moz-search-engine';
35 |
36 | /*DragDropItemObserver*/
37 | var DDIO =
38 | {
39 | onDragStart: function (evt,transferData,action)
40 | {
41 | var oDZ = evt.target;
42 | if (oDZ.getAttribute('class') != "dz") oDZ = oDZ.parentNode;
43 | var sData = oDZ.getAttribute("id");
44 | oDZ.setAttribute('dragstate', '1');
45 | transferData.data = new TransferData();
46 | transferData.data.addDataForFlavour("text/unicode", sData);
47 | }
48 | };
49 |
50 | /*DragDropSearchEngineItemObserver*/
51 | var DDSSIO =
52 | {
53 | onDragStart: function (evt,transferData,action)
54 | {
55 | var oListbox = evt.target.parentNode;
56 | if (!oListbox || oListbox.nodeName != "listbox") return;
57 |
58 | var iSelectedIndex = oListbox.selectedIndex;
59 | if (iSelectedIndex == -1) return;
60 |
61 | transferData.data = new TransferData();
62 | transferData.data.addDataForFlavour(ENGINE_FLAVOR, "ss_" + iSelectedIndex.toString());
63 | }
64 | };
65 |
66 | /*DragDropContextMenuItemObserver*/
67 | var DDCMIO =
68 | {
69 | onDragStart: function (evt,transferData,action)
70 | {
71 | var oListbox = evt.target.parentNode;
72 | if (!oListbox || oListbox.nodeName != "listbox") return;
73 |
74 | var iSelectedIndex = oListbox.selectedIndex;
75 | if (iSelectedIndex == -1) return;
76 |
77 | transferData.data = new TransferData();
78 | transferData.data.addDataForFlavour(ENGINE_FLAVOR, "cm_" + iSelectedIndex.toString());
79 | }
80 | };
81 |
82 | var DenDZones_DragDropObserver =
83 | {
84 | getSupportedFlavours : function ()
85 | {
86 | var oFS = new FlavourSet();
87 | oFS.appendFlavour("text/unicode");
88 | oFS.appendFlavour("text/x-moz-search-engine");
89 | return oFS;
90 | },
91 |
92 | onDragOver: function (evt,flavour,session)
93 | {
94 | var oDZs = document.getElementsByAttribute('class', 'dz');
95 | var oDZ;
96 | var iIndex, iLen = oDZs.length;
97 |
98 | for (iIndex = 0; iIndex < iLen; iIndex ++)
99 | {
100 | oDZs[iIndex].setAttribute('dragstate', '');
101 | if (oDZs[iIndex].getAttribute('dendid') == '') oDZs[iIndex].style.backgroundColor = "";
102 | }
103 |
104 | oDZ = session.sourceNode;
105 | if (oDZ.getAttribute('class') != "dz") oDZ = oDZ.parentNode;
106 | if (oDZ.getAttribute('class') != "dz")
107 | {
108 | //Dragging a Search Engine.
109 | oDZ = evt.originalTarget;
110 | if (oDZ.getAttribute('class') != "dz") oDZ = oDZ.parentNode;
111 | if (oDZ.getAttribute('class') == "dz")
112 | {
113 | oDZ.setAttribute('dragstate', '2');
114 | if (oDZ.getAttribute('selected') != 'true') oDZ.style.backgroundColor = document.getElementById('dropzonecolor').color;
115 | session.canDrop = true;
116 | }
117 | }
118 | else
119 | {
120 | //Dragging a zone.
121 | oDZ.setAttribute('dragstate', '1');
122 |
123 | oDZ = evt.originalTarget;
124 | if (oDZ.getAttribute('class') != "dz") oDZ = oDZ.parentNode;
125 | oDZ.setAttribute('dragstate', '2');
126 |
127 | session.canDrop = true;
128 | }
129 | return session.canDrop;
130 | },
131 |
132 | onDrop: function (evt,dropdata,session)
133 | {
134 | if (dropdata.data && dropdata.data.substr(0, 3) == "dz_")
135 | {
136 | //Dropping a zone.
137 | var oDZs = document.getElementsByAttribute('class', 'dz');
138 | var oDZ;
139 | var sDroppedID;
140 | var sTargetID;
141 | var iIndex, iLen = oDZs.length;
142 |
143 | sDroppedID = dropdata.data;
144 | oDZ = evt.target;
145 | if (oDZ.getAttribute('class') != "dz") oDZ = oDZ.parentNode;
146 | sTargetID = oDZ.getAttribute('id');
147 |
148 | DenDZones_DragSwitchDropZone(sDroppedID, sTargetID);
149 |
150 | for (iIndex = 0; iIndex < iLen; iIndex ++) {oDZs[iIndex].setAttribute('dragstate', '');}
151 | }
152 | else
153 | {
154 | var oDZ = evt.target;
155 | if (oDZ.getAttribute('class') != "dz") oDZ = oDZ.parentNode;
156 | var sTargetID = oDZ.getAttribute('id');
157 | DenDZones_DragAssignDropZone(dropdata.data, sTargetID);
158 |
159 | for (iIndex = 0; iIndex < iLen; iIndex ++) {oDZs[iIndex].setAttribute('dragstate', '');}
160 | }
161 | }
162 | };
163 |
164 | var DenDZones_DragDropRMItemObserver =
165 | {
166 | getSupportedFlavours : function ()
167 | {
168 | var oFS = new FlavourSet();
169 | oFS.appendFlavour("text/unicode");
170 | return oFS;
171 | },
172 |
173 | onDragOver: function (evt,flavour,session)
174 | {
175 | session.canDrop = false;
176 | var oDZ;
177 | oDZ = session.sourceNode;
178 | if (oDZ.getAttribute('class') != "dz") oDZ = oDZ.parentNode;
179 | if (oDZ.getAttribute('class') == "dz")
180 | {
181 | if (evt.target && evt.target.nodeName && evt.target.nodeName.indexOf('tree') < 0)
182 | {
183 | session.canDrop = true;
184 | }
185 | }
186 | return session.canDrop;
187 | },
188 |
189 | onDrop: function (evt,dropdata,session)
190 | {
191 | if (dropdata.data && dropdata.data.substr(0, 3) == "dz_")
192 | {
193 | var sDroppedID = dropdata.data;
194 | DenDZones_DragRemoveDropZone(sDroppedID);
195 |
196 | var oDZs = document.getElementsByAttribute('class', 'dz');
197 | var iIndex, iLen = oDZs.length;
198 | for (iIndex = 0; iIndex < iLen; iIndex ++) {oDZs[iIndex].setAttribute('dragstate', '');}
199 | }
200 | }
201 | };
202 |
203 | function DenDZones_DropZoneDrop(oEvent)
204 | {
205 | nsDragAndDrop.drop(oEvent, DenDZones_DragDropObserver);
206 | }
207 |
208 | function DenDZones_DropZoneDragOver(oEvent)
209 | {
210 | nsDragAndDrop.dragOver(oEvent, DenDZones_DragDropObserver);
211 | }
212 |
213 | function DenDZones_DropZoneRMDrop(oEvent)
214 | {
215 | nsDragAndDrop.drop(oEvent, DenDZones_DragDropRMItemObserver);
216 | }
217 |
218 | function DenDZones_DropZoneRMDragOver(oEvent)
219 | {
220 | nsDragAndDrop.dragOver(oEvent, DenDZones_DragDropRMItemObserver);
221 | }
222 |
223 | function DenDZones_InitEngineManager()
224 | {
225 | this.oDenDZones_Utils = new DenDUtils();
226 | this.gEngineView = (function () {
227 | if (typeof EngineView !== 'undefined' && typeof EngineStore !== 'undefined') {
228 | return new EngineView(new EngineStore());
229 | }
230 | return {
231 | _engineStore: {
232 | _engines: Services.search.getVisibleEngines()
233 | }
234 | }
235 | })();
236 |
237 | this.aCMItems = new Array();
238 |
239 | DenDZones_InitPrefs();
240 | DenDZones_InitDropZones(true);
241 | DenDZones_InitSearchEngines();
242 | DenDZones_InitCMItems();
243 | DenDZones_InitDropZones(false);
244 |
245 | document.getElementById("searchengines").addEventListener('dragover', DenDZones_DropZoneRMDragOver, false);
246 | document.getElementById("searchengines").addEventListener('dragdrop', DenDZones_DropZoneRMDrop, false);
247 | document.getElementById("cmitems").addEventListener('dragover', DenDZones_DropZoneRMDragOver, false);
248 | document.getElementById("cmitems").addEventListener('dragdrop', DenDZones_DropZoneRMDrop, false);
249 | document.getElementById("dropzonebox").addEventListener('dragover', DenDZones_DropZoneDragOver, false);
250 | document.getElementById("dropzonebox").addEventListener('dragdrop', DenDZones_DropZoneDrop, false);
251 |
252 | document.getElementById("dropzonebox").setAttribute("maxaxis", this.oDenDZones_Utils.GetInt("maxaxis"));
253 |
254 | this.sizeToContent();
255 | }
256 |
257 | function DenDZones_DeInitEngineManager(bAndSave)
258 | {
259 | if (document.documentElement.getButton("accept").hidden) bAndSave = true;
260 | if (bAndSave)
261 | {
262 | DenDZones_SaveDropZones();
263 | }
264 |
265 | var oObService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
266 | oObService.notifyObservers(opener, "dendzones-apply-settings", "OK");
267 | return 1;
268 | }
269 |
270 | function DenDZones_SaveDropZones()
271 | {
272 | var oDZs = document.getElementsByAttribute('class', 'dz');
273 | var sDZID, sLabel, sCommand, sImage, sColor;
274 | var iIndex, iLen, iX, iY;
275 |
276 | this.aDenDZones_DropZones = null;
277 | this.aDenDZones_DropZones = new Array(10);
278 | for (iIndex = 0; iIndex < 10; iIndex ++) this.aDenDZones_DropZones[iIndex] = new Array(10);
279 |
280 | iLen = oDZs.length;
281 | for (iIndex = 0; iIndex < iLen; iIndex ++)
282 | {
283 | sDZID = oDZs[iIndex].getAttribute('dendid');
284 | if (sDZID && sDZID != "")
285 | {
286 | sLabel = oDZs[iIndex].getAttribute('dendlabel');
287 | sCommand = oDZs[iIndex].getAttribute('dendcommand');
288 | sImage = oDZs[iIndex].firstChild.getAttribute('src');
289 | sColor = oDZs[iIndex].style.backgroundColor;
290 | iX = parseInt(oDZs[iIndex].getAttribute('id').substr(3, 1));
291 | iY = parseInt(oDZs[iIndex].getAttribute('id').substr(5, 1));
292 | this.aDenDZones_DropZones[iX][iY] = new Array(sDZID, sLabel, sCommand, sImage, sColor);
293 | }
294 | }
295 | this.oDenDZones_Utils.SetDropZones(this.aDenDZones_DropZones);
296 | }
297 |
298 | function DenDZones_InitPrefs()
299 | {
300 | this.oDenDZones_Color = document.getElementById('dropzonecolor');
301 |
302 | if (this.oDenDZones_Color.mPicker) //Does not exist if you have Rainbowpicker installed. Not sure if this should be my problem, but my extension does not work otherwise...
303 | {
304 | //Add the Captain Caveman color...
305 | this.oDenDZones_Color.mPicker.mBox.lastChild.lastChild.style.backgroundColor = "#6487DC";
306 | this.oDenDZones_Color.mPicker.mBox.lastChild.lastChild.style.color = "#6487DC";
307 | this.oDenDZones_Color.mPicker.mBox.lastChild.lastChild.setAttribute('color', '#6487DC');
308 | }
309 | }
310 |
311 | function DenDZones_InitSearchEngines()
312 | {
313 | var oList = document.getElementById("searchengines");
314 | var oEngine;
315 | var oItem;
316 | var sExtraStyle = "";
317 |
318 | for each(oEngine in gEngineView._engineStore._engines)
319 | {
320 | oItem = oList.appendItem(oEngine.name, oEngine.name);
321 | oItem.value = oEngine.name;
322 | oItem.addEventListener("draggesture", function(event) {
323 | nsDragAndDrop.startDrag(event, DDSSIO);
324 | });
325 | oItem.setAttribute("tooltiptext", oEngine.description);
326 | oItem.setAttribute("class", "listitem-iconic");
327 | sExtraStyle = "";
328 | if (HasDropZone(oEngine.name)) sExtraStyle = " color: rgb(100,135,220);";
329 | if (oEngine.iconURI)
330 | {
331 | oItem.setAttribute("icon", oEngine.iconURI.spec);
332 | oItem.setAttribute("style", "list-style-image: url('" + oEngine.iconURI.spec + "');" + sExtraStyle);
333 | }
334 | else
335 | {
336 | oItem.setAttribute("icon", "");
337 | oItem.setAttribute("style", "list-style-image: none;" + sExtraStyle);
338 | }
339 | }
340 | }
341 |
342 | function DenDZones_InitCMItems()
343 | {
344 | var oBrowser;
345 | var oList = document.getElementById("cmitems");
346 | var iIndex, iLen;
347 |
348 | var oBrowser;
349 | var oWindowMediator = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator);
350 | var oBrowserWindow = oWindowMediator.getMostRecentWindow("navigator:browser");
351 | if (oBrowserWindow) oBrowser = oBrowserWindow.getBrowser();
352 | if (!oBrowser)
353 | {
354 | if (typeof(opener.getBrowser) == "function") oBrowser = opener.getBrowser();
355 | else
356 | {
357 | if (!opener.opener) oBrowser = opener.top.document.getElementById("content");
358 | else if (typeof(opener.opener.getBrowser) == "function") oBrowser = opener.opener.getBrowser();
359 | }
360 | }
361 | if (oBrowser)
362 | {
363 | var oContextMenu = oBrowser.ownerDocument.getElementById('contentAreaContextMenu');
364 | this.aCMItems = null;
365 | this.aCMItems = new Array();
366 | DenDZones_AddCMItems(oContextMenu, "");
367 | this.aCMItems.sort(DenDZones_SortCMItems);
368 | DenDZones_DisplayCMItems();
369 | }
370 | }
371 |
372 | function DenDZones_AddCMItems(oParentNode, sParentLabel)
373 | {
374 | if (oParentNode && (oParentNode.nodeName == "popup" || oParentNode.nodeName == "menu" || oParentNode.nodeName == "menuitem" || oParentNode.nodeName == "menupopup"))
375 | {
376 | var oList = document.getElementById("cmitems");
377 | var oCMItem, oLItem;
378 | var oStyle;
379 | var sLabel, sTooltip, sID, sCommand, sImage;
380 | var iIndex;
381 | var bFoundSomething;
382 |
383 | if (!sParentLabel) sParentLabel = "";
384 |
385 | for each(oCMItem in oParentNode.childNodes)
386 | {
387 | bFoundSomething = false;
388 | if (typeof(oCMItem.getAttribute) == "function")
389 | {
390 | sLabel = oCMItem.label;
391 | if (!sLabel) sLabel = oCMItem.getAttribute("tooltiptext");
392 | if (sLabel && sLabel != "" && (oCMItem.getAttribute('command') != "" || oCMItem.getAttribute('oncommand') != ""))
393 | {
394 | sID = oCMItem.id;
395 | if (!sID || sID == "") sID = sLabel;
396 | sTooltip = sLabel;
397 | if (sParentLabel && sParentLabel != "") sTooltip = sParentLabel + " - " + sTooltip;
398 | sCommand = oCMItem.getAttribute("command");
399 | if (!sCommand || sCommand == "") sCommand = oCMItem.getAttribute("oncommand");
400 | iIndex = this.aCMItems.length;
401 |
402 | sImage = "";
403 | try {
404 | sImage = oCMItem.getAttribute("fseicon");
405 | } catch (e) {sImage = "";}
406 | if (sImage == "") {
407 | try {
408 | sImage = oCMItem.childNodes[0].src;
409 | } catch (e) {sImage = "";}
410 | }
411 | if (sImage == "") {
412 | try {
413 | sImage = oCMItem.getAttribute("image");
414 | } catch (e) {sImage = "";}
415 | }
416 | if (sImage == "") {
417 | try {
418 | sImage = oCMItem.childNodes[0].childNodes[0].src;
419 | } catch (e) {sImage = "";}
420 | }
421 | if (sImage == "") {
422 | try {
423 | oStyle = oCMItem.ownerDocument.defaultView.getComputedStyle(oCMItem, null);
424 | sImage = oStyle.getPropertyValue("list-style-image");
425 | } catch (e) {sImage = "";}
426 | }
427 | if (!sImage || sImage == "" || sImage == "none") {
428 | sImage = "chrome://dendzones/skin/context_menu_action.png";
429 | }
430 | else {
431 | sImage = sImage.replace('url("', '').replace('")', '');
432 | }
433 | this.aCMItems[iIndex] = new Array(sID, sLabel, sTooltip, sCommand, sImage);
434 |
435 | DenDZones_AddCMItems(oCMItem, sTooltip);
436 | bFoundSomething = true;
437 | }
438 | }
439 | if (!bFoundSomething)
440 | {
441 | if (oCMItem)
442 | {
443 | if (oCMItem.label && oCMItem.label != "" && sParentLabel && sParentLabel != "") sTooltip = sParentLabel + " - " + oCMItem.label;
444 | else if (oCMItem.label && oCMItem.label != "") sTooltip = oCMItem.label;
445 | else sTooltip = sParentLabel;
446 |
447 | DenDZones_AddCMItems(oCMItem, sTooltip);
448 | }
449 | }
450 | }
451 | }
452 | }
453 |
454 | function DenDZones_DisplayCMItems()
455 | {
456 | var oList = document.getElementById("cmitems");
457 | var oLItem;
458 | var sExtraStyle = "";
459 | var iIndex, iLen = this.aCMItems.length;
460 |
461 | for (iIndex = 0; iIndex < iLen; iIndex ++)
462 | {
463 | sExtraStyle = "";
464 | if (HasDropZone(this.aCMItems[iIndex][0])) sExtraStyle = " color: rgb(100,135,220);";
465 | oLItem = oList.appendItem(this.aCMItems[iIndex][1], this.aCMItems[iIndex][0]);
466 | oLItem.setAttribute("dendlabel", this.aCMItems[iIndex][1]);
467 | oLItem.setAttribute("dendcommand", this.aCMItems[iIndex][3]);
468 | oLItem.addEventListener("draggesture", function(event) {nsDragAndDrop.startDrag(event, DDCMIO);});
469 | oLItem.setAttribute("tooltiptext", this.aCMItems[iIndex][2]);
470 | oLItem.setAttribute("class", "listitem-iconic");
471 | oLItem.setAttribute("icon", this.aCMItems[iIndex][4]);
472 | oLItem.setAttribute("style", "list-style-image: url('" + this.aCMItems[iIndex][4] + "');" + sExtraStyle);
473 | }
474 | }
475 |
476 | function DenDZones_SortCMItems(a1, a2)
477 | {
478 | if (a1[1] < a2[1]) return -1;
479 | return 1;
480 | }
481 |
482 | function DenDZones_InitDropZones(bDataOnly)
483 | {
484 | this.aDenDZones_DropZones = null;
485 | this.aDenDZones_DropZones = this.oDenDZones_Utils.GetDropZones();
486 |
487 | if (!bDataOnly) setTimeout(function() {DenDZones_InitDropZonesUI();}, 100);
488 | }
489 |
490 | function DenDZones_InitDropZonesUI()
491 | {
492 | var oDZ;
493 | var oItem;
494 | var sID, sLabel, sFavIcon;
495 | var iFSEIndex, iIndex, iLen = this.aDenDZones_DropZones.length;
496 | var iX, iY;
497 |
498 | for (iX = 0; iX < 10; iX ++)
499 | {
500 | for (iY = 0; iY < 10; iY ++)
501 | {
502 | if (this.aDenDZones_DropZones[iX][iY][0] == "")
503 | {
504 | oDZ = document.getElementById('dz_' + iX + '_' + iY);
505 | oDZ.setAttribute('dendid', '');
506 | oDZ.setAttribute('dendlabel', '');
507 | oDZ.setAttribute('dendcommand', '');
508 | oDZ.setAttribute('selected', false);
509 | oDZ.addEventListener('click', function() {DenDZones_SetColor(this);});
510 | oDZ.firstChild.setAttribute('tooltiptext', '');
511 | oDZ.firstChild.setAttribute('src', '');
512 | oDZ.style.backgroundColor = "";
513 | }
514 | else
515 | {
516 | oDZ = document.getElementById('dz_' + iX + '_' + iY);
517 | oItem = DenDZones_GetListboxItemByValue(this.aDenDZones_DropZones[iX][iY][0]);
518 | if (oItem)
519 | {
520 | oDZ.setAttribute('dendid', oItem.value);
521 | oDZ.setAttribute('dendlabel', oItem.label);
522 | oDZ.setAttribute('dendcommand', oItem.getAttribute('dendcommand'));
523 | oDZ.setAttribute('tooltiptext', oItem.getAttribute('tooltiptext'));
524 | oDZ.setAttribute('selected', true);
525 | oDZ.addEventListener('click', function() {DenDZones_SetColor(this);});
526 | oDZ.firstChild.setAttribute('tooltiptext', oItem.getAttribute('tooltiptext'));
527 | oDZ.firstChild.setAttribute('src', oItem.getAttribute('icon'));
528 | oDZ.style.backgroundColor = this.aDenDZones_DropZones[iX][iY][4];
529 | }
530 | else
531 | {
532 | oDZ.setAttribute('dendid', this.aDenDZones_DropZones[iX][iY][0]);
533 | oDZ.setAttribute('dendlabel', this.aDenDZones_DropZones[iX][iY][1]);
534 | oDZ.setAttribute('dendcommand', this.aDenDZones_DropZones[iX][iY][2]);
535 | oDZ.setAttribute('tooltiptext', this.aDenDZones_DropZones[iX][iY][1]);
536 | oDZ.setAttribute('selected', true);
537 | oDZ.addEventListener('click', function() {DenDZones_SetColor(this);});
538 | oDZ.firstChild.setAttribute('tooltiptext', this.aDenDZones_DropZones[iX][iY][1]);
539 | oDZ.firstChild.setAttribute('src', this.aDenDZones_DropZones[iX][iY][3]);
540 | oDZ.style.backgroundColor = this.aDenDZones_DropZones[iX][iY][4]
541 | }
542 | }
543 | }
544 | }
545 | }
546 |
547 | function DenDZones_GetListboxItemByValue(sValue)
548 | {
549 | var oList, oItem;
550 | var iIndex, iLen
551 |
552 | oList = document.getElementById('searchengines');
553 | iLen = oList.getRowCount();
554 | for (iIndex = 0; iIndex < iLen; iIndex ++)
555 | {
556 | oItem = oList.getItemAtIndex(iIndex);
557 | if (oItem.value == sValue) return oItem;
558 | }
559 | oList = document.getElementById('cmitems');
560 | iLen = oList.getRowCount();
561 | for (iIndex = 0; iIndex < iLen; iIndex ++)
562 | {
563 | oItem = oList.getItemAtIndex(iIndex);
564 | if (oItem.value == sValue) return oItem;
565 | }
566 |
567 | return null;
568 | }
569 |
570 | function DenDZones_DragAssignDropZone(sIndex, sTargetID)
571 | {
572 | var oList, oItem;
573 | var sType = sIndex.substr(0, 2);
574 | var iIndex = parseInt(sIndex.substr(3));
575 |
576 | if (iIndex < 0 || isNaN(iIndex)) return;
577 |
578 | if (sType == "ss") oList = document.getElementById('searchengines');
579 | else if (sType == "cm") oList = document.getElementById('cmitems');
580 |
581 | if (iIndex > oList.getRowCount()) return;
582 | oItem = oList.getItemAtIndex(iIndex);
583 |
584 | if (!oItem) return;
585 |
586 | var oDZ = document.getElementById(sTargetID);
587 | if (oDZ)
588 | {
589 | oDZ.setAttribute('dendid', oItem.value);
590 | oDZ.setAttribute('dendlabel', oItem.label);
591 | oDZ.setAttribute('dendcommand', oItem.getAttribute('dendcommand'));
592 | oDZ.setAttribute('tooltiptext', oItem.getAttribute('tooltiptext'));
593 | oDZ.setAttribute('selected', true);
594 | oDZ.firstChild.setAttribute('tooltiptext', oItem.getAttribute('tooltiptext'));
595 | oDZ.firstChild.setAttribute('src', oItem.getAttribute('icon'));
596 | oDZ.style.backgroundColor = this.oDenDZones_Color.color;
597 | }
598 | }
599 |
600 | function DenDZones_SetColor(oDZ)
601 | {
602 | if (oDZ)
603 | {
604 | if (oDZ.getAttribute("selected") == "true") oDZ.style.backgroundColor = this.oDenDZones_Color.color;
605 | else oDZ.style.backgroundColor = "";
606 | }
607 | }
608 |
609 | function DenDZones_DragSwitchDropZone(sSourceID, sTargetID)
610 | {
611 | var oSource = document.getElementById(sSourceID);
612 | var oTarget = document.getElementById(sTargetID);
613 |
614 | if (oSource && oTarget && sSourceID != sTargetID)
615 | {
616 | var sSID = oSource.getAttribute('dendid');
617 | var sSLabel = oSource.getAttribute('dendlabel');
618 | var sSCommand = oSource.getAttribute('dendcommand');
619 | var sSTooltiptext = oSource.getAttribute('tooltiptext');
620 | var sSSRC = oSource.firstChild.getAttribute('src');
621 | var sSSelected = oSource.getAttribute('selected');
622 | var sSColor = oSource.style.backgroundColor;
623 |
624 | var sTID = oTarget.getAttribute('dendid');
625 | var sTLabel = oTarget.getAttribute('dendlabel');
626 | var sTCommand = oTarget.getAttribute('dendcommand');
627 | var sTTooltiptext = oTarget.getAttribute('tooltiptext');
628 | var sTSRC = oTarget.firstChild.getAttribute('src');
629 | var sTSelected = oTarget.getAttribute('selected');
630 | var sTColor = oTarget.style.backgroundColor;
631 |
632 | if (sTargetID != "dropzonebox")
633 | {
634 | oSource.setAttribute('dendid', sTID);
635 | oSource.setAttribute('dendlabel', sTLabel);
636 | oSource.setAttribute('dendcommand', sTCommand);
637 | oSource.setAttribute('tooltiptext', sTTooltiptext);
638 | oSource.setAttribute('selected', sTSelected);
639 | oSource.firstChild.setAttribute('tooltiptext', sTTooltiptext);
640 | oSource.firstChild.setAttribute('src', sTSRC);
641 | oSource.style.backgroundColor = sTColor;
642 |
643 | oTarget.setAttribute('dendid', sSID);
644 | oTarget.setAttribute('dendlabel', sSLabel);
645 | oTarget.setAttribute('dendcommand', sSCommand);
646 | oTarget.setAttribute('tooltiptext', sSTooltiptext);
647 | oTarget.setAttribute('selected', sSSelected);
648 | oTarget.firstChild.setAttribute('tooltiptext', sSTooltiptext);
649 | oTarget.firstChild.setAttribute('src', sSSRC);
650 | oTarget.style.backgroundColor = sSColor;
651 | }
652 | else
653 | {
654 | oSource.setAttribute('dendid', '');
655 | oSource.setAttribute('dendlabel', '');
656 | oSource.setAttribute('dendcommand', '');
657 | oSource.setAttribute('tooltiptext', '');
658 | oSource.setAttribute('selected', false);
659 | oSource.firstChild.setAttribute('tooltiptext', '');
660 | oSource.firstChild.setAttribute('src', '');
661 | oSource.style.backgroundColor = "";
662 | }
663 | }
664 | }
665 |
666 | function DenDZones_DragRemoveDropZone(sSourceID)
667 | {
668 | var oSource = document.getElementById(sSourceID);
669 | if (oSource)
670 | {
671 | oSource.setAttribute('dendid', '');
672 | oSource.setAttribute('dendlabel', '');
673 | oSource.setAttribute('dendcommand', '');
674 | oSource.setAttribute('tooltiptext', '');
675 | oSource.setAttribute('selected', false);
676 | oSource.firstChild.setAttribute('tooltiptext', '');
677 | oSource.firstChild.setAttribute('src', '');
678 | oSource.style.backgroundColor = "";
679 | }
680 | }
681 |
682 | function ValidateOpacity(oPreference)
683 | {
684 | var iValue = parseInt(oPreference.value);
685 | if (isNaN(iValue) || iValue < 0 || iValue > 1) oPreference.reset();
686 | }
687 |
688 | function UpdateDZMaxAxis(oPreference)
689 | {
690 | document.getElementById("dropzonebox").setAttribute("maxaxis", oPreference.value);
691 | }
692 |
693 | function HasDropZone(sID)
694 | {
695 | var iX, iY;
696 |
697 | for (iX = 0; iX < 10; iX ++)
698 | {
699 | for (iY = 0; iY < 10; iY ++)
700 | {
701 | if (this.aDenDZones_DropZones[iX][iY][0] == sID) return true;
702 | }
703 | }
704 | return false;
705 | }
706 |
--------------------------------------------------------------------------------