check_finished()
else: # remote camera
- remote.get_config(local_config, on_response_builder(camera_id, local_config))
+ if local_config['@enabled']:
+ remote.get_config(local_config, on_response_builder(camera_id, local_config))
+
+ else: # don't try to reach the remote of the camera is disabled
+ on_response_builder(camera_id, local_config)(None)
if length[0] == 0:
self.finish_json({'cameras': []})
background-color: #212121;
}
+select,
+input[type=text],
+input[type=password] {
+ box-sizing: border-box;
+}
+
/* fonts */
table.add-camera-dialog select,
table.add-camera-dialog input[type=text],
table.add-camera-dialog input[type=password] {
- width: 10em;
+ width: 17em;
}
});
/* fetch & push handlers */
- $('#videoDeviceSelect').change(function () {
+ $('#videoDeviceSelect').focus(function () {
+ /* remember the previously selected index */
+ this._prevSelectedIndex = this.selectedIndex;
+
+ }).change(function () {
if ($('#videoDeviceSelect').val() === 'add') {
runAddCameraDialog();
- if ($('#videoDeviceSelect').find('option').length > 1) {
- $('#videoDeviceSelect')[0].selectedIndex = 0;
- }
- else {
- $('#videoDeviceSelect')[0].selectedIndex = -1;
- }
-
- updateConfigUi();
+ this.selectedIndex = this._prevSelectedIndex;
}
else {
+ this._prevSelectedIndex = this.selectedIndex;
beginProgress([$(this).val()]);
fetchCurrentCameraConfig(endProgress);
}
/* errors while getting the configuration */
$('#videoDeviceSwitch')[0].error = true;
- $('#videoDeviceSwitch')[0].checked = true;
+ $('#videoDeviceSwitch')[0].checked = false;
updateConfigUi();
return;
}
videoDeviceSelect.append('<option value="add">add camera...</option>');
- if (cameras.length) { /* at least one camera */
+ var enabledCameras = cameras.filter(function (camera) {return camera['enabled'];});
+ if (enabledCameras.length > 0) { /* prefer the first enabled camera */
+ videoDeviceSelect[0].selectedIndex = cameras.indexOf(enabledCameras[0]);
+ fetchCurrentCameraConfig();
+ }
+ else if (cameras.length) { /* a disabled camera */
videoDeviceSelect[0].selectedIndex = 0;
fetchCurrentCameraConfig();
}
else { /* no camera at all */
videoDeviceSelect[0].selectedIndex = -1;
}
-
+
updateConfigUi();
}
}
});
- deviceSelect.append('<option value="remote">Remote device...</option>');
+ deviceSelect.append('<option value="remote">Remote motionEye camera...</option>');
updateUi();