| 1 | /* |
|---|
| 2 | * ¤Ê JavaScript |
|---|
| 3 | * |
|---|
| 4 | * |
|---|
| 5 | * Copyright (c) 2003 DRECOM CO.,LTD. All rights reserved. |
|---|
| 6 | * |
|---|
| 7 | * [email protected] |
|---|
| 8 | * http://www.drecom.co.jp/ |
|---|
| 9 | */ |
|---|
| 10 | |
|---|
| 11 | /** |
|---|
| 12 | * uEUæÊÌæÌðæ¾ |
|---|
| 13 | */ |
|---|
| 14 | function getWidth(win) |
|---|
| 15 | { |
|---|
| 16 | var tmp_width; |
|---|
| 17 | |
|---|
| 18 | if (win.document.documentElement) { |
|---|
| 19 | tmp_width = win.document.documentElement.clientWidth; |
|---|
| 20 | if (tmp_width > 0) { |
|---|
| 21 | return tmp_width; |
|---|
| 22 | } |
|---|
| 23 | } |
|---|
| 24 | if (win.document.all) { |
|---|
| 25 | tmp_width = win.document.body.clientWidth; |
|---|
| 26 | return tmp_width; |
|---|
| 27 | } |
|---|
| 28 | return win.innerWidth; |
|---|
| 29 | } |
|---|
| 30 | |
|---|
| 31 | /** |
|---|
| 32 | * uEUæÊÌæÌ³ðæ¾ |
|---|
| 33 | */ |
|---|
| 34 | function getHeight(win) |
|---|
| 35 | { |
|---|
| 36 | var tmp_height; |
|---|
| 37 | |
|---|
| 38 | if (win.document.documentElement) { |
|---|
| 39 | tmp_height = win.document.documentElement.clientHeight; |
|---|
| 40 | if (tmp_height > 0) { |
|---|
| 41 | return(tmp_height); |
|---|
| 42 | } |
|---|
| 43 | } |
|---|
| 44 | if (win.document.all) { |
|---|
| 45 | return(win.document.body.clientHeight); |
|---|
| 46 | } |
|---|
| 47 | return(win.innerHeight); |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | /** |
|---|
| 51 | * WindowðSÉÚ® |
|---|
| 52 | */ |
|---|
| 53 | function moveWindowToCenter(win) { |
|---|
| 54 | x = (screen.width - getWidth(win)) / 2; |
|---|
| 55 | y = (screen.height - getHeight(win)) / 2; |
|---|
| 56 | win.moveTo(x,y); |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | /** |
|---|
| 60 | * íÉèOÉ\¦·éEBhEðJ |
|---|
| 61 | */ |
|---|
| 62 | function openModalWindow(url, name, height, width, scrollbars, resizable, status) |
|---|
| 63 | { |
|---|
| 64 | ModalWindow = openWindow(url, name, height, width, scrollbars, resizable, status); |
|---|
| 65 | onfocus = function onFocus(){ |
|---|
| 66 | if (null !=ModalWindow && !ModalWindow.closed) { |
|---|
| 67 | try { |
|---|
| 68 | ModalWindow.focus(); |
|---|
| 69 | } catch(e) { |
|---|
| 70 | document.onmousemove = null; |
|---|
| 71 | } |
|---|
| 72 | } else { |
|---|
| 73 | document.onmousemove = null; |
|---|
| 74 | } |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | document.onmousemove = onfocus; |
|---|
| 78 | |
|---|
| 79 | return ModalWindow; |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | /** |
|---|
| 83 | * EBhEðJ |
|---|
| 84 | */ |
|---|
| 85 | function openWindow(url, name, height, width, scrollbars, resizable, status, left, top) |
|---|
| 86 | { |
|---|
| 87 | var window_condition = "height=" + height + ",width=" + width + |
|---|
| 88 | ((left) ? ",left=" + left : "") + ((top) ? ",top=" + top : "") + |
|---|
| 89 | ",scrollbars=" + scrollbars + ",resizable=" + resizable + ",toolbar=no,status=" + status; |
|---|
| 90 | |
|---|
| 91 | subWindow = window.open(url, name, window_condition); |
|---|
| 92 | // |bvAbvubJ[ÈÇÅubN³ê½êÉJavaScriptG[ÉÈçÈ¢æ¤É |
|---|
| 93 | if (subWindow) { |
|---|
| 94 | subWindow.focus(); |
|---|
| 95 | } |
|---|
| 96 | |
|---|
| 97 | return subWindow; |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | /** |
|---|
| 101 | * EBhEðãëÉJ |
|---|
| 102 | */ |
|---|
| 103 | function openWindowBack(url, name, height, width, scrollbars, resizable, status) |
|---|
| 104 | { |
|---|
| 105 | var window_condition = "height=" + height + ",width=" + width + |
|---|
| 106 | ",scrollbars=" + scrollbars + ",resizable=" + resizable + ",toolbar=no,status=" + status + |
|---|
| 107 | ",left=" + window.screen.width; |
|---|
| 108 | subWindow = window.open(url, name, window_condition); |
|---|
| 109 | subWindow.blur(); |
|---|
| 110 | window.focus(); |
|---|
| 111 | subWindow.moveTo(0,0); |
|---|
| 112 | return subWindow; |
|---|
| 113 | } |
|---|
| 114 | |
|---|
| 115 | /** |
|---|
| 116 | * EscL[ÅEBhEð¶éCxg |
|---|
| 117 | * |
|---|
| 118 | * ¦TuEBhEÌonloadÅ |
|---|
| 119 | * document.body.onkeypress = subwinCloseOnEsc; |
|---|
| 120 | * Ìæ¤ÉgÁľ³¢B |
|---|
| 121 | */ |
|---|
| 122 | function subwinCloseOnEsc(ev) |
|---|
| 123 | { |
|---|
| 124 | ev || (ev = window.event); |
|---|
| 125 | if (ev.keyCode == 27) { |
|---|
| 126 | window.close(); |
|---|
| 127 | return false; |
|---|
| 128 | } |
|---|
| 129 | return true; |
|---|
| 130 | } |
|---|
| 131 | |
|---|
| 132 | |
|---|
| 133 | |
|---|
| 134 | // 2004-06-09 Takanori Ishikawa |
|---|
| 135 | // ----------------------------------------------------------- |
|---|
| 136 | // htmlAlert(), htmlConfirm() Í html ð»ÌÜÜ |
|---|
| 137 | // o͹¸ATj^CY·éæ¤Éµ½B |
|---|
| 138 | |
|---|
| 139 | // sanitize html message |
|---|
| 140 | function sanitize_msg(msg) |
|---|
| 141 | { |
|---|
| 142 | msg = msg.replace(/</g, '<'); |
|---|
| 143 | msg = msg.replace(/>/g, '>'); |
|---|
| 144 | msg = msg.replace(/<br\s*>/g, '<br>'); |
|---|
| 145 | |
|---|
| 146 | return msg; |
|---|
| 147 | } |
|---|
| 148 | // alert |
|---|
| 149 | function htmlAlert(msg, height, width) |
|---|
| 150 | { |
|---|
| 151 | height = (null == height) ? 150: height; |
|---|
| 152 | width = (null == width) ? 300: width; |
|---|
| 153 | msg = sanitize_msg(msg); |
|---|
| 154 | |
|---|
| 155 | if (defined(window.showModalDialog)) { |
|---|
| 156 | showModalDialog("/drecomcms/html/message_box.html", sanitize_msg(msg), "dialogHeight: " + height + "px; dialogWidth: " + width + "px; edge: Raised; center: Yes; help: No; resizable: No; status: No;"); |
|---|
| 157 | } else { |
|---|
| 158 | dialogArguments = msg; |
|---|
| 159 | ModalWindow = open("/drecomcms/html/message_box.html", "sub_alert","height=" + height + ",width=" + width + |
|---|
| 160 | ",scrollbars=no,resizable=no,toolbar=no,status=no,alwaysRaised=yes"); |
|---|
| 161 | onfocus = function onFocus(){ |
|---|
| 162 | if (null !=ModalWindow && !ModalWindow.closed) { |
|---|
| 163 | ModalWindow.focus(); |
|---|
| 164 | } |
|---|
| 165 | } |
|---|
| 166 | document.onmousemove = onfocus; |
|---|
| 167 | return ModalWindow; |
|---|
| 168 | } |
|---|
| 169 | } |
|---|
| 170 | // confirm |
|---|
| 171 | function htmlConfirm(msg, height, width) |
|---|
| 172 | { |
|---|
| 173 | height = (null == height) ? 150: height; |
|---|
| 174 | width = (null == width) ? 300: width; |
|---|
| 175 | if (defined(window.showModalDialog)) { |
|---|
| 176 | var value = showModalDialog("/drecomcms/html/confirm.html", sanitize_msg(msg), "dialogHeight: " + height + "px; dialogWidth: " + width + "px; edge: Raised; center: Yes; help: No; resizable: No; status: No;"); |
|---|
| 177 | if (typeof value == "undefined") { |
|---|
| 178 | value = false; |
|---|
| 179 | } |
|---|
| 180 | return value; |
|---|
| 181 | } else { |
|---|
| 182 | return window.confirm(msg.replace(/<br[^>]*\/?>/, '\n')); |
|---|
| 183 | } |
|---|
| 184 | } |
|---|
| 185 | |
|---|
| 186 | /** |
|---|
| 187 | * júðæ¾·éÖ |
|---|
| 188 | * year: N |
|---|
| 189 | * month: |
|---|
| 190 | * day: ú |
|---|
| 191 | */ |
|---|
| 192 | function getDayOfWeek(year, month, day) { |
|---|
| 193 | |
|---|
| 194 | DateOfWeek = new Date(); |
|---|
| 195 | DateOfWeek.setYear(year); |
|---|
| 196 | DateOfWeek.setMonth(month - 1); |
|---|
| 197 | DateOfWeek.setDate(day); |
|---|
| 198 | day_of_week_number = DateOfWeek.getDay(); |
|---|
| 199 | |
|---|
| 200 | days = new Array('ú','','Î','
','Ø','à','y'); |
|---|
| 201 | return days[day_of_week_number]; |
|---|
| 202 | } |
|---|
| 203 | |
|---|
| 204 | |
|---|
| 205 | // ----------------------------------------------------------- |
|---|
| 206 | // |[^Awb_ |
|---|
| 207 | // ----------------------------------------------------------- |
|---|
| 208 | /** |
|---|
| 209 | * INPUT FORM ÌwiFÏX |
|---|
| 210 | */ |
|---|
| 211 | function focusForm(obj,flag){ |
|---|
| 212 | if (obj == null || obj.style == null) { |
|---|
| 213 | return; |
|---|
| 214 | } |
|---|
| 215 | obj.style.backgroundColor = flag ? '#FFFFCC' : '#FFFFFF' |
|---|
| 216 | } |
|---|
| 217 | function Skinup(fnr){ |
|---|
| 218 | win = window.open('/contents/skinpop_'+fnr,'skin','width=455,height=300,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes'); |
|---|
| 219 | win.focus(); |
|---|
| 220 | } |
|---|
| 221 | function imgSwap(name,gifPath) { |
|---|
| 222 | document.images[name].src = gifPath ; |
|---|
| 223 | } |
|---|
| 224 | |
|---|
| 225 | |
|---|
| 226 | // ----------------------------------------------------------- |
|---|
| 227 | // æ |
|---|
| 228 | // ----------------------------------------------------------- |
|---|
| 229 | /** |
|---|
| 230 | * æÌ\¦TCY²® |
|---|
| 231 | */ |
|---|
| 232 | function adjustImageSize(imgElementName, widthMax, heightMax) { |
|---|
| 233 | var imgs = document.getElementsByName(imgElementName); |
|---|
| 234 | if (imgs) { |
|---|
| 235 | if (!imgs.length) { |
|---|
| 236 | if (widthMax && imgs.width > widthMax) { |
|---|
| 237 | imgs.height = imgs.height * widthMax / imgs.width; |
|---|
| 238 | imgs.width = widthMax; |
|---|
| 239 | } |
|---|
| 240 | if (heightMax && imgs.height > heightMax) { |
|---|
| 241 | imgs.width = imgs.width * heightMax / imgs.height; |
|---|
| 242 | imgs.height = heightMax; |
|---|
| 243 | } |
|---|
| 244 | } else { |
|---|
| 245 | for (i=0; i<imgs.length; i++) { |
|---|
| 246 | if (widthMax && imgs[i].width > widthMax) { |
|---|
| 247 | imgs[i].height = imgs[i].height * widthMax / imgs[i].width; |
|---|
| 248 | imgs[i].width = widthMax; |
|---|
| 249 | } |
|---|
| 250 | if (heightMax && imgs[i].height > heightMax) { |
|---|
| 251 | imgs[i].width = imgs[i].width * heightMax / imgs[i].height; |
|---|
| 252 | imgs[i].height = heightMax; |
|---|
| 253 | } |
|---|
| 254 | } |
|---|
| 255 | } |
|---|
| 256 | } |
|---|
| 257 | } |
|---|
| 258 | |
|---|
| 259 | /** |
|---|
| 260 | * {¶ÌHTML\[XæèOæURL("http://`")ðPickUp |
|---|
| 261 | */ |
|---|
| 262 | function getExternalImageList(orgHtml) { |
|---|
| 263 | |
|---|
| 264 | var extImageList = new Array(); |
|---|
| 265 | var list = new Array(); |
|---|
| 266 | var n = 0; |
|---|
| 267 | var exp; |
|---|
| 268 | |
|---|
| 269 | exp = new RegExp("<img [^>]*src=[\"']?http://[^\"']*[\"']?[^>]*>", 'ig'); |
|---|
| 270 | list = orgHtml.match(exp); |
|---|
| 271 | if (list) { |
|---|
| 272 | for (var i = 0; i < list.length; i++) { |
|---|
| 273 | var str = ""; |
|---|
| 274 | exp = new RegExp("src=[\"']?"); |
|---|
| 275 | list[i].match(exp); |
|---|
| 276 | str = RegExp.rightContext; |
|---|
| 277 | exp = new RegExp("[\"'\\s>]|/>"); |
|---|
| 278 | if (str) { |
|---|
| 279 | str.match(exp); |
|---|
| 280 | str = RegExp.leftContext; |
|---|
| 281 | |
|---|
| 282 | var isExist = false; |
|---|
| 283 | for (var j = 0; j < extImageList.length; j++) { |
|---|
| 284 | if (extImageList[j] == str) { isExist = true; break; } |
|---|
| 285 | } |
|---|
| 286 | if (!isExist) { extImageList[n++] = str; } |
|---|
| 287 | } |
|---|
| 288 | } |
|---|
| 289 | } |
|---|
| 290 | return extImageList; |
|---|
| 291 | } |
|---|
| 292 | |
|---|
| 293 | /** |
|---|
| 294 | * {¶ÌHTML\[XæèOFlashURL("http://`")ðPickUp |
|---|
| 295 | */ |
|---|
| 296 | function getExternalFlashList(orgHtml) { |
|---|
| 297 | |
|---|
| 298 | var extFlashList = new Array(); |
|---|
| 299 | var list = new Array(); |
|---|
| 300 | var n = 0; |
|---|
| 301 | var exp; |
|---|
| 302 | |
|---|
| 303 | var flashTag = "\\{\\\$CMSInclude [^\\\$\\}]*name=\"flash\"\\s*param=\"[^\"]*Movie=http://[^\"]*\"\\s*\\\$\\}"; |
|---|
| 304 | exp = new RegExp(flashTag, 'ig'); |
|---|
| 305 | list = orgHtml.match(exp); |
|---|
| 306 | if (list) { |
|---|
| 307 | for (var i = 0; i < list.length; i++) { |
|---|
| 308 | var str = ""; |
|---|
| 309 | exp = new RegExp("Movie="); |
|---|
| 310 | list[i].match(exp); |
|---|
| 311 | str = RegExp.rightContext; |
|---|
| 312 | exp = new RegExp(";"); |
|---|
| 313 | if (str) { |
|---|
| 314 | str.match(exp); |
|---|
| 315 | str = RegExp.leftContext; |
|---|
| 316 | |
|---|
| 317 | var isExist = false; |
|---|
| 318 | for (var j = 0; j < extFlashList.length; j++) { |
|---|
| 319 | if (extFlashList[j] == str) { isExist = true; break; } |
|---|
| 320 | } |
|---|
| 321 | if (!isExist) { extFlashList[n++] = str; } |
|---|
| 322 | } |
|---|
| 323 | } |
|---|
| 324 | } |
|---|
| 325 | return extFlashList; |
|---|
| 326 | } |
|---|
| 327 | |
|---|
| 328 | /** |
|---|
| 329 | * NÌJÚæð³øÉ·éB |
|---|
| 330 | * i<a>^OÌhref®«ð"javascript:void(0)"Éu·j |
|---|
| 331 | */ |
|---|
| 332 | function replaceLinkInvalid(html) { |
|---|
| 333 | html = html.replace(/<a [^>]*>/ig, '<a href="javascript:void(0);">'); |
|---|
| 334 | html = html.replace(/openPermLink\([^)]*\)/ig, 'void(0)'); |
|---|
| 335 | return html; |
|---|
| 336 | } |
|---|
| 337 | |
|---|
| 338 | /** |
|---|
| 339 | * URLpÌGXP[vðs¢Ü·B |
|---|
| 340 | * '&' -> '&' |
|---|
| 341 | * '>' -> '>' |
|---|
| 342 | * '<' -> '<' |
|---|
| 343 | * '"' -> '"' |
|---|
| 344 | * ¼[ÌóÍ Trim |
|---|
| 345 | * ' ' -> '%20' |
|---|
| 346 | * @param src ÎÛ¶ñ |
|---|
| 347 | */ |
|---|
| 348 | function /*: String :*/ escapeUrl(/*: String :*/ src) { |
|---|
| 349 | var s = replaceAll(src, '&', '&'); |
|---|
| 350 | s = replaceAll(s, '>', '>'); |
|---|
| 351 | s = replaceAll(s, '<', '<'); |
|---|
| 352 | s = replaceAll(s, '"', '"'); |
|---|
| 353 | s = trim(s); |
|---|
| 354 | s = replaceAll(s, ' ', '%20'); |
|---|
| 355 | return s; |
|---|
| 356 | } |
|---|
| 357 | function /*: String :*/ escapeScript(/*: String :*/ src) { |
|---|
| 358 | var s = replaceAll(src, "\\", "\\\\"); |
|---|
| 359 | s = replaceAll(s, "'", "\\'"); |
|---|
| 360 | s = replaceAll(s, "\"", "\\\""); |
|---|
| 361 | return s; |
|---|
| 362 | } |
|---|
| 363 | /** |
|---|
| 364 | * ¶ñÌSu·ðs¢Ü·B |
|---|
| 365 | * @param src ÎÛ¶ñ |
|---|
| 366 | * @param oldc ¶ñ |
|---|
| 367 | * @param newc V¶ñ |
|---|
| 368 | */ |
|---|
| 369 | function /*: String :*/ replaceAll(/*: String :*/src, /*: String :*/oldc, /*: String :*/newc) { |
|---|
| 370 | var h = ""; |
|---|
| 371 | var b = src; |
|---|
| 372 | var index = 0; |
|---|
| 373 | while (true) { |
|---|
| 374 | index = b.indexOf(oldc, 0); |
|---|
| 375 | if (index == -1) { |
|---|
| 376 | break; |
|---|
| 377 | } |
|---|
| 378 | src = b.replace(oldc, newc); |
|---|
| 379 | h += src.substring(0, index + newc.length); |
|---|
| 380 | b = src.substring(index + newc.length, src.length); |
|---|
| 381 | } |
|---|
| 382 | return h + b; |
|---|
| 383 | } |
|---|
| 384 | /** |
|---|
| 385 | * ¼[̼p/SpXy[Xðæè«Ü·B |
|---|
| 386 | * @param src ÎÛ¶ñ |
|---|
| 387 | */ |
|---|
| 388 | function /*: String :*/ trim(/*: String :*/src ) { |
|---|
| 389 | var s = trimR(src); |
|---|
| 390 | return trimL(s); |
|---|
| 391 | } |
|---|
| 392 | /** |
|---|
| 393 | * E[̼p/SpXy[Xðæè«Ü·B |
|---|
| 394 | * @param src ÎÛ¶ñ |
|---|
| 395 | */ |
|---|
| 396 | function /*: String :*/ trimR(/*: String :*/src) { |
|---|
| 397 | var nLoop = 0; |
|---|
| 398 | var strFinal = src; |
|---|
| 399 | var strTemp = src; |
|---|
| 400 | while (nLoop < strTemp.length) { |
|---|
| 401 | if ((strFinal.substring(strFinal.length - 1, strFinal.length) == " ") || (strFinal.substring(strFinal.length - 1, strFinal.length) == "@")) { |
|---|
| 402 | strFinal = strTemp.substring(0, strTemp.length - (nLoop + 1)); |
|---|
| 403 | } |
|---|
| 404 | else { |
|---|
| 405 | break; |
|---|
| 406 | } |
|---|
| 407 | nLoop++; |
|---|
| 408 | } |
|---|
| 409 | return strFinal; |
|---|
| 410 | } |
|---|
| 411 | /** |
|---|
| 412 | * ¶[̼p/SpXy[Xðæè«Ü·B |
|---|
| 413 | * @param src ÎÛ¶ñ |
|---|
| 414 | */ |
|---|
| 415 | function /*: String :*/ trimL(/*: String :*/src) { |
|---|
| 416 | var nLoop = 0; |
|---|
| 417 | var strFinal = src; |
|---|
| 418 | var strTemp = src; |
|---|
| 419 | while (nLoop < strTemp.length) { |
|---|
| 420 | if ((strFinal.substring(0, 1) == " ") || (strFinal.substring(0, 1) == "@")) { |
|---|
| 421 | strFinal = strTemp.substring(nLoop + 1, strTemp.length ); |
|---|
| 422 | } |
|---|
| 423 | else { |
|---|
| 424 | break; |
|---|
| 425 | } |
|---|
| 426 | nLoop++; |
|---|
| 427 | } |
|---|
| 428 | return strFinal; |
|---|
| 429 | } |
|---|
| 430 | |
|---|
| 431 | /** |
|---|
| 432 | * p³ |
|---|
| 433 | */ |
|---|
| 434 | function extend(subClass, superClass) { |
|---|
| 435 | for (var prop in superClass.prototype) { |
|---|
| 436 | subClass.prototype[prop] = superClass.prototype[prop]; |
|---|
| 437 | } |
|---|
| 438 | } |
|---|
| 439 | |
|---|
| 440 | |
|---|
| 441 | /** |
|---|
| 442 | * |bvAbvubJ[Îô |
|---|
| 443 | * window.onPopupBlocked,window.onPopupNonBlockedðI[o[ChµÄ¾³¢B |
|---|
| 444 | */ |
|---|
| 445 | window.onPopupBlocked = function(){ |
|---|
| 446 | alert('EBhEðJ¯Ü¹ñŵ½B|bvAbvubJ[ðLøÉµÄ¢éêÍA³øÉµÄ¾³¢B'); |
|---|
| 447 | }; |
|---|
| 448 | |
|---|
| 449 | window.onPopupNonBlocked = function(){} |
|---|
| 450 | |
|---|
| 451 | if (typeof window.org_open == 'undefined'){ |
|---|
| 452 | window.org_open = window.open; |
|---|
| 453 | window.open = function() { |
|---|
| 454 | var win = (2 == window.open.arguments.length) |
|---|
| 455 | ? window.org_open(window.open.arguments[0], window.open.arguments[1]) |
|---|
| 456 | : window.org_open(window.open.arguments[0], window.open.arguments[1], window.open.arguments[2]); |
|---|
| 457 | if (null == win) { |
|---|
| 458 | window.onPopupBlocked(window.open.arguments); |
|---|
| 459 | } else { |
|---|
| 460 | window.onPopupNonBlocked(window.open.arguments); |
|---|
| 461 | } |
|---|
| 462 | return win; |
|---|
| 463 | } |
|---|
| 464 | } |
|---|
| 465 | |
|---|
| 466 | |
|---|