OLD | NEW |
(Empty) | |
| 1 /* Copyright 2016 The Chromium Authors. All Rights Reserved. |
| 2 * |
| 3 * Use of this source code is governed by a BSD-style |
| 4 * license that can be found in the LICENSE file or at |
| 5 * https://developers.google.com/open-source/licenses/bsd |
| 6 */ |
| 7 |
| 8 /** |
| 9 * @fileoverview Functions that support project name checks when |
| 10 * creating a new project. |
| 11 */ |
| 12 |
| 13 /** |
| 14 * Function that communicates with the server. |
| 15 * @param {string} projectName The proposed project name. |
| 16 */ |
| 17 function checkProjectName(projectName) { |
| 18 var createProjectUrl = '/hosting/createProject/checkProjectName.do'; |
| 19 var args = { |
| 20 'project': projectName |
| 21 }; |
| 22 CS_doPost(createProjectUrl, nameTaken, args); |
| 23 } |
| 24 |
| 25 /** |
| 26 * Function that evaluates the server response and sets the error message. |
| 27 * @param {event} event with xhr server's JSON response to the AJAX request. |
| 28 */ |
| 29 function nameTaken(event) { |
| 30 var xhr = event.target; |
| 31 if (xhr.readyState != 4 || xhr.status != 200) |
| 32 return; |
| 33 var resp = CS_parseJSON(xhr); |
| 34 var errorMessage = resp['error_message']; |
| 35 document.getElementById('projectnamefeedback').innerText = errorMessage; |
| 36 if (errorMessage != '') { |
| 37 document.getElementById('submit_btn').disabled = 'disabled'; |
| 38 } |
| 39 } |
| 40 |
| 41 // Make this function globally available |
| 42 _CP_checkProjectName = checkProjectName; |
OLD | NEW |