]> err.no Git - sope/blob - sope-appserver/WEExtensions/WEDropScript.js
added strict OSX bundle dependencies
[sope] / sope-appserver / WEExtensions / WEDropScript.js
1 <SCRIPT LANGUAGE="JScript">
2 <!--
3 function fnGetInfo(dropElem, myurl) {
4   event.returnValue = false;
5   event.dataTransfer.dropEffect = "none";
6   myData = event.dataTransfer.getData("Text");
7   myData = myData.split('?');
8   myType = myData[1];
9   myID   = myData[0];
10   event.dataTransfer.clearData("Text");
11   this.location=''+myurl+'?'+myID+'='+myType;
12   this.status='url:'+myurl+' data'+myData;
13 }
14 function fnCancelDefault(validObj, effect) {
15   myData = event.dataTransfer.getData("Text");
16   myData = myData.split('?');
17   myType = myData[1];
18   myID   = myData[0];
19   if ((validObj.indexOf(myType) != -1) || (validObj == '*')) {
20     event.returnValue = false;
21     event.dataTransfer.dropEffect = effect;
22   }
23   else {
24     event.returnValue = false;
25     event.dataTransfer.dropEffect = "none";
26   }
27 }
28 function dropFieldSwapColor(obj,doLight) {
29   if (!obj.bgColor && !obj.activeColor && !obj.inactiveColor) return false;
30   if (doLight && event.dataTransfer.dropEffect == 'none') return false;
31
32   if (!obj.isColorsSet) {
33      obj.inactiveColor = obj.bgColor;
34      obj.isColorsSet   = true;
35   }
36
37   if (doLight) {
38     if (obj.activeColor)
39       obj.bgColor = obj.activeColor;
40     else if (obj.inactiveColor)
41       obj.bgColor = lighterColor(obj.inactiveColor);
42   }
43   else {
44     if (obj.inactiveColor)
45       obj.bgColor = obj.inactiveColor;
46     else
47       obj.removeAttribute("bgColor");
48   }
49 }
50       
51 var lightAddition = 20;
52 var hex = '0123456789ABCDEF';
53 function convertHexToDec(h) {
54   h1 = hex.indexOf(h.substr(0,1).toUpperCase());
55   h2 = hex.indexOf(h.substr(1,1).toUpperCase());
56   return (h1 * 16 + h2);
57 }
58 function convertDecToHex(d) {
59   if (d >= 255) return 'FF';
60   if (d <= 0)   return '00';
61   d2 = d % 16; d1 = parseInt((d-d2) / 16);
62   return hex.substr(d1,1)+hex.substr(d2,1);
63 }
64 function lighterColor(c) {
65   if (!c) return c;
66   if ((c.length != 7) || (c.substr(0,1) != '#')) return c;
67   r = convertDecToHex(convertHexToDec(c.substr(1,2)) + lightAddition);
68   g = convertDecToHex(convertHexToDec(c.substr(3,2)) + lightAddition);
69   b = convertDecToHex(convertHexToDec(c.substr(5,2)) + lightAddition);
70
71   return '#'+r+g+b;
72 }
73 // -->
74 </SCRIPT>