$(document).ready(function () { window['validationEnterRoofArea.checkRoofAreaMinimum'] = function (element) { // init var validationMessage = ''; // action // var roofLength = element.val(); // var roofWidth = element.val(); var roofLength = $('#pnlRoofArea input[name=roofLength]').val(); var roofWidth = $('#pnlRoofArea input[name=roofWidth]').val(); if (roofLength != '' && roofWidth != '') { $.ajax({ async: false, url: 'plugin/top50solar/newPlant/enterRoofArea/ajax?key=' + getUrlParameter('key'), context: element, headers: { 'Accept': 'application/json' }, method: 'POST', data: { method: 'checkRoofAreaMinimum', roofLength: roofLength, roofWidth: roofWidth } }).done(function (data) { if (data != 'true') { validationMessage = 'Ihre Dachfläche ist leider zu klein für den wirtschaftlichen Betrieb einer Anlage. Die Installationskosten wären unverhältnismäßig hoch.'; } window.validationCallback(element, validationMessage); }); } // return return validationMessage; }; // window['validationEnterRoofArea.checkRoofAreaMaximum'] = function (element) { // // init // var validationMessage = ''; // // // action // // var roofLength = element.val(); // // var roofWidth = element.val(); // var roofLength = $('#pnlRoofArea input[name=roofLength]').val(); // var roofWidth = $('#pnlRoofArea input[name=roofWidth]').val(); // if (roofLength != '' && roofWidth != '') { // $.ajax({ // async: false, // url: 'plugin/top50solar/newPlant/enterRoofArea/ajax?key=' + getUrlParameter('key'), // context: element, // headers: { // 'Accept': 'application/json' // }, // method: 'POST', // data: { // method: 'checkRoofAreaMaximum', // roofLength: roofLength, // roofWidth: roofWidth // } // }).done(function (data) { // if (data != 'true') { // validationMessage = 'Für die Berechnung nutzen wir maximal 100 qm Ihrer verfügbaren Dachfläche, da diese für Anlagen bis 10 kWp ausreichen. Bei größeren Anlagen fällt die EEG-Umlage an.'; // } // window.validationCallback(element, validationMessage); // }); // } // // // return // return validationMessage; // }; window['validationEnterRoofArea.checkRoofAreaMaximum'] = function(element) { // init var checkMessage = ''; // action // var roofLength = element.val(); // var roofWidth = element.val(); var roofLength = $('#pnlRoofArea input[name=roofLength]').val(); var roofWidth = $('#pnlRoofArea input[name=roofWidth]').val(); if (roofLength != '' && roofWidth != '') { $.ajax({ async: false, url: 'plugin/top50solar/newPlant/enterRoofArea/ajax?key=' + getUrlParameter('key'), context: element, headers: { 'Accept': 'application/json' }, method: 'POST', data: { method: 'checkRoofAreaMaximum', roofLength: roofLength, roofWidth: roofWidth } }).done(function (data) { if (data != 'true') { checkMessage = 'Für die Berechnung nutzen wir maximal 100 qm Ihrer verfügbaren Dachfläche, da diese für Anlagen bis 10 kWp ausreichen. Bei größeren Anlagen fällt die EEG-Umlage an.'; } window.checkCallback(element, checkMessage); }); } // return return checkMessage; }; window.getUrlParameter = function getUrlParameter(sParam) { var sPageURL = decodeURIComponent(window.location.search.substring(1)), sURLVariables = sPageURL.split('&'), sParameterName, i; for (i = 0; i < sURLVariables.length; i++) { sParameterName = sURLVariables[i].split('='); if (sParameterName[0] === sParam) { return sParameterName[1] === undefined ? true : sParameterName[1]; } } }; var calculateRoofArea = function () { // get length and width var roofLength = $('#pnlRoofArea input[name=\'roofLength\']').val().replace(',', '.'); if (isNaN(roofLength)) { roofLength = 0; } var roofWidth = $('#pnlRoofArea input[name=\'roofWidth\']').val().replace(',', '.'); if (isNaN(roofWidth)) { roofWidth = 0; } if (roofLength != '' && roofWidth != '') { // ajax $.ajax({ url: 'plugin/top50solar/newPlant/enterRoofArea/ajax?key=' + getUrlParameter('key'), // ?method=checkZipCode&zipCode=' + zipCode, //context: document.body, context: $(this), headers: { 'Accept': 'application/json' }, method: 'POST', data: { method: 'calculateRoofArea', roofLength: roofLength, roofWidth: roofWidth } }).done(function (data) { // update input field var roofArea = data; $('#pnlRoofArea .lblRoofArea').html('Ermittelte Fläche: ' + roofArea + ' m2'); }); } }; $('#pnlRoofArea input[name=\'roofLength\']').bind('blur', function (e) { calculateRoofArea(); }); $('#pnlRoofArea input[name=\'roofWidth\']').bind('blur', function (e) { calculateRoofArea(); }); });