From 3eb16e7cf29dde4a4c50b544f794756b6c0ae439 Mon Sep 17 00:00:00 2001 From: Alex Xu Date: Tue, 6 Aug 2013 13:50:37 -0400 Subject: fix stuff and such, work on unrpyc imachine --- www/js/html5ks.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'www') diff --git a/www/js/html5ks.js b/www/js/html5ks.js index 11cbf78..f97a1f0 100644 --- a/www/js/html5ks.js +++ b/www/js/html5ks.js @@ -6,12 +6,13 @@ window.html5ks = { persistent: {}, init: function () { var defaultPersistent = { + version: 0, fade: 100, gotit: false, hdisable: false, skipUnread: false, skipAfterChoices: false, - useWebP: null, + useWebP: false, fullscreen: false, scaleAll: true, scaleVideo: true, @@ -23,6 +24,7 @@ window.html5ks = { language: "en" }; var loaded = localStorage.persistent ? JSON.parse(localStorage.persistent) : {}; + html5ks.state._loaded = typeof loaded.version !== undefined; var defProp = function (v) { Object.defineProperty(html5ks.persistent, k, { get: function () { @@ -38,6 +40,18 @@ window.html5ks = { for (var k in defaultPersistent) { defProp(typeof loaded[k] === "undefined" ? defaultPersistent[k] : loaded[k]); } + + document.addEventListener("DOMContentLoaded", function () { + html5ks.onload(); + }, false); + + if (html5ks.state._loaded) { + var img = new Image(); + img.onload = function () { + html5ks.persistent.useWebP = img.width === 4; + }; + img.src = 'data:image/webp;base64,UklGRjgAAABXRUJQVlA4ICwAAAAQAgCdASoEAAQAAAcIhYWIhYSIgIIADA1gAAUAAAEAAAEAAP7%2F2fIAAAAA'; + } }, store: { seen_scenes: {}, @@ -248,6 +262,3 @@ window.html5ks = { } }; html5ks.init(); -document.addEventListener("DOMContentLoaded", function () { - html5ks.onload(); -}, false); -- cgit v1.2.3-70-g09d2