Add lib.main.js and lib.board.js
Migrate code from main.js to lib.main.js Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
parent
bcf984022b
commit
3e66cdad8d
12
UpNext.md
12
UpNext.md
@ -23,6 +23,18 @@
|
||||
- find-code.js
|
||||
- service-worker.js
|
||||
|
||||
### In Progress:
|
||||
|
||||
* Frontend code refactoring: --- Pre-Refactor /static/js folder size: 22132B
|
||||
- Refactor into files:
|
||||
- lib.main.js
|
||||
- lib.board.js
|
||||
- simple-board.js
|
||||
- index.js
|
||||
- settings.js
|
||||
- find-code.js
|
||||
- service-worker.js
|
||||
|
||||
### Completed - Testing:
|
||||
|
||||
* Implement calling list.
|
||||
|
0
static/js/lib.board.js
Normal file
0
static/js/lib.board.js
Normal file
61
static/js/lib.main.js
Normal file
61
static/js/lib.main.js
Normal file
@ -0,0 +1,61 @@
|
||||
/* Feature Detectors */
|
||||
|
||||
/* Valid values for ${type}: localstorage, sessionstorage */
|
||||
async function storageAvailable(type) {
|
||||
try {
|
||||
var storage = window[type],
|
||||
x = '__storage_test__';
|
||||
storage.setItem(x, x);
|
||||
storage.getItem(x);
|
||||
return true;
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Delays */
|
||||
/* Usage: '' */
|
||||
const delay = ms => new Promise(res => setTimeout(res, ms));
|
||||
|
||||
|
||||
/* Log Helper */
|
||||
/* Values for level: 1, 2, 3 */
|
||||
/* Maintains backwards compatibility for previous
|
||||
implementation of log helper */
|
||||
async function log(msg, type) {
|
||||
var time = new Date().toISOString();
|
||||
switch (type) {
|
||||
case "ERR":
|
||||
console.error(`${time} - ${msg}`);
|
||||
break;
|
||||
case "WARN":
|
||||
console.warn(`${time} - ${msg}`);
|
||||
break;
|
||||
case "INFO":
|
||||
console.info(`${time} - ${msg}`);
|
||||
break;
|
||||
default:
|
||||
console.log(`${time} - ${msg}`);
|
||||
break;
|
||||
};
|
||||
};
|
||||
|
||||
/* Loading Box Control */
|
||||
async function hideLoading() {
|
||||
document.getElementById("loading").style = "display: none;";
|
||||
}
|
||||
|
||||
/* DEPRECIATED: Alias for hideLoading() - Marked for removal*/
|
||||
async function clearLoading() {
|
||||
log("Depreciated function called - clearLoading()", "WARN")
|
||||
await hideLoading();
|
||||
}
|
||||
|
||||
async function showLoading() {
|
||||
document.getElementById("loading").style = "display: block;";
|
||||
}
|
||||
|
||||
async function setLoadingDesc(desc) {
|
||||
document.getElementById("loading_desc").textContent = `${desc}`;
|
||||
}
|
Reference in New Issue
Block a user