From 0f327a772b24ed797d930606c8fa21dc212240d5 Mon Sep 17 00:00:00 2001 From: Amanda Anganes <aanganes@mitre.org> Date: Fri, 29 Mar 2013 12:46:33 -0400 Subject: [PATCH] Updated js files to use results returned from JsonErrorView; factored out markup into modal definition. --- .../src/main/webapp/WEB-INF/tags/header.tag | 5 ++++- .../src/main/webapp/resources/js/admin.js | 8 ++++---- .../src/main/webapp/resources/js/client.js | 8 ++++---- .../src/main/webapp/resources/js/grant.js | 4 ++-- .../src/main/webapp/resources/js/scope.js | 8 ++++---- .../src/main/webapp/resources/js/whitelist.js | 8 ++++---- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/openid-connect-server/src/main/webapp/WEB-INF/tags/header.tag b/openid-connect-server/src/main/webapp/WEB-INF/tags/header.tag index 1847766dc..d644d70e3 100644 --- a/openid-connect-server/src/main/webapp/WEB-INF/tags/header.tag +++ b/openid-connect-server/src/main/webapp/WEB-INF/tags/header.tag @@ -109,7 +109,10 @@ <body> <div id="modalAlert" class="modal hide fade"> - <div class="modal-body"></div> + <div class="alert alert-error"> + <strong>Warning!</strong> + <div class="modal-body"></div> + </div> <div class="modal-footer"><button class="btn primary" type="button" onclick="$('#modalAlert').modal('hide');">OK</button></div> </div> diff --git a/openid-connect-server/src/main/webapp/resources/js/admin.js b/openid-connect-server/src/main/webapp/resources/js/admin.js index 8ad3d3f13..5155ca50d 100644 --- a/openid-connect-server/src/main/webapp/resources/js/admin.js +++ b/openid-connect-server/src/main/webapp/resources/js/admin.js @@ -38,10 +38,10 @@ var ListWidgetChildView = Backbone.View.extend({ console.log("An error occurred when deleting from a list widget"); //Pull out the response text. - var responseText = JSON.parse(response.responseText); + var responseJson = JSON.parse(response.responseText); //Display an alert with an error message - $('#modalAlert div.modal-body').html("<div class='alert alert-error'><strong>Warning!</strong>" + responseText + "</div>"); + $('#modalAlert div.modal-body').html(responseJson.errorMessage); $("#modalAlert").modal({ // wire up the actual modal functionality and show the dialog "backdrop" : "static", @@ -271,10 +271,10 @@ var BlackListWidgetView = ListWidgetView.extend({ }, error:function(error, response) { //Pull out the response text. - var responseText = JSON.parse(response.responseText); + var responseJson = JSON.parse(response.responseText); //Display an alert with an error message - $('#modalAlert div.modal-body').html("<div class='alert alert-error'><strong>Warning!</strong>" + responseText + "</div>"); + $('#modalAlert div.modal-body').html(responseJson.errorMessage); $("#modalAlert").modal({ // wire up the actual modal functionality and show the dialog "backdrop" : "static", diff --git a/openid-connect-server/src/main/webapp/resources/js/client.js b/openid-connect-server/src/main/webapp/resources/js/client.js index a8d3d5c0b..deb867be8 100644 --- a/openid-connect-server/src/main/webapp/resources/js/client.js +++ b/openid-connect-server/src/main/webapp/resources/js/client.js @@ -165,10 +165,10 @@ var ClientView = Backbone.View.extend({ console.log("An error occurred when deleting a client"); //Pull out the response text. - var responseText = JSON.parse(response.responseText); + var responseJson = JSON.parse(response.responseText); //Display an alert with an error message - $('#modalAlert div.modal-body').html("<div class='alert alert-error'><strong>Warning!</strong>" + responseText + "</div>"); + $('#modalAlert div.modal-body').html(responseJson.errorMessage); $("#modalAlert").modal({ // wire up the actual modal functionality and show the dialog "backdrop" : "static", @@ -502,10 +502,10 @@ var ClientFormView = Backbone.View.extend({ console.log("An error occurred when deleting from a list widget"); //Pull out the response text. - var responseText = JSON.parse(response.responseText); + var responseJson = JSON.parse(response.responseText); //Display an alert with an error message - $('#modalAlert div.modal-body').html("<div class='alert alert-error'><strong>Warning!</strong>" + responseText + "</div>"); + $('#modalAlert div.modal-body').html(responseJson.errorMessage); $("#modalAlert").modal({ // wire up the actual modal functionality and show the dialog "backdrop" : "static", diff --git a/openid-connect-server/src/main/webapp/resources/js/grant.js b/openid-connect-server/src/main/webapp/resources/js/grant.js index f71d0adbd..3e6c63ba2 100644 --- a/openid-connect-server/src/main/webapp/resources/js/grant.js +++ b/openid-connect-server/src/main/webapp/resources/js/grant.js @@ -133,10 +133,10 @@ var ApprovedSiteView = Backbone.View.extend({ error:function (error, response) { //Pull out the response text. - var responseText = JSON.parse(response.responseText); + var responseJson = JSON.parse(response.responseText); //Display an alert with an error message - $('#modalAlert div.modal-body').html("<div class='alert alert-error'><strong>Warning!</strong>" + responseText + "</div>"); + $('#modalAlert div.modal-body').html(responseJson.errorMessage); $("#modalAlert").modal({ // wire up the actual modal functionality and show the dialog "backdrop" : "static", diff --git a/openid-connect-server/src/main/webapp/resources/js/scope.js b/openid-connect-server/src/main/webapp/resources/js/scope.js index 76f6cf176..dd4e5403e 100644 --- a/openid-connect-server/src/main/webapp/resources/js/scope.js +++ b/openid-connect-server/src/main/webapp/resources/js/scope.js @@ -87,10 +87,10 @@ var SystemScopeView = Backbone.View.extend({ error:function (error, response) { //Pull out the response text. - var responseText = JSON.parse(response.responseText); + var responseJson = JSON.parse(response.responseText); //Display an alert with an error message - $('#modalAlert div.modal-body').html("<div class='alert alert-error'><strong>Warning!</strong>" + responseText + "</div>"); + $('#modalAlert div.modal-body').html(responseJson.errorMessage); $("#modalAlert").modal({ // wire up the actual modal functionality and show the dialog "backdrop" : "static", @@ -241,7 +241,7 @@ var SystemScopeFormView = Backbone.View.extend({ error:function(error, response) { //Pull out the response text. - var responseText = JSON.parse(response.responseText); + var responseJson = JSON.parse(response.responseText); if (response.status == 409) { //Conflict, scope already exists @@ -256,7 +256,7 @@ var SystemScopeFormView = Backbone.View.extend({ } else { //Display an alert with an error message - $('#modalAlert div.modal-body').html("<div class='alert alert-error'><strong>Warning!</strong>" + responseText + "</div>"); + $('#modalAlert div.modal-body').html(responseJson.errorMessage); $("#modalAlert").modal({ // wire up the actual modal functionality and show the dialog "backdrop" : "static", diff --git a/openid-connect-server/src/main/webapp/resources/js/whitelist.js b/openid-connect-server/src/main/webapp/resources/js/whitelist.js index 0e5daf567..107f4475a 100644 --- a/openid-connect-server/src/main/webapp/resources/js/whitelist.js +++ b/openid-connect-server/src/main/webapp/resources/js/whitelist.js @@ -134,10 +134,10 @@ var WhiteListView = Backbone.View.extend({ console.log("An error occurred when deleting a whitelist entry"); //Pull out the response text. - var responseText = JSON.parse(response.responseText); + var responseJson = JSON.parse(response.responseText); //Display an alert with an error message - $('#modalAlert div.modal-body').html("<div class='alert alert-error'><strong>Warning!</strong>" + responseText + "</div>"); + $('#modalAlert div.modal-body').html(responseJson.errorMessage); $("#modalAlert").modal({ // wire up the actual modal functionality and show the dialog "backdrop" : "static", @@ -201,10 +201,10 @@ var WhiteListFormView = Backbone.View.extend({ console.log("An error occurred when deleting from a list widget"); //Pull out the response text. - var responseText = JSON.parse(response.responseText); + var responseJson = JSON.parse(response.responseText); //Display an alert with an error message - $('#modalAlert div.modal-body').html("<div class='alert alert-error'><strong>Warning!</strong>" + responseText + "</div>"); + $('#modalAlert div.modal-body').html(responseJson.errorMessage); $("#modalAlert").modal({ // wire up the actual modal functionality and show the dialog "backdrop" : "static",