| 1 | 1 | simandl | // global variable for subwindow reference |
| 2 | | | |
| 3 | | | var newWindow; |
| 4 | | | |
| 5 | | | var helptexts = new Object; |
| 6 | | | |
| 7 | | | // seed the help text. Done in a big lump here, so we could make a foreign language version someday. |
| 8 | | | |
| 9 | | | helptexts.link_target |
| 10 | | | = 'Where should Weathermap get data for this link? This can either be an RRD file, or an HTML with special comments in it (normally from MRTG).'; |
| 11 | | | helptexts.link_width = 'How wide the link arrow will be drawn, in pixels.'; |
| 12 | | | helptexts.link_infourl |
| 13 | | | = 'If you are using the \'overlib\' HTML style then this is the URL that will be opened when you click on the link'; |
| 14 | | | helptexts.link_hover |
| 15 | | | = 'If you are using the \'overlib\' HTML style then this is the URL of the image that will be shown when you hover over the link'; |
| 16 | | | |
| 17 | | | helptexts.tb_newfile = 'Change to a different file, or start creating a new one.'; |
| 18 | | | helptexts.tb_addnode = 'Add a new node to the map'; |
| 19 | | | helptexts.tb_addlink = 'Add a new link to the map, by joining two nodes together.'; |
| 20 | | | |
| 21 | | | helptexts.hover_tb_newfile = 'Select a different map to edit, or start a new one.'; |
| 22 | | | |
| 23 | | | helptexts.link_default = 'This is where help appears for links'; |
| 24 | | | helptexts.map_default = 'This is where help appears for maps'; |
| 25 | | | helptexts.node_default = 'This is where help appears for nodes'; |
| 26 | | | helptexts.tb_defaults = 'or click a Node or Link to edit it\'s properties'; |
| 27 | | | |
| 28 | | | addEvent(window, 'load', initJS); |
| 29 | | | addEvent(window, 'unload', cleanupJS); |
| 30 | | | |
| 31 | | | function addEvent(obj, evType, fn) |
| 32 | | | { |
| 33 | | | if (obj.addEventListener) |
| 34 | | | { |
| 35 | | | obj.addEventListener(evType, fn, false); |
| 36 | | | return true; |
| 37 | | | } |
| 38 | | | |
| 39 | | | else if (obj.attachEvent) |
| 40 | | | { |
| 41 | | | var r = obj.attachEvent("on" + evType, fn); |
| 42 | | | return r; |
| 43 | | | } |
| 44 | | | |
| 45 | | | else |
| 46 | | | { |
| 47 | | | return false; |
| 48 | | | } |
| 49 | | | } |
| 50 | | | |
| 51 | | | function initJS() |
| 52 | | | { |
| 53 | | | // check if DOM is available, if not, we'll stop here, leaving the warning showing |
| 54 | | | if (!document.getElementById || !document.createTextNode || !document.getElementsByTagName) |
| 55 | | | { |
| 56 | | | return; |
| 57 | | | } |
| 58 | | | |
| 59 | | | // check if there is a "No JavaScript" message |
| 60 | | | var nojsmsg = document.getElementById('nojs'); |
| 61 | | | |
| 62 | | | if (nojsmsg) |
| 63 | | | { |
| 64 | | | nojsmsg.style.display = 'none'; |
| 65 | | | } |
| 66 | | | |
| 67 | | | // so that's the warning hidden, now let's show the content |
| 68 | | | |
| 69 | | | // check if there is a "with JavaScript" div |
| 70 | | | var jsmsg = document.getElementById('withjs'); |
| 71 | | | |
| 72 | | | if (jsmsg) |
| 73 | | | { |
| 74 | | | jsmsg.style.display = 'block'; |
| 75 | | | } |
| 76 | | | |
| 77 | | | // if the xycapture element is there, then we are in the main edit screen |
| 78 | | | if (document.getElementById('xycapture')) |
| 79 | | | { |
| 80 | | | attach_click_events(); |
| 81 | | | attach_help_events(); |
| 82 | | | show_context_help('node_label', 'node_help'); |
| 83 | | | |
| 84 | | | // set the mapmode, so we know where we stand. |
| 85 | | | mapmode('existing'); |
| 86 | | | } |
| 87 | | | } |
| 88 | | | |
| 89 | | | function cleanupJS() |
| 90 | | | { |
| 91 | | | |
| 92 | | | // This should be cleaning up all the handlers we added in initJS, to avoid killing |
| 93 | | | // IE/Win and Safari (at least) over a period of time with memory leaks. |
| 94 | | | |
| 95 | | | } |
| 96 | | | |
| 97 | | | function attach_help_events() |
| 98 | | | { |
| 99 | | | var helps; |
| 100 | | | |
| 101 | | | // add an onblur/onfocus handler to all the visible <input> items |
| 102 | | | helps = document.getElementsByTagName('input'); |
| 103 | | | |
| 104 | | | for (i = 0; i < helps.length; ++i) |
| 105 | | | { |
| 106 | | | if (helps[i].getAttribute('type') != 'hidden') |
| 107 | | | { |
| 108 | | | addEvent(helps[i], 'focus', help_handler); |
| 109 | | | addEvent(helps[i], 'blur', help_handler); |
| 110 | | | } |
| 111 | | | } |
| 112 | | | |
| 113 | | | if (6 == 8) |
| 114 | | | { |
| 115 | | | // add an onmousein/onmouseout handler to the toolbar buttons |
| 116 | | | helps = document.getElementsByTagName('li'); |
| 117 | | | |
| 118 | | | for (i = 0; i < helps.length; ++i) |
| 119 | | | { |
| 120 | | | // alert(helps[i].id.slice(0,3)); |
| 121 | | | //alert(helps[i].className); |
| 122 | | | if (helps[i].className == 'tb_active') |
| 123 | | | { // alert(helps[i].id); |
| 124 | | | addEvent(helps[i], 'mouseover', mouse_help_handler); |
| 125 | | | addEvent(helps[i], 'mouseout', mouse_help_handler); |
| 126 | | | // alert('Attaching to ' + helps[i].className); |
| 127 | | | } |
| 128 | | | } |
| 129 | | | } |
| 130 | | | } |
| 131 | | | |
| 132 | | | function attach_click_events() |
| 133 | | | { |
| 134 | | | var alt, i; |
| 135 | | | var areas, type; |
| 136 | | | |
| 137 | | | areas = document.getElementsByTagName('area'); |
| 138 | | | |
| 139 | | | for (i = 0; i < areas.length; ++i) |
| 140 | | | { |
| 141 | | | alt = areas[i].getAttribute('alt'); |
| 142 | | | type = alt.slice(0, 5); |
| 143 | | | |
| 144 | | | if (type == 'LINK:' || type == 'NODE:') |
| 145 | | | { |
| 146 | | | // we add the href so that the browser adds a 'hand' cursor |
| 147 | | | areas[i].setAttribute('href', '#'); |
| 148 | | | // and the click_handler does the actual work |
| 149 | | | addEvent(areas[i], 'click', click_handler); |
| 150 | | | } |
| 151 | | | |
| 152 | | | if (type == 'TIMES') |
| 153 | | | { |
| 154 | | | areas[i].setAttribute('href', '#'); |
| 155 | | | addEvent(areas[i], 'click', position_timestamp); |
| 156 | | | } |
| 157 | | | |
| 158 | | | if (type == 'LEGEN') |
| 159 | | | { |
| 160 | | | areas[i].setAttribute('href', '#'); |
| 161 | | | addEvent(areas[i], 'click', position_legend); |
| 162 | | | } |
| 163 | | | } |
| 164 | | | |
| 165 | | | addEvent(document.getElementById('tb_newfile'), 'click', new_file); |
| 166 | | | addEvent(document.getElementById('tb_addnode'), 'click', add_node); |
| 167 | | | addEvent(document.getElementById('tb_mapprops'), 'click', map_properties); |
| 168 | | | addEvent(document.getElementById('tb_mapstyle'), 'click', map_style); |
| 169 | | | |
| 170 | | | addEvent(document.getElementById('tb_addlink'), 'click', add_link); |
| 171 | | | addEvent(document.getElementById('tb_poslegend'), 'click', position_first_legend); |
| 172 | | | addEvent(document.getElementById('tb_postime'), 'click', position_timestamp); |
| 173 | | | addEvent(document.getElementById('tb_colours'), 'click', manage_colours); |
| 174 | | | addEvent(document.getElementById('tb_manageimages'), 'click', manage_images); |
| 175 | | | addEvent(document.getElementById('tb_prefs'), 'click', prefs); |
| 176 | | | |
| 177 | | | addEvent(document.getElementById('tb_node_cancel'), 'click', cancel_op); |
| 178 | | | addEvent(document.getElementById('tb_node_submit'), 'click', do_submit); |
| 179 | | | addEvent(document.getElementById('node_move'), 'click', move_node); |
| 180 | | | addEvent(document.getElementById('node_delete'), 'click', delete_node); |
| 181 | | | |
| 182 | | | addEvent(document.getElementById('tb_link_cancel'), 'click', cancel_op); |
| 183 | | | addEvent(document.getElementById('tb_link_submit'), 'click', do_submit); |
| 184 | | | addEvent(document.getElementById('link_delete'), 'click', delete_link); |
| 185 | | | |
| 186 | | | addEvent(document.getElementById('tb_map_cancel'), 'click', cancel_op); |
| 187 | | | addEvent(document.getElementById('tb_map_submit'), 'click', do_submit); |
| 188 | | | |
| 189 | | | addEvent(document.getElementById('tb_mapstyle_cancel'), 'click', cancel_op); |
| 190 | | | addEvent(document.getElementById('tb_mapstyle_submit'), 'click', do_submit); |
| 191 | | | |
| 192 | | | addEvent(document.getElementById('tb_colours_cancel'), 'click', cancel_op); |
| 193 | | | addEvent(document.getElementById('tb_colours_submit'), 'click', do_submit); |
| 194 | | | |
| 195 | | | addEvent(document.getElementById('tb_images_cancel'), 'click', cancel_op); |
| 196 | | | addEvent(document.getElementById('tb_images_submit'), 'click', do_submit); |
| 197 | | | |
| 198 | | | var cp = document.getElementById('link_cactipick'); |
| 199 | | | addEvent(cp, 'click', cactipicker); |
| 200 | | | cp.setAttribute('href', '#'); |
| 201 | | | } |
| 202 | | | |
| 203 | | | // used by the cancel button on each of the properties dialogs |
| 204 | | | function cancel_op() |
| 205 | | | { |
| 206 | | | hide_all_dialogs(); |
| 207 | | | document.frmMain.action.value = ''; |
| 208 | | | } |
| 209 | | | |
| 210 | | | function help_handler(e) |
| 211 | | | { |
| 212 | | | var el; |
| 213 | | | |
| 214 | | | if (window.event && window.event.srcElement) |
| 215 | | | { |
| 216 | | | el = window.event.srcElement; |
| 217 | | | } |
| 218 | | | |
| 219 | | | if (e && e.target) |
| 220 | | | { |
| 221 | | | el = e.target; |
| 222 | | | } |
| 223 | | | |
| 224 | | | if (!el) |
| 225 | | | { |
| 226 | | | return; |
| 227 | | | } |
| 228 | | | |
| 229 | | | var objectid = el.id; |
| 230 | | | |
| 231 | | | if ((e.type == 'focus') || (e.type == 'mouseover')) |
| 232 | | | { |
| 233 | | | if (helptexts[objectid]) |
| 234 | | | { |
| 235 | | | var help = helptexts[objectid]; |
| 236 | | | var target = objectid.slice(0, objectid.indexOf('_')) + '_help'; |
| 237 | | | |
| 238 | | | document.getElementById(target).firstChild.nodeValue = help; |
| 239 | | | |
| 240 | | | // alert(target); |
| 241 | | | } |
| 242 | | | } |
| 243 | | | |
| 244 | | | if ((e.type == 'blur') || (e.type == 'mouseout')) |
| 245 | | | { |
| 246 | | | // alert('blurred - figure out default, and apply it.'); |
| 247 | | | |
| 248 | | | var section = objectid.slice(0, objectid.indexOf('_')); |
| 249 | | | var target = section + '_help'; |
| 250 | | | var help = helptexts[section + '_default']; |
| 251 | | | |
| 252 | | | if (help == 'undefined') |
| 253 | | | { |
| 254 | | | alert('OID is: ' + objectid + ' and target is:' + target + ' and section is: ' + section); |
| 255 | | | } |
| 256 | | | |
| 257 | | | document.getElementById(target).firstChild.nodeValue = help; |
| 258 | | | } |
| 259 | | | } |
| 260 | | | |
| 261 | | | function mouse_help_handler(e) |
| 262 | | | { |
| 263 | | | var el; |
| 264 | | | |
| 265 | | | // alert('ddd'); |
| 266 | | | |
| 267 | | | if (window.event && window.event.srcElement) |
| 268 | | | { |
| 269 | | | el = window.event.srcElement; |
| 270 | | | } |
| 271 | | | |
| 272 | | | if (e && e.target) |
| 273 | | | { |
| 274 | | | el = e.target; |
| 275 | | | } |
| 276 | | | |
| 277 | | | if (!el) |
| 278 | | | { |
| 279 | | | return; |
| 280 | | | } |
| 281 | | | |
| 282 | | | var objectid = el.firstChild.id; |
| 283 | | | |
| 284 | | | if ((e.type == 'focus') || (e.type == 'mouseover')) |
| 285 | | | { |
| 286 | | | if (helptexts[objectid]) |
| 287 | | | { |
| 288 | | | var help = helptexts[objectid]; |
| 289 | | | var target = objectid.slice(0, objectid.indexOf('_')) + '_help'; |
| 290 | | | |
| 291 | | | document.getElementById(target).firstChild.nodeValue = help; |
| 292 | | | |
| 293 | | | // alert(target); |
| 294 | | | } |
| 295 | | | } |
| 296 | | | |
| 297 | | | if ((e.type == 'blur') || (e.type == 'mouseout')) |
| 298 | | | { |
| 299 | | | // alert('blurred - figure out default, and apply it.'); |
| 300 | | | |
| 301 | | | var section = objectid.slice(0, objectid.indexOf('_')); |
| 302 | | | var target = section + '_help'; |
| 303 | | | var help = helptexts[section + '_default']; |
| 304 | | | |
| 305 | | | if (help == 'undefined') |
| 306 | | | { |
| 307 | | | alert('OID is: ' + objectid + ' and target is:' + target + ' and section is: ' + section); |
| 308 | | | } |
| 309 | | | |
| 310 | | | document.getElementById(target).firstChild.nodeValue = help; |
| 311 | | | } |
| 312 | | | } |
| 313 | | | |
| 314 | | | // Any clicks in the imagemap end up here. |
| 315 | | | function click_handler(e) |
| 316 | | | { |
| 317 | | | var el; |
| 318 | | | var alt, objectname, objecttype; |
| 319 | | | |
| 320 | | | if (window.event && window.event.srcElement) |
| 321 | | | { |
| 322 | | | el = window.event.srcElement; |
| 323 | | | } |
| 324 | | | |
| 325 | | | if (e && e.target) |
| 326 | | | { |
| 327 | | | el = e.target; |
| 328 | | | } |
| 329 | | | |
| 330 | | | if (!el) |
| 331 | | | { |
| 332 | | | return; |
| 333 | | | } |
| 334 | | | |
| 335 | | | alt = el.getAttribute('alt'); |
| 336 | | | |
| 337 | | | objecttype = alt.slice(0, 4); |
| 338 | | | objectname = alt.slice(5, alt.length); |
| 339 | | | |
| 340 | | | // if we're not in a mode yet... |
| 341 | | | if (document.frmMain.action.value === '') |
| 342 | | | { |
| 343 | | | |
| 344 | | | // if we're waiting for a node specifically (e.g. "make link") then ignore links here |
| 345 | | | if (objecttype == 'NODE') |
| 346 | | | { |
| 347 | | | show_node(objectname); |
| 348 | | | } |
| 349 | | | |
| 350 | | | if (objecttype == 'LINK') |
| 351 | | | { |
| 352 | | | show_link(objectname); |
| 353 | | | } |
| 354 | | | } |
| 355 | | | |
| 356 | | | // we've got a command queued, so do the appropriate thing |
| 357 | | | else |
| 358 | | | { |
| 359 | | | if (objecttype == 'NODE' && document.getElementById('action').value == 'add_link') |
| 360 | | | { |
| 361 | | | document.getElementById('param').value = objectname; |
| 362 | | | document.frmMain.submit(); |
| 363 | | | } |
| 364 | | | |
| 365 | | | else if (objecttype == 'NODE' && document.getElementById('action').value == 'add_link2') |
| 366 | | | { |
| 367 | | | document.getElementById('param').value = objectname; |
| 368 | | | document.frmMain.submit(); |
| 369 | | | } |
| 370 | | | |
| 371 | | | else |
| 372 | | | { |
| 373 | | | // Halfway through one operation, the user has done something unexpected. |
| 374 | | | // reset back to standard state, and see if we can oblige them |
| 375 | | | // alert('A bit confused'); |
| 376 | | | document.frmMain.action.value = ''; |
| 377 | | | hide_all_dialogs() |
| 378 | | | click_handler(e); |
| 379 | | | } |
| 380 | | | } |
| 381 | | | } |
| 382 | | | |
| 383 | | | // used by the Submit button on each of the properties dialogs |
| 384 | | | function do_submit() |
| 385 | | | { |
| 386 | | | document.frmMain.submit(); |
| 387 | | | } |
| 388 | | | |
| 389 | | | function cactipicker() |
| 390 | | | { |
| 391 | | | // make sure it isn't already opened |
| 392 | | | if (!newWindow || newWindow.closed) |
| 393 | | | { |
| 394 | | | newWindow = window.open("", "cactipicker", "status,scrollbars=yes,height=400,width=400"); |
| 395 | | | } |
| 396 | | | |
| 397 | | | else if (newWindow.focus) |
| 398 | | | { |
| 399 | | | // window is already open and focusable, so bring it to the front |
| 400 | | | newWindow.focus(); |
| 401 | | | } |
| 402 | | | |
| 403 | | | newWindow.location = "cacti-pick.php"; |
| 404 | | | } |
| 405 | | | |
| 406 | | | function show_context_help(itemid, targetid) |
| 407 | | | { |
| 408 | | | // var itemid = item.id; |
| 409 | | | var helpbox, helpboxtext, message; |
| 410 | | | // var ct = document.getElementById(targetid); |
| 411 | | | // if(ct) |
| 412 | | | // { |
| 413 | | | message = "We'd show helptext for " + itemid + " in the'" + targetid + "' div"; |
| 414 | | | // } |
| 415 | | | helpbox = document.getElementById(targetid); |
| 416 | | | helpboxtext = helpbox.firstChild; |
| 417 | | | helpboxtext.nodeValue = message; |
| 418 | | | } |
| 419 | | | |
| 420 | | | function manage_colours() |
| 421 | | | { |
| 422 | | | mapmode('existing'); |
| 423 | | | |
| 424 | | | hide_all_dialogs(); |
| 425 | | | document.getElementById('action').value = "set_map_colours"; |
| 426 | | | show_dialog('dlgColours'); |
| 427 | | | } |
| 428 | | | |
| 429 | | | function manage_images() |
| 430 | | | { |
| 431 | | | mapmode('existing'); |
| 432 | | | |
| 433 | | | hide_all_dialogs(); |
| 434 | | | document.getElementById('action').value = "set_image"; |
| 435 | | | show_dialog('dlgImages'); |
| 436 | | | } |
| 437 | | | |
| 438 | | | function prefs() |
| 439 | | | { |
| 440 | | | alert("Not Yet"); |
| 441 | | | } |
| 442 | | | |
| 443 | | | function default_toolbar() |
| 444 | | | { |
| 445 | | | } |
| 446 | | | |
| 447 | | | function working_toolbar() |
| 448 | | | { |
| 449 | | | } |
| 450 | | | |
| 451 | | | function new_file() |
| 452 | | | { |
| 453 | | | self.location = "?action=newfile"; |
| 454 | | | } |
| 455 | | | |
| 456 | | | function mapmode(m) |
| 457 | | | { |
| 458 | | | if (m == 'xy') |
| 459 | | | { |
| 460 | | | document.getElementById('debug').value = "xy"; |
| 461 | | | document.getElementById('xycapture').style.display = 'inline'; |
| 462 | | | document.getElementById('existingdata').style.display = 'none'; |
| 463 | | | } |
| 464 | | | |
| 465 | | | else if (m == 'existing') |
| 466 | | | { |
| 467 | | | document.getElementById('debug').value = "existing"; |
| 468 | | | document.getElementById('xycapture').style.display = 'none'; |
| 469 | | | document.getElementById('existingdata').style.display = 'inline'; |
| 470 | | | } |
| 471 | | | |
| 472 | | | else |
| 473 | | | { |
| 474 | | | alert('invalid mode'); |
| 475 | | | } |
| 476 | | | } |
| 477 | | | |
| 478 | | | function add_node() |
| 479 | | | { |
| 480 | | | document.getElementById('tb_help').innerText = 'Click on the map where you would like to add a new node.'; |
| 481 | | | document.getElementById('action').value = "add_node"; |
| 482 | | | mapmode('xy'); |
| 483 | | | } |
| 484 | | | |
| 485 | | | function delete_node() |
| 486 | | | { |
| 487 | | | if (confirm("This node (and any links it is part of) will be deleted permanently.")) |
| 488 | | | { |
| 489 | | | document.getElementById('action').value = "delete_node"; |
| 490 | | | document.frmMain.submit(); |
| 491 | | | } |
| 492 | | | } |
| 493 | | | |
| 494 | | | function move_node() |
| 495 | | | { |
| 496 | | | hide_dialog('dlgNodeProperties'); |
| 497 | | | document.getElementById('tb_help').innerText = 'Click on the map where you would like to move the node to.'; |
| 498 | | | document.getElementById('action').value = "move_node"; |
| 499 | | | mapmode('xy'); |
| 500 | | | } |
| 501 | | | |
| 502 | | | function add_link() |
| 503 | | | { |
| 504 | | | document.getElementById('tb_help').innerText = 'Click on the first node for one end of the link.'; |
| 505 | | | document.getElementById('action').value = "add_link"; |
| 506 | | | mapmode('existing'); |
| 507 | | | } |
| 508 | | | |
| 509 | | | function delete_link() |
| 510 | | | { |
| 511 | | | if (confirm("This link will be deleted permanently.")) |
| 512 | | | { |
| 513 | | | document.getElementById('action').value = "delete_link"; |
| 514 | | | document.frmMain.submit(); |
| 515 | | | } |
| 516 | | | } |
| 517 | | | |
| 518 | | | function map_properties() |
| 519 | | | { |
| 520 | | | mapmode('existing'); |
| 521 | | | |
| 522 | | | hide_all_dialogs(); |
| 523 | | | document.getElementById('action').value = "set_map_properties"; |
| 524 | | | show_dialog('dlgMapProperties'); |
| 525 | | | } |
| 526 | | | |
| 527 | | | function map_style() |
| 528 | | | { |
| 529 | | | mapmode('existing'); |
| 530 | | | |
| 531 | | | hide_all_dialogs(); |
| 532 | | | document.getElementById('action').value = "set_map_style"; |
| 533 | | | show_dialog('dlgMapStyle'); |
| 534 | | | } |
| 535 | | | |
| 536 | | | function position_timestamp() |
| 537 | | | { |
| 538 | | | document.getElementById('tb_help').innerText = 'Click on the map where you would like to put the timestamp.'; |
| 539 | | | document.getElementById('action').value = "place_stamp"; |
| 540 | | | mapmode('xy'); |
| 541 | | | } |
| 542 | | | |
| 543 | | | // called from clicking the toolbar |
| 544 | | | function position_first_legend() |
| 545 | | | { |
| 546 | | | real_position_legend('DEFAULT'); |
| 547 | | | } |
| 548 | | | |
| 549 | | | // called from clicking on the existing legends |
| 550 | | | function position_legend(e) |
| 551 | | | { |
| 552 | | | var el; |
| 553 | | | var alt, objectname, objecttype; |
| 554 | | | |
| 555 | | | if (window.event && window.event.srcElement) |
| 556 | | | { |
| 557 | | | el = window.event.srcElement; |
| 558 | | | } |
| 559 | | | |
| 560 | | | if (e && e.target) |
| 561 | | | { |
| 562 | | | el = e.target; |
| 563 | | | } |
| 564 | | | |
| 565 | | | if (!el) |
| 566 | | | { |
| 567 | | | return; |
| 568 | | | } |
| 569 | | | |
| 570 | | | // we need to figure out WHICH legend, nowadays |
| 571 | | | alt = el.getAttribute('alt'); |
| 572 | | | |
| 573 | | | // objecttype = alt.slice(0, 5); |
| 574 | | | objectname = alt.slice(7, alt.length); |
| 575 | | | |
| 576 | | | real_position_legend(objectname); |
| 577 | | | |
| 578 | | | //document.getElementById('tb_help').innerText = 'Click on the map where you would like to put the legend.'; |
| 579 | | | //document.getElementById('action').value = "place_legend"; |
| 580 | | | //document.getElementById('param').value = objectname; |
| 581 | | | //mapmode('xy'); |
| 582 | | | } |
| 583 | | | |
| 584 | | | function real_position_legend(scalename) |
| 585 | | | { |
| 586 | | | document.getElementById('tb_help').innerText = 'Click on the map where you would like to put the legend.'; |
| 587 | | | document.getElementById('action').value = "place_legend"; |
| 588 | | | document.getElementById('param').value = scalename; |
| 589 | | | mapmode('xy'); |
| 590 | | | } |
| 591 | | | |
| 592 | | | function show_node(name) |
| 593 | | | { |
| 594 | | | var found = -1; |
| 595 | | | mapmode('existing'); |
| 596 | | | |
| 597 | | | hide_all_dialogs(); |
| 598 | | | |
| 599 | | | var mynode = Nodes[name]; |
| 600 | | | |
| 601 | | | if (mynode) |
| 602 | | | { |
| 603 | | | document.frmMain.action.value = "set_node_properties"; |
| 604 | | | document.frmMain.node_name.value = name; |
| 605 | | | document.frmMain.node_new_name.value = name; |
| 606 | | | |
| 607 | | | document.frmMain.node_name.value = mynode.name; |
| 608 | | | document.frmMain.node_new_name.value = mynode.name; |
| 609 | | | document.frmMain.node_label.value = mynode.label; |
| 610 | | | document.frmMain.node_infourl.value = mynode.infourl; |
| 611 | | | document.frmMain.node_hover.value = mynode.overliburl; |
| 612 | | | |
| 613 | | | if(mynode.iconfile != '') |
| 614 | | | { |
| 615 | | | document.frmMain.node_iconfilename.value = mynode.iconfile; |
| 616 | | | } |
| 617 | | | else |
| 618 | | | { |
| 619 | | | document.frmMain.node_iconfilename.value = '--NONE--'; |
| 620 | | | } |
| 621 | | | |
| 622 | | | |
| 623 | | | // save this here, just in case they choose delete_node or move_node |
| 624 | | | document.getElementById('param').value = mynode.name; |
| 625 | | | |
| 626 | | | show_dialog('dlgNodeProperties'); |
| 627 | | | } |
| 628 | | | } |
| 629 | | | |
| 630 | | | function show_link(name) |
| 631 | | | { |
| 632 | | | var found = -1; |
| 633 | | | mapmode('existing'); |
| 634 | | | |
| 635 | | | hide_all_dialogs(); |
| 636 | | | |
| 637 | | | var mylink = Links[name]; |
| 638 | | | |
| 639 | | | if (mylink) |
| 640 | | | { |
| 641 | | | document.frmMain.link_name.value = mylink.name; |
| 642 | | | document.frmMain.link_target.value = mylink.target; |
| 643 | | | document.frmMain.link_width.value = mylink.width; |
| 644 | | | |
| 645 | | | document.frmMain.link_bandwidth_in.value = mylink.bw_in; |
| 646 | | | |
| 647 | | | if (mylink.bw_in == mylink.bw_out) |
| 648 | | | { |
| 649 | | | document.frmMain.link_bandwidth_out.value = ''; |
| 650 | | | document.frmMain.link_bandwidth_out_cb.checked = 1; |
| 651 | | | } |
| 652 | | | |
| 653 | | | else |
| 654 | | | { |
| 655 | | | document.frmMain.link_bandwidth_out_cb.checked = 0; |
| 656 | | | document.frmMain.link_bandwidth_out.value = mylink.bw_out; |
| 657 | | | } |
| 658 | | | |
| 659 | | | document.frmMain.link_infourl.value = mylink.infourl; |
| 660 | | | document.frmMain.link_hover.value = mylink.overliburl; |
| 661 | | | |
| 662 | | | document.getElementById('link_nodename1').firstChild.nodeValue = mylink.a; |
| 663 | | | document.getElementById('link_nodename1a').firstChild.nodeValue = mylink.a; |
| 664 | | | document.getElementById('link_nodename1b').firstChild.nodeValue = mylink.a; |
| 665 | | | |
| 666 | | | document.getElementById('link_nodename2').firstChild.nodeValue = mylink.b; |
| 667 | | | |
| 668 | | | document.getElementById('param').value = mylink.name; |
| 669 | | | |
| 670 | | | document.frmMain.action.value = "set_link_properties"; |
| 671 | | | |
| 672 | | | show_dialog('dlgLinkProperties'); |
| 673 | | | } |
| 674 | | | } |
| 675 | | | |
| 676 | | | function show_dialog(dlg) |
| 677 | | | { |
| 678 | | | document.getElementById(dlg).style.display = 'block'; |
| 679 | | | } |
| 680 | | | |
| 681 | | | function hide_dialog(dlg) |
| 682 | | | { |
| 683 | | | document.getElementById(dlg).style.display = 'none'; |
| 684 | | | // reset the action. The use pressed Cancel, if this function was called |
| 685 | | | // (that, or they're about to open a new Properties dialog, so the value is irrelevant) |
| 686 | | | document.frmMain.action.value = ''; |
| 687 | | | // alert('ACTION=' + document.frmMain.action.value); |
| 688 | | | } |
| 689 | | | |
| 690 | | | function hide_all_dialogs() |
| 691 | | | { |
| 692 | | | hide_dialog('dlgMapProperties'); |
| 693 | | | hide_dialog('dlgMapStyle'); |
| 694 | | | hide_dialog('dlgLinkProperties'); |
| 695 | | | hide_dialog('dlgNodeProperties'); |
| 696 | | | hide_dialog('dlgColours'); |
| 697 | | | hide_dialog('dlgImages'); |
| 698 | | | } |