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