2 * Copyright 2016-2017 Huawei Technologies Co., Ltd.
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
16 $(document).ready(function() {
\r
17 var USER_SERVICE = "/openoapi/auth/v1/users";
\r
19 function initialPage() {
\r
21 getUserDetails(userId).done(function(data) {
\r
22 listUserDetails(data);
\r
25 /*initial the event*/
\r
26 $("#confirm").click(function(e) {
\r
27 var data = getModifyUser();
\r
28 modifyUser(data).done(function() {
\r
29 window.document.location = "/openoui/user/user.html";
\r
32 $("#cancel").click(function(e) {
\r
33 window.document.location = "/openoui/user/user.html";
\r
37 function getModifyUser() {
\r
39 data.description = $("#description").val();
\r
40 data.email = "xxxx@xxxx.com";
\r
43 function getUserDetails(id) {
\r
45 url: USER_SERVICE + "/" + id + "?=" + new Date().getTime(),
\r
48 contentType: 'application/json',
\r
53 function listUserDetails(data) {
\r
54 $("#userName").val(data.name);
\r
55 $("#description").val(data.description);
\r
58 function modifyUser(data) {
\r
60 url: USER_SERVICE + "/" + userId + "?=" + new Date().getTime(),
\r
63 contentType: 'application/json',
\r
65 data: JSON.stringify(data)
\r
70 var qs = location.search;
\r
71 qs = qs.indexOf("?") === 0 ? qs : ("?" + qs);
\r
72 var start = qs.indexOf("id=") + 3;
\r
73 var end = qs.indexOf("&") === -1 ? qs.length : qs.indexOf("&") - start;
\r
74 return qs.substr(start, end);
\r