From ab6ca080771b706a310ebfd8a4192841cdfef05c Mon Sep 17 00:00:00 2001 From: Private Island Networks Inc Date: Tue, 3 Mar 2026 15:56:53 -0500 Subject: initial commit of experimental code base for PI Explorer (PI-EXP) --- static/js/main.js | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 static/js/main.js (limited to 'static/js/main.js') diff --git a/static/js/main.js b/static/js/main.js new file mode 100644 index 0000000..3caa3a7 --- /dev/null +++ b/static/js/main.js @@ -0,0 +1,118 @@ +/* + * + * Copyright (C) 2026 Private Island Networks Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * file: main.js + * + */ + + +"use strict"; + +let selected_mode = MODE_LIVE; + +window.addEventListener("load", function(e) { + // re-initialize controls, as needed + /* + $('#mc-mode-live').checked=true; + $('#mc-filename').value = null; // clear any file that was previously selected + + // set up event listeners + $('#mc-mode-live').addEventListener('change',wl_changeMode); + $('#mc-mode-file').addEventListener('change',wl_changeMode); + $('#mc-filename').addEventListener('change',wl_filename); + $('#mc-start').addEventListener('click', wl_start); + $('#mc-stop').addEventListener('click', wl_stop); + $('#mc-help').addEventListener('click', wl_help); + $('#mc-clear').addEventListener('click', wl_clear); + */ + console.log("strict mode test: ",isStrictMode()); +}); + + +function wl_changeMode(event) { + event.preventDefault(); + console.log('change mode: ',event.target.id); + if (event.target.id == "mc-mode-file") { + selected_mode = MODE_FILE; + } + else { + selected_mode = MODE_LIVE; + } +} + +function wl_filename(event) { + event.preventDefault(); + $.loading('block'); + + let data = { 'filename': event.target.files[0].name }; + + $.post("/filename", data, function(resp) { + console.log("filename"); + }); + + $.loading('none'); +} + +function wl_start(event) { + event.preventDefault(); + let data = { 'mode': selected_mode } + $.loading('block'); + + $.post("/start", data, function(resp) { + $('#mc-mode').innerText = "Running"; + }); + // await new Promise(r => setTimeout(r, 1000)); + $.loading('none'); +} + +function wl_stop(event) { + event.preventDefault(); + let data = { 'mode': MODE_IDLE } + $('#mc-mode').innerText = "Idle"; + $.loading('block'); + $.post("/stop", data, function(resp) { + $('#mc-mode').innerText = "Idle"; + }); + $.loading('none'); +} + +function wl_help(event) { + event.preventDefault(); + m = modal('large'); + /* jshint multistr: true */ + m.display('

GEODSS WebLogger Help:

\ + '); +} + +function wl_clear(event) { + event.preventDefault(); + let log = $('#mc-log'); + while (log.firstChild) { + log.removeChild(log.firstChild); + } +} + +function update_fw_version(fw_version) { + $('#mc-fw-version').innerText = fw_version.substring(2,4); +} + +function update_fw_increment(fw_increment) { + $('#mc-fw-increment').innerText = fw_increment.substring(2,4); +} + +function update_temperature(temperature) { + $('#mc-temperature').innerText = parseInt(temperature,16) + " \xB0F"; +} -- cgit v1.2.3-8-gadcc