Skip to content

Commit 917408e

Browse files
committed
experiment feature added - custom links
1 parent c9fe21c commit 917408e

File tree

9 files changed

+365
-319
lines changed

9 files changed

+365
-319
lines changed

classes/cards/MediaCard.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class MediaCard {
9494
var endTime = et.toLocaleTimeString("en-US", {hour: '2-digit', minute:'2-digit'});
9595

9696
this.triviaRender="";
97+
this.linkRender="";
9798
// if a trivia card, then prepare html
9899

99100
if(this.cardType[0] == "Trivia Question"){
@@ -125,8 +126,9 @@ class MediaCard {
125126
hiddenFooter = "hidden";
126127
fullScreen="fullscreen";
127128
hiddenTitle="hidden";
128-
//this.linkRender = `<embed type="text/html" src="` + this.linkUrl + `" width=100% height=100%>`
129-
this.linkRender = `<iframe scrolling="no" src="` + this.linkUrl + `" width=100% height=100% style="border: none; overflow: hidden;" >`
129+
this.linkRender = `<embed type="text/html" src="` + this.linkUrl + `" width=100% height=100% style="border: none; overflow: hidden;>`
130+
//this.linkRender = `<iframe scrolling="no" src="` + this.linkUrl + `" width=100% height=100% style="border: none; overflow: hidden;" >`;
131+
// console.log(this.linkRender);
130132
}
131133

132134

@@ -301,7 +303,7 @@ class MediaCard {
301303
`"></div>
302304
</div>
303305
<div class="hidden" id="poster` + this.ID + `AR">`+this.posterAR+`</div>` +
304-
this.triviaRender +
306+
this.triviaRender + this.linkRender +
305307
`</div>
306308
307309
<div class="bottomBanner mx-auto transparent` +

classes/core/settings.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ class Settings {
8080
this.links = DEFAULT_SETTINGS.links;
8181
this.enableAwtrix = DEFAULT_SETTINGS.enableAwtrix;
8282
this.awtrixIP = DEFAULT_SETTINGS.awtrixIP;
83+
this.enableLinks = DEFAULT_SETTINGS.enableLinks;
84+
this.links = DEFAULT_SETTINGS.links;
8385
return;
8486
}
8587

@@ -367,8 +369,6 @@ class Settings {
367369
else this.links = cs.links;
368370
if (jsonObject.enableLinks) this.enableLinks = jsonObject.enableLinks;
369371
else this.enableLinks = cs.enableLinks;
370-
if (jsonObject.linkFrequency) this.linkFrequency = jsonObject.linkFrequency;
371-
else this.linkFrequency = cs.linkFrequency;
372372
if (jsonObject.enableAwtrix) this.enableAwtrix = jsonObject.enableAwtrix;
373373
else this.enableAwtrix = cs.enableAwtrix;
374374
if (jsonObject.awtrixIP) this.awtrixIP = jsonObject.awtrixIP;

classes/custom/links.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ class Links {
1616
async GetAllLinks(linksArray) {
1717
let allLinkCards = [];
1818
// get link cards
19-
for (const linkURL of linksArray) {
20-
const linkSet = await this.GetLinkCard(linkURL);
19+
for (const lnk of linksArray) {
20+
//console.log('process link', lnk);
21+
const linkSet = await this.GetLinkCard(lnk);
22+
//console.log(linkSet);
2123
if(linkSet.length !== 0) {
2224
allLinkCards = allLinkCards.concat(linkSet);
2325
}
@@ -47,7 +49,7 @@ class Links {
4749
medCard.cardType = cType.CardTypeEnum.WebURL;
4850
medCard.mediaType = "WebURL";
4951
medCard.linkUrl = url;
50-
medCard.posterAR = 0;
52+
medCard.posterAR = 1.47;
5153
medCard.theme = "";
5254
medCard.posterURL = "";
5355
medCard.posterArtURL = "";

consts.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ const DEFAULT_SETTINGS = {
6666
triviaNumber: "",
6767
contentRatings: "",
6868
enableAwtrix: "false",
69-
awtrixIP: ""
69+
awtrixIP: "",
70+
enableLinks: "false",
71+
links: ""
7072
};
7173

7274
module.exports = DEFAULT_SETTINGS;

index.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ let contentRatings;
119119
let oldAwtrixApps = [];
120120
let isAwtrixEnabled = false;
121121
let awtrixIP = "";
122-
let restartSeconds = 86400000; //60000; //
122+
let restartSeconds = 86400000;
123123

124124
// create working folders if they do not exist
125125
// needed for package binaries
@@ -179,15 +179,15 @@ function checkTime(i) {
179179
return i;
180180
}
181181
}
182-
182+
loadLinks
183183
/**
184184
* @desc Wrapper function to call links.
185185
* @returns {Promise<object>} mediaCards array - LINKS
186186
*/
187187
async function loadLinks() {
188188
// stop the clock
189189
clearInterval(linksClock);
190-
let linkTicks = loadedSettings.linkFrequency * 1000 * 60; // convert to seconds and then minutes
190+
let linkTicks = 86400000; //loadedSettings.linkFrequency * 1000 * 60; // convert to seconds and then minutes
191191

192192
// stop timers and dont run if disabled
193193
if (!isLinksEnabled) {
@@ -200,10 +200,10 @@ async function loadLinks() {
200200
// call links
201201
try {
202202
linkCards = await links.GetAllLinks(linkArray);
203+
//console.log(linkCards);
203204
} catch (err) {
204205
let now = new Date();
205206
console.log(now.toLocaleString() + " *Links: " + err);
206-
linkTicks = 60000;
207207
console.log("✘✘ WARNING ✘✘ - Next links query will run in 1 minute.");
208208
isLinksUnavailable = true;
209209
}
@@ -769,7 +769,7 @@ async function loadNowScreening() {
769769
}
770770
}
771771
}
772-
772+
//console.log(linkCards.length);
773773
// globalPage.cards = mCards;
774774
}
775775

@@ -866,6 +866,8 @@ async function loadOnDemand() {
866866
* @returns nothing
867867
*/
868868
async function houseKeeping() {
869+
//cold_start_time = new Date();
870+
869871
// clean cache
870872
await core.DeleteMP3Cache();
871873
await core.DeleteImageCache();
@@ -1104,6 +1106,9 @@ async function checkEnabled() {
11041106
Trivia: ` +
11051107
isTriviaEnabled +
11061108
`
1109+
Links: ` +
1110+
isLinksEnabled +
1111+
`
11071112
Daily restart commencing at: ` +
11081113
timeObject.toLocaleTimeString() +
11091114
`
@@ -1181,7 +1186,6 @@ async function wake(theater) {
11811186
* @returns nothing
11821187
*/
11831188
async function startup(clearCache) {
1184-
11851189
// stop all clocks
11861190
clearInterval(nowScreeningClock);
11871191
clearInterval(onDemandClock);
@@ -1886,6 +1890,8 @@ app.post(
18861890
triviaFrequency: req.body.triviaFrequency,
18871891
enableAwtrix: req.body.enableAwtrix,
18881892
awtrixIP: req.body.awtrixIP,
1893+
enableLinks: req.body.enableLinks,
1894+
links: req.body.links,
18891895
saved: false
18901896
};
18911897

myviews/settings.ejs

+34
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,38 @@
937937
</div>
938938
<hr>
939939
940+
941+
<div class="panel panel-default">
942+
<div class="panel-heading" role="tab" id="headingLinks">
943+
<h4 class="panel-title">
944+
<a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapseLinks" aria-expanded="false" aria-controls="collapseLinks">
945+
CUSTOM LINKS <i class="accordion_icon fal fa-plus"></i>
946+
</a>
947+
</h4>
948+
</div>
949+
<div id="collapseLinks" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingLinks">
950+
<div class="panel-body">
951+
952+
<div class="form-group">
953+
<div class="custom-control custom-control-nolabel custom-switch ml-auto">
954+
<input type="checkbox" class="custom-control-input" name="enableLinks" id="enableLinks"
955+
value="true" <% if(typeof formData !== 'undefined' && errors){%><%=formData.enableLinks ? 'checked' : '' %><%}else{%><%=(settings.enableLinks == 'true') ? 'checked' : '' %><%}%>>
956+
<label class="custom-control-label" for="enableLinks">Enabled</label>
957+
</div>
958+
</div>
959+
960+
<div class="form-group">
961+
<label for="links">Links</label>
962+
<input type="text" class="form-control" id="links" name="links" aria-describedby="linksHelp"
963+
placeholder="http://n.n.n.n;https://n.n.n.n" value="<% if(typeof formData !== 'undefined' && errors){%><%=formData.links%>"<%}else{%><%=settings.links%>"<%}%>>
964+
<small id="linksHelp" class="form-text text-muted">Enter links separated by ;. (This feature is somewhat experimental. Only links that allow being loaded in iframes will work. If a link doesnt work, try another.)</small>
965+
</div>
966+
967+
</div>
968+
</div>
969+
</div>
970+
<hr>
971+
940972
<div class="panel panel-default">
941973
<div class="panel-heading" role="tab" id="headingTrivia">
942974
<h4 class="panel-title">
@@ -1022,6 +1054,8 @@
10221054
10231055
</div>
10241056
1057+
1058+
10251059
<script type="text/javascript">
10261060
$(".checkbox-menu").on("change", "input[type='checkbox']", function() {
10271061
$(this).closest("li").toggleClass("active", this.checked);

0 commit comments

Comments
 (0)