-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlocked.php
More file actions
118 lines (100 loc) · 3.57 KB
/
locked.php
File metadata and controls
118 lines (100 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Jukebox Locked</title>
<?php
require_once("config.php");
require_once("common.php");
require_once("jukebox-common.php");
require_once("fppversion.php");
$pluginJson = convertAndGetSettings('jukebox');
$start_time = $pluginJson['locked_start_time'] != '' ? $pluginJson['locked_start_time'] : '';
$end_time = $pluginJson['locked_end_time'] != '' ? $pluginJson['locked_end_time'] : '';
$location = isset($pluginJson['logo_location']) ? $pluginJson['logo_location'] : 'left';
$base_url = $pluginJson['remote_ip'] != '' ? 'http://' . $pluginJson['remote_ip'] : '';
$jquery = glob("$fppDir/www/js/jquery-*.min.js");
printf("<script type='text/javascript' src='js/%s'></script>\n", basename($jquery[0]));
?>
<link rel="stylesheet" href="/plugin.php?plugin=fpp-jukebox&file=assets/css/bootstrap5.min.css&nopage=1" />
<link rel="stylesheet" href="/plugin.php?plugin=fpp-jukebox&file=assets/css/locked.css&nopage=1" />
<script type="text/javascript">
var startTime = '<?php echo $start_time; ?>';
var endTime = '<?php echo $end_time; ?>';
function get24Hr(time) {
var hours = Number(time.match(/^(\d+)/)[1]);
var AMPM = time.match(/\s(.*)$/)[1];
if (AMPM == "PM" && hours < 12) hours = hours + 12;
if (AMPM == "AM" && hours == 12) hours = hours - 12;
var minutes = Number(time.match(/:(\d+)/)[1]);
hours = hours * 100 + minutes;
// console.log(time + " - " + hours);
return hours;
}
function getval() {
var currentTime = new Date()
var hours = currentTime.getHours()
var minutes = currentTime.getMinutes()
if (minutes < 10) minutes = "0" + minutes;
var suffix = "AM";
if (hours >= 12) {
suffix = "PM";
hours = hours - 12;
}
if (hours == 0) {
hours = 12;
}
var current_time = hours + ":" + minutes + " " + suffix;
return current_time;
}
function inSideTime() {
var curr_time = getval();
if (get24Hr(curr_time) > get24Hr(startTime) && get24Hr(curr_time) < get24Hr(endTime)) {
console.log('inside active time send user back to jukebox page');
window.location.replace("/plugin.php?_menu=status&plugin=fpp-jukebox&page=jukebox.php&nopage=1");
} else {
console.log('outside active time stay here');
}
}
function showTime() {
// to get current time/ date.
var date = new Date();
// to get the current hour
var h = date.getHours();
// to get the current minutes
var m = date.getMinutes();
//to get the current second
var s = date.getSeconds();
// AM, PM setting
var session = "AM";
//conditions for times behavior
if (h == 0) {
h = 12;
}
if (h >= 12) {
session = "PM";
}
if (h > 12) {
h = h - 12;
}
m = (m < 10) ? m = "0" + m : m;
s = (s < 10) ? s = "0" + s : s;
//putting time in one variable
var time = "Current Time: " + h + ":" + m + ":" + s + " " + session;
//putting time in our div
$('#clock').html(time);
//to change time in every seconds
setTimeout(showTime, 1000);
}
$(function () {
inSideTime();
setInterval(inSideTime, 10000);
showTime();
});
</script>
</head>
<body>
<div class="cover-container d-flex h-100 p-3 mx-auto flex-column">
<main role="main" class="inner cover mt-auto mb-auto">
<?php include_once('locked_templates/' . $location . '.php'); ?>
</main>
</div>
</body>