GUI Code refactor
[vnfsdk/refrepo.git] / openo-portal / portal-auth / src / main / webapp / user / js / modifyUser.js
index e75e977..7e57144 100644 (file)
@@ -1,78 +1,78 @@
-/*
- * Copyright 2016 Huawei Technologies Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-$(document).ready(function() {
-    var USER_SERVICE = "/openoapi/auth/v1/users";
-    var userId;
-    function initialPage() {
-        userId = getId();
-        getUserDetails(userId).done(function(data) {
-            listUserDetails(data);
-        });
-
-        /*initial the event*/
-        $("#confirm").click(function(e) {
-            var data = getModifyUser();
-            modifyUser(data).done(function() {
-                window.document.location = "/openoui/user/user.html";
-            })
-        })
-        $("#cancel").click(function(e) {
-            window.document.location = "/openoui/user/user.html";
-        })
-    }
-
-    function getModifyUser() {
-        var data = {};
-        data.description = $("#description").val();
-        data.email = "xxxx@xxxx.com";
-        return data;
-    }
-    function getUserDetails(id) {
-        return Rest.http({
-            url: USER_SERVICE + "/" + id + "?=" + new Date().getTime(),
-            type: "GET",
-            async: false,
-            contentType: 'application/json',
-            dataType: "json"
-        })
-    }
-
-    function listUserDetails(data) {
-        $("#userName").val(data.name);
-        $("#description").val(data.description);
-    }
-
-    function modifyUser(data) {
-        return Rest.http({
-            url: USER_SERVICE + "/" + userId + "?=" + new Date().getTime(),
-            type: "PATCH",
-            async: false,
-            contentType: 'application/json',
-            dataType: "json",
-            data: JSON.stringify(data)
-        })
-    }
-
-    function getId() {
-        var qs = location.search;
-        qs = qs.indexOf("?") === 0 ? qs : ("?" + qs);
-        var start = qs.indexOf("id=") + 3;
-        var end = qs.indexOf("&") === -1 ? qs.length : qs.indexOf("&") - start;
-        return qs.substr(start, end);
-    }
-
-    initialPage();
+/*\r
+ * Copyright 2016 Huawei Technologies Co., Ltd.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+$(document).ready(function() {\r
+    var USER_SERVICE = "/openoapi/auth/v1/users";\r
+    var userId;\r
+    function initialPage() {\r
+        userId = getId();\r
+        getUserDetails(userId).done(function(data) {\r
+            listUserDetails(data);\r
+        });\r
+\r
+        /*initial the event*/\r
+        $("#confirm").click(function(e) {\r
+            var data = getModifyUser();\r
+            modifyUser(data).done(function() {\r
+                window.document.location = "/openoui/user/user.html";\r
+            })\r
+        })\r
+        $("#cancel").click(function(e) {\r
+            window.document.location = "/openoui/user/user.html";\r
+        })\r
+    }\r
+\r
+    function getModifyUser() {\r
+        var data = {};\r
+        data.description = $("#description").val();\r
+        data.email = "xxxx@xxxx.com";\r
+        return data;\r
+    }\r
+    function getUserDetails(id) {\r
+        return Rest.http({\r
+            url: USER_SERVICE + "/" + id + "?=" + new Date().getTime(),\r
+            type: "GET",\r
+            async: false,\r
+            contentType: 'application/json',\r
+            dataType: "json"\r
+        })\r
+    }\r
+\r
+    function listUserDetails(data) {\r
+        $("#userName").val(data.name);\r
+        $("#description").val(data.description);\r
+    }\r
+\r
+    function modifyUser(data) {\r
+        return Rest.http({\r
+            url: USER_SERVICE + "/" + userId + "?=" + new Date().getTime(),\r
+            type: "PATCH",\r
+            async: false,\r
+            contentType: 'application/json',\r
+            dataType: "json",\r
+            data: JSON.stringify(data)\r
+        })\r
+    }\r
+\r
+    function getId() {\r
+        var qs = location.search;\r
+        qs = qs.indexOf("?") === 0 ? qs : ("?" + qs);\r
+        var start = qs.indexOf("id=") + 3;\r
+        var end = qs.indexOf("&") === -1 ? qs.length : qs.indexOf("&") - start;\r
+        return qs.substr(start, end);\r
+    }\r
+\r
+    initialPage();\r
 })
\ No newline at end of file