[8] | 1 | /* |
---|
[17] | 2 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. |
---|
[8] | 3 | * |
---|
| 4 | * http://www.lockon.co.jp/ |
---|
| 5 | */ |
---|
| 6 | var obj; |
---|
| 7 | var offsetX; |
---|
| 8 | var offsetY; |
---|
| 9 | var arrObj; |
---|
| 10 | var objParam; |
---|
| 11 | |
---|
| 12 | // ¥Ñ¥é¥á¡¼¥¿´ÉÍý¥¯¥é¥¹¤ÎÄêµÁ |
---|
| 13 | function SC_Param() { |
---|
| 14 | this.ITEM_MAX = 3; |
---|
| 15 | } |
---|
| 16 | |
---|
| 17 | // ¥µ¥¤¥º´ÉÍý¥¯¥é¥¹¤ÎÄêµÁ |
---|
| 18 | function SC_Size() { |
---|
| 19 | this.id = ''; |
---|
| 20 | this.left = 0; |
---|
| 21 | this.top = 0; |
---|
| 22 | this.width = 0; |
---|
| 23 | this.height = 0; |
---|
| 24 | this.obj; |
---|
| 25 | }; |
---|
| 26 | |
---|
| 27 | // ¥ª¥ó¥í¡¼¥É½èÍý |
---|
| 28 | onload=function () { |
---|
| 29 | // ¥Ñ¥é¥á¡¼¥¿¤Î½é´ü²½ |
---|
| 30 | objParam = new SC_Param(); |
---|
| 31 | |
---|
| 32 | // WIN-IE |
---|
| 33 | if (document.all) { |
---|
| 34 | objlist = document.all.tags("div"); |
---|
| 35 | // WIN-NN,WIN-FF |
---|
| 36 | } else if (document.getElementsByTagName) { |
---|
| 37 | objlist = document.getElementsByTagName("div"); |
---|
| 38 | } else { |
---|
| 39 | return; |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | arrObj = new Array(); |
---|
| 43 | for (i = 0; i < objlist.length; i++) { |
---|
| 44 | id = objlist[i].id; |
---|
| 45 | arrObj[id] = new SC_Size(); |
---|
| 46 | arrObj[id].id = id; |
---|
| 47 | arrObj[id].obj = objlist[id]; |
---|
| 48 | arrObj[id].left = objlist[id].style.left; |
---|
| 49 | arrObj[id].top = objlist[id].style.top; |
---|
| 50 | arrObj[id].width = objlist[id].style.width; |
---|
| 51 | arrObj[id].height = objlist[id].style.height; |
---|
| 52 | arrObj[id].left = Number(arrObj[id].left.replace(/px/, '')); |
---|
| 53 | arrObj[id].top = Number(arrObj[id].top.replace(/px/, '')); |
---|
| 54 | arrObj[id].width = Number(arrObj[id].width.replace(/px/, '')); |
---|
| 55 | arrObj[id].height = Number(arrObj[id].height.replace(/px/, '')); |
---|
| 56 | arrObj[id].right = Number(arrObj[id].left) + Number(arrObj[id].width); |
---|
| 57 | arrObj[id].bottom =Number(arrObj[id].top) + Number(arrObj[id].height); |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | // MouseDown¥¤¥Ù¥ó¥È½èÍý¤ÎÆþ¤ìÂؤ¨ |
---|
| 61 | objlist['item0'].onmousedown = onMouseDown; |
---|
| 62 | objlist['item1'].onmousedown = onMouseDown; |
---|
| 63 | objlist['item2'].onmousedown = onMouseDown; |
---|
| 64 | |
---|
| 65 | document.onmousemove = onMouseMove; |
---|
| 66 | document.onmouseup = onMouseUp; |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | // MouseDown¥¤¥Ù¥ó¥È |
---|
| 70 | function onMouseDown(e) { |
---|
| 71 | obj = this; |
---|
| 72 | // WIN-IE |
---|
| 73 | if (document.all) { |
---|
| 74 | offsetX = event.offsetX + 2; |
---|
| 75 | offsetY = event.offsetY + 2; |
---|
| 76 | // WIN-NN,WIN-FF |
---|
| 77 | } else if (obj.getElementsByTagName) { |
---|
| 78 | offsetX = e.pageX - parseInt(obj.style.left); |
---|
| 79 | offsetY = e.pageY - parseInt(obj.style.top); |
---|
| 80 | } |
---|
| 81 | return false; |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | // MouseMove¥¤¥Ù¥ó¥È |
---|
| 85 | function onMouseMove(e) { |
---|
| 86 | if (!obj) { |
---|
| 87 | return true; |
---|
| 88 | } |
---|
| 89 | // WIN-IE |
---|
| 90 | if (document.all) { |
---|
| 91 | x = event.clientX - offsetX; |
---|
| 92 | // ²èÌ̳°¤Ë½Ð¤Ê¤¤¤è¤¦¤ËÀ©¸æ¤¹¤ë¡¡ |
---|
| 93 | if(x <= 0) { |
---|
| 94 | x = 0; |
---|
| 95 | } |
---|
| 96 | left_max = document.body.clientWidth - arrObj[obj.id].width; |
---|
| 97 | if(x >= left_max) { |
---|
| 98 | x =left_max; |
---|
| 99 | } |
---|
| 100 | obj.style.left = x; |
---|
| 101 | // ²èÌ̳°¤Ë½Ð¤Ê¤¤¤è¤¦¤ËÀ©¸æ¤¹¤ë¡¡ |
---|
| 102 | y = event.clientY - offsetY; |
---|
| 103 | if(y <= 0) { |
---|
| 104 | y = 0; |
---|
| 105 | } |
---|
| 106 | top_max = document.body.clientHeight - arrObj[obj.id].height; |
---|
| 107 | if(y >= top_max) { |
---|
| 108 | y =top_max; |
---|
| 109 | } |
---|
| 110 | obj.style.top = y; |
---|
| 111 | // WIN-NN,WIN-FF |
---|
| 112 | } else if (obj.getElementsByTagName) { |
---|
| 113 | x = e.pageX - offsetX; |
---|
| 114 | // ²èÌ̳°¤Ë½Ð¤Ê¤¤¤è¤¦¤ËÀ©¸æ¤¹¤ë¡¡ |
---|
| 115 | if(x <= 0) { |
---|
| 116 | x = 0; |
---|
| 117 | } |
---|
| 118 | left_max = window.innerWidth - arrObj[obj.id].width; |
---|
| 119 | if(x >= left_max) { |
---|
| 120 | x =left_max; |
---|
| 121 | } |
---|
| 122 | obj.style.left = x; |
---|
| 123 | |
---|
| 124 | y = e.pageY - offsetY; |
---|
| 125 | // ²èÌ̳°¤Ë½Ð¤Ê¤¤¤è¤¦¤ËÀ©¸æ¤¹¤ë¡¡ |
---|
| 126 | if(y <= 0) { |
---|
| 127 | y = 0; |
---|
| 128 | obj.style.top = 0; |
---|
| 129 | } |
---|
| 130 | top_max = window.innerHeight - arrObj[obj.id].height; |
---|
| 131 | if(y >= top_max) { |
---|
| 132 | y =top_max; |
---|
| 133 | } |
---|
| 134 | obj.style.top = y; |
---|
| 135 | } |
---|
| 136 | |
---|
| 137 | if(isInFlame('flame0', obj)) { |
---|
| 138 | document.getElementById('td1').style.backgroundColor = '#fffadd'; |
---|
| 139 | } else { |
---|
| 140 | document.getElementById('td1').style.backgroundColor = '#ffffff'; |
---|
| 141 | } |
---|
| 142 | return false; |
---|
| 143 | } |
---|
| 144 | |
---|
| 145 | // MouseUp¥¤¥Ù¥ó¥È |
---|
| 146 | function onMouseUp(e) { |
---|
| 147 | if (!obj) { |
---|
| 148 | return true; |
---|
| 149 | } |
---|
| 150 | |
---|
| 151 | if(!isInFlame('flame0', obj)) { |
---|
| 152 | // WIN-IE |
---|
| 153 | if (document.all) { |
---|
| 154 | // ºÇ½é¤Î°ÌÃÖ¤ËÌ᤹ |
---|
| 155 | obj.style.left = arrObj[obj.id].left; |
---|
| 156 | obj.style.top = arrObj[obj.id].top; |
---|
| 157 | // WIN-NN,WIN-FF |
---|
| 158 | } else if (obj.getElementsByTagName) { |
---|
| 159 | // ºÇ½é¤Î°ÌÃÖ¤ËÌ᤹ |
---|
| 160 | obj.style.left = arrObj[obj.id].left; |
---|
| 161 | obj.style.top = arrObj[obj.id].top; |
---|
| 162 | } |
---|
| 163 | } |
---|
| 164 | document.getElementById('td1').style.backgroundColor = '#ffffff'; |
---|
| 165 | obj = null; |
---|
| 166 | } |
---|
| 167 | |
---|
| 168 | // ¥Õ¥ì¡¼¥àÆâ¤Ë¥¢¥¤¥Æ¥à¤¬Â¸ºß¤¹¤ë¤«È½Äꤹ¤ë¡¡ |
---|
| 169 | function isInFlame(flame_id, item) { |
---|
| 170 | top_val = item.style.top; |
---|
| 171 | top_val = Number(top_val.replace(/px/, '')); |
---|
| 172 | bottom_val = top_val + arrObj[item.id].height; |
---|
| 173 | left_val = item.style.left; |
---|
| 174 | left_val = Number(left_val.replace(/px/, '')) |
---|
| 175 | right_val = left_val + arrObj[item.id].width; |
---|
| 176 | if( |
---|
| 177 | top_val > arrObj[flame_id].top && |
---|
| 178 | bottom_val < arrObj[flame_id].bottom && |
---|
| 179 | left_val > arrObj[flame_id].left && |
---|
| 180 | right_val < arrObj[flame_id].right |
---|
| 181 | ) { |
---|
| 182 | return true; |
---|
| 183 | } |
---|
| 184 | return false; |
---|
| 185 | } |
---|
| 186 | |
---|
| 187 | // Á÷¿®Á°¤Î½èÍý |
---|
| 188 | function preSubmit() { |
---|
| 189 | for(i = 0; i < 3; i++) { |
---|
| 190 | id = 'item' + i; |
---|
| 191 | obj = arrObj[id].obj; |
---|
| 192 | if(isInFlame ('flame0', obj)) { |
---|
| 193 | document.form1[obj.id].value = "in"; |
---|
| 194 | } else { |
---|
| 195 | document.form1[obj.id].value = "out"; |
---|
| 196 | } |
---|
| 197 | } |
---|
| 198 | } |
---|
| 199 | |
---|
| 200 | |
---|
| 201 | |
---|