| 133 | | |
|---|
| 134 | | |
|---|
| 135 | | } |
|---|
| | 165 | } |
|---|
| | 166 | |
|---|
| | 167 | |
|---|
| | 168 | |
|---|
| | 169 | /*======================= |
|---|
| | 170 | | editControl |
|---|
| | 171 | | |
|---|
| | 172 | |called when the dom is ready and the new layer button is clicked |
|---|
| | 173 | | |
|---|
| | 174 | |sets up a new layer in the global map object and populates toolbox 2 with empty input boxes |
|---|
| | 175 | =========================*/ |
|---|
| | 176 | function editControl(ID){ |
|---|
| | 177 | /*store the toolbox div in tbid (toolboxid)*/ |
|---|
| | 178 | var tbid = $('toolBox2Content'); |
|---|
| | 179 | var tb1SelectedControl = $('tb1ControlListDropdown'); |
|---|
| | 180 | var tb1SelectedPanel = $('tb1ControlListPanelDropdown'); |
|---|
| | 181 | |
|---|
| | 182 | /*get title*/ |
|---|
| | 183 | var controlTitle = map.controls[ID].CLASS_NAME; |
|---|
| | 184 | controlTitle = controlTitle.replace("OpenLayers.Control.", ""); |
|---|
| | 185 | |
|---|
| | 186 | /*add the html to the toolbox*/ |
|---|
| | 187 | tbid.innerHTML = getEmptyToolBox2HTML("block", "Control"); |
|---|
| | 188 | |
|---|
| | 189 | /*Create the control list dropdown in Toolbox 2, called tb2controlListDropdown'*/ |
|---|
| | 190 | $('tb2blcBase').innerHTML += "Control Selected " + createSelectList('tb2ControlListDropdown', 'Control Picklist', 'changeControl(this, ' + ID + ',\"' + tb1SelectedControl.value + '\", true );', getControlListMenu()); //Layer List Dropdown |
|---|
| | 191 | /*Set the value of the controlList dropdown in toolbox2 to the value of the dropdown in toolbox1*/ |
|---|
| | 192 | $('tb2ControlListDropdown').value = tb1SelectedControl.value; |
|---|
| | 193 | |
|---|
| | 194 | |
|---|
| | 195 | console.log(controlTitle); |
|---|
| | 196 | eval("loadControl" + controlTitle + "();"); //Call the loadLayerConfig function; |
|---|
| | 197 | //pass in the ID and false (don't get values from openlayers) |
|---|
| | 198 | populateControlValues(ID, controlTitle, false); //get data from the map object and fill in the inp |
|---|
| | 199 | |
|---|
| | 200 | |
|---|
| | 201 | /*Create the save and reset buttons*/ |
|---|
| | 202 | $('tb2blcButtons').innerHTML += "<br /><br /><input id='resetButton' onclick='populateControlValues( " + ID + ", \"" + tb1SelectedControl.value + "\", true);'type='button' value='Reset'/><input id='saveButton' type='button' class='" + ID + "' value='Save' onclick='saveControlConfig(" + ID + ", false);'><br />"; //Save Button |
|---|
| | 203 | |
|---|
| | 204 | /*Set the the name to "editMode", this allows us to determine if we should clear toolbox2's content or not. If the name = editMode, then we should clear toolbox2 once the layer delete button has been pressed*/ |
|---|
| | 205 | $('layerListItems').set('title', 'editMode'); |
|---|
| | 206 | } |
|---|
| | 207 | |
|---|
| | 208 | |
|---|
| | 291 | |
|---|
| | 292 | |
|---|
| | 293 | |
|---|
| | 294 | |
|---|
| | 295 | |
|---|
| | 296 | /*======================= |
|---|
| | 297 | | populateControlValues(ID, controlName, isControlNew) |
|---|
| | 298 | | |
|---|
| | 299 | |used to fill in default values from OpenLayers.prototype or values stored in the map object, if the layer already exists |
|---|
| | 300 | | |
|---|
| | 301 | |ID is the id of the current layer - an integer |
|---|
| | 302 | |controlName is the name of the layer service which coresponds with OpenLayers.Control.controlName.prototype |
|---|
| | 303 | |isControlNew determines if the layer is a newly created one or already exists |
|---|
| | 304 | =========================*/ |
|---|
| | 305 | /*Warning:Confusion follows*/ |
|---|
| | 306 | /*Because some values in OL are set as 'false' by default we check to see if the prototype != null*/ |
|---|
| | 307 | function populateControlValues(ID, controlName, isControlNew,type){ |
|---|
| | 308 | /*by default, we assuse the isControlNew is "new"*/ |
|---|
| | 309 | if(isControlNew == undefined || isControlNew == null) |
|---|
| | 310 | isControlNew = true; |
|---|
| | 311 | |
|---|
| | 312 | |
|---|
| | 313 | var elName = $('layerListItems').get('title') |
|---|
| | 314 | if(elName == "editMode"){ |
|---|
| | 315 | if($('tb2ControlListDropdown').value == controlName) |
|---|
| | 316 | isControlNew = false; |
|---|
| | 317 | } |
|---|
| | 318 | /*pull values from OpenLayers*/ |
|---|
| | 319 | if(isControlNew == true){ |
|---|
| | 320 | /*Loop through the common values*/ |
|---|
| | 321 | var curDropDownVal = $('tb2ControlListDropdown').value; |
|---|
| | 322 | for (var i = 0; i < $('tb2blcCommon').childNodes.length; i++){ |
|---|
| | 323 | /*set a variable equal to the current node*/ |
|---|
| | 324 | var tempNode = $('tb2blcCommon').childNodes[i]; |
|---|
| | 325 | /*if the childnode has an ID, then it is an input which we will get a value from to put in the map object*/ |
|---|
| | 326 | if (tempNode.type == "text"){ |
|---|
| | 327 | //By default, set the value to nothing. If something exists, override the null value |
|---|
| | 328 | tempNode.value = ''; |
|---|
| | 329 | /*Get the map name value*/ |
|---|
| | 330 | /*Check the DEFAULT_PARAMS and everything else*/ |
|---|
| | 331 | if (OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS != null){ |
|---|
| | 332 | if(OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS[tempNode.name] != null) |
|---|
| | 333 | tempNode.value = OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS[tempNode.name]; |
|---|
| | 334 | } |
|---|
| | 335 | if(OpenLayers.Control[curDropDownVal].prototype[tempNode.name] != null){ |
|---|
| | 336 | tempNode.value = OpenLayers.Control[curDropDownVal].prototype[tempNode.name]; |
|---|
| | 337 | } |
|---|
| | 338 | $(tempNode).erase('class'); //clear the ValueUpdated class - it won't think the value is updated |
|---|
| | 339 | } |
|---|
| | 340 | /* SELECT LIST*/ |
|---|
| | 341 | else if(tempNode.type == "select-one" ){ |
|---|
| | 342 | //By default, set the value to 0. Override the value is necessary |
|---|
| | 343 | tempNode.selectedIndex = 0; |
|---|
| | 344 | if (OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS != null || OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS != undefined){ |
|---|
| | 345 | if(OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS[tempNode.name] != null){ |
|---|
| | 346 | var olVal = OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS[tempNode.name]; |
|---|
| | 347 | /*check for True / False lists*/ |
|---|
| | 348 | if(tempNode.options[0].value == "True" || tempNode.options[0].value == "False"){ |
|---|
| | 349 | if( Boolean(tempNode.options[0].name) == olVal) |
|---|
| | 350 | tempNode.selectedIndex = 0; |
|---|
| | 351 | if( Boolean(tempNode.options[1].name) == olVal) |
|---|
| | 352 | tempNode.selectedIndex = 1; |
|---|
| | 353 | } |
|---|
| | 354 | /*check for Jpg / Gif / Png, and other type of lists*/ |
|---|
| | 355 | else{ |
|---|
| | 356 | if(tempNode.options[0].value == olVal) |
|---|
| | 357 | tempNode.selectedIndex = 0; |
|---|
| | 358 | if(tempNode.options[1].value == olVal) |
|---|
| | 359 | tempNode.selectedIndex = 1; |
|---|
| | 360 | if(tempNode.options[2]){ |
|---|
| | 361 | if(tempNode.options[2].value == olVal) |
|---|
| | 362 | tempNode.selectedIndex = 2; |
|---|
| | 363 | } |
|---|
| | 364 | if(tempNode.options[3]){ |
|---|
| | 365 | if(tempNode.options[3].value == olVal) |
|---|
| | 366 | tempNode.selectedIndex = 3; |
|---|
| | 367 | } |
|---|
| | 368 | } |
|---|
| | 369 | } |
|---|
| | 370 | } |
|---|
| | 371 | if(OpenLayers.Control[curDropDownVal].prototype[tempNode.name] != null){ |
|---|
| | 372 | var olVal = OpenLayers.Control[curDropDownVal].prototype[tempNode.name]; |
|---|
| | 373 | /*check for True / False lists*/ |
|---|
| | 374 | if(tempNode.options[0].value == "True" || tempNode.options[0].value == ''){ |
|---|
| | 375 | if( Boolean(tempNode.options[0].name) == olVal){ |
|---|
| | 376 | tempNode.selectedIndex = 0; |
|---|
| | 377 | } |
|---|
| | 378 | if( Boolean(tempNode.options[1].name) == olVal){ |
|---|
| | 379 | tempNode.selectedIndex = 1; |
|---|
| | 380 | } |
|---|
| | 381 | } |
|---|
| | 382 | /*check for Jpg / Gif / Png, and other type of lists*/ |
|---|
| | 383 | else{ |
|---|
| | 384 | if(tempNode.options[0].value == olVal) |
|---|
| | 385 | tempNode.selectedIndex = 0; |
|---|
| | 386 | if(tempNode.options[1].value == olVal) |
|---|
| | 387 | tempNode.selectedIndex = 1; |
|---|
| | 388 | if(tempNode.options[2]){ |
|---|
| | 389 | if(tempNode.options[2].value == olVal) |
|---|
| | 390 | tempNode.selectedIndex = 2; |
|---|
| | 391 | } |
|---|
| | 392 | if(tempNode.options[3]){ |
|---|
| | 393 | if(tempNode.options[3].value == olVal) |
|---|
| | 394 | tempNode.selectedIndex = 3; |
|---|
| | 395 | } |
|---|
| | 396 | } |
|---|
| | 397 | $(tempNode).erase('class'); //clear the ValueUpdated class - it won't think the value is updated |
|---|
| | 398 | } |
|---|
| | 399 | } |
|---|
| | 400 | } |
|---|
| | 401 | |
|---|
| | 402 | /*CHECK ADVANCED*/ |
|---|
| | 403 | for (var i = 0; i < $('tb2blcAdvanced').childNodes.length; i++){ |
|---|
| | 404 | /*set a variable equal to the current node*/ |
|---|
| | 405 | var tempNode = $('tb2blcAdvanced').childNodes[i]; |
|---|
| | 406 | /*if the childnode has an ID, then it is an input which we will get a value from to put in the map object*/ |
|---|
| | 407 | if (tempNode.type == "text"){ |
|---|
| | 408 | //By default, set the value to nothing. If something exists, override the null value |
|---|
| | 409 | tempNode.value = ''; |
|---|
| | 410 | /*Get the map name value*/ |
|---|
| | 411 | /*Check the DEFAULT_PARAMS and everything else*/ |
|---|
| | 412 | if (OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS != null){ |
|---|
| | 413 | if(OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS[tempNode.name] != null) |
|---|
| | 414 | tempNode.value = OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS[tempNode.name]; |
|---|
| | 415 | } |
|---|
| | 416 | if(OpenLayers.Control[curDropDownVal].prototype[tempNode.name] != null){ |
|---|
| | 417 | tempNode.value = OpenLayers.Control[curDropDownVal].prototype[tempNode.name]; |
|---|
| | 418 | |
|---|
| | 419 | } |
|---|
| | 420 | $(tempNode).erase('class'); //clear the ValueUpdated class - it won't think the value is updated |
|---|
| | 421 | } |
|---|
| | 422 | |
|---|
| | 423 | /* SELECT LIST*/ |
|---|
| | 424 | else if(tempNode.type == "select-one" ){ |
|---|
| | 425 | //By default, set the value to 0. Override the value is necessary |
|---|
| | 426 | tempNode.selectedIndex = 0; |
|---|
| | 427 | if (OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS != null || OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS != undefined){ |
|---|
| | 428 | if(OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS[tempNode.name] != null){ |
|---|
| | 429 | var olVal = OpenLayers.Control[curDropDownVal].prototype.DEFAULT_PARAMS[tempNode.name]; |
|---|
| | 430 | /*check for True / False lists*/ |
|---|
| | 431 | if(tempNode.options[0].value == "True" || tempNode.options[0].value == "False"){ |
|---|
| | 432 | if( Boolean(tempNode.options[0].name) == olVal) |
|---|
| | 433 | tempNode.selectedIndex = 0; |
|---|
| | 434 | if( Boolean(tempNode.options[1].name) == olVal) |
|---|
| | 435 | tempNode.selectedIndex = 1; |
|---|
| | 436 | } |
|---|
| | 437 | /*check for Jpg / Gif / Png, and other type of lists*/ |
|---|
| | 438 | else{ |
|---|
| | 439 | if(tempNode.options[0].value == olVal) |
|---|
| | 440 | tempNode.selectedIndex = 0; |
|---|
| | 441 | if(tempNode.options[1].value == olVal) |
|---|
| | 442 | tempNode.selectedIndex = 1; |
|---|
| | 443 | if(tempNode.options[2]){ |
|---|
| | 444 | if(tempNode.options[2].value == olVal) |
|---|
| | 445 | tempNode.selectedIndex = 2; |
|---|
| | 446 | } |
|---|
| | 447 | if(tempNode.options[3]){ |
|---|
| | 448 | if(tempNode.options[3].value == olVal) |
|---|
| | 449 | tempNode.selectedIndex = 3; |
|---|
| | 450 | } |
|---|
| | 451 | } |
|---|
| | 452 | } |
|---|
| | 453 | } |
|---|
| | 454 | if(OpenLayers.Control[curDropDownVal].prototype[tempNode.name] != null){ |
|---|
| | 455 | var olVal = OpenLayers.Control[curDropDownVal].prototype[tempNode.name]; |
|---|
| | 456 | /*check for True / False lists*/ |
|---|
| | 457 | if(tempNode.options[0].value == "True" || tempNode.options[0].value == ''){ |
|---|
| | 458 | if( Boolean(tempNode.options[0].name) == olVal){ |
|---|
| | 459 | tempNode.selectedIndex = 0; |
|---|
| | 460 | } |
|---|
| | 461 | if( Boolean(tempNode.options[1].name) == olVal){ |
|---|
| | 462 | tempNode.selectedIndex = 1; |
|---|
| | 463 | } |
|---|
| | 464 | } |
|---|
| | 465 | /*check for Jpg / Gif / Png, and other type of lists*/ |
|---|
| | 466 | else{ |
|---|
| | 467 | if(tempNode.options[0].value == olVal) |
|---|
| | 468 | tempNode.selectedIndex = 0; |
|---|
| | 469 | if(tempNode.options[1].value == olVal) |
|---|
| | 470 | tempNode.selectedIndex = 1; |
|---|
| | 471 | if(tempNode.options[2]){ |
|---|
| | 472 | if(tempNode.options[2].value == olVal) |
|---|
| | 473 | tempNode.selectedIndex = 2; |
|---|
| | 474 | } |
|---|
| | 475 | if(tempNode.options[3]){ |
|---|
| | 476 | if(tempNode.options[3].value == olVal) |
|---|
| | 477 | tempNode.selectedIndex = 3; |
|---|
| | 478 | } |
|---|
| | 479 | } |
|---|
| | 480 | $(tempNode).erase('class'); //clear the ValueUpdated class - it won't think the value is updated |
|---|
| | 481 | } |
|---|
| | 482 | } |
|---|
| | 483 | } |
|---|
| | 484 | |
|---|
| | 485 | |
|---|
| | 486 | |
|---|
| | 487 | } |
|---|
| | 488 | |
|---|
| | 489 | /*If the layer is not new, grab values from the map object*/ |
|---|
| | 490 | if(isControlNew == false){ |
|---|
| | 491 | /*Loop through the common values*/ |
|---|
| | 492 | for (var i = 0; i < $('tb2blcCommon').childNodes.length; i++){ |
|---|
| | 493 | /*set a variable equal to the current node*/ |
|---|
| | 494 | var tempNode = $('tb2blcCommon').childNodes[i]; |
|---|
| | 495 | /*if the childnode has an ID, then it is an input which we will get a value from to put in the map object*/ |
|---|
| | 496 | if (tempNode.type == "text" || tempNode.type == "select-one" ){ |
|---|
| | 497 | /*Get the map name value*/ |
|---|
| | 498 | var mapLayerVal = map.controls[ID][tempNode.name]; |
|---|
| | 499 | /*If there is valid data, fill in the current form*/ |
|---|
| | 500 | if(mapLayerVal != undefined || mapLayerVal != null){ |
|---|
| | 501 | tempNode.value = map.controls[ID][tempNode.name]; |
|---|
| | 502 | } |
|---|
| | 503 | else{ |
|---|
| | 504 | tempNode.value = ''; |
|---|
| | 505 | if(tempNode.type == "select-one" ) |
|---|
| | 506 | tempNode.selectedIndex = 0; |
|---|
| | 507 | $(tempNode).erase('class'); //clear the class - it won't think the value is updated |
|---|
| | 508 | } |
|---|
| | 509 | } |
|---|
| | 510 | } |
|---|
| | 511 | /*Loop through the advanced values*/ |
|---|
| | 512 | for (var i = 0; i < $('tb2blcAdvanced').childNodes.length; i++){ |
|---|
| | 513 | /*set a variable equal to the current node*/ |
|---|
| | 514 | var tempNode = $('tb2blcAdvanced').childNodes[i]; |
|---|
| | 515 | /*if the childnode has an ID, then it is an input which we will get a value from to put in the map object*/ |
|---|
| | 516 | if (tempNode.type == "text" || tempNode.type == "select-one"){ |
|---|
| | 517 | /*Get the map name value*/ |
|---|
| | 518 | var mapLayerVal = map.controls[ID][tempNode.name]; |
|---|
| | 519 | /*If there is valid data, fill in the current form*/ |
|---|
| | 520 | if(mapLayerVal != undefined || mapLayerVal != null){ |
|---|
| | 521 | tempNode.value = map.controls[ID][tempNode.name]; |
|---|
| | 522 | } |
|---|
| | 523 | else{ |
|---|
| | 524 | tempNode.value = ''; |
|---|
| | 525 | if(tempNode.type == "select-one" ) |
|---|
| | 526 | tempNode.selectedIndex = 0; |
|---|
| | 527 | $(tempNode).erase('class'); //clear the class - it won't think the value is updated |
|---|
| | 528 | } |
|---|
| | 529 | } |
|---|
| | 530 | } |
|---|
| | 531 | } |
|---|
| | 532 | } |
|---|
| | 533 | |
|---|
| | 534 | |
|---|