/** * Webstekker RDS Javascript * requires jquery * @version 2.2.1 * @package RDS */ /* */ /* constants */ /* */ var CR = '\n'; var CRLF = '\r\n'; var TAB = '\t'; var DROP_DOWN_LIST_LENGTH = 10; var DROP_DOWN_LIST_ROW_HEIGHT = 15; var KEYCODE_BACKSPACE = 8; var KEYCODE_TAB = 9; var KEYCODE_ENTER = 13; var KEYCODE_SHIFT = 16; /* use eventObject.shiftKey to test */ var KEYCODE_CTRL = 17; /* use eventObject.ctrlKey to test */ var KEYCODE_ALT = 18; /* use eventObject.altKey to test */ var KEYCODE_PAUSE = 19; var KEYCODE_CAPS_LOCK = 20; var KEYCODE_ESCAPE = 27; var KEYCODE_BLANK = 32; var KEYCODE_PAGE_UP = 33; var KEYCODE_PAGE_DOWN = 34; var KEYCODE_END = 35; var KEYCODE_HOME = 36; var KEYCODE_LEFT = 37; var KEYCODE_UP = 38; var KEYCODE_RIGHT = 39; var KEYCODE_DOWN = 40; var KEYCODE_PRTSCN = 44; var KEYCODE_INSERT = 45; var KEYCODE_DELETE = 46; var WIZARD_STEP_DEFAULT = 0; var WIZARD_STEP_START = 1; var WIZARD_STEP_LOGIN_FROM_COOKIE = 2; var WIZARD_STEP_LOGIN_FROM_FORM = 3; var WIZARD_STEP_FINISHED_LOGIN = 4; var ERROR_RESPONSE = /^\*ERROR\* /; var IS_FORM_ELEMENT = /(input|button|textarea|select)/i; var ACL_RESELLER = 1; var ACL_USER = 2; var REGEXP_EMPTY = /^\s*$/; var REGEXP_ANY_VALUE = /\S+/; var REGEXP_ANY_NUMBER = /\d/; var REGEXP_ALL_NUMBERS = /^\d+$/; var REGEXP_FIRSTNAME = /[a-z]{1}/i; var REGEXP_LASTNAME = /[a-z]{2}/i; var REGEXP_HOUSENUMBER = /^[\d\-]+$/; var REGEXP_POSTOFFICEBOX = /p+\s*o+\s*s+\s*t+\s*b+\s*u+\s*s+/i; var REXEXP_POSTALCODE = /^.{3,}$/i; var REXEXP_POSTALCODE_NL = /^[0-9]{4}[A-Z]{2}$/i; var REGEXP_PHONE = /^[1-9]\d+$/; var REGEXP_PHONE_NL = /^[1-9]\d{8}$/; var REGEXP_EMAILADDRESS = /^[a-z0-9\-\._]{2,}@[a-z0-9\-\._]{2,}\.[a-z]{2,4}$/i; var REGEXP_NAMESERVER = /^[a-z0-9\-]+\.[a-z0-9\-]{3,}\.[a-z0-9\-\.]{2,}$/i; var REGEXP_IPV4_ADDRESS = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/; var REGEXP_SIDN_REGISTRATION = /^(BV|BVI\/O|COOP|CV|EENMANSZAAK|NV|MAATSCHAP|OWM|STICHTING|VERENIGING|VOF)$/; var REGEXP_DATE = /^(0?[1-9]|[12]\d|3[01])[\-/](0?[1-9]|1[012])[\-/]([12]\d{3})$/; var REGEXP_OWNER_STREET_NL = /^((?![P|p][O|o][S|s][T|t][B|b][U|u][S|s]).)*$/; var SEVEN_DAYS = 7 * 24 * 60 * 60 * 1000; /* Seven days in in milliseconds */ var SIX_MONTHS = 183 * 24 * 60 * 60 * 1000; /* Six months, for a leapyear, in milliseconds */ var HISTORY_AUTO_REFRESH = 1800000; /* 30 minutes in milliseconds */ /* */ /* global variables */ /* */ var gBodyOnLoadList = []; var gDynamicInputValue = ''; var gDynamicInputObject = null; var gDynamicInputValueList = []; var gDynamicInputEventList = []; var gValueMatchesList = []; var gDropdownBoxTopItem = 0; var gDropdownBoxCursorPosition = -1; var gGetUserFromDomainName = false; var gDomainOption = null; var gErrorMessages = []; var gErrorFields = []; var gFormPostData = []; var gLastPageHeight = 0; function toggleHistoryOverview() { if(document.getElementById('actionTable').style.display == 'none') { document.getElementById('actionTable').style.display = ''; document.getElementById('historyOverviewImg').src = '/img/rds_detailsMin.jpg'; } else { $('#actionTable').hide(); document.getElementById('historyOverviewImg').src = '/img/rds_detailsPlus.jpg'; } return false; } /* */ /* body onload handler */ /* */ function bodyOnLoad() { var index; gDynamicInputObject = document.getElementById('dynamicInputDropDown'); if (gBodyOnLoadList.length) { for (index = 0; index < gBodyOnLoadList.length; index ++) { eval(gBodyOnLoadList[index]); } } resizeFrame(); } function bodyOnLoadAdd(evalCode) { gBodyOnLoadList.push(evalCode); } function bodyOnFocus() { dynamicInputHide(); } /* */ /* resize the iFrame to the size of the contents */ /* */ function resizeFrame() { if (document.getElementById('callBackFrame') && document.getElementById('drsPage') && document.getElementById('drsPage').scrollHeight) { if (gLastPageHeight != document.getElementById('drsPage').scrollHeight) { var cleanUrl = document.getElementById('callBackFrame').src.replace(/#.*$/, ''); document.getElementById('callBackFrame').src = cleanUrl + '#' + document.getElementById('drsPage').scrollHeight; gLastPageHeight = document.getElementById('drsPage').scrollHeight; } } // setTimeout(resizeFrame, 100); } /* */ /* dynamic inputbox functions */ /* */ /* add a dynamic inputbox to the page */ function dynamicInputAdd(inputId, valueList, evalCode) { gDynamicInputValueList[inputId] = valueList.split(','); gDynamicInputEventList[inputId] = evalCode; } /* position, fill and show the dropdown box */ function dynamicInputShow(inputObject) { var subListToShow; var subListAsHtml; var showMoreUp; var showMoreDown; var index; if (gDynamicInputObject) { if (inputObject) { /* position the dropdown box */ var $input = $(inputObject); var offset = $input.offset(); var width = $input.width(); if (document.body.className.indexOf('home') !== -1) width -= 7; $(gDynamicInputObject).css({ width: width, top: offset.top + $input.height(), left: offset.left }); /* fill the dropdown box */ if (gValueMatchesList.length > 0) { if (gValueMatchesList.length <= DROP_DOWN_LIST_LENGTH) { /* use the entire list */ gDropdownBoxTopItem = 0; showMoreUp = false; showMoreDown = false; } else { /* take a subset of the whole list */ gDropdownBoxTopItem = Math.min(gDropdownBoxTopItem, gValueMatchesList.length - DROP_DOWN_LIST_LENGTH); showMoreUp = (gDropdownBoxTopItem > 0); showMoreDown = (gDropdownBoxTopItem + DROP_DOWN_LIST_LENGTH < gValueMatchesList.length); } /* build HTML */ subListAsHtml = []; for (index = gDropdownBoxTopItem; index < Math.min(gValueMatchesList.length, gDropdownBoxTopItem + DROP_DOWN_LIST_LENGTH); index ++) { var printValue printValue = gValueMatchesList[index] if (gDynamicInputValue) { printValue = gValueMatchesList[index].replace(new RegExp(gDynamicInputValue, 'i'), '' + gDynamicInputValue + ''); } if (index == gDropdownBoxCursorPosition) { subListAsHtml.push('' + printValue + ''); } else { subListAsHtml.push('' + printValue + ''); } } gDynamicInputObject.innerHTML = subListAsHtml.join(CRLF); gDynamicInputObject.style.height = (subListAsHtml.length * DROP_DOWN_LIST_ROW_HEIGHT) + 'px'; if (showMoreUp && showMoreDown) { gDynamicInputObject.innerHTML += '
'; } else if (showMoreUp) { gDynamicInputObject.innerHTML += '
'; } else if (showMoreDown) { gDynamicInputObject.innerHTML += '
'; } else { gDynamicInputObject.innerHTML += '
'; } } else { gDynamicInputObject.innerHTML = '(no matches)'; gDynamicInputObject.style.height = DROP_DOWN_LIST_ROW_HEIGHT + 'px'; } } /* show the dropdown box */ gDynamicInputObject.style.visibility = 'visible'; } } /* hide the dropdown box */ function dynamicInputHide() { if (gDynamicInputObject) { setTimeout('dynamicInputHideReal();', 250); } } function dynamicInputHideReal() { if (gDynamicInputObject) { gDropdownBoxCursorPosition = -1; gDynamicInputObject.style.visibility = 'hidden'; } } /* update the inputbox dropdown based on the inputbox value */ function dynamicInputUpdate(eventObject, inputObject) { var eventKey = eventObject.keyCode; var eventType = eventObject.type; var matchExpression; var matchesList; var dropDownOutput; if (! eventObject) { eventObject = window.event; } eventKey = eventObject.keyCode; if (eventKey == KEYCODE_ENTER || (eventKey == KEYCODE_TAB && ! (eventObject.shiftKey || eventObject.ctrlKey || eventObject.altKey))) { eval(gDynamicInputEventList[inputObject.id]); } else if (gDynamicInputValueList[inputObject.id] && gDynamicInputValueList[inputObject.id].length) { /* don't update the current input value for control keys: */ if (eventKey == KEYCODE_BACKSPACE || eventKey == KEYCODE_ESCAPE || eventKey == KEYCODE_BLANK || eventKey == KEYCODE_DELETE || eventKey >= 48 || inputObject.value == '') { gDynamicInputValue = inputObject.value; } /* build the list to show */ if (trimString(gDynamicInputValue)) { matchesList = matchInArray(trimString(gDynamicInputValue), gDynamicInputValueList[inputObject.id]); } else { matchesList = gDynamicInputValueList[inputObject.id]; } /* update hte global list and cursor position if the list has changed */ if (gValueMatchesList.join(',') != matchesList.join(',')) { if (gDropdownBoxCursorPosition > -1) { gDropdownBoxCursorPosition = findInArray(matchesList, gValueMatchesList[gDropdownBoxCursorPosition]); } gValueMatchesList = matchesList; } /* update the global cursor position on cursor keys (keydown only) */ if (eventType == 'keydown') { switch (eventKey) { case KEYCODE_UP: gDropdownBoxCursorPosition = Math.max(gDropdownBoxCursorPosition - 1, -1); inputObject.value = (gDropdownBoxCursorPosition == -1 ? '' : gValueMatchesList[gDropdownBoxCursorPosition]); break; case KEYCODE_DOWN: gDropdownBoxCursorPosition = Math.min(gDropdownBoxCursorPosition + 1, gValueMatchesList.length - 1); if (typeof(gValueMatchesList[gDropdownBoxCursorPosition]) == 'string') { inputObject.value = gValueMatchesList[gDropdownBoxCursorPosition]; } break; case KEYCODE_PAGE_UP: gDropdownBoxCursorPosition = Math.max(gDropdownBoxCursorPosition - (DROP_DOWN_LIST_LENGTH - 1), 0); if (typeof(gValueMatchesList[gDropdownBoxCursorPosition]) == 'string') { inputObject.value = (gDropdownBoxCursorPosition == -1 ? '' : gValueMatchesList[gDropdownBoxCursorPosition]); } break; case KEYCODE_PAGE_DOWN: gDropdownBoxCursorPosition = Math.min(gDropdownBoxCursorPosition + (DROP_DOWN_LIST_LENGTH - 1), gValueMatchesList.length - 1); if (typeof(gValueMatchesList[gDropdownBoxCursorPosition]) == 'string') { inputObject.value = gValueMatchesList[gDropdownBoxCursorPosition]; } break; default: } } /* update the top to the new list and curor position */ gDropdownBoxTopItem = Math.max(Math.min(gDropdownBoxTopItem, Math.max(gDropdownBoxCursorPosition, 0)), gDropdownBoxCursorPosition - DROP_DOWN_LIST_LENGTH + 1); /* show the list object */ dynamicInputShow(inputObject); } } function dynamicInputHover(eventObject, inputId, row) { gDropdownBoxCursorPosition = row; dynamicInputShow(document.getElementById(inputId)); } /* handle a click in the inputbox dropdown */ function dynamicInputClick(eventObject, inputId, row) { document.getElementById(inputId).value = gValueMatchesList[row]; eval(gDynamicInputEventList[inputId]); } /* */ /* clientAccountNumber functions (load, show, select) */ /* */ function clientAccountNumberLoadData() { $('#clientAccountNumberForm').hide(); if (loginAccountNumber && loginPassword) { $('#clientAccountNumberLoading').show(); initPostData(); postDataToUrl('ajaxUserList.php', clientAccountNumberLoaded); } } function clientAccountNumberLoaded(xmlRequestObject, ajaxData) { document.getElementById('clientAccountNumber').value = ''; dynamicInputAdd('clientAccountNumber', xmlRequestObject.responseText, 'clientAccountNumberSelected();'); if (xmlRequestObject.responseText) { $('#clientAccountNumberLoading').hide(); $('#clientAccountNumberForm').show(); $('#clientAccountNumberError').hide(); document.getElementById('clientAccountNumber').focus(); if (document.getElementById('domainNameSubmit')) $('#domainNameSubmit').hide(); } else { $('#clientAccountNumberLoading').hide(); $('#clientAccountNumberForm').hide(); $('#clientAccountNumberError').show(); } } function clientAccountNumberFromDomainLoad() { if (loginAccountNumber && loginPassword && domainName) { initPostData(); addPostDataValue('domainName', domainName); postDataToUrl('ajaxUserFromDomainName.php', clientAccountNumberFromDomainLoaded); } } function clientAccountNumberFromDomainLoaded(xmlRequestObject, ajaxData) { if (ERROR_RESPONSE.test(xmlRequestObject.responseText)) { alert(xmlRequestObject.responseText.substr(8)); } else { clientAccountNumber = xmlRequestObject.responseText document.getElementById('clientAccountNumber').value = xmlRequestObject.responseText; if (clientAccountNumber) { domainOptionsOverviewClick(clientAccountNumber, domainName); } } } function clientAccountNumberSelected() { $('#domainOptionsForm').hide(); clientAccountNumber = trimString(document.getElementById('clientAccountNumber').value.toUpperCase()); var matchesList = matchInArray(clientAccountNumber, gDynamicInputValueList['clientAccountNumber']); if (matchesList.length == 1 || matchesList[0] == clientAccountNumber) { window.focus(); dynamicInputHide(); clientAccountNumber = matchesList[0]; document.getElementById('clientAccountNumber').value = clientAccountNumber; domainNameLoadData(); } else { alert('There is no user with that accountnumber in your userlist.'); } } /* */ /* resellerSettings functions */ /* */ function resellerSettingsClientAccountNumberSelected() { clientAccountNumber = trimString(document.getElementById('clientAccountNumber').value.toUpperCase()); if( clientAccountNumber.length > 1 ) { var matchesList = matchInArray(clientAccountNumber, gDynamicInputValueList['clientAccountNumber']); if (matchesList.length == 1 || matchesList[0] == clientAccountNumber) { window.focus(); dynamicInputHide(); clientAccountNumber = matchesList[0]; document.getElementById('clientAccountNumber').value = clientAccountNumber; } else { alert('There is no user with that accountnumber in your userlist.') } } } function resellerSettingsAddToList(listObjectId) { if (listObjectId && document.getElementById(listObjectId) && document.getElementById('clientAccountNumber')) { document.getElementById(listObjectId).value = document.getElementById(listObjectId).value + CRLF + document.getElementById('clientAccountNumber').value; resellerSettingsCleanList(listObjectId); } } function resellerSettingsCleanList(listObjectId, sortList) { if (listObjectId && document.getElementById(listObjectId)) { var listValues = document.getElementById(listObjectId).value.split(CR); var uniqueListValues = []; var index; for (index = 0; index < listValues.length; index ++) { var itemValue = listValues[index].toUpperCase().replace(/[^a-z0-9_\-.]/ig, ''); if (itemValue.length && findInArray(uniqueListValues, itemValue) == -1) { uniqueListValues.push(itemValue); } } if (sortList) { uniqueListValues.sort(); } document.getElementById(listObjectId).value = uniqueListValues.join(CRLF); } } /* */ /* domainName functions (load, show, select) */ /* */ function domainNameLoadData(forReseller) { $('#domainNameForm').hide(); $('#domainNameError').hide(); if (forReseller) { gGetUserFromDomainName = true; $('#domainNameLoading').show(); initPostData(); addPostDataValue('allClients', 'TRUE'); postDataToUrl('ajaxDomainList.php', domainNameLoaded); } else { gGetUserFromDomainName = false; $('#domainNameLoading').show(); initPostData(); addPostDataValue('clientAccountNumber', clientAccountNumber); postDataToUrl('ajaxDomainList.php', domainNameLoaded); } } function domainNameLoaded(xmlRequestObject, ajaxData) { $('#domainNameLoading').hide(); document.getElementById('domainName').value = ''; dynamicInputAdd('domainName', xmlRequestObject.responseText, 'domainNameSelected();'); if (xmlRequestObject.responseText) { $('#domainNameForm').show(); $('#domainNameError').hide(); document.getElementById('domainName').value = ''; if (! document.getElementById('clientAccountNumber')) { document.getElementById('domainName').focus(); } if (typeof(autoLoadDomainName)=='string') { document.getElementById('domainName').value = autoLoadDomainName; domainNameSelected(); } } else { $('#domainNameForm').show(); $('#domainNameError').show(); document.getElementById('domainName').value = ''; if (! document.getElementById('clientAccountNumber')) { document.getElementById('domainName').focus(); } } } function domainNameSelected() { domainName = trimString(document.getElementById('domainName').value.toLowerCase()); var matchesList = matchInArray(domainName, gDynamicInputValueList['domainName']); if (matchesList.length == 1 || matchesList[0] == domainName) { domainName = matchesList[0]; } document.getElementById('domainName').value = domainName; window.focus(); dynamicInputHide(); if (gGetUserFromDomainName) { clientAccountNumberFromDomainLoad(); } else { domainOptionsLoadData(); } } /* */ /* domainOptions functions (load, show, select) */ /* */ function domainOptionsLoadData(optionsOnly, historyOnly) { if (loginAccountNumber && loginPassword && clientAccountNumber && domainName) { showStatus(); /** * Reset before loading new */ $('#domainNameOptionsMenu').html(''); $('#domainNameOptionsHistory').html(''); initPostData(); addPostDataValue('domainName', domainName); if (optionsOnly) { addPostDataValue('optionsOnly', 'TRUE'); postDataToUrl('ajaxDomainOptions.php', domainOptionsLoadedOptionsOnly); $('#domainNameOptionsMenu').show(); } else if (historyOnly) { addPostDataValue('historyOnly', 'TRUE'); postDataToUrl('ajaxDomainOptions.php', domainOptionsLoadedHistoryOnly); $('#domainNameOptionsHistory').show(); } else { postDataToUrl('ajaxDomainOptions.php', domainOptionsLoaded, { actionTitle: domainName, show: ['#domainNameOptionsMenu', '#domainNameOptionsHistory'] }); } } } function domainOptionsLoaded(xmlRequestObject, ajaxData) { hideStatus(); var dialogOptions = { html: xmlRequestObject.responseText, height: 0.9 * ws.ui.getViewPort().height }; if (ajaxData && typeof ajaxData.actionTitle != 'undefined') dialogOptions.title = ajaxData.actionTitle; showDialogSafe(xmlRequestObject.responseText); $('#domainNameOptionsHistory').show(); var taskList = $('#tasks'); if( taskList ) { //taskList.load('ajaxHistoryOverviewShort.php'); } if (!ajaxData) return; $.each(['show', 'hide'], function(key, method) { if (typeof ajaxData[method] == 'undefined') return; if (!ajaxData[method].sort) ajaxData[method] = [ajaxData[method]]; $.each(ajaxData[method], function(key, selector) { $(selector)[method](); }); }); if (typeof ajaxData.onComplete != 'undefined') ajaxData.onComplete(); } function domainOptionsLoadedOptionsOnly(xmlRequestObject, ajaxData) { hideStatus(); $('#domainNameOptionsMenu').show(); showDialogSafe(xmlRequestObject.responseText); $('#domainNameOptionsHistory').hide(); $('#domainNameOptionsMenu').show(); } function domainOptionsLoadedHistoryOnly(xmlRequestObject, ajaxData) { hideStatus(); $('#domainNameOptionsHistory').show(); showDialogSafe(xmlRequestObject.responseText); $('#domainNameOptionsMenu').hide(); $('#domainNameOptionsHistory').show(); // window.setTimeout('domainOptionsLoadData(false, true);', HISTORY_AUTO_REFRESH); } function domainOptionsSelected(option) { if (eval('typeof ' + option + 'LoadData == \'function\'')) { gDomainOption = option; eval(option + 'LoadData();'); } else { alert('unknown error'); } } function domainOptionsRefresh(withoutConfirm) { if (withoutConfirm || confirm('This will cancel the current form and erase all data' + CRLF + CRLF + 'are you sure?')) { domainOptionsLoadData(true, false); } } /* */ /* actionRequired functions */ /* */ function actionRequiredLoadData() { showStatus('actielijst wordt geladen…'); initPostData(); postDataToUrl('ajaxHistoryOverview.php', actionRequiredLoaded); } function actionRequiredLoaded(xmlRequestObject, ajaxData) { hideStatus(); $('#actionRequiredTable').html(xmlRequestObject.responseText); $('#actionRequiredTable').show(); } function hideActionsRequired() { var actionRequiredTable = $('#actionRequiredTable'); if(actionRequiredTable) { actionRequiredTable.hide(); } } function showActionsRequired() { var actionRequiredTable = $('#actionRequiredTable'); if(actionRequiredTable) { actionRequiredTable.show(); } hideDialog() ; } function actionRequiredClick(actionRequiredForclientAccountNumber, actionRequiredForDomainName, callbackCode) { // Global! domainOptionsLoadData() clientAccountNumber = actionRequiredForclientAccountNumber; domainName = actionRequiredForDomainName; autoLoadDomainName = domainName; $('#clientAccountNumber').val(clientAccountNumber); $('#domainName').val(domainName); showStatus(); initPostData(); addPostDataValue('domainName', actionRequiredForDomainName); postDataToUrl('ajaxDomainOptions.php', domainOptionsLoaded, { onComplete: function() { eval(callbackCode); }, actionTitle: domainName, hide: ['#dialog #domainNameOptionsHistory'], //, '#dialog #options' show: '#dialog' }); } function showHideCompletedActions( ) { var trs = $('#actionTable tr'); trs.each( function (i, e) { if($(e).hasClass('hidden')) { $(e).removeClass('hidden'); $(e).addClass('visible'); }else { if($(e).hasClass('visible')) { $(e).removeClass('visible'); $(e).addClass('hidden'); } } }); } function ignoreHistory( btn, domainNameId, messageId, messageDirection, messageIgnore ) { initPostData(); addPostDataValue('domainNameId', domainNameId); addPostDataValue('messageId', messageId); addPostDataValue('messageDirection', messageDirection); addPostDataValue('messageIgnore', messageIgnore); postDataToUrl('ajaxIgnoreHistoryItem.php', ignoreHistoryLoaded); if( btn.messageIgnore != undefined ) { messageIgnore = btn.messageIgnore; } btn.messageIgnore = messageIgnore? 0:1; btn = $(btn); var historyItem = btn.parent().parent(); if(messageIgnore) { historyItem.addClass('hidden'); btn.html('Reactivate'); btn.bind("click", function(e){ //ignoreHistory( btn, domainNameId, messageId, messageDirection, 0 ); }); } else { btn.html('Ignore'); historyItem.removeClass('visible'); historyItem.removeClass('hidden'); btn.bind("click", function(e){ //ignoreHistory( btn, domainNameId, messageId, messageDirection, 1 ); }); } } function ignoreHistoryLoaded(xmlRequestObject, ajaxData) { ; } function showDialogSafe( htmlTxt ) { if( htmlTxt ) { var domainNameOptionsMenu = $('#domainNameOptionsMenu'); if(domainNameOptionsMenu.length > 0) { domainNameOptionsMenu.html( htmlTxt ); domainNameOptionsMenu.show(); var dialog = $('#dialog'); if(dialog.length > 0) { dialog.show(); } } else { showDialog( htmlTxt ); } /*var domainNameOptionsHistory = $('#domainNameOptionsHistory'); if(domainNameOptionsHistory) { domainNameOptionsHistory.hide(); }*/ } } function showDialog( htmlTxt ) { var dialog = $('#dialog'); dialog.html(htmlTxt); dialog.show(); var inf = $('#domainComboInfo'); if(inf) { inf.hide('slow'); } hideActionsRequired(); } function hideDialog() { var dialog = $('#dialog'); if( dialog ) { dialog.hide('fast'); } } function getDialog() { if (typeof this.$dialog == 'undefined') this.$dialog = $('#dialog'); return this.$dialog; } function openDialogForRequest(xmlRequestObject, ajaxData) { hideStatus(); showDialog(xmlRequestObject.responseText); /* ws.ui.openDialog(getDialog(), { html: xmlRequestObject.responseText, title: ajaxData.title, height: 0.9 * ws.ui.getViewPort().height });*/ if (typeof ajaxData.show != 'undefined') $(ajaxData.show).show(); if (typeof ajaxData.hide != 'undefined') { if (typeof ajaxData.hide == 'Array') { $(ajaxData.hide).each.hide(); } else { $(ajaxData.hide).each.hide(); } } } function getStatus() { if (typeof this.$status == 'undefined') this.$status = $('#status'); return this.$status; } function showStatus(message) { var message = message || 'bezig met laden…'; $('#status-message').html(message); getStatus().css('visibility', 'visible'); } function hideStatus() { getStatus().css('visibility', 'hidden'); } function historyOverviewClick(clientAccountNumber, domainName) { $('#clientAccountNumber').val(clientAccountNumber); $('#domainName').val(domainName); showStatus(); initPostData(); addPostDataValue('domainName', domainName); postDataToUrl('ajaxDomainOptions.php', openDialogForRequest, { title: domainName, hide: '#domainNameOptionsMenu', show: '#domainNameOptionsHistory' }); } function historyToolClick() { $('#domainNameOptionsMenu').hide(); $('#domainNameOptionsHistory').show(); } function domainOptionsToolClick() { $('#domainNameOptionsHistory').hide(); $('#domainNameOptionsMenu').show(); } function domainOptionsOverviewClick(clientAccountNumber, domainName) { showStatus(); $('#clientAccountNumber').val(clientAccountNumber); $('#domainName').val(domainName); initPostData(); addPostDataValue('domainName', domainName); postDataToUrl('ajaxDomainOptions.php', openDialogForRequest, { title: domainName, show: ['#domainNameOptionsMenu','#domainNameOptionsHistory'], hide: '' }); } function toggleHelpContainer() { var helpContainerObj = document.getElementById('helpContainer'); if(helpContainerObj.style.display=='none') { helpContainerObj.style.display = ''; } else { helpContainerObj.style.display = 'none'; } } function helpLoad(id) { initPostData(); addPostDataValue('id', id); postDataToUrl('ajaxHelp.php', helpLoaded); } function helpLoaded(xmlRequestObject, ajaxData) { $('#helpContainer').html(xmlRequestObject.responseText); } /* */ /* registerForm functions (load, show, form) */ /* */ function formRegistrationLoad() { showStatus(); initPostData(); addPostDataValue('domainName', domainName); postDataToUrl('formRegistration.php', formRegistrationLoaded); } function formRegistrationLoaded(xmlRequestObject, ajaxData) { hideStatus(); var domainNameOptionsMenu = $('#domainNameOptionsMenu'); if(domainNameOptionsMenu.length > 0) { domainNameOptionsMenu.html(xmlRequestObject.responseText); domainNameOptionsMenu.show(); } else { showDialog(xmlRequestObject.responseText); } $('textarea.expanding').autogrow({ minHeight: 30, lineHeight: 16 }); } function formRegistrationSubmit() { var valid; gErrorMessages = []; gErrorFields = []; validateDomains(); validateOwner(); validateContacts(); if (! showErrors('registerOwnerForm', 'registerOwnerFormErrors')) { $('#registerOwnerForm').hide(); $('#nameServerForm').show(); } } /* */ /* get Domain Status */ /* */ function formStatusDomainLoad() { showStatus(); initPostData(); addPostDataValue('domainName', domainName); postDataToUrl('formStatusDomain.php', formStatusDomainLoaded); } function formStatusDomainLoaded(xmlRequestObject, ajaxData) { hideStatus(); showDialogSafe(xmlRequestObject.responseText); } /* */ /* resellerConfirmRegistrationForm functions (load, show, form, submit) */ /* */ function formResellerCompleteRegistrationLoad(domainNameId, messageId) { if (domainNameId && messageId) { showStatus(); initPostData(); addPostDataValue('domainNameId', domainNameId); addPostDataValue('messageId', messageId); postDataToUrl('formResellerRegistrationComplete.php', formResellerCompleteRegistrationLoaded); } } function formResellerCompleteRegistrationLoaded(xmlRequestObject, ajaxData) { hideStatus(); //$('#domainNameOptionsMenu').html(xmlRequestObject.responseText); showDialogSafe(xmlRequestObject.responseText); } function formResellerCompleteRegistrationSubmit() { gErrorMessages = []; gErrorFields = []; validateOwner(); validateContacts(); if (! showErrors('resellerConfirmRegistrationForm', 'resellerConfirmRegistrationFormErrors')) { $('#resellerConfirmRegistrationForm').hide(); $('#domainNameOptionsMenu').hide(); $('#domainNameOptionsMenuSaving').show(); initPostData(); addPostDataOwner(); addPostDataContacts(); addPostDataNameServers(); postDataToUrl('submitResellerRegistrationComplete.php', formResellerCompleteRegistrationSaved); } } function formResellerCompleteRegistrationSaved(xmlRequestObject, ajaxData) { $('#domainNameOptionsMenuSaving').hide(); showDialogSafe(xmlRequestObject.responseText); //$('#domainNameOptionsMenu').show(); // domainOptionsLoadData(false, true); } /* */ /* resellerConfirmTransferInForm functions (load, show, form, submit) */ /* */ function formResellerCompleteTransferInLoad(domainNameId, messageId) { if (domainNameId && messageId) { showStatus(); initPostData(); addPostDataValue('domainNameId', domainNameId); addPostDataValue('messageId', messageId); postDataToUrl('formResellerTransferInComplete.php', formResellerCompleteTransferInLoaded); } } function formResellerCompleteTransferInLoaded(xmlRequestObject, ajaxData) { hideStatus(); showDialogSafe(xmlRequestObject.responseText); } function formResellerCompleteTransferInSubmit() { gErrorMessages = []; gErrorFields = []; //validateOwner(); validateContacts(); if (! showErrors('resellerConfirmTransferInForm', 'resellerConfirmTransferInFormErrors')) { $('#resellerConfirmTransferInForm').hide(); $('#domainNameOptionsMenu').hide(); $('#domainNameOptionsMenuSaving').show(); initPostData(); addPostDataContacts(); postDataToUrl('submitResellerTransferInComplete.php', formResellerCompleteTransferInSaved); } } function formResellerCompleteTransferInSaved(xmlRequestObject, ajaxData) { $('#domainNameOptionsMenuSaving').hide(); showDialogSafe(xmlRequestObject.responseText); //$('#domainNameOptionsMenu').show(); // domainOptionsLoadData(false, true); } /* */ /* formResellerCompleteCancellation functions (load, show, form, submit) */ /* */ function formResellerCompleteCancellationLoad(domainNameId, messageId) { if (domainNameId && messageId) { showStatus(); initPostData(); addPostDataValue('domainNameId', domainNameId); addPostDataValue('messageId', messageId); postDataToUrl('formResellerCancelDomainNameComplete.php', formResellerCompleteCancellationLoaded); } } function formResellerCompleteCancellationLoaded(xmlRequestObject, ajaxData) { hideStatus(); showDialogSafe(xmlRequestObject.responseText); } function formResellerCompleteCancellationSubmit() { var dateElements; var dateDifference; gErrorMessages = []; gErrorFields = []; if (validateField(REGEXP_DATE, 'cancelDate', 'cancellation date is required and should be formatted dd-mm-yyyy or dd/mm/yyyy')) { dateElements = document.getElementById('cancelDate').value.split('-'); if (dateElements.length != 3) { dateElements = document.getElementById('cancelDate').value.split('/'); } if (dateElements.length != 3) { gErrorFields.push('cancelDate'); gErrorMessages.push('cancellation date is required and should be formatted dd-mm-yyyy or dd/mm/yyyy'); } else { dateDifference = (new Date(dateElements[2], dateElements[1] - 1, dateElements[0])) - (new Date()); if (dateDifference < SEVEN_DAYS) { gErrorMessages.push('for administrative purposes, the cancellation cannot be earlier than 1 (one) week from now'); gErrorFields.push('cancelDate'); } else if (dateDifference > SIX_MONTHS) { gErrorMessages.push('for administrative purposes, the cancellation cannot be later than 6 (six) months from now'); gErrorFields.push('cancelDate'); } } } if (! showErrors('resellerConfirmCancellationForm', 'resellerConfirmCancellationFormErrors')) { $('#resellerConfirmCancellationForm').hide(); $('#domainNameOptionsMenuSaving').show(); initPostData(); addPostDataField('cancelDate', 'cancelDate'); addPostDataValue('resellerAgrees', (document.getElementById('resellerAgreesYes').checked ? 'YES' : 'NO')); postDataToUrl('submitResellerCancelDomainNameComplete.php', formResellerCompleteCancelSubmitSaved); } } function formResellerCompleteCancelSubmitSaved(xmlRequestObject, ajaxData) { $('#domainNameOptionsMenuSaving').hide(); showDialogSafe(xmlRequestObject.responseText); //$('#domainNameOptionsMenu').html(xmlRequestObject.responseText); $('#domainNameOptionsMenu').show(); // domainOptionsLoadData(false, true); } /* */ /* resellerConfirmTransferInForm functions (load, show, form, submit) */ /* */ function resellerConfirmTransferInFormLoadData() { if (loginAccountNumber && loginPassword && clientAccountNumber && domainName) { showStatus(); initPostData(); postDataToUrl('formResellerTransferInComplete.php', resellerConfirmTransferInFormLoaded); } } function resellerConfirmTransferInFormLoaded(xmlRequestObject, ajaxData) { hideStatus(); showDialogSafe(xmlRequestObject.responseText); } function resellerConfirmTransferInFormSubmit() { gErrorMessages = []; gErrorFields = []; validateContacts(); if (! showErrors('resellerConfirmTransferInForm', 'resellerConfirmTransferInFormErrors')) { $('#resellerConfirmTransferInForm').hide(); $('#domainNameOptionsMenu').hide(); $('#domainNameOptionsMenuSaving').show(); initPostData(); addPostDataContacts(); postDataToUrl('submitResellerTransferInComplete.php', formResellerTransferInCompleteSubmitDone); } } function formResellerTransferInCompleteSubmitDone(xmlRequestObject, ajaxData) { $('#domainNameOptionsMenuSaving').hide(); showDialogSafe(xmlRequestObject.responseText); //$('#domainNameOptionsMenu').show(); // domainOptionsLoadData(false, true); } /* */ /* fixTransferInForm functions (load, show, form) */ /* */ function formFixTransferInLoad(domainNameId, messageId) { // $('#domainNameOptionsMenu').hide(); if (domainNameId && messageId) { showStatus(); initPostData(); addPostDataValue('domainNameId', domainNameId); addPostDataValue('messageId', messageId); postDataToUrl('formFixTransferIn.php', formFixTransferInLoaded); } } function formFixTransferInLoaded(xmlRequestObject, ajaxData) { hideStatus(); showDialogSafe(xmlRequestObject.responseText); } function formFixTransferInSubmit() { gErrorMessages = []; gErrorFields = []; validateOwner(); validateContacts(); if (! showErrors('fixTransferInForm', 'fixTransferInFormErrors')) { $('#fixTransferInForm').hide(); $('#domainNameOptionsMenu').hide(); $('#domainNameOptionsMenuSaving').show(); initPostData(); addPostDataOwner(); addPostDataContacts(); postDataToUrl('submitFixTransferIn.php', formFixTransferInSubmitSaved); } } function formFixTransferInSubmitSaved(xmlRequestObject, ajaxData) { $('#domainNameOptionsMenuSaving').hide(); showDialogSafe(xmlRequestObject.responseText); //$('#domainNameOptionsMenu').html(xmlRequestObject.responseText); //$('#domainNameOptionsMenu').show(); // domainOptionsLoadData(false, true); } /* */ /* transferInForm functions (load, show, form) */ /* */ function formTransferInLoad() { showStatus(); initPostData(); postDataToUrl('formTransferIn.php', formTransferInLoaded); } function formTransferInLoadMultiple() { showStatus(); initPostData(); postDataToUrl('formTransferInMultiple.php', formTransferInLoaded); } function formTransferInLoaded(xmlRequestObject, ajaxData) { hideStatus(); showDialogSafe(xmlRequestObject.responseText); $('textarea.expanding').autogrow({ maxHeight: 500, minHeight: 30, lineHeight: 16 }); } function formTransferInSubmit() // isn't called anymore. checks are now in nameServerFormSubmit { gErrorMessages = []; gErrorFields = []; if( document.getElementById('ownerIsCompanyYes')) { validateOwner(); } if (document.getElementById('authorisationCodeRequired') && document.getElementById('authorisationCodeRequired').value == 'YES') { validateField(REGEXP_ANY_VALUE, 'authorisationCode', 'an authorisation code is required for the transfer of this domainname'); } if (document.getElementById('agreeToTransferTerms')) { validateField(1, 'authorisationCode', 'Voordat u verder dient u aan te vinken dat u de eigenaar van de domeinnamen of gemachtigd bent door de eigenaar om de domeinnamen te verhuizen.'); } validateContacts(); if (! showErrors('transferInOwnerForm', 'transferInOwnerFormErrors')) { $('#transferInOwnerForm').hide(); $('#nameServerForm').show(); formNoSignatureSubmit(); } } function formTransferInCopyCompanyToPersonal() { document.getElementById('ownerCompanyForm').style.display='none'; if(document.getElementById('whoisOwnerCompanyName').value) { document.getElementById('ownerLastName').value = document.getElementById('whoisOwnerCompanyName').value; } else { document.getElementById('ownerLastName').value = document.getElementById('whoisOwnerLastName').value; } disableField('ownerFirstName'); disableField('ownerLastNameExtension'); disableField('ownerLastName'); } function formTransferInCopyPersonalToCompany() { var fullName; $('#ownerCompanyForm').show(); if (document.getElementById('whoisOwnerFullName') && document.getElementById('whoisOwnerFullName').value) { document.getElementById('ownerCompanyName').value = document.getElementById('whoisOwnerFullName').value; } else { document.getElementById('ownerCompanyName').value = document.getElementById('whoisOwnerCompanyName').value; } disableField('ownerFirstName', false); disableField('ownerLastNameExtension', false); disableField('ownerLastName', false); } /* */ /* requestAuthorisationCodeForm functions (load, show) */ /* */ function formRequestAuthorisationCodeLoad(domainName) { if (domainName) { showStatus(); initPostData(); addPostDataValue('domainName', domainName); postDataToUrl('formRequestAuthorisationCode.php', formRequestAuthorisationCodeLoaded); } } function formRequestAuthorisationCodeLoaded(xmlRequestObject, ajaxData) { hideStatus(); showDialogSafe(xmlRequestObject.responseText); } /* */ /* requestAuthorisationCodeForm functions (load, show) */ /* */ function formLockUnlockLoad(domainName) { if (domainName) { showStatus(); initPostData(); addPostDataValue('domainName', domainName); postDataToUrl('formLockUnlock.php', formLockUnlockLoaded); } } function formLockUnlockLoaded(xmlRequestObject, ajaxData) { hideStatus(); showDialogSafe(xmlRequestObject.responseText); //$('#domainNameOptionsMenu').html(xmlRequestObject.responseText); } function formLockUnlockSubmit() { $('#lockUnlockForm').hide(); $('#domainNameOptionsMenuSaving').show(); initPostData(); postDataToUrl('submitLockUnlock.php', formLockUnlockSubmitSaved); } function formLockUnlockSubmitSaved(xmlRequestObject, ajaxData) { $('#domainNameOptionsMenuSaving').hide(); showDialogSafe(xmlRequestObject.responseText); //$('#domainNameOptionsMenu').html(xmlRequestObject.responseText); //$('#domainNameOptionsMenu').show(); // domainOptionsLoadData(false, true); } /* */ /* changeOwnerForm functions (load, show, form) */ /* */ function formChangeOwnerLoad() { // $('#domainNameOptionsMenu').hide(); if (arguments[0]) { addPostDataValue('domainName', arguments[0]); } showStatus(); initPostData(); postDataToUrl('formChangeOwner.php', formChangeOwnerLoaded); } function formChangeOwnerLoaded(xmlRequestObject, ajaxData) { hideStatus(); /*if($('#domainNameOptionsMenu').length > 0) { $('#domainNameOptionsMenu').html(xmlRequestObject.responseText); } else { */ showDialogSafe(xmlRequestObject.responseText); //} $('textarea.expanding').autogrow({ minHeight: 30, lineHeight: 16 }); } function formChangeOwnerSubmit() { gErrorMessages = []; gErrorFields = []; validateOwner(); if (document.getElementById('keepCurrentContactsNo') && document.getElementById('keepCurrentContactsNo').checked) { validateContacts(); } if (! showErrors('changeOwnerForm', 'changeOwnerFormErrors')) { $('#changeOwnerForm').hide(); // $('#signatureForm').show(); // signatureBuildFlash(); formNoSignatureSubmit(); } } /* */ /* TransferOutForm functions (load, show, form) */ /* */ function formTransferOutLoad(domainName) { // $('#domainNameOptionsMenu').hide(); if (domainName) { showStatus(); initPostData(); addPostDataValue('domainName', domainName); postDataToUrl('formTransferOut.php', formTransferOutLoaded); } } function formTransferOutLoaded(xmlRequestObject, ajaxData) { hideStatus(); showDialogSafe(xmlRequestObject.responseText); //$('#domainNameOptionsMenu').html(xmlRequestObject.responseText); } function formTransferOutSubmit() { $('#TransferOutForm').hide(); $('#domainNameOptionsMenuSaving').show(); initPostData(); addPostDataField('newProviderName', 'newProviderName'); addPostDataField('transferReason', 'transferReason'); postDataToUrl('submitTransferOut.php', formTransferOutSubmitSaved); } function formTransferOutSubmitSaved(xmlRequestObject, ajaxData) { $('#domainNameOptionsMenuSaving').hide(); showDialogSafe(xmlRequestObject.responseText); //$('#domainNameOptionsMenu').html(xmlRequestObject.responseText); //$('#domainNameOptionsMenu').show(); // domainOptionsLoadData(false, true); } /* */ /* transferOutReplyForm functions (load, show, form) */ /* */ function formTransferOutReplyLoad(domainNameId, messageId) { // $('#domainNameOptionsMenu').hide(); if (domainNameId && messageId) { showStatus(); initPostData(); addPostDataValue('domainNameId', domainNameId); addPostDataValue('messageId', messageId); postDataToUrl('formTransferOutReply.php', formTransferOutReplyLoaded); } } function formTransferOutReplyLoaded(xmlRequestObject, ajaxData) { hideStatus(); //$('#domainNameOptionsMenu').html(xmlRequestObject.responseText); showDialogSafe(xmlRequestObject.responseText); } function formTransferOutReplySubmit() { gErrorMessages = []; gErrorFields = []; if (! document.getElementById('acceptTransferOutYes').checked && ! document.getElementById('acceptTransferOutNo').checked) { gErrorMessages.push('You have to accept or decline the transfer to continue'); gErrorFields.push('acceptTransferOutYes'); gErrorFields.push('acceptTransferOutNo'); showErrors('transferOutReplyForm', 'transferOutReplyFormErrors'); } else { $('#transferOutReplyForm').hide(); $('#domainNameOptionsMenuSaving').show(); initPostData(); addPostDataValue('acceptTransferOut', (document.getElementById('acceptTransferOutYes').checked ? 'YES' : 'NO')); postDataToUrl('submitTransferOutReply.php', formTransferOutReplySubmitSaved); } } function formTransferOutReplySubmitSaved(xmlRequestObject, ajaxData) { $('#domainNameOptionsMenuSaving').hide(); //$('#domainNameOptionsMenu').html(xmlRequestObject.responseText); showDialogSafe(xmlRequestObject.responseText); //$('#domainNameOptionsMenu').show(); // domainOptionsLoadData(false, true); } /* */ /* nameserver form functions */ /* */ function nameServerFormSubmit() { // validate the registration / contact forms (save, even if forms are non existant) gErrorMessages = []; gErrorFields = []; validateDomains(); validateOwner(); validateContacts(); // decide on form: if( $('#transferInOwnerForm').length ) { var formId = 'transferInOwnerForm'; var formErrors = 'transferInOwnerFormErrors'; } else { var formId = 'registerOwnerForm'; var formErrors = 'registerOwnerFormErrors'; } if (document.getElementById('authorisationCodeRequired') && document.getElementById('authorisationCodeRequired').value == 'YES') { validateField(REGEXP_ANY_VALUE, 'authorisationCode', 'an authorisation code is required for the transfer of this domainname'); } if (document.getElementById('agreeToTransferTerms')) { validateField(1, 'authorisationCode', 'Voordat u verder dient u aan te vinken dat u de eigenaar van de domeinnamen of gemachtigd bent door de eigenaar om de domeinnamen te verhuizen.'); } if(!showErrors(formId, formErrors)) { //if(!showErrors('registerOwnerForm', 'registerOwnerFormErrors')) { // validate the nameserver form gErrorMessages = []; gErrorFields = []; validateNameServers(); if (!showErrors('nameServerForm', 'nameServerFormErrors')) { $('#nameServerForm').hide(); // $('#signatureForm').show(); // signatureBuildFlash(); formNoSignatureSubmit(); } } } /* */ /* signature functions */ /* */ function formSignatureSubmit() { $('#signatureForm').hide(); $('#domainNameOptionsMenu').hide(); $('#domainNameOptionsMenuSaving').show(); initPostData(); addPostDataOwner(); if (document.getElementById('cancelDate')) { addPostDataField('cancelDate', 'cancelDate'); } if (document.getElementById('keepCurrentContactsNo') && document.getElementById('keepCurrentContactsNo').checked) { addPostDataValue('keepCurrentContacts', 'NO'); } else if (document.getElementById('keepCurrentContactsYes')) { addPostDataValue('keepCurrentContacts', 'YES'); } if (document.getElementById('techForm')) { addPostDataContacts(); } if (document.getElementById('nameServerForm')) { addPostDataNameServers(); } if (document.getElementById('signatureForm')) { addPostDataValue('useSignature', (document.getElementById('useSignatureYes').checked ? 'YES' : 'NO')); } if (document.getElementById('authorisationCode')) { addPostDataField('authorisationCode', 'authorisationCode'); } /* the PHP script to receive the data depends on the kind of action */ if (document.getElementById('transferInOwnerForm')) { postDataToUrl('submitTransferIn.php', formSignatureSubmitSaved); } else if (document.getElementById('changeOwnerForm')) { postDataToUrl('submitChangeOwner.php', formSignatureSubmitSaved); } else if (document.getElementById('cancelDomainNameForm')) { postDataToUrl('submitCancelDomainName.php', formSignatureSubmitSaved); } else { postDataToUrl('submitRegistration.php', formSignatureSubmitSaved); } } function formNoSignatureSubmit() { $('#domainNameOptionsMenu').hide(); $('#domainNameOptionsMenuSaving').show(); initPostData(); addPostDataOwner(); if (document.getElementById('cancelDate')) { addPostDataField('cancelDate', 'cancelDate'); } if (document.getElementById('keepCurrentContactsNo') && document.getElementById('keepCurrentContactsNo').checked) { addPostDataValue('keepCurrentContacts', 'NO'); } else if (document.getElementById('keepCurrentContactsYes')) { addPostDataValue('keepCurrentContacts', 'YES'); } if (document.getElementById('techForm')) { addPostDataContacts(); } if (document.getElementById('nameServerForm')) { addPostDataNameServers(); } if (document.getElementById('signatureForm')) { addPostDataValue('useSignature', (document.getElementById('useSignatureYes').checked ? 'YES' : 'NO')); } if (document.getElementById('authorisationCode')) { addPostDataField('authorisationCode', 'authorisationCode'); } /* the PHP script to receive the data depends on the kind of action */ if (document.getElementById('transferInOwnerForm')) { postDataToUrl('submitTransferIn.php', formSignatureSubmitSaved); } else if (document.getElementById('changeOwnerForm')) { postDataToUrl('submitChangeOwner.php', formSignatureSubmitSaved); } else if (document.getElementById('cancelDomainNameForm')) { postDataToUrl('submitCancelDomainName.php', formSignatureSubmitSaved); } else { showStatus(); postDataToUrl('submitRegistration.php', formSignatureSubmitSaved); } } function formSignatureSubmitSaved(xmlRequestObject, ajaxData) { hideStatus(); $('#domainNameOptionsMenuSaving').hide(); showDialogSafe(xmlRequestObject.responseText); //$('#domainNameOptionsMenu').html(xmlRequestObject.responseText); //$('#domainNameOptionsMenu').show(); // domainOptionsLoadData(false, true); } function signatureBuildFlash() { /* SWFObject(movieFile, divName, width, height, flashVersion, backgroundColor [, quality [, xiRedirectUrl [, redirectUrl [,detectKey]]]]) */ /* http://blog.deconcept.com/swfobject/ */ var signatureObject = new SWFObject('images/drawSignature.swf', 'signatureFlash', '600', '400', '8', '#ffffff'); signatureObject.addParam('allowScriptAccess', 'always'); signatureObject.write('signatureMoviePlaceHolder'); } function signatureClear() { if (document.getElementById('signatureFlash')) { document.getElementById('signatureFlash').erase(); } } function signatureSave() { if (document.getElementById('signatureFlash')) { document.getElementById('signatureFlash').save(); } } function signatureSaveData(drawingData) { if (drawingData && drawingData != 'null') { initPostData(); addPostDataValue('drawingData', drawingData); postDataToUrl('ajaxSignatureCreate.php', signatureSaveDataDone); } } function signatureSaveDataDone(xmlRequestObject, ajaxData) { if (xmlRequestObject.responseText && xmlRequestObject.responseText != 'null') { signatureClear(); signatureRefresh(xmlRequestObject.responseText); } } function signatureRefresh(imagePath) { if (document.getElementById('signatureImage')) { document.getElementById('signatureImage').src = imagePath + '?' + (new Date()).getTime(); $('#signatureImageBlock').show(); $('#signatureImageMissingBlock').hide(); var useSignatureYes = document.getElementById('useSignatureYes'); if(useSignatureYes) { useSignatureYes.disabled = false; useSignatureYes.checked = true; } removeClassName(document.getElementById('useSignatureYesLabel'), 'disabled'); var signatureEditorOff = document.getElementById('signatureEditorOff'); if(signatureEditorOff) { signatureEditorOff.getElementById('signatureEditorOff').style.display='block'; } var useSignatureNo = document.getElementById('useSignatureNo'); if(useSignatureNo) { useSignatureNo.checked = false; } } } /* */ /* cancelDomainNameForm functions (load, show, form) */ /* */ function formCancelDomainNameLoad(domainName) { // $('#domainNameOptionsMenu').hide(); if (domainName) { showStatus(); initPostData(); addPostDataValue('domainName', domainName); postDataToUrl('formCancelDomainName.php', formCancelDomainNameLoaded); } } function formCancelDomainNameLoaded(xmlRequestObject, ajaxData) { hideStatus(); showDialogSafe(xmlRequestObject.responseText); //$('#domainNameOptionsMenu').html(xmlRequestObject.responseText); } function formCancelDomainNameSubmit() { var dateElements; var dateDifference; gErrorMessages = []; gErrorFields = []; validateOwner(); if( $('autoUnlockBeforeCancellation').length > 0 ) { validateCheckBox('autoUnlockBeforeCancellation', 'Voor een succesvolle opheffing moet de domeinnaam automatisch ontgrendeld kunnen worden.' ); } if (validateField(REGEXP_DATE, 'cancelDate', 'cancellation date is required and should be formatted dd-mm-yyyy or dd/mm/yyyy')) { dateElements = document.getElementById('cancelDate').value.split('-'); if (dateElements.length != 3) { dateElements = document.getElementById('cancelDate').value.split('/'); } if (dateElements.length != 3) { gErrorFields.push('cancelDate'); gErrorMessages.push('cancellation date is required and should be formatted dd-mm-yyyy or dd/mm/yyyy'); } else { var dateRequested = new Date(dateElements[2], dateElements[1] - 1, dateElements[0]); var dateNow = new Date(); dateRequested.setHours(0, 0, 0, 0); dateNow.setHours(0, 0, 0, 0); dateDifference = dateRequested - dateNow; if (dateDifference < SEVEN_DAYS) { gErrorMessages.push('for administrative purposes, the cancellation cannot be earlier than 1 (one) week from now (' + datTest + ')'); gErrorFields.push('cancelDate'); } else if (dateDifference > SIX_MONTHS) { gErrorMessages.push('cancellation date should be less then 6 months in the future'); gErrorFields.push('cancelDate'); } } } if (! showErrors('cancelDomainNameForm', 'cancelDomainNameFormErrors')) { //alert('would have proceeded'); $('#cancelDomainNameForm').hide(); // $('#signatureForm').show(); // signatureBuildFlash(); formNoSignatureSubmit(); } } function formCancelDomainNameSubmitSaved(xmlRequestObject, ajaxData) { $('#domainNameOptionsMenuSaving').hide(); showDialogSafe(xmlRequestObject.responseText); //$('#domainNameOptionsMenu').html(xmlRequestObject.responseText); //$('#domainNameOptionsMenu').show(); // domainOptionsLoadData(false, true); } /* */ /* changeNameServerForm functions (load, show, form) */ /* */ function formChangeNameServersLoad() { if (arguments[0]) { addPostDataValue('domainname', arguments[0]); } showStatus(); initPostData(); postDataToUrl('formChangeNameServers.php', formChangeNameServersLoaded); } function formChangeNameServersLoaded(xmlRequestObject, ajaxData) { hideStatus(); if($('#domainNameOptionsMenu').length > 0) { showDialogSafe(xmlRequestObject.responseText); } else { showDialog(xmlRequestObject.responseText); } } function formChangeNameServersSubmit() { gErrorMessages = []; gErrorFields = []; validateDomains(); validateNameServers(); if (! showErrors('changeNameServerForm', 'changeNameServerFormErrors')) { $('#changeNameServerForm').hide(); $('#domainNameOptionsMenuSaving').show(); initPostData(); addPostDataNameServers(); $('#domainOptionsLoading').show(); postDataToUrl('submitChangeNameServers.php', formChangeNameServersSubmitSaved); } } function formChangeNameServersSubmitSaved(xmlRequestObject, ajaxData) { $('#domainNameOptionsMenuSaving').hide(); showDialogSafe(xmlRequestObject.responseText); //$('#domainNameOptionsMenu').html(xmlRequestObject.responseText); //$('#domainNameOptionsMenu').show(); $('#domainOptionsLoading').hide(); // domainOptionsLoadData(false, true); } /* */ /* fixNameServersForm functions (load, show, form) */ /* */ function formFixNameServersLoad(domainNameId, messageId) { if (domainNameId && messageId) { showStatus(); initPostData(); addPostDataValue('domainNameId', domainNameId); addPostDataValue('messageId', messageId); postDataToUrl('formFixNameServers.php', formFixNameServersLoaded); } } function formFixNameServersLoaded(xmlRequestObject, ajaxData) { hideStatus(); showDialogSafe(xmlRequestObject.responseText); } function formFixNameServersSubmit() { gErrorMessages = []; gErrorFields = []; validateNameServers(); if (! showErrors('fixNameServersForm', 'fixNameServersFormErrors')) { $('#fixNameServersForm').hide(); $('#domainNameOptionsMenuSaving').show(); initPostData(); addPostDataNameServers(); postDataToUrl('submitFixNameServers.php', formFixNameServersSubmitSaved); } } function formFixNameServersSubmitSaved(xmlRequestObject, ajaxData) { showDialogSafe(xmlRequestObject.responseText); // domainOptionsLoadData(false, true); } /* */ /* fixRegistrationForm functions (load, show, form) */ /* */ function formFixRegistrationLoad(domainNameId, messageId) { if (domainNameId && messageId) { showStatus(); initPostData(); addPostDataValue('domainNameId', domainNameId); addPostDataValue('messageId', messageId); postDataToUrl('formFixRegistration.php', formFixRegistrationLoaded); } } function formFixRegistrationLoaded(xmlRequestObject, ajaxData) { hideStatus(); //$('#domainNameOptionsMenu').html(xmlRequestObject.responseText); showDialog(xmlRequestObject.responseText); } function formFixRegistrationSubmit() { gErrorMessages = []; gErrorFields = []; validateOwner(); validateContacts(); if (! showErrors('fixRegistrationForm', 'fixRegistrationFormErrors')) { $('#fixRegistrationForm').hide(); $('#domainNameOptionsMenuSaving').show(); initPostData(); addPostDataOwner(); addPostDataContacts(); postDataToUrl('submitFixRegistration.php', formFixRegistrationSubmitSaved); } } function formFixRegistrationSubmitSaved(xmlRequestObject, ajaxData) { showDialogSafe(xmlRequestObject.responseText); //$('#domainNameOptionsMenuSaving').hide(); //$('#domainNameOptionsMenu').html(xmlRequestObject.responseText); //$('#domainNameOptionsMenu').show(); // domainOptionsLoadData(false, true); } /* */ /* fixChangeOwnerForm functions (load, show, form) */ /* */ function formFixChangeOwnerLoad(domainNameId, messageId) { if (domainNameId && messageId) { showStatus(); initPostData(); addPostDataValue('domainNameId', domainNameId); addPostDataValue('messageId', messageId); postDataToUrl('formFixChangeOwner.php', formFixChangeOwnerLoaded); } } function formFixChangeOwnerLoaded(xmlRequestObject, ajaxData) { hideStatus(); //$('#domainNameOptionsMenu').html(xmlRequestObject.responseText); showDialogSafe(xmlRequestObject.responseText); } function formFixChangeOwnerSubmit() { gErrorMessages = []; gErrorFields = []; validateOwner(); validateContacts(); if (! showErrors('fixChangeOwnerForm', 'fixChangeOwnerFormErrors')) { $('#fixChangeOwnerForm').hide(); $('#domainNameOptionsMenuSaving').show(); initPostData(); addPostDataOwner(); addPostDataContacts(); postDataToUrl('submitFixChangeOwner.php', formFixChangeOwnerSubmitSaved); } } function formFixChangeOwnerSubmitSaved(xmlRequestObject, ajaxData) { showDialogSafe(xmlRequestObject.responseText); $('#domainNameOptionsMenuSaving').hide(); //$('#domainNameOptionsMenu').html(xmlRequestObject.responseText); //$('#domainNameOptionsMenu').show(); // domainOptionsLoadData(false, true); } /* */ /* history functions */ /* */ function historyClick(domainNameId, messageId, messageDirection) { var detailRow = document.getElementById('detailed_' + domainNameId + '_' + messageId); var detailImg = document.getElementById('detailImg_' + domainNameId + '_' + messageId); var detailInfoCell = document.getElementById('detailedInfo_' + domainNameId + '_' + messageId); if (detailRow && detailInfoCell) { if (detailRow.style.display == 'none') { showStatus(); detailRow.style.display = ''; detailImg.src = '/ui/icons/16/collapse.png'; initPostData(); addPostDataValue('domainNameId', parseInt(domainNameId)); addPostDataValue('messageId', parseInt(messageId)); addPostDataValue('messageDirection', messageDirection); var ajaxData = new Object(); ajaxData.domainNameId = parseInt(domainNameId); ajaxData.messageId = parseInt(messageId); postDataToUrl('ajaxHistoryDetails.php', historyDetailsLoaded,ajaxData); } else { detailRow.style.display = 'none'; detailImg.src = '/ui/icons/16/expand.png'; } } else { alert('Click: "detailed_' + domainNameId2 + '_' + messageId + '" not found'); } } function historyDetailsLoaded(xmlRequestObject, ajaxData) { hideStatus(); var detailInfoCell = document.getElementById('detailedInfo_' + ajaxData.domainNameId + '_' + ajaxData.messageId); if (detailInfoCell) { detailInfoCell.innerHTML = xmlRequestObject.responseText; } else { alert('Loaded: "detailedInfo_' + ajaxData.domainNameId + '_' + ajaxData.messageId + '" not found'); } } function formEditDnsLoad(domainName) { showStatus(); postDataToUrl('/dns/edit.php?domainName=' + domainName, formEditDnsLoaded); } function formEditDnsLoaded(xmlRequestObject, ajaxData) { hideStatus(); //$('#domainNameOptionsMenu').html(xmlRequestObject.responseText); showDialogSafe(xmlRequestObject.responseText); } function addTemplate(p, t) { var newItem = $(p + ' > ' + t).clone().prependTo($(p)); var newItemHtml = newItem.html(); newItemHtml = newItemHtml.replace(/##i##/g, 99); newItem.html(newItemHtml); newItem.removeClass('template'); } function dnsRecordSave( frm ) { var record = new Object(); record.target = frm.recordTarget.value; record.type = frm.recordType.value; record.domainName = frm.recordHost.value; record.nodepri = frm.recordNodePri.value; record.formId = frm.id; $.post('/dns/saveRecord.php', record, dnsRecordSaved, "json"); } function dnsRecordSaved( data ) { ; } /* */ /* build form POST data */ /* */ function addPostDataValue(variableName, value) { deletePostDataField(variableName); gFormPostData.push(variableName + '=' + encodeURIComponent(value)); } function addPostDataField(variableName, fieldId) { if (document.getElementById(fieldId)) { addPostDataValue(variableName, document.getElementById(fieldId).value); } } function deletePostDataField(variableName) { var postDataEntry; var index; postDataEntry = matchInArray(variableName + '=', gFormPostData, true); if (postDataEntry.length == 1) { index = findInArray(gFormPostData, postDataEntry[0]); if (index > -1) { gFormPostData.splice(index, 1); } } } function initPostData() { gFormPostData = []; } function addPostDataOwner() { if(document.getElementById('agreeToTransferTerms')) { if (document.getElementById('agreeToTransferTerms').checked) { addPostDataValue('agreeToTransferTerms', '1'); } } /* company */ if(!document.getElementById('ownerIsCompanyYes')) { return false; } if (document.getElementById('ownerIsCompanyYes').checked) { addPostDataValue('ownerIsCompany', 'YES'); addPostDataField('ownerCompanyName', 'ownerCompanyName'); addPostDataField('ownerCompanyType', 'ownerCompanyType'); addPostDataField('ownerCompanyRegistration', 'ownerCompanyRegistration'); addPostDataField('ownerVatId', 'ownerVatId'); } else { addPostDataValue('ownerIsCompany', 'NO'); } /* person */ addPostDataField('ownerGender', 'ownerGender'); addPostDataField('ownerFirstName', 'ownerFirstName'); addPostDataField('ownerLastNameExtension', 'ownerLastNameExtension'); addPostDataField('ownerLastName', 'ownerLastName'); addPostDataField('ownerPhoneNumberCountryCode', 'ownerPhoneNumberCountryCode'); addPostDataField('ownerPhoneNumber', 'ownerPhoneNumber'); addPostDataField('ownerEmailAddress', 'ownerEmailAddress'); /* owner address */ addPostDataField('ownerStreet', 'ownerStreet'); addPostDataField('ownerHouseNumber', 'ownerHouseNumber'); addPostDataField('ownerHouseNumberExtension', 'ownerHouseNumberExtension'); addPostDataField('ownerCity', 'ownerCity'); addPostDataField('ownerPostalCode', 'ownerPostalCode'); addPostDataField('ownerCountryCode', 'ownerCountryCode'); } function addPostDataContacts() { if (isResellerOrWSU) { /* technical contact */ if (document.getElementById('copyOwnerToTechYes') && document.getElementById('copyOwnerToTechYes').checked) { addPostDataValue('copyOwnerToTech', 'YES'); } else { addPostDataValue('copyOwnerToTech', 'NO'); addPostDataField('techGender', 'techGender'); addPostDataField('techFirstName', 'techFirstName'); addPostDataField('techLastName', 'techLastName'); addPostDataField('techLastNameExtension', 'techLastNameExtension'); addPostDataField('techPhoneNumberCountryCode', 'techPhoneNumberCountryCode'); addPostDataField('techPhoneNumber', 'techPhoneNumber'); addPostDataField('techEmailAddress', 'techEmailAddress'); /* tech address */ addPostDataField('techStreet', 'techStreet'); addPostDataField('techHouseNumber', 'techHouseNumber'); addPostDataField('techHouseNumberExtension', 'techHouseNumberExtension'); addPostDataField('techCity', 'techCity'); addPostDataField('techPostalCode', 'techPostalCode'); addPostDataField('techCountryCode', 'techCountryCode'); } /* admin/billing contact */ if (document.getElementById('copyTechToBillingYes') && document.getElementById('copyTechToBillingYes').checked) { addPostDataValue('copyTechToBilling', 'YES'); } else { addPostDataValue('copyTechToBilling', 'NO'); addPostDataField('adminGender', 'adminGender'); addPostDataField('adminFirstName', 'adminFirstName'); addPostDataField('adminLastName', 'adminLastName'); addPostDataField('adminLastNameExtension', 'adminLastNameExtension'); addPostDataField('adminPhoneNumberCountryCode', 'adminPhoneNumberCountryCode'); addPostDataField('adminPhoneNumber', 'adminPhoneNumber'); addPostDataField('adminEmailAddress', 'adminEmailAddress'); /* admin address */ addPostDataField('adminStreet', 'adminStreet'); addPostDataField('adminHouseNumber', 'adminHouseNumber'); addPostDataField('adminHouseNumberExtension', 'adminHouseNumberExtension'); addPostDataField('adminCity', 'adminCity'); addPostDataField('adminPostalCode', 'adminPostalCode'); addPostDataField('adminCountryCode', 'adminCountryCode'); } } } function addPostDataNameServers() { var nsValue = $("input[name=nameServerOption]:checked").val(); if( nsValue.length <= 0 ) { nsValue = 'DEFAULT'; } addPostDataValue('nameServerOption', nsValue); if (nsValue == 'CUSTOM') { addPostDataField('nameServerHostName1', 'nameServerHostName1'); addPostDataField('nameServerIpAddress1', 'nameServerIpAddress1'); addPostDataField('nameServerHostName2', 'nameServerHostName2'); addPostDataField('nameServerIpAddress2', 'nameServerIpAddress2'); addPostDataField('nameServerHostName3', 'nameServerHostName3'); addPostDataField('nameServerIpAddress3', 'nameServerIpAddress3'); } if (nsValue == 'PARK') { addPostDataField('nameServerParkIp', 'nameServerParkIp'); addPostDataField('nameServerParkMx', 'nameServerParkMx'); } } function postDataToUrl(url, onLoadCallBack, ajaxData) { jsDebug(url + '?' + gFormPostData.join('&') + CRLF); ajaxObject(url, onLoadCallBack, ajaxData, 'post', gFormPostData.join('&')); } /* */ /* validate form data */ /* */ function validateDomains() { if(!checkDomainsInList()) { gErrorMessages.push('Please add one or more domainnames to the list'); var extraDomainName = $('#extraDomainName'); if( extraDomainName ) { extraDomainName.focus(); } return false; } } function validateOwner() { var CC=document.getElementById('ownerCountryCode'); if(document.getElementById('ownerIsCompanyYes') && document.getElementById('ownerCompanyType')) { if (document.getElementById('ownerIsCompanyYes').checked) { validateField(REGEXP_ANY_VALUE, 'ownerCompanyName', 'company name is required to register to a company'); if (validateField(REGEXP_ANY_VALUE, 'ownerCompanyType', 'company type is required to register to a company')) { if (REGEXP_SIDN_REGISTRATION.test(document.getElementById('ownerCompanyType').value)) { validateField(REGEXP_ANY_VALUE, ['ownerCompanyRegistration', 'ownerCompanyType'], 'registration is required for this company type') } } } } validateField(REGEXP_FIRSTNAME, 'ownerFirstName', '.owner first name is required and should be more than an initial..'); validateField(REGEXP_LASTNAME, 'ownerLastName', 'owner last name is required and should be two characters or more'); validateField(REGEXP_ANY_VALUE, 'ownerStreet', 'street is required'); validateField(REGEXP_HOUSENUMBER, 'ownerHouseNumber', 'housenumber is required and expected to be numerical'); validateField(REGEXP_ANY_VALUE, 'ownerCity', 'city is required'); validateField(REXEXP_POSTALCODE, 'ownerPostalCode', 'postalcode is required'); if ( CC && CC.options[CC.selectedIndex].value == 'NL' ) { document.getElementById('ownerPostalCode').value=document.getElementById('ownerPostalCode').value.toUpperCase(); validateField(REGEXP_OWNER_STREET_NL, "ownerStreet", "Het veld 'straat' mag geen Postbus zijn."); validateField(REXEXP_POSTALCODE_NL,'ownerPostalCode','Nederlandse postcodes moeten 4 cijfers bevatten en 2 letters zonder spatie ertussen'); } if ( validateField(REGEXP_PHONE, 'ownerPhoneNumber', 'owner phonenumber is required, should only contain digits and should not start with a 0') && document.getElementById('ownerPhoneNumberCountryCode') && document.getElementById('ownerPhoneNumberCountryCode').value == '31' ) { validateField(REGEXP_PHONE_NL, 'ownerPhoneNumber', 'phonenumbers in the netherlands are always 9 digits and do not start with a 0'); } validateField(REGEXP_EMAILADDRESS, 'ownerEmailAddress', 'owner email address is required and should be a valid email address'); } function validateContacts() { var TC=document.getElementById('techCountryCode'); var AC=document.getElementById('adminCountryCode'); /* technical contact */ if (document.getElementById('techFirstName') && (! document.getElementById('copyOwnerToTechYes') || ! document.getElementById('copyOwnerToTechYes').checked)) { validateField(REGEXP_FIRSTNAME, 'techFirstName', 'technical contact first name is required'); validateField(REGEXP_LASTNAME, 'techLastName', 'technical contact lastname is required and should be two characters or more'); validateField(REGEXP_ANY_VALUE, 'techStreet', 'street is required'); validateField(REGEXP_HOUSENUMBER, 'techHouseNumber', 'housenumber is required and expected to be numerical'); validateField(REGEXP_ANY_VALUE, 'techCity', 'city is required'); validateField(REXEXP_POSTALCODE, 'techPostalCode', 'postalcode is required'); if ( TC && TC.options[TC.selectedIndex].value == 'NL' ) { validateField(REGEXP_OWNER_STREET_NL, "techStreet", "Het veld 'straat' mag geen Postbus zijn."); validateField(REXEXP_POSTALCODE_NL,'techPostalCode','Nederlandse postcodes moeten 4 cijfers bevatten en 2 letters zonder spatie ertussen'); } if ( validateField(REGEXP_PHONE, 'techPhoneNumber', 'technical contact phonenumber is required, should only contain digits and should not start with a 0') && document.getElementById('techPhoneNumberCountryCode').value == '31' ) { validateField(REGEXP_PHONE_NL, 'techPhoneNumber', 'phonenumbers in the netherlands are always 9 digits and do not start with a 0'); } validateField(REGEXP_EMAILADDRESS, 'techEmailAddress', 'technical contact email address is required and should be a valid email address'); } /* admin/billing contact */ if (document.getElementById('adminFirstName') && (! document.getElementById('copyTechToBillingYes') || ! document.getElementById('copyTechToBillingYes').checked)) { validateField(REGEXP_FIRSTNAME, 'adminFirstName', 'administrative contact first name is required'); validateField(REGEXP_LASTNAME, 'adminLastName', 'administrative contact lastname is required and should be two characters or more'); validateField(REGEXP_ANY_VALUE, 'adminStreet', 'street is required'); validateField(REGEXP_HOUSENUMBER, 'adminHouseNumber', 'housenumber is required and expected to be numerical'); validateField(REGEXP_ANY_VALUE, 'adminCity', 'city is required'); validateField(REXEXP_POSTALCODE, 'adminPostalCode', 'postalcode is required'); if ( AC && AC.options[AC.selectedIndex].value == 'NL' ) { validateField(REGEXP_OWNER_STREET_NL, "adminStreet", "Het veld 'straat' mag geen Postbus zijn."); validateField(REXEXP_POSTALCODE_NL,'adminPostalCode','Nederlandse postcodes moeten 4 cijfers bevatten en 2 letters zonder spatie ertussen'); } if ( validateField(REGEXP_PHONE, 'adminPhoneNumber', 'administrative contact phonenumber is required, should only contain digits and should not start with a 0') && document.getElementById('adminPhoneNumberCountryCode').value == '31' ) { validateField(REGEXP_PHONE_NL, 'adminPhoneNumber', 'phonenumbers in the netherlands are always 9 digits and do not start with a 0'); } validateField(REGEXP_EMAILADDRESS, 'adminEmailAddress', 'administrative contact email address is required and should be a valid email address'); } } function validateNameServers() { if (document.getElementById('nameServerOptionCustom').checked) { validateField(REGEXP_NAMESERVER, 'nameServerHostName1', 'primary nameserver hostname is required and should be a valid hostname'); validateField(REGEXP_IPV4_ADDRESS, 'nameServerIpAddress1', 'primary nameserver IP address is required and should be a valid (v4) IP adress'); validateField(REGEXP_NAMESERVER, 'nameServerHostName2', 'secundary nameserver hostname is required and should be a valid hostname'); validateField(REGEXP_IPV4_ADDRESS, 'nameServerIpAddress2', 'secundary nameserver IP address is required and should be a valid (v4) IP adress'); if (document.getElementById('nameServerHostName3').value || document.getElementById('nameServerIpAddress3').value) { validateField(REGEXP_NAMESERVER, 'nameServerHostName3', 'optional nameserver hostname is required and should be a valid hostname if the IP address is specified'); validateField(REGEXP_IPV4_ADDRESS, 'nameServerIpAddress3', 'optional nameserver IP address is required and should be a valid (v4) IP adress if the hostname is specified'); } } } function validateField(regularExpression, fieldIdList, message, invertMatch) { var index; if (typeof(fieldIdList) != 'object') { fieldIdList = [fieldIdList]; } if (! document.getElementById(fieldIdList[0])) { jsDebug('"' + fieldIdList[0] + '" is missing' + CRLF); return true; } var fieldObj = document.getElementById(fieldIdList[0]); if( fieldObj.readOnly == true || fieldObj.readOnly == "readonly" ) { return true; } var match = regularExpression.test(document.getElementById(fieldIdList[0]).value); if ( (!invertMatch && match) || (invertMatch && !match) ) { return true } for (index = 0; index < fieldIdList.length; index++) { gErrorFields.push(fieldIdList[index]); } gErrorMessages.push(message); return false; } function validateCheckBox( checkBoxId, message ) { var checkBox = document.getElementById(checkBoxId); if( checkBox ) { if( checkBox.checked ) { return true; } } gErrorFields.push(checkBoxId); gErrorMessages.push(message); return false; } function validateDomains() { taDn = $('#extraDomainName'); if( taDn.length ) { var domains = $('ul#domainNameList li'); if( domains.length < 1 ) { gErrorFields.push(taDn[0].id); message = "Please add at least one domainname"; gErrorMessages.push(message); } } } function disableField(fieldId, disable) { if (disable === false) { // document.getElementById(fieldId).disabled = false; removeClassName(fieldId, 'disabled'); } else { // document.getElementById(fieldId).disabled = true; addClassName(fieldId, 'disabled'); } } function showErrors(formObjectId, errorObjectId) { var formObject var errorObject var index; var formElementObject; if (formObjectId && (formObject = document.getElementById(formObjectId))) { for (index in formObject.elements) { if (index && formObject.elements[index] && formObject.elements[index].nodeName) { var formElementObject = formObject.elements[index]; if (IS_FORM_ELEMENT.test(formElementObject.nodeName)) { if (findInArray(gErrorFields, formElementObject.id) != -1) { addClassName(formElementObject, 'error'); } else { removeClassName(formElementObject, 'error'); } } else if (formElementObject.nodeName == 'BUTTON' && formElementObject.type && formElementObject.type == 'submit') { addClassName(formElementObject, 'error'); } } } } if (errorObjectId && (errorObject = document.getElementById(errorObjectId))) { if (gErrorMessages.length) { errorObject.innerHTML = 'There are errors in the form:
' + gErrorMessages.join('
'); errorObject.style.display = 'block'; } else { errorObject.innerHTML = ''; errorObject.style.display = 'none'; } } if (gErrorFields.length) { document.getElementById(gErrorFields[0]).focus(); return true; } return false; } /* */ /* generic functions */ /* */ function makeValidForRegExp(text) { text = text.replace(/\./g, '\\.'); text = text.replace(/\(/g, '\\('); text = text.replace(/\)/g, '\\)'); text = text.replace(/\[/g, '\\['); text = text.replace(/\]/g, '\\]'); text = text.replace(/\^/g, '\\^'); text = text.replace(/\$/g, '\\$'); text = text.replace(/\?/g, '\\?'); text = text.replace(/\*/g, '\\*'); text = text.replace(/\+/g, '\\+'); text = text.replace(/\:/g, '\\:'); return text; } function addClassName(object, className) { if (object && typeof(object.className) == 'string') { var classNameList = object.className.split(' '); if (findInArray(classNameList, className) == -1) { classNameList.push(className); } object.className = classNameList.join(' '); } } function removeClassName(object, className) { if (object && typeof(object.className) == 'string') { var classNameList = object.className.split(' '); var pos = findInArray(classNameList, className); if (pos != -1) { classNameList.splice(pos, 1); } object.className = classNameList.join(' '); } } function findInArray(arrayObject, value) { for (var i = 0; i < arrayObject.length; i ++) { if (arrayObject[i] == value) { return i; } } return -1; } function matchInArray(needle, hayStackList, fromStart) { var matchList = []; var needleRegExp; var index; if (fromStart) { needleRegExp = new RegExp('^' + makeValidForRegExp(needle), 'i'); } else { needleRegExp = new RegExp(makeValidForRegExp(needle), 'i'); } for (index = 0; index < hayStackList.length; index ++) { if (needleRegExp.test(hayStackList[index])) { matchList.push(hayStackList[index]); } } return matchList; } function trimString(text) { return text.replace(/^\s+|\s+$/g, ''); } function formDomainNamesFormSubmit(domainname) { domainname.removeClass("error"); $('addDomainNameSubmit').disabled = true; if(!domainname[0].value || domainname[0].value == '') { return; } /* var domain = new ws.DomainName(domainname[0].value); domainBase = domain.getBase(domainname[0].value); // validateBase will throw an error if invalid, // catch and set input css to 'error' try { domain.validateBase(domainBase); } catch(e) { domainname.addClass("error"); return; } */ $.post('ajaxVerifyDomainName.php', { domainName: domainname[0].value}, handleAddedDomain, "json"); } function handleAddedDomain( responses ) { $('addDomainNameSubmit').disabled = false; var inpt = $('#extraDomainName'); resetErrorBox(); var errors = new Array(); var domainList = $('ul#domainNameList'); domainList.html(''); showState = 1; if(window.registerOrTransfer) { if(window.registerOrTransfer == 'TRANSFER') { showState = 2; } } for( r in responses ) { resp = responses[r]; var domainName = resp.domainName; if( resp.isValid && resp.isSupported ) { var domainName = resp.domainName; var cssClass = 'new'; if( resp.isAvailable != 1 ) { var cssClass = 'transfer'; if( !resp.messageSeen ) resp.messageSeen = false; errors.push({'msg': resp.message, 'domainName':domainName, 'seen':resp.messageSeen}); } /*if( resp.isAvailable == showState ) { var liHtml = '
  • '+ domainName +''; liHtml += '(x)
  • '; domainList.append(liHtml); } */ //if( resp.isAvailable == showState ) { var liHtml = '
  • '+ domainName +''; liHtml += '(x)'; if(resp.isAvailable != 1 ) { var ownerStr = ''; if(resp.whoisInfo.ownerFullName) { ownerStr += resp.whoisInfo.ownerFullName ; } if(ownerStr.length > 0) { ownerStr += ', '; } if(resp.whoisInfo.ownerCompanyName) { ownerStr += resp.whoisInfo.ownerCompanyName + ', '; } if(resp.whoisInfo.ownerCity) { ownerStr += resp.whoisInfo.ownerCity; } liHtml += '

    ' + ownerStr + '

    '; } liHtml += '
  • '; domainList.append(liHtml); //} if(inpt) { inpt.value = ''; if( inpt.html() ) { inpt.html(''); inpt.value = ''; } } } else { if( !resp.messageSeen ) resp.messageSeen = false; errors.push({'msg': resp.message, 'domainName':domainName, 'seen':resp.messageSeen}); } } if( errors.length > 0 ) { if( showGeneralErrors(errors) ) { if(inpt) inpt.addClass('error'); } } } function checkDomainsInList() { var domainList = $('ul#domainNameList'); if(domainList) { var domains = domainList.children('li'); if( domains.length ) { return true; } } return false; } function showGeneralErrors( errors ) { var errorBox = $('div#generalFormErrors'); var errorsShown = false; errorBox.html(''); var errorsHtml = ''; for( e in errors ) { if(errors[e]) { if(errors[e].msg && !errors[e].seen) { errorsShown = true; errMsg = errors[e].msg; domainName = errors[e].domainName; errorsHtml += ('
  • ' + domainName + ': ' + errMsg + ' 
  • ' ); } } } errorBox.html(''); if( errorsShown ) errorBox.show('slow'); return errorsShown; } function removeError( lnk, domainName ) { $(lnk).parent().remove(); var r = $.post('ajaxClearDomainError.php', {'domainName':domainName} ); var errorBox = $('div#generalFormErrors'); var errors = $('div#generalFormErrors ul li'); if(errors.length < 1) { errorBox.hide(); } } function resetErrorBox() { var errorBox = $('div#generalFormErrors'); errorBox.html(''); errorBox.hide('fast'); } function removeDomain(domainname) { $.post('ajaxRemoveDomainName.php', {domainName: domainname}, handleRemovedDomain, "json"); } function handleRemovedDomain( resp ) { resetErrorBox(); if( resp.status ) { var domainList = $('#domainNameList'); if(domainList) { var domainListLi = domainList.children(); var domainName = resp.domainName; for( i=0; i'); this.dummy.css({ 'font-size' : this.textarea.css('font-size'), 'font-family': this.textarea.css('font-family'), 'width' : this.textarea.css('width'), 'padding' : this.textarea.css('padding'), 'line-height': this.line_height + 'px', 'overflow-x' : 'hidden', 'position' : 'absolute', 'top' : 0, 'left' : -9999 }).appendTo('body'); } // Strip HTML tags var html = this.textarea.val().replace(/(<|>)/g, ''); // IE is different, as per usual if ($.browser.msie) { html = html.replace(/\n/g, '
    new'); } else { html = html.replace(/\n/g, '
    new'); } if (this.dummy.html() != html) { this.dummy.html(html); if (this.max_height > 0 && (this.dummy.height() + this.line_height > this.max_height)) { this.textarea.css('overflow-y', 'auto'); } else { this.textarea.css('overflow-y', 'hidden'); if (this.textarea.height() < this.dummy.height() + this.line_height || (this.dummy.height() < this.textarea.height())) { this.textarea.animate({height: (this.dummy.height() + this.line_height) + 'px'}, 100); } } } } }); })(jQuery); /* * Auto grow textareaz */ $(document).ready (function() { // initialize autogrow $('textarea.expanding').autogrow({ maxHeight: 500, minHeight: 30, lineHeight: 16 }); // add notes events $('#txtNotes').blur( function() { var data = { 'userNotes': this.value }; $.post( 'ajaxSaveNotes.php', data); }); }); function bigger(lnk, id) { var obj= $('#'+id); var min = 500; var height = obj.height(); if( height <= min ) { obj.height(min); lnk = $(lnk); if(lnk.length >= 1) { $(lnk).addClass('faded'); } } obj.autogrow({ minHeight: min, lineHeight: 16 }); } function showHideOptions() { var opt = $('#moreoptions'); opt.toggle('slow'); } function showHideList( toShow, toHide ) { for( var s=0; s 0) { domainNameOptionsMenu.html(xmlRequestObject.responseText); domainNameOptionsMenu.show(); } else { showDialog(xmlRequestObject.responseText); } $('textarea.expanding').autogrow({ minHeight: 30, lineHeight: 16 }); } /* */ /* debugging functions */ /* */ function jsDebug(message, clearFirst) { if (document.getElementById('jsDebug')) { if (clearFirst) { document.getElementById('jsDebug').value = message; } else { document.getElementById('jsDebug').value += message; } window.status = message; } } function printObject(objectToPrint) { var index; if (typeof(objectToPrint) != 'object') { jsDebug('printObject expects object type, got ' + typeof(objectToPrint) + CRLF); return; } for (index in objectToPrint) { if (index && objectToPrint[index] && typeof(objectToPrint[index])) { jsDebug(index + ' [' + typeof(objectToPrint[index]) + ']'); if (typeof(objectToPrint[index]) == 'string') { jsDebug(TAB + TAB + TAB + TAB + TAB + '"' + objectToPrint[index].replace(new RegExp('\\s', 'g'), ' ') + '"'); } jsDebug(CRLF); } } jsDebug('________________________________________________________________________________' + CRLF); } function printFormElements(formObject) { var index; if (typeof(formObject) != 'object') { jsDebug('printFormElements expects object type, got ' + typeof(formObject) + CRLF); return; } jsDebug(formObject.id + CRLF); for (index in formObject.elements) { if (index && formObject.elements[index] && formObject.elements[index].nodeName && IS_FORM_ELEMENT.test(formObject.elements[index].nodeName)) { jsDebug(TAB + formObject.elements[index].id + CRLF); } } jsDebug('________________________________________________________________________________' + CRLF); }