Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit 6f4def8

Browse files
committed
do not update timezone if no services
1 parent 5e90156 commit 6f4def8

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

runestone/common/js/bookfuncs.js

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function addReadingList() {
7272

7373
function timedRefresh() {
7474
var timeoutPeriod = 900000; // 75 minutes
75-
$(document).bind("idle.idleTimer", function () {
75+
$(document).on("idle.idleTimer", function () {
7676
// After timeout period send the user back to the index. This will force a login
7777
// if needed when they want to go to a particular page. This may not be perfect
7878
// but its an easy way to make sure laptop users are properly logged in when they
@@ -165,26 +165,27 @@ export var pageProgressTracker = {};
165165

166166
async function handlePageSetup() {
167167
var mess;
168-
let headers = new Headers({
169-
"Content-type": "application/json; charset=utf-8",
170-
Accept: "application/json",
171-
});
172-
let data = { timezoneoffset: new Date().getTimezoneOffset() / 60 };
173-
let request = new Request(`${eBookConfig.new_server_prefix}/logger/set_tz_offset`, {
174-
method: "POST",
175-
body: JSON.stringify(data),
176-
headers: headers,
177-
});
178-
try {
179-
let response = await fetch(request);
180-
if (!response.ok) {
181-
console.error(`Failed to set timezone! ${response.statusText}`);
168+
if (eBookConfig.useRunestoneServices) {
169+
let headers = new Headers({
170+
"Content-type": "application/json; charset=utf-8",
171+
Accept: "application/json",
172+
});
173+
let data = { timezoneoffset: new Date().getTimezoneOffset() / 60 };
174+
let request = new Request(`${eBookConfig.new_server_prefix}/logger/set_tz_offset`, {
175+
method: "POST",
176+
body: JSON.stringify(data),
177+
headers: headers,
178+
});
179+
try {
180+
let response = await fetch(request);
181+
if (!response.ok) {
182+
console.error(`Failed to set timezone! ${response.statusText}`);
183+
}
184+
data = await response.json();
185+
} catch (e) {
186+
console.error(`Error setting timezone ${e}`);
182187
}
183-
data = await response.json();
184-
} catch (e) {
185-
console.error(`Error setting timezone ${e}`);
186188
}
187-
188189
if (eBookConfig.isLoggedIn) {
189190
mess = `username: ${eBookConfig.username}`;
190191
if (!eBookConfig.isInstructor) {

0 commit comments

Comments
 (0)