index.json

This commit is contained in:
2022-02-12 18:54:39 -07:00
parent 19bb4e1308
commit 8a808d24b1
5 changed files with 66 additions and 20 deletions

View File

@ -7,8 +7,10 @@
var _Root;
var _RootAlt;
var _ImageZero;
var _JsonTimer;
var _ImageTimer;
var _DataDirectory;
var _Pause = 0;
var _Images = [];
@ -28,12 +30,33 @@
document.addEventListener('keyup', getInput, false);
loadDevice();
loadData();
_JsonTimer = setInterval(onTickJSON, _JsonInterval);
_ImageTimer = setInterval(onTickImage, _ImageInterval);
var url = '../slideshow/index.json';
console.log(url);
var _ = $.getJSON(url, function (data) {
console.log(url + " downloaded successfully");
_RootAlt = null;
_Root = data.Root;
_ImageZero = data.ImageZero;
_DataDirectory = data.DataDirectory;
console.log(url + " used successfully");
})
.done(function () {
loadData();
_JsonTimer = setInterval(onTickJSON, _JsonInterval);
_ImageTimer = setInterval(onTickImage, _ImageInterval);
})
.fail(function (er) {
console.log("error", er);
_Root = "../pictures";
_DataDirectory = "../random";
// _ImageZero = "images/img_tree.gif";
// _ImageZero = "images/output-onlinepngtools.png";
_ImageZero = "images/1x1_00000000.png"; // https://shoonia.github.io/1x1/#00000000
})
.always(function () {
console.log("complete");
});
});
function onPause() {
@ -141,14 +164,9 @@
}
}
function loadDevice() {
_Root = '../pictures';
_RootAlt = null;
}
function loadData() {
var isoString = new Date().toISOString();
var url = '../random/' + isoString.substring(5, isoString.indexOf("T")) + '.json';
var url = _DataDirectory + '/' + isoString.substring(5, isoString.indexOf("T")) + '.json';
console.log(url);
var _ = $.getJSON(url, function (data) {
console.log("success", data.length);
@ -162,9 +180,7 @@
})
.fail(function (er) {
console.log("error", er);
//_Images = ['images/img_tree.gif'];
//_Images = ['images/output-onlinepngtools.png'];
_Images = ['images/1x1_00000000.png']; // https://shoonia.github.io/1x1/#00000000
_Images = [_ImageZero];
})
.always(function () {
console.log("complete");
@ -187,9 +203,7 @@
if (_RootAlt !== null) {
result = result + _RootAlt + _Images[_ImageIndex] + "'), url('";
}
//result = result + "images/img_tree.gif');";
//result = result + "images/output-onlinepngtools.png');";
result = result + "images/1x1_00000000.png');"; // https://shoonia.github.io/1x1/#00000000
result = result + _ImageZero + "');";
return result;
}