Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div class="row">
<div class="">
<header class="primary">
<h1>Camera Control</h1>
<h1><p id="camName"></p></h1>
</header>
<nav class="primary">
<ul>
Expand Down Expand Up @@ -326,7 +326,18 @@ <h4 class="modal-title" id="cam_adjust_control_settings_label">Preferences</h4>
<input class="form-control" type="text" id="cam_ip" value=""></div>
<div class="col-xs-6">
<label>&nbsp;</label>
<button class="btn btn-default form-control reload_cam">Reload Camera</button>
<button class="btn btn-primary form-control reload_cam">Reload Camera</button>
</div>
</div>

<div class="row">
<div class="col-xs-6">
<label for="cam_name">Camera Name</label>
<input class="form-control" type="text" id="cam_name" value="">
</div>
<div class="col-xs-6">
<label>&nbsp;</label>
<button class="btn btn-primary form-control reload_name">Change Name</button>
</div>
</div>

Expand Down Expand Up @@ -457,4 +468,4 @@ <h4 class="modal-title" id="cam_adjust_control_settings_label">Preferences</h4>
</script>

<!-- Insert this line after script imports -->
<script>if (window.module) module = window.module;</script>
<script>if (window.module) module = window.module;</script>
31 changes: 29 additions & 2 deletions js/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@

var camera_ip = "192.168.0.190";
var camera_name = "PTZ Optics";
var base_url = "http://" + camera_ip + "/cgi-bin";
// config defaults
var defaults = {
ip: camera_ip,
name: camera_name,
flip: 1,
mirror: 1,
invertcontrols: 1,
Expand All @@ -18,6 +20,7 @@ var defaults = {
};
var config = defaults;
config.ip = camera_ip;
config.name = camera_name;

function get_config () {
var result = localStorage.getItem('configStorage');
Expand All @@ -40,7 +43,7 @@ function run_action (action_url) {
type: 'GET',
})
.done(function() {
// console.log("success");
document.getElementById("camName").innerHTML = setCamName();
})
.fail(function(jqXHR, responseText, errorThrown) {
// console.log("error");
Expand All @@ -60,6 +63,9 @@ function config_init () {
$("#cam_ip").val(config.ip);
base_url = "http://" + config.ip + "/cgi-bin";

// set the inital name for the camera.
$("#cam_name").val(config.name)

// set the camera's initial configuration for each value in the saved config object
config_setting("flip", config.flip);
config_setting("mirror", config.mirror);
Expand Down Expand Up @@ -166,6 +172,7 @@ function update_labels () {
}

config.ip = $('#cam_ip').val();
config.name = $('#cam_name').val();
}

function reload_cam () {
Expand All @@ -184,6 +191,14 @@ function reload_cam () {
}
}

function reload_name () {
config.name = $('#cam_name').val();
config.name = config.name;
save_config();
document.getElementById("camName").innerHTML = setCamName();
alert("Name Saved.");
}

function adjust_setting (action) {

switch (action) {
Expand Down Expand Up @@ -554,6 +569,12 @@ function clear_active_preset () {
$('.preset_button').removeClass("active");
}

function setCamName() {
return config.name;
}

document.getElementById("camName").innerHTML = setCamName();

$('body').on('click', '.autopan', function(e) {
e.preventDefault();
clear_active_preset();
Expand Down Expand Up @@ -616,6 +637,12 @@ $('body').on('click', '.reload_cam', function(e) {
return false;
});

$('body').on('click', '.reload_name', function(e) {
e.preventDefault();
reload_name();
return false;
});

$('body').on('mousedown', '.adjust_pantilt', function(e) {
e.preventDefault();
stop_autopan();
Expand Down Expand Up @@ -793,4 +820,4 @@ const {app} = remote;
app.on('before-quit', () => {
// reset the camera to home position before closing the application
cam_pantilt(1, 'home');
})
})