diff --git a/account/assets/js/init.js b/account/assets/js/init.js new file mode 100644 index 0000000..d1104eb --- /dev/null +++ b/account/assets/js/init.js @@ -0,0 +1,20 @@ +/* Store bundle name in global variable */ +var BUNDLE_NAME = ""; + +var xhr = new XMLHttpRequest(); +xhr.open('GET', 'api/settings/name', true); +xhr.send(); + +xhr.onloadend = function() { + if(xhr.status == 200) { + BUNDLE_NAME = xhr.response; + } + else { + if (xhr.response != undefined && xhr.response.length != 0) { + alert('Error getting bundle name: ' + xhr.status); + } + else { + alert('An error has occurred while getting the bundle name. If problem persists please contact your community administrator.'); + } + } +} \ No newline at end of file diff --git a/account/assets/js/panelHandlers/domains_subdomains/domain_link.js b/account/assets/js/panelHandlers/domains_subdomains/domain_link.js new file mode 100644 index 0000000..2c31eae --- /dev/null +++ b/account/assets/js/panelHandlers/domains_subdomains/domain_link.js @@ -0,0 +1,30 @@ +jQuery('._js_link-domain-form').on('submit', function(e){ + e.preventDefault(); + + if(jQuery('#linkDomain') && jQuery('#linkDomain').val()) { + var requestData = {}; + requestData["domain"] = jQuery('#linkDomain').val(); + requestData["name"] = BUNDLE_NAME; + + var xhr = new XMLHttpRequest(); + xhr.open(jQuery(this).attr('method'), jQuery(this).attr('action'), true); + xhr.send(JSON.stringify(requestData)); + + xhr.onloadend = function() { + if(xhr.status == 204) { + ListDomains(BUNDLE_NAME); + } + else { + if(xhr.response != undefined && xhr.response.length != 0) { + alert('Error: ' + xhr.status); + } + else { + alert('An error has occurred. If problem persists please contact your community administrator.'); + } + } + } + } + else { + alert('The domain field must be filled out to submit this form.'); + } +}); \ No newline at end of file diff --git a/account/assets/js/panelHandlers/domains_subdomains/domain_management.js b/account/assets/js/panelHandlers/domains_subdomains/domain_management.js new file mode 100644 index 0000000..3a8172c --- /dev/null +++ b/account/assets/js/panelHandlers/domains_subdomains/domain_management.js @@ -0,0 +1,40 @@ +var domainManagementModal = jQuery('.domain-management-modal'); + +jQuery('._js_domain-management').on('click', function(e){ + e.preventDefault(); + + ListDomains(BUNDLE_NAME); + domainManagementModal.modal('show'); +}); + +function ListDomains(bundle_name) { + var list = jQuery('._js_registered-domains'); + + var requestData = {}; + requestData["name"] = bundle_name; + + var xhr = new XMLHttpRequest(); + xhr.open('POST', 'api/domain/list', true); + xhr.send(JSON.stringify(requestData)); + + xhr.onloadend = function() { + list.html(''); + if(xhr.status == 200) { + jsonResponse = JSON.parse(xhr.response) + jQuery.each(jsonResponse, function(k, v) { + list.append('

'+v+'

'); + }); + } + else if(xhr.status == 204) { + list.html('

No registered domains exist for this account.

'); + } + else { + if(xhr.response != undefined && xhr.response.length != 0) { + alert('Error: ' + xhr.status); + } + else { + alert('An error has occurred. If problem persists please contact your community administrator.'); + } + } + } +} \ No newline at end of file diff --git a/account/assets/js/panelHandlers/domains_subdomains/domain_unlink.js b/account/assets/js/panelHandlers/domains_subdomains/domain_unlink.js new file mode 100644 index 0000000..931f67b --- /dev/null +++ b/account/assets/js/panelHandlers/domains_subdomains/domain_unlink.js @@ -0,0 +1,29 @@ +jQuery(document).on('click', '._js_delete-registered-domain', function(e){ + e.preventDefault(); + + var domain = jQuery(this).attr('data'); + var ensure = confirm("Are you sure you want to unlink the domain \""+ domain +"\" from your account?"); + + if(ensure) { + var requestData = {}; + requestData["domain"] = domain; + + var xhr = new XMLHttpRequest(); + xhr.open('DELETE', 'api/domain/unlink', true); + xhr.send(JSON.stringify(requestData)); + + xhr.onloadend = function () { + if (xhr.status == 204) { + ListDomains(BUNDLE_NAME); + } + else { + if (xhr.response != undefined && xhr.response.length != 0) { + alert('Error: ' + xhr.status); + } + else { + alert('An error has occurred. If problem persists please contact your community administrator.'); + } + } + } + } +}); \ No newline at end of file diff --git a/account/assets/js/panelHandlers/users/open.js b/account/assets/js/panelHandlers/users/open.js index df75bc4..ce82195 100644 --- a/account/assets/js/panelHandlers/users/open.js +++ b/account/assets/js/panelHandlers/users/open.js @@ -27,7 +27,7 @@ function listCurrentUsers() { }); } else { - display.html('

An error has occurred, please refresh. If problem persists please contact your administrator.

'); + display.html('

An error has occurred, please refresh. If problem persists please contact your administrator.

'); } } else if(xhr.status == 204) { diff --git a/account/gPanel.html b/account/gPanel.html index 58c21ca..58b09ed 100644 --- a/account/gPanel.html +++ b/account/gPanel.html @@ -185,6 +185,40 @@ + + +
@@ -273,6 +307,20 @@
+ +
+
+
+
+

Domains & Sub-domains

+
View registered domains, register new domains, and set up or manage existing document roots for sub-domains.
+
+ +
+
+
+
+