X-Git-Url: https://git.yukkurigames.com/?p=labelle.git;a=blobdiff_plain;f=acnl-outfit.js;h=a09d6451c23affd8bf471fc6040c64d9ee2b2a88;hp=50b98325c5481e81e52af03850c983ae30c83079;hb=HEAD;hpb=a3c1e9ba1e78827a8045d4bb874af9c6e0c45ff0 diff --git a/acnl-outfit.js b/acnl-outfit.js index 50b9832..a09d645 100644 --- a/acnl-outfit.js +++ b/acnl-outfit.js @@ -76,7 +76,8 @@ function isPosessive (item) { } function isPlural (item) { - return (item.substr(-1) === "s" + return item.substr(-8) === "headgear" + || (item.substr(-1) === "s" && item.substr(-2) !== "ss" && item.substr(-6) !== "cosmos"); // :( } @@ -123,15 +124,48 @@ function litanize (names, link) { return names.join(names.length == 2 ? " " : ", "); } -function litanizeElement (eid, tid) { +function updateTime () { + var date = new Date(); + document.documentElement.className = "month" + date.getMonth() + document.body.className = "hour" + date.getHours(); + if (window.navigator.standalone) + document.body.className += " standalone"; +} +setInterval(updateTime, 20 * 60 * 1000); + +function update () { var o = outfit(); - document.getElementById(eid).innerHTML = litanize(o, true) + "?"; + var wearing = document.getElementById('wearing'); + wearing.innerHTML = litanize(o, true) + "?"; // TODO: This often generates > 140 characters. Do I care? // Maybe pick shorter prefixes if it would help. - var t = document.getElementById(tid); - t.href = t.href.replace( + var twitter = document.getElementById('twitter'); + twitter.href = twitter.href.replace( /&text=[^&]+/, "&text=" + encodeURIComponent( choice(["Going out in ", "Labelle suggested ", "I'll wear "]) + litanize(o, false) + ".")); + + var buttons = document.getElementById("buttons"); + buttons.className = ""; + setTimeout(function () { + buttons.className = "open"; + }, 300); + updateTime(); } + +window.addEventListener("DOMContentLoaded", update); + +window.addEventListener('load', function () { + if (typeof FastClick !== "undefined") + FastClick.attach(document.body, { tapDelay: 50 }); + + if (applicationCache && applicationCache.status) { + applicationCache.update(); + applicationCache.addEventListener('updateready', function () { + if (applicationCache.status === applicationCache.UPDATEREADY) { + applicationCache.swapCache(); + } + }); + } +});