Download pool/shard002/JavaScript/0012731_status-updater.factory.js from Variable-role/sajaniemi_variable_dataset_large: direct link, hf CLI and curl.
- Browser
- Download file 1.6 kB
-
https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard002/JavaScript/0012731_status-updater.factory.js
- Command line
-
hf download hf://datasets/Variable-role/sajaniemi_variable_dataset_large/pool/shard002/JavaScript/0012731_status-updater.factory.js
-
curl -L -o 0012731_status-updater.factory.js https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard002/JavaScript/0012731_status-updater.factory.js
1.6 kB
| angular | |
| .module("hwboard") | |
| .factory("statusUpdater", statusUpdater); | |
| function statusUpdater($injector, $log, $timeout) { | |
| // ----------- | |
| // Initialization | |
| // ----------- | |
| var frequency = 2000; // How often to update. | |
| var _updateTimeout = undefined; | |
| var onStatusUpdateCallback = undefined; | |
| // ------------- | |
| // Declare the API | |
| // ------------- | |
| return { | |
| start: start, | |
| stop: stop, | |
| setOnStatusUpdate: setOnStatusUpdate | |
| }; // !return | |
| // ----------- | |
| // Implementations | |
| // ----------- | |
| function setOnStatusUpdate(callback) { | |
| onStatusUpdateCallback = callback; | |
| } | |
| function start() { | |
| _updateTimeout = $timeout(updateStatus, frequency); | |
| } // !start | |
| function stop() { | |
| $timeout.cancel(_updateTimeout); | |
| } // !stop | |
| function updateStatus() { | |
| //Weblab.dbgSetOfflineSendCommandResponse("STATE=programming"); | |
| weblab.sendCommand("STATE") | |
| .done(onStatusSuccess) | |
| .fail(onStatusError); | |
| } | |
| function onStatusSuccess(response) { | |
| $log.debug("SUCCESS: STATUS: " + response); | |
| if(onStatusUpdateCallback != undefined) { | |
| var status = response.substring(6); // Remove the "STATE=" part. | |
| onStatusUpdateCallback(status) | |
| } | |
| _updateTimeout = $timeout(updateStatus, frequency); | |
| } | |
| function onStatusError(error) { | |
| $log.error("ERROR: sendCommand (status)"); | |
| $log.error(error); | |
| _updateTimeout = $timeout(updateStatus, frequency); | |
| } | |
| } // !statusUpdater | |