1 2$.fn.onChangeZipCodeToCity = function(options) { 3 4 var settings = $.extend({ 5 target: null, 6 handleData: null 7 }, options || {}); 8 9 var $this = $(this); 10 var $target = settings.target; 11 var run = true; 12 var timeoutID; 13 14 $this.bind("change", function () { 15 // TODO: an keyup binden und auf geänderten Eingabewert prüfen 16 if (timeoutID) clearTimeout(timeoutID); 17 timeoutID = setTimeout(changeAction, 200); 18 }); 19 20 function changeAction() { 21 if (run) { 22 run = false; 23 $target.text($this.val()); 24 askPLZ(); 25 } 26 run = true; 27 } 28 29 function askPLZ() { 30 if ($this.length > 0) { 31 $target.prop('disabled', true); 32 $target.attr("required", false); 33 if ($this.val().length == 5 && $.isNumeric($this.val())) { 34 35 $.ajax('?c=ospreisrechner&a=findort', { 36 'dataType': 'json', 37 'data': $this.serialize() 38 }).done(function (data) { 39 if (data.aOrte != '' && $this.val().length <= 5) { 40 if (typeof data.aOrte != 'undefined') { 41 $target.prop('disabled', false); 42 $target.empty(); 43 if (data.aOrte.length > 1) { 44 $target.append('<option>Bitte wählen</option>'); 45 } 46 47 var i = 1; 48 $.each(data.aOrte, function (key, val) { 49 if (val.ID == val.AktuellerOrt) { 50 var sel = ' selected="selected"'; 51 } else { 52 var sel = ''; 53 } 54 $target.append('<option value=' + i + '' + sel + '>' + val.Ort + '</option>'); 55 i++; 56 }); 57 $target.attr("required", true); 58 } 59 } else { 60 $('#error_message').html('<em>Bitte geben Sie eine gültige Postleitzahl ein.</em><br /><br />'); 61 $this.val(''); 62 $target.empty(); 63 $target.append('<option>- Kein Wert -</option>'); 64 $target.prop('disabled', true); 65 } 66 67 if( typeof handleData === 'function' ) { 68 handleData(data); 69 } 70 71 }); //end done 72 } else { 73 if ($this.val().length > 5) { 74 $('#error_message').html('Bitte geben Sie eine gültige Postleitzahl ein!'); 75 $this.val(''); 76 $target.empty(); 77 $target.append('<option>- Kein Wert -</option>'); 78 $target.prop('disabled', true); 79 } 80 } 81 } 82 } 83 84 askPLZ(); 85 86 return this; 87} 88 89$(document).ready(function ($) { 90 91 $('#checkboxTagNacht').parent().parent().parent().parent().hide(); 92 $('#hint-new').hide(); 93 $('#hint-change').hide(); 94 $('#heading_more_strom').hide(); 95 $('#heading_more_gas').hide(); 96 97 /* 98 * 99 * Aktives Eingeabefeld hervorheben 100 * 101 * 102 103 $('#PLZ, #KWhStromT, #KWhGas, #sPlzCheck, .inputText').focusin(function() { 104 $(this).css({ 105 backgroundColor: "#E0ECF8" 106 }); 107 }); 108 109 $('#PLZ, #KWhStromT, #KWhGas, #sPlzCheck, .inputText').focusout(function() { 110 $(this).css({ 111 backgroundColor: "#ffffff" 112 }); 113 }); 114 115 * 116 * 117 * Ein- und Ausblenden von Strom- und Gaseingabe 118 * 119 */ 120 121 if ($('#KWhStromT').val()) { 122 $('#checkboxTagNacht').prop('disabled', false); 123 $('#KWhStromT').prop('disabled', false); 124 $('#Strom').prop('disabled', false); 125 if ($('#KWhStromT').val() != '') { 126 $('#Strom').parent().hide(); 127 } 128 } else { 129 $('#checkboxTagNacht').prop('disabled', true); 130 $('#KWhStromT').prop('disabled', true); 131 $('#Strom').prop('disabled', true); 132 if ($('#KWhStromT').val() != '') { 133 $('#Strom').parent().show(); 134 } 135 } 136 if ($('#KWhGas').val()) { 137 $('#KWhGas').prop('disabled', false); 138 $('#Gas').prop('disabled', false); 139 if ($('#KWhGas').val() != '') { 140 $('#Gas').parent().hide(); 141 } 142 } else { 143 $('#KWhGas').prop('disabled', true); 144 $('#Gas').prop('disabled', true); 145 if ($('#KWhGas').val() != '') { 146 $('#Gas').parent().show(); 147 } 148 } 149 150 151 $('#PLZ').focusout(function () { 152 if ($('#checkboxStrom').is(':checked')) { 153 clickStrom(); 154 } 155 if ($('#checkboxGas').is(':checked')) { 156 clickGas(); 157 } 158 });
159 160 clickStrom(); 161 clickGas(); 162 $('#checkboxStrom').click(function (event) { 163 clickStrom(); 164 clickGas(); 165 }); 166 $('#checkboxGas').click(function (event) { 167 clickGas(); 168 clickStrom(); 169 }); 170 function clickStrom() { 171 172 if ($('#checkboxStrom').is(':checked')) { 173 if ($('#PLZ').val().length == 5) { 174 $('#checkboxTagNacht').prop('disabled', false); 175 $('#KWhStromT').prop('disabled', false); 176 $('#KWhStromN').prop('disabled', false); 177 $('#Strom').prop('disabled', false); 178 $("#KWhStromT").attr("required", true); 179 $("#checkboxGas").attr("required", false); 180 } else { 181 $('#Strom').val(''); 182 $('#KWhStromT').val(''); 183 $('#checkboxTagNacht').prop('checked', false); 184 $('#checkboxTagNacht').prop('disabled', true); 185 $('#KWhStromT').prop('disabled', true); 186 $('#Strom').prop('disabled', true); 187 $("#KWhStromT").attr("required", false); 188 $("#checkboxStrom").attr("required", true); 189 if ($('#checkboxGas').is(':checked')) { 190 $("#checkboxStrom").attr("required", false); 191 } 192 clickTagNacht(); 193 } 194 $('#KWhStromT').parent().show('slow'); 195 if (showIfPrivate() && $('#KWhStromT').val() == '') { 196 $('#Strom').parent().show('slow'); 197 } 198 } else { 199 $('#Strom').val(''); 200 $('#KWhStromT').val(''); 201 $('#checkboxTagNacht').prop('checked', false); 202 $('#checkboxTagNacht').prop('disabled', true); 203 $('#KWhStromT').prop('disabled', true); 204 $('#Strom').prop('disabled', true); 205 $('#checkboxTagNacht').parent().parent().parent().parent().hide('slow'); 206 $('#KWhStromT').parent().hide('slow'); 207 $('#Strom').parent().hide('slow'); 208 $("#KWhStromT").attr("required", false); 209 $("#checkboxStrom").attr("required", true); 210 if ($('#checkboxGas').is(':checked')) { 211 $("#checkboxStrom").attr("required", false); 212 } 213 clickTagNacht(); 214 } 215 } 216 217 function clickGas() { 218 if ($('#checkboxGas').is(':checked')) { 219 if ($('#PLZ').val().length == 5) { 220 $('#KWhGas').prop('disabled', false); 221 $('#Gas').prop('disabled', false); 222 $("#KWhGas").attr("required", true); 223 $("#checkboxStrom").attr("required", false); 224 } else { 225 $('#Gas').val(''); 226 $('#KWhGas').val(''); 227 $('#KWhGas').prop('disabled', true); 228 $('#Gas').prop('disabled', true); 229 $("#KWhGas").attr("required", false); 230 $("#checkboxGas").attr("required", true); 231 if ($('#checkboxStrom').is(':checked')) { 232 $("#checkboxGas").attr("required", false); 233 } 234 } 235 $('#KWhGas').parent().show('slow'); 236 if (showIfPrivate() && $('#KWhGas').val() == '') { 237 $('#Gas').parent().show('slow'); 238 } 239 } else { 240 $('#Gas').val(''); 241 $('#KWhGas').val(''); 242 $('#KWhGas').prop('disabled', true); 243 $('#Gas').prop('disabled', true); 244 $('#KWhGas').parent().hide('slow'); 245 $('#Gas').parent().hide('slow'); 246 $("#KWhGas").attr("required", false); 247 $("#checkboxGas").attr("required", true); 248 if ($('#checkboxStrom').is(':checked')) { 249 $("#checkboxGas").attr("required", false); 250 } 251 } 252 } 253 254 clickTagNacht(); 255 $('#checkboxTagNacht').click(function (event) { 256 clickTagNacht(); 257 }); 258 function clickTagNacht() { 259 if ($('#checkboxTagNacht').is(':checked')) { 260 $('#KWhStromN').parent().show('slow'); 261 $('#KWhStromN').prop('disabled', false); 262 $('#KWhStromT').parent().find('label').html('kWh Strom Tag / Jahr <sup>*</sup>'); 263 $("#KWhStromN").attr("required", true); 264 } else { 265 $('#KWhStromT').parent().find('label').html('kWh Strom (Verbrauch / Jahr) <sup>*</sup>'); 266 $('#KWhStromN').parent().hide('slow'); 267 $('#KWhStromN').val(''); 268 $('#KWhStromN').prop('disabled', true); 269 $("#KWhStromN").attr("required", false); 270 } 271 } 272 273 /* 274 * 275 * Automatisches Befüllen ausblenden, wenn manuell eingegeben 276 * 277 */ 278 if ($('#KWhStromT').val() != '') { 279 $('#Strom').parent().hide(); 280 } else { 281 if (showIfPrivate()) { 282 $('#Strom').parent().show(); 283 } 284 } 285 286 if ($('#KWhGas').val() != '') { 287 $('#Gas').parent().hide(); 288 } else { 289 if (showIfPrivate()) { 290 $('#Gas').parent().show(); 291 } 292 } 293 294 if (showIfPrivate() 295 && $('#checkboxStrom').is(':checked') 296 && $('#KWhStromT').val() == '') { 297 $('#Strom').parent().show('slow'); 298 } else { 299 $('#Strom').parent().hide('slow'); 300 } 301 if (showIfPrivate() 302 && $('#checkboxGas').is(':checked') 303 && $('#KWhGas').val() == '') { 304 $('#Gas').parent().show('slow'); 305 } else { 306 $('#Gas').parent().hide('slow'); 307 } 308 309 $('#KWhStromT').focusout(function () { 310 if ($('#KWhStromT').val() != '') { 311 $('#Strom').parent().hide('slow'); 312 } else { 313 if (showIfPrivate()) { 314 $('#Strom').parent().show('slow'); 315 } 316 } 317 });
318 319 $('#KWhGas').focusout(function () { 320 if ($('#KWhGas').val() != '') { 321 $('#Gas').parent().hide('slow'); 322 } else { 323 if (showIfPrivate()) { 324 $('#Gas').parent().show('slow'); 325 } 326 } 327 }); 328 329 $('#selectPrivatGeschaeft').change(function () { 330 if (showIfPrivate() 331 && $('#checkboxStrom').is(':checked') 332 && $('#KWhStromT').val() == '') { 333 $('#Strom').parent().show('slow'); 334 } else { 335 $('#Strom').parent().hide('slow'); 336 } 337 if (showIfPrivate() 338 && $('#checkboxGas').is(':checked') 339 && $('#KWhGas').val() == '') { 340 $('#Gas').parent().show('slow'); 341 } else { 342 $('#Gas').parent().hide('slow'); 343 } 344 }); 345 346 function showIfPrivate() { 347 if ($('#selectPrivatGeschaeft').val() == 1) { 348 return false; 349 } else { 350 return true; 351 } 352 } 353 354 355 /** 356 * kWh je nach Auswahl befüllen 357 */ 358 $('#Strom').change(function () { 359 switch ($('#Strom').val()) { 360 case '1': 361 $('#KWhStromT').val("1500"); 362 break; 363 case '2': 364 $('#KWhStromT').val("2300"); 365 break; 366 case '3': 367 $('#KWhStromT').val("2800"); 368 break; 369 case '4': 370 $('#KWhStromT').val("3300"); 371 break; 372 case '5': 373 $('#KWhStromT').val("3800"); 374 break; 375 case '6': 376 $('#KWhStromT').val("4300"); 377 break; 378 default: 379 $('#KWhStromT').val(""); 380 break; 381 } 382 }); 383 $('#Gas').change(function () { 384 switch ($('#Gas').val()) { 385 case '1': 386 $('#KWhGas').val("3000"); 387 break; 388 case '2': 389 $('#KWhGas').val("7000"); 390 break; 391 case '3': 392 $('#KWhGas').val("12000"); 393 break; 394 case '4': 395 $('#KWhGas').val("14000"); 396 break; 397 case '5': 398 $('#KWhGas').val("18000"); 399 break; 400 case '6': 401 $('#KWhGas').val("21000"); 402 break; 403 case '7': 404 $('#KWhGas').val("25000"); 405 break; 406 default: 407 $('#KWhGas').val(""); 408 break; 409 } 410 }); 411 412 /** 413 * Bei Anrede 'Damen und Herren', Vorname kein Pflichtfeld 414 */ 415 $('#anrede').change(function () { 416 if ($(this).val() == 'Damen und Herren') { 417 $("#first-name").attr("required", false); 418 $("#first-name").parent().find('label').html('Vorname'); 419 } else { 420 $("#first-name").attr("required", true); 421 $("#first-name").parent().find('label').html('Vorname <sup>*</sup>'); 422 } 423 }); 424 425 /** 426 * Anzeige Wechsel-/Neukunde 427 */ 428 if (!$("#neubezug:checked").val() == "1") { 429 $("#neubezug").attr("required", true); 430 } 431 432 function wechsel() { 433 if ($("#wechsel:checked").val() == "2") { 434 $('.wechsel').show('slow'); 435 $("#BisherLieferantStrom").attr("required", true); 436 $("#BisherKundennummerStrom").attr("required", true); 437 $("#BisherLieferantGas").attr("required", true); 438 $("#BisherKundennummerGas").attr("required", true); 439 $("#neubezug").attr("required", false); 440 } else { 441 $('.wechsel').hide(); 442 } 443 } 444 wechsel(); 445 $("#wechsel").click(function () { 446 wechsel(); 447 }); 448 function neubezug() { 449 if ($("#neubezug:checked").val() == "1") { 450 $('.wechsel').hide('slow'); 451 $("#BisherLieferantStrom").attr("required", false); 452 $("#BisherKundennummerStrom").attr("required", false); 453 $("#BisherLieferantGas").attr("required", false); 454 $("#BisherKundennummerGas").attr("required", false); 455 $('#BisherLieferant').val(''); 456 $('#BisherKundennummer').val(''); 457 $('#BisherWeitereKundennummer').val(''); 458 $("#wechsel").attr("required", false); 459 } 460 } 461 neubezug(); 462 $("#neubezug").click(function () { 463 neubezug(); 464 });
465 /* 466 * 467 * Andere Lieferanschrift 468 * 469 */ 470 function andersLiefer() { 471 if ($('#checkKontaktanschrift').is(':checked')) { 472 $(".lieferNeu").show('slow'); 473 $("#UserLieferStrasse").attr("required", true); 474 $("#UserLieferHausnr").attr("required", true); 475 } else { 476 $('.lieferNeu').hide('slow'); 477 $("#UserLieferStrasse").attr("required", false); 478 $("#UserLieferHausnr").attr("required", false); 479 } 480 } 481 andersLiefer(); 482 $('#checkKontaktanschrift').click(function () { 483 andersLiefer(); 484 }); 485 /* 486 * 487 * Andere Rechnungsanschrift 488 * 489 */ 490 function andereRechnung() { 491 if ($('#checkRechnungsanschrift').is(':checked')) { 492 $('.rechnungNeu').show('slow'); 493 $("#UserRechnungsName").attr("required", true); 494 $("#UserRechnungsStrasse").attr("required", true); 495 $("#UserRechnungsHausnr").attr("required", true); 496 $("#UserRechnungsPLZ").attr("required", true); 497 $("#UserRechnungsOrt").attr("required", true); 498 } else { 499 $('.rechnungNeu').hide('slow'); 500 $("#UserRechnungsName").attr("required", false); 501 $("#UserRechnungsStrasse").attr("required", false); 502 $("#UserRechnungsHausnr").attr("required", false); 503 $("#UserRechnungsPLZ").attr("required", false); 504 $("#UserRechnungsOrt").attr("required", false); 505 } 506 } 507 andereRechnung(); 508 $('#checkRechnungsanschrift').click(function () { 509 andereRechnung(); 510 }); 511 /* 512 * 513 * Anzeige SEPA 514 * 515 */ 516 function SEPA() { 517 if ($('#checkSEPA').is(':checked')) { 518 $('.sepa').show('slow'); 519 $("#UserKontoinhaber").attr("required", true); 520 $("#UserBank").attr("required", true); 521 $("#UserBLZ").attr("required", true); 522 $("#UserIBAN").attr("required", true); 523 } else { 524 $('.sepa').hide('slow'); 525 $("#UserKontoinhaber").attr("required", false); 526 $("#UserBank").attr("required", false); 527 $("#UserBLZ").attr("required", false); 528 $("#UserIBAN").attr("required", false); 529 } 530 } 531 SEPA(); 532 $('#checkSEPA').click(function () { 533 SEPA(); 534 }); 535 536 537 var birthday = $( "#UserGeb" ); 538 birthday.datepicker( OsSettings.germanDate ); 539 birthday.datepicker( "option", "maxDate", "-18Y" ); 540 541 /* 542 * ############## 543 * Kontrolle Datum Lieferbeginn 544 * ############## 545 */ 546 var $lieferbeginn = $( '#UserLieferbeginn' ); 547 548 $lieferbeginn.datepicker( OsSettings.germanDate ); 549 550 $lieferbeginn.focusout(function () { 551 if ($("#neubezug:checked").val() == "1") { 552 if (!datumNeubezug($lieferbeginn.val())) { 553 $lieferbeginn.val(''); 554 } else { 555 $('#hint-change').hide('slow'); 556 $('#hint-new').hide('slow'); 557 } 558 } 559 if ($("#wechsel:checked").val() == "2") { 560 if (!datumWechsel($lieferbeginn.val())) { 561 $lieferbeginn.val(''); 562 } else { 563 $('#hint-change').hide('slow'); 564 $('#hint-new').hide('slow'); 565 } 566 } 567 }); 568 $('#neubezug').click(function () { 569 if (!datumNeubezug($lieferbeginn.val())) { 570 $lieferbeginn.val(''); 571 } 572 }); 573 $('#wechsel').click(function () { 574 if (!datumWechsel($lieferbeginn.val())) { 575 $lieferbeginn.val(''); 576 } 577 }); 578 function datumNeubezug(datum) { 579 $('#hint-change').hide('slow'); 580 581 datum = dateToArray(datum); 582 583 if (datum == false) { 584 return false; 585 } 586 587 var kontrolldatum = new Date(); 588 var numberOfDaysToRemove = 42; 589 kontrolldatum.setDate(kontrolldatum.getDate() - numberOfDaysToRemove); 590 datum = new Date(datum[2], datum[1] - 1, datum[0]); 591 datum.setDate(datum.getDate()); // ?? 592 kontrolldatum.setHours(0); 593 kontrolldatum.setMinutes(0); 594 kontrolldatum.setSeconds(0); 595 if (kontrolldatum <= datum) { 596 $('#hint-new').hide('slow'); 597 return true; 598 } else { 599 $('#hint-new').show('slow'); 600 return false; 601 } 602 } 603 604 function datumWechsel(datum) { 605 $('#hint-new').hide('slow'); 606 607 datum = dateToArray(datum); 608 609 if (datum == false) { 610 return false; 611 } 612 613 var kontrolldatum = new Date(); 614 var numberOfDaysToAdd = 14; 615 616 kontrolldatum.setDate(kontrolldatum.getDate() + numberOfDaysToAdd); 617 datum = new Date(datum[2], datum[1] - 1, datum[0]); 618 datum.setDate(datum.getDate()); 619 kontrolldatum.setHours(0); 620 kontrolldatum.setMinutes(0); 621 kontrolldatum.setSeconds(0); 622 if (kontrolldatum <= datum) { 623 $('#hint-change').hide('slow'); 624 return true; 625 } else { 626 $('#hint-change').show('slow'); 627 return false; 628 } 629 } 630 631 632 /* 633 * ############## 634 * Kontrolle gültiges Datum 635 * ############## 636 */ 637 $lieferbeginn.focusout( function () { 638 if ( !gueltigesDatum( $lieferbeginn.val() ) ) { 639 $lieferbeginn.val( '' ); 640 } 641 } ); 642 643 /* 644 * ############## 645 * Errormessage bei Erklärungen ändern 646 * ############## 647 */ 648 649 $('#page3 input[required=required]').on('change invalid', function () { 650 var checkbox = $(this).get(0); 651 652 checkbox.setCustomValidity(''); 653 654 if (!checkbox.validity.valid) { 655 checkbox.setCustomValidity('Bitte bestätigen Sie, indem Sie das Kästchen aktivieren/anklicken.'); 656 } 657 });
658 659 /* 660 * ############## 661 * AJAX 662 * ############## 663 */ 664 665 /** 666 * 667 * PLZ abfragen und entsprechende Felder anzeigen / ausblenden 668 * 669 */ 670 671 var $plz = $('#PLZ'); 672 var $ort = $('#Ort'); 673 674 $('#error_message').empty(); 675 $plz.change(function () { 676 $('#error_message').empty(); 677 }); 678 $plz.keyup(function () { 679 $('#error_message').empty(); 680 }); 681 $plz.onChangeZipCodeToCity({ 682 target: $ort, 683 handleData: function(data){ 684 if (data[0].GasHH == 0 && data[0].GasGew == 0) { 685 $('#checkboxGas').parent().hide('slow'); 686 $('#checkboxGas').removeAttr('checked'); 687 $('#wattage-natural-gas').parent().hide(); 688 $('#wattage-natural-gas').val(''); 689 $('#natural-gas').parent().hide('slow'); 690 $('#natural-gas').removeAttr('checked'); 691 $('.wattage-helper').show(); 692 clickGas(); 693 } else if ($('#checkboxGas').is(':checked')) { 694 $('#checkboxGas').parent().show('slow'); 695 $('#natural-gas').parent().show('slow'); 696 $('#wattage-natural-gas').parent().show(); 697 } 698 699 if (data[0].StromHH == 0 && data[0].StromGew == 0) { 700 $('#checkboxStrom').parent().hide('slow'); 701 $('#checkboxStrom').removeAttr('checked'); 702 $('#wattage-current').parent().hide(); 703 $('#wattage-current').val(''); 704 $('#current').parent().hide('slow'); 705 $('#current').removeAttr('checked'); 706 $('.wattage-helper').show(); 707 clickStrom(); 708 } 709 if ($('#checkboxStrom').is(':checked')) { 710 $('#checkboxStrom').parent().show('slow'); 711 $('#current').parent().show('slow'); 712 $('#wattage-current').parent().show(); 713 } 714 } 715 }); 716 717 $(this).find('#current, #natural-gas').change(function () { 718 handleHelper($(this)); 719 }); 720 721 /** 722 * Filter Produktauswahl verarbeiten 723 */ 724 var filterProductsChanged = function() 725 { 726 if(0 == $(".product-filter").length) 727 { 728 return; 729 } 730 731 var preisgarantieSelected = $("#Preisgarantie option:selected").val() ? true : false; 732 var energiemixSelected = $("#Energiemix option:selected").val() ? true : false; 733 var vertragslaufzeitSelected = $("#Vertragslaufzeit option:selected").val() ? true : false; 734 var serviceleistungenSelected = $("#Serviceleistungen option:selected").val() ? true : false; 735 736 var triggerElement = $(this).prop("id"); 737 738 $.post( 739 '?c=Ospreisrechner&a=findfilters', 740 { aData: { 741 Preisgarantie: preisgarantieSelected ? $("#Preisgarantie option:selected").val() : "", 742 Energiemix: energiemixSelected ? $("#Energiemix option:selected").val() : "", 743 Vertragslaufzeit: vertragslaufzeitSelected ? $("#Vertragslaufzeit option:selected").val() : "", 744 Serviceleistungen: serviceleistungenSelected ? $("#Serviceleistungen option:selected").val() : "" 745 }}, 746 function(data) 747 { 748 var parsedData = $.parseJSON(data); 749 $.each(parsedData, function(selectIndex, selectElement) 750 { 751 if(triggerElement == selectIndex) 752 { 753 return true; 754 } 755 756 if(0 == selectElement.length) 757 { 758 $("#" + selectIndex + " option").remove(); 759 $("#" + selectIndex) 760 .prop("disabled", "disabled") 761 .append('<option value="">- nicht verfügbar -</option>'); 762 } 763 else 764 { 765 var selectedValue = $("#" + selectIndex + " option:selected").val(); 766 767 $("#" + selectIndex + " option").remove(); 768 769 $("#" + selectIndex) 770 .removeProp("disabled") 771 .append('<option value="">- bitte wählen -</option>'); 772 773 $.each(selectElement, function(optionIndex, optionElement) 774 { 775 var optionCode = '<option'; 776 if(selectedValue == optionElement.id) 777 { 778 optionCode += ' selected="selected"'; 779 } 780 optionCode += ' value="' + optionElement.id + '">' + optionElement.bezeichnung + '</option>'; 781 $("#" + selectIndex).append(optionCode); 782 }); 783 } 784 785 }); 786 787 } 788 ); 789 }; 790 $(".product-filter").on("change", ".filter", filterProductsChanged); 791 filterProductsChanged(); 792 793 /** 794 * Device-Item (Verbrauchsstelle) hinzufügen 795 */ 796 $(".device-items").on("click", ".button-add-device-item", function(event) 797 { 798 event.preventDefault(); 799 800 var nextKey = $(event.target).data("last-key") + 1; 801 $(event.target).data("last-key", nextKey); 802 803 var newItem; 804 newItem = $(".device-item-container").children(".device-item:first").clone(); 805 newItem.find("label").each(function() { 806 $(this).prop("for", $(this).prop("for").replace(0, nextKey)); 807 }); 808 newItem.find("input,select").each(function() { 809 $(this).prop("name", $(this).prop("name").replace(0, nextKey)); 810 $(this).prop("id", $(this).prop("id").replace(0, nextKey)); 811 }); 812 newItem.find("span.error").remove(); 813 newItem.find("input").val(""); 814 newItem.find("option").removeProp("disabled"); 815 newItem.append('<p><a class="button-remove-device-item" href="#">Diese Verbrauchsstelle entfernen</a></p>'); 816 817 $(".device-item-container").append(newItem); 818 });
819 820 $(".device-items").on("click", ".button-remove-device-item", function(event) 821 { 822 event.preventDefault(); 823 $(event.target).parents(".device-item").remove(); 824 }); 825 826 827 /* Nach dem Laden der Produktseite zum Anfag der Suchergebnisse scrollen */ 828 $("#page_strom, #page_gas").each(function() 829 { 830 $('html, body').animate({scrollTop: $(this).offset().top - 120}, 'slow'); 831 }); 832 833}); 834 835/** 836 * Wandelt ein eingegebenes Datum in ein Array um, damit man damit rechnen kann. 837 * 838 * @param datumValue 839 * @returns boolean|Array 840 */ 841function dateToArray(datumValue) 842{ 843 if ( !datumValue ) { 844 return false; 845 } 846 var datum = datumValue.toString().split( '-' ).reverse(); 847 if ( datum.length != 3 ) { 848 849 datum = datumValue.toString().split( '.' ); 850 if ( datum.length != 3 ) { 851 return false; 852 } 853 } 854 855 datum[0] = parseInt(datum[0], 10); 856 datum[1] = parseInt(datum[1], 10); 857 if (datum[2].length == 2) { 858 datum[2] = '20' + datum[2]; 859 } 860 861 return datum; 862} 863 864/** 865 * Prüft, ob ein Datum gültig ist. 866 * 867 * @param datum 868 * @returns {boolean} 869 */ 870function gueltigesDatum(datum) 871{ 872 datum = dateToArray(datum); 873 874 if (datum == false) { 875 return false; 876 } 877 878 var kontrolldatum = new Date(datum[2], datum[1], datum[0]); 879 if (kontrolldatum.getDate() == datum[0] && kontrolldatum.getMonth() == datum[1] && kontrolldatum.getFullYear() == datum[2]) { 880 return true; 881 } 882 883 return false; 884} 885 886/** 887 * Setzt das hidden-Feld action des Formulars; 888 * 889 * @param action 890 * @returns {boolean} 891 */ 892function changeAction( action ) 893{ 894 document.getElementById('action' ).value = action; 895 return true; 896} 897 898/** 899 * Ãbersicht auf Abschlusseite ein-/ausblenden. 900 */ 901function toggleOverview() 902{ 903 $('#overview').toggle(); 904} 905 906/** 907 * Abmelden-Fomular 908 */ 909 910$( '#errorGeb' ).hide(); 911$( '#errorDate' ).hide(); 912var $geburtsdatum = $( '#Geburtsdatum' ); 913var $anrede = $( '#Anrede' ); 914var $vorname = $( '#Vorname' ); 915 916$( '#Kunde' ).change( function () { 917 if ( $( '#Kunde' ).val() == 'Haushaltskunde' ) { 918 $anrede.empty(); 919 $anrede.append( '<option>Bitte wählen</option>' ); 920 $anrede.append( '<option value="Frau">Frau</option>' ); 921 $anrede.append( '<option value="Herr">Herr</option>' ); 922 $anrede.append( '<option value="Familie">Familie</option>' ); 923 924 $( '#Nachname' ).parent().find( 'label' ).html( 'Nachname: <sup>*</sup>' ); 925 926 $vorname.attr( 'required', true ); 927 $vorname.parent().find( 'label' ).html( 'Vorname: <sup>*</sup>' ); 928 929 $( '#HrbNummer' ).attr( 'id', 'Geburtsdatum' ); 930 $geburtsdatum.parent().find( 'label' ).html( 'Geburtsdatum:' ); 931 $geburtsdatum.datepicker( OsSettings.germanDate ); 932 933 focusoutDate( '#Geburtsdatum' ); 934 } else { 935 $anrede.empty(); 936 $anrede.append( '<option>Bitte wählen</option>' ); 937 $anrede.append( '<option value="Frau">Frau</option>' ); 938 $anrede.append( '<option value="Herr">Herr</option>' ); 939 $anrede.append( '<option value="Damen und Herren">Damen und Herren</option>' ); 940 941 $( '#Nachname' ).parent().find( 'label' ).html( 'Nachname: <sup>*</sup><br /><em>(Firmenname)</em>' ); 942 943 $vorname.attr( 'required', false ); 944 $vorname.parent().find( 'label' ).html( 'Vorname:' ); 945 946 $geburtsdatum.parent().find( 'label' ).html( 'Geburtsdatum:<br /><em>(HRB-Nummer)</em>' ); 947 $geburtsdatum.attr( 'id', 'HrbNummer' ); 948 $geburtsdatum.datepicker( 'destroy' ); 949 } 950}); 951 952$geburtsdatum.datepicker( OsSettings.germanDate ); 953$geburtsdatum.focusout( function () { 954 focusoutDate( '#Geburtsdatum' ); 955} ); 956 957var $abmeldedatum = $( '#Abmeldedatum' ); 958$abmeldedatum.datepicker( OsSettings.germanDate ); 959$abmeldedatum.focusout( function () { 960 focusoutDate( '#Abmeldedatum' ); 961} ); 962 963function focusoutDate( date ) { 964 if ( !gueltigesDatum( $( date ).val() ) && $( date ).val() != '' ) { 965 $( date ).val( '' ); 966 if ( $( '#Kunde' ).val() == 'Haushaltskunde' ) { 967 if ( date == '#Geburtsdatum' ) { 968 $( '#errorDate' ).hide( 'slow' ); 969 $( '#errorGeb' ).show( 'slow' ); 970 } else { 971 $( '#errorGeb' ).hide( 'slow' ); 972 $( '#errorDate' ).show( 'slow' ); 973 } 974 } else { 975 $( '#errorDate' ).hide( 'slow' ); 976 $( '#errorGeb' ).hide( 'slow' ); 977 } 978 } else { 979 $( '#errorDate' ).hide( 'slow' ); 980 $( '#errorGeb' ).hide( 'slow' ); 981 } 982} 983 984/** 985 * Sepa-Widerruf 986 */ 987 988var $errorDatum = $( '#errorDatum' ); 989var $datum = $( '#Datum' ); 990$datum.datepicker( OsSettings.germanDate ); 991$datum.focusout( function () { 992 if ( !gueltigesDatum( $datum.val() ) ) { 993 $errorDatum.show( 'slow' ); 994 $errorDatum.val( 'Bitte tragen Sie ein gültiges Datum ein.' ); 995 } 996 if ( dateNotPast( $datum.val() ) ) { 997 $errorDatum.show( 'slow' ); 998 $errorDatum.val( 'Das Datum der Vertragsänderung darf nicht in der Vergangenheit liegen.' ); 999 } else { 1000 $errorDatum.hide( 'slow' ); 1001 } 1002} ); 1003 1004function dateNotPast( datum ) { 1005 datum = dateToArray( datum ); 1006 1007 if ( datum == false ) { 1008 return false; 1009 } 1010 1011 var kontrolldatum = new Date(); 1012 kontrolldatum.setDate( kontrolldatum.getDate() ); 1013 datum = new Date( datum[2], datum[1] - 1, datum[0] ); 1014 datum.setDate( datum.getDate() ); 1015 datum.setSeconds( 1 ); 1016 kontrolldatum.setHours( 0 ); 1017 kontrolldatum.setMinutes( 0 ); 1018 kontrolldatum.setSeconds( 0 ); 1019 1020 return (kontrolldatum > datum); 1021} 1022 1023/** 1024 * Zählerstand 1025 */ 1026 1027var $ablesedatum = $( '#Ablesedatum' ); 1028$ablesedatum.datepicker( OsSettings.germanDate ); 1029$ablesedatum.focusout( function () { 1030 focusoutDate( '#Ablesedatum' ); 1031} ); 1032
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.