From: Olivier Lamy Date: Mon, 19 Dec 2011 13:25:15 +0000 (+0000) Subject: start adding comments in js files X-Git-Tag: archiva-1.4-M3~1705 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6f32db32939496bd390376c46223b039614da7c6;p=archiva.git start adding comments in js files git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1220733 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js index 4470c7c0c..e4fa4a935 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js @@ -19,11 +19,15 @@ $(function() { // define a container object with various datas - window.redbackModel = {usersViewModel:null,userOperationNames:null,key:null,userCreate:false}; - + window.redbackModel = {usersViewModel:null,userOperationNames:null,key:null,userCreate:false,i18n:$.i18n.map}; + /** + * display redback error from redback json error response + * {"redbackRestError":{"errorMessages":{"args":1,"errorKey":"user.password.violation.numeric"}}} + * @param obj + * @param idToAppend + */ displayRedbackError=function(obj,idToAppend) { - // {"redbackRestError":{"errorMessages":{"args":1,"errorKey":"user.password.violation.numeric"}}} if ($.isArray(obj.redbackRestError.errorMessages)) { $.log("displayRedbackError with array"); for(var i=0; i"; }; + /** + * open a confirm dialog + * @param okFn callback function to call on ok confirm + * @param okMessage + * @param cancelMessage + * @param title + */ openDialogConfirm=function(okFn, okMessage, cancelMessage, title){ $("#dialog-confirm" ).dialog({ resizable: false, diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/register.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/register.js index c81535bbd..691a30eb3 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/register.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/register.js @@ -18,6 +18,9 @@ */ $(function() { + /** + * open the register modal box + */ registerBox=function(){ if (window.modalRegisterWindow==null) { window.modalRegisterWindow = $("#modal-register").modal({backdrop:'static',show:false}); @@ -38,6 +41,9 @@ $(function() { $("#modal-register").focus(); } + /** + * validate the register form and call REST service + */ register=function(){ var valid = $("#user-register-form").valid(); if (!valid) { diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/user-grids.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/user-grids.html index 39da87c9e..af413da71 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/user-grids.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/user-grids.html @@ -95,7 +95,7 @@ Users
  • - {{$.i18n.prop('user.add')}} + {window.redbackModel.i18n('user.add')}
  • diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js index d2a9471c1..7e7086ab3 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js @@ -17,6 +17,22 @@ * under the License. */ $(function() { + /** + * object model for user with some function to create/update/delete users + * @param username + * @param password + * @param confirmPassword + * @param fullName + * @param email + * @param permanent + * @param validated + * @param timestampAccountCreation + * @param timestampLastLogin + * @param timestampLastPasswordChange + * @param locked + * @param passwordChangeRequired + * @param ownerViewModel + */ user=function(username, password, confirmPassword,fullName,email,permanent,validated,timestampAccountCreation,timestampLastLogin,timestampLastPasswordChange,locked,passwordChangeRequired,ownerViewModel) { // Potentially Editable Field. this.username = ko.observable(username); @@ -116,7 +132,7 @@ $(function() { type: "GET", dataType: 'json', success: function(data) { - // FIXME i18n and use a messages div + // FIXME i18n window.redbackModel.usersViewModel.users.remove(currentUser); displaySuccessMessage("user " + currentUser.username() + " deleted"); }, @@ -180,11 +196,16 @@ $(function() { this.i18n = $.i18n.prop; } - + /** + * view for admin user creation + */ adminUserViewModel=function() { this.user = new user("admin","aze123","aze123", "the admin"); } + /** + * open a modal box to create admin user + */ adminCreateBox=function() { window.redbackModel.createUser=true; jQuery("#main-content").attr("data-bind",'template: {name:"redback/user-edit-tmpl",data: user}'); @@ -203,6 +224,9 @@ $(function() { } + /** + * open a modal box for login + */ loginBox=function(){ screenChange(); if (window.modalLoginWindow==null) { @@ -224,6 +248,11 @@ $(function() { $("#modal-login").focus(); } + /** + * callback success function on rest login call. + * modal close and hide/show some links (login,logout,register...) + * @param result + */ var successLoginCallbackFn=function(result){ var logged = false; if (result == null) { @@ -264,17 +293,28 @@ $(function() { $("#modal-login-err-message").show(); } + /** + * callback error function on rest login call. display error message + * @param result + */ var errorLoginCallbackFn= function(result) { var obj = jQuery.parseJSON(result.responseText); displayRedbackError(obj,"modal-login-err-message"); $("#modal-login-err-message").show(); } + /** + * callback complate function on rest login call. remove spinner from modal login box + * @param result + */ var completeLoginCallbackFn=function(){ $("#modal-login-ok").removeAttr("disabled"); $("#login-spinner").remove(); } + /** + * validate login box before ajax call + */ login=function(){ $("#modal-login-err-message").html(""); screenChange(); @@ -293,10 +333,16 @@ $(function() { loginCall($("#user-login-form-username").val(),$("#user-login-form-password").val() ,successLoginCallbackFn,errorLoginCallbackFn,completeLoginCallbackFn); - - } + /** + * call REST method for login + * @param username + * @param password + * @param successCallbackFn + * @param errorCallbackFn + * @param completeCallbackFn + */ loginCall=function(username,password,successCallbackFn, errorCallbackFn, completeCallbackFn) { var url = 'restServices/redbackServices/loginService/logIn?userName='+username; url += "&password="+password; @@ -351,6 +397,9 @@ $(function() { $("#modal-password-change").focus(); } + /** + * display modal box for updating current user details + */ editUserDetailsBox=function(){ screenChange(); $("#modal-user-edit-err-message").hide(); @@ -397,6 +446,10 @@ $(function() { $("#modal-user-edit").focus(); } + /** + * REST call to update current user + * @param user + */ editUserDetails=function(user){ $("#modal-user-edit-err-message").html(""); $.ajax("restServices/redbackServices/userService/updateMe", { @@ -406,7 +459,7 @@ $(function() { dataType: 'json', success: function(result) { var created = JSON.parse(result); - // FIXME use a message div and i18n + // FIXME i18n if (created == true) { displaySuccessMessage("details updated."); window.modalEditUserBox.modal('hide'); @@ -430,7 +483,7 @@ $(function() { /** * * @param previousPassword display and validate previous password text field - * @param registration are we in registration mode ? + * @param registration are we in registration mode ? if yes the user will be logged */ changePassword=function(previousPassword,registration,user){ var valid = $("#password-change-form").valid(); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js index d68b0bc74..399947525 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js @@ -18,6 +18,9 @@ */ $(function() { + /** + * view model used for users grid + */ usersViewModel=function() { this.users = ko.observableArray([]); var self = this; @@ -154,6 +157,9 @@ $(function() { } + /** + * called from the menu to display tabs with users grid + */ displayUsersGrid=function() { screenChange(); jQuery("#main-content").attr("data-bind",""); @@ -198,7 +204,10 @@ $(function() { $("#users-view-tabs-li-user-edit").addClass("active"); } - + /** + * not used as we don't have the mapping in web.xml + * but why to handle such urls which go directly to a view + */ $(document).ready(function() { // url ends with /users/list // and current has archiva-manage-users karma