OLD | NEW |
1 /** | 1 /** |
2 * Copyright 2014 The Chromium Authors. All rights reserved. | 2 * Copyright 2014 The Chromium Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 /** | 7 /** |
8 * See http://dev.w3.org/2011/webrtc/editor/getusermedia.html for more | 8 * See http://dev.w3.org/2011/webrtc/editor/getusermedia.html for more |
9 * information on getUserMedia. See | 9 * information on getUserMedia. See |
10 * http://dev.w3.org/2011/webrtc/editor/webrtc.html for more information on | 10 * http://dev.w3.org/2011/webrtc/editor/webrtc.html for more information on |
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 * @param {!string} element_id to be used as a key for local storage and the id | 1055 * @param {!string} element_id to be used as a key for local storage and the id |
1056 * of the element to store the state for. | 1056 * of the element to store the state for. |
1057 */ | 1057 */ |
1058 function registerLocalStorage_(element_id) { | 1058 function registerLocalStorage_(element_id) { |
1059 var element = $(element_id); | 1059 var element = $(element_id); |
1060 if (element.tagName != 'INPUT') { | 1060 if (element.tagName != 'INPUT') { |
1061 error_('You can only use registerLocalStorage_ for input elements. ' + | 1061 error_('You can only use registerLocalStorage_ for input elements. ' + |
1062 'Element \"' + element.tagName + '\" is not an input element. '); | 1062 'Element \"' + element.tagName + '\" is not an input element. '); |
1063 } | 1063 } |
1064 | 1064 |
1065 if (localStorage.getItem(element.id) == 'undefined') { | 1065 if (localStorage.getItem(element.id) == null) { |
1066 storeLocalStorageField_(element); | 1066 storeLocalStorageField_(element); |
1067 } else { | 1067 } else { |
1068 getLocalStorageField_(element); | 1068 getLocalStorageField_(element); |
1069 } | 1069 } |
| 1070 |
1070 // Registers the appropriate events for input elements. | 1071 // Registers the appropriate events for input elements. |
1071 if (element.type == 'checkbox') { | 1072 if (element.type == 'checkbox') { |
1072 element.onclick = function() { storeLocalStorageField_(this); }; | 1073 element.onclick = function() { storeLocalStorageField_(this); }; |
1073 } else if (element.type == 'text') { | 1074 } else if (element.type == 'text') { |
1074 element.onblur = function() { storeLocalStorageField_(this); }; | 1075 element.onblur = function() { storeLocalStorageField_(this); }; |
1075 } else { | 1076 } else { |
1076 error_('Unsupportered input type: ' + '\"' + element.type + '\"'); | 1077 error_('Unsupportered input type: ' + '\"' + element.type + '\"'); |
1077 } | 1078 } |
1078 } | 1079 } |
1079 | 1080 |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1390 | 1391 |
1391 /** @private */ | 1392 /** @private */ |
1392 function readResponseHeader_(request, key) { | 1393 function readResponseHeader_(request, key) { |
1393 var value = request.getResponseHeader(key); | 1394 var value = request.getResponseHeader(key); |
1394 if (value == null || value.length == 0) { | 1395 if (value == null || value.length == 0) { |
1395 error_('Received empty value ' + value + | 1396 error_('Received empty value ' + value + |
1396 ' for response header key ' + key + '.'); | 1397 ' for response header key ' + key + '.'); |
1397 } | 1398 } |
1398 return parseInt(value); | 1399 return parseInt(value); |
1399 } | 1400 } |
OLD | NEW |