From d7806702a25397c8253a9b02c1669c7fddbceee5 Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Sat, 6 Sep 2014 11:09:08 +1000 Subject: [PATCH 01/11] Use event listener for time formatting. Make instant! --- assets/app.js | 19 +++++++------------ homeslice.appcache | 2 +- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/assets/app.js b/assets/app.js index ab44956..6001f65 100644 --- a/assets/app.js +++ b/assets/app.js @@ -110,15 +110,7 @@ var creditEl = document.createElement("div"); creditEl.setAttribute("class", "credit"); var creditCopy = "

Homeslice is a project by Andy Taylor (@andytlr).

If you find it useful (I hope you do), why not Tweet about it or post it on Facebook.

Please submit bugs and requests on GitHub.

" -var formatCurrentTime = '' -var formatTime = '' -var formatNewDay = '' -var formatTimePlusThirty = '' -var formatMidday = '' -var formatTimeForList = '' -var formatForEmail = '' - -function setTimeFormat() { +function setTimeFormats() { if (getCookie("timeformat") == "12hr" || getCookie("timeformat") == undefined) { timeFormatButtonEl.innerHTML = "Use 24hr" formatCurrentTime = 'ddd h:mma' @@ -142,10 +134,9 @@ function setTimeFormat() { } } -setTimeFormat() -setInterval(setTimeFormat, interval); +setTimeFormats(); -timeFormatButtonEl.onclick = function setTwentyFourHourTime() { +function changeTimeFormatting() { if (getCookie("timeformat") == "12hr" || getCookie("timeformat") == undefined) { setCookie("timeformat", "24hr", 365); // console.log(getCookie("timeformat")); @@ -155,6 +146,10 @@ timeFormatButtonEl.onclick = function setTwentyFourHourTime() { } } +timeFormatButtonEl.addEventListener("click", changeTimeFormatting, false); +timeFormatButtonEl.addEventListener("click", setTimeFormats, false); +timeFormatButtonEl.addEventListener("click", updateCities, false); + function areCookiesEnabled() { var cookieEnabled = (navigator.cookieEnabled) ? true : false; diff --git a/homeslice.appcache b/homeslice.appcache index a7f7869..65268d4 100644 --- a/homeslice.appcache +++ b/homeslice.appcache @@ -1,6 +1,6 @@ CACHE MANIFEST -# Version 1 +# Version 1.0.13 CACHE: index.html From 16eccc06317a6c196f4b26f0fc7c6ad34ca8f35b Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Sat, 6 Sep 2014 11:19:34 +1000 Subject: [PATCH 02/11] Add info on disabling Application Cache for development --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 8f0e9a8..84bb8af 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,11 @@ Moment Timezone provides a copy of this data from 2010–2020. So times *should* If you'd like to request a city, please check out the [list of timezones in the database][4]. +## Disabling Application Cache for Development in Chrome + +1. Remove `manifest="homeslice.appcache"` from ``. +2. Visit [chrome://appcache-internals/](chrome://appcache-internals/) and delete the cache. + ## License ![Creative Commons License](http://i.creativecommons.org/l/by-nc/4.0/80x15.png) From d32bf71bbec2c1af574ba1a1573f4074cfe0cce6 Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Sat, 6 Sep 2014 13:00:57 +1000 Subject: [PATCH 03/11] This is a reasonable start --- assets/app.js | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/assets/app.js b/assets/app.js index 6001f65..611b0c0 100644 --- a/assets/app.js +++ b/assets/app.js @@ -367,21 +367,35 @@ function updateCities(){ hourNode.setAttribute("data-email-content", cities[city][0] + "%0D%0A" + currentTime.format(formatForEmail) + "%0D%0A%0D%0A"); } - if (!hourNode.classList.contains("current")) { - hourNode.onclick = function toggleClassOnSelectedHours() { - selectedIndex = index; - } + function addSelectedClass() { + this.classList.add("selectedhourforsharing"); + selectedIndex = index; } + // if (!hourNode.classList.contains("current")) { + // } + + // function setSelectedIndex() { + // selectedIndex = index; + // } + + // function clearSelection() { + // selectedIndex = undefined; + // } + + function selectOtherCellsInRow() { + } + // When this is inside the function above, it doesn't work. if (index == selectedIndex) { hourNode.classList.add("selectedhourforsharing"); - hourNode.onclick = function clearSelection() { - selectedIndex = undefined; - } } else { hourNode.classList.remove("selectedhourforsharing"); } + hourNode.addEventListener("click", addSelectedClass, true); + hourNode.addEventListener("click", selectOtherCellsInRow, true); + hourNode.addEventListener("click", hideOrShowEmailButton, true); + // If timezone doesn't have a half hour difference, // And it's midnight, // and it isn't the first item (current time). @@ -543,7 +557,6 @@ function hideOrShowEmailButton() { } } hideOrShowEmailButton(); -setInterval(hideOrShowEmailButton, interval); shareButton.onclick = function emailSelectedHours() { var shareableHours = document.querySelectorAll('.selectedhourforsharing'); From 483ca6cbdccd409889e2b8f6b3ee2a65bc599324 Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Sun, 7 Sep 2014 08:27:54 +1000 Subject: [PATCH 04/11] Move into function with arguments --- assets/app.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/assets/app.js b/assets/app.js index 611b0c0..cfad759 100644 --- a/assets/app.js +++ b/assets/app.js @@ -367,11 +367,6 @@ function updateCities(){ hourNode.setAttribute("data-email-content", cities[city][0] + "%0D%0A" + currentTime.format(formatForEmail) + "%0D%0A%0D%0A"); } - function addSelectedClass() { - this.classList.add("selectedhourforsharing"); - selectedIndex = index; - } - // if (!hourNode.classList.contains("current")) { // } @@ -383,18 +378,23 @@ function updateCities(){ // selectedIndex = undefined; // } - function selectOtherCellsInRow() { + function addSelectedClass() { + this.classList.add("selectedhourforsharing"); + selectedIndex = index; } - // When this is inside the function above, it doesn't work. - if (index == selectedIndex) { - hourNode.classList.add("selectedhourforsharing"); - } else { - hourNode.classList.remove("selectedhourforsharing"); + + function selectOtherCellsInRow(index, selectedIndex) { + if (index == selectedIndex) { + hourNode.classList.add("selectedhourforsharing"); + } else { + hourNode.classList.remove("selectedhourforsharing"); + } } hourNode.addEventListener("click", addSelectedClass, true); - hourNode.addEventListener("click", selectOtherCellsInRow, true); hourNode.addEventListener("click", hideOrShowEmailButton, true); + // selectOtherCellsInRow doesn't run on click. It's still happening on the interval timer. + hourNode.addEventListener("click", selectOtherCellsInRow(index, selectedIndex), true); // If timezone doesn't have a half hour difference, // And it's midnight, From 71b04f3140c5a0d02fd9163aba4be7166afb051b Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Sun, 7 Sep 2014 08:41:41 +1000 Subject: [PATCH 05/11] Pass hourNode because why not --- assets/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/app.js b/assets/app.js index cfad759..8a3d2c7 100644 --- a/assets/app.js +++ b/assets/app.js @@ -383,7 +383,7 @@ function updateCities(){ selectedIndex = index; } - function selectOtherCellsInRow(index, selectedIndex) { + function selectOtherCellsInRow(index, selectedIndex, hourNode) { if (index == selectedIndex) { hourNode.classList.add("selectedhourforsharing"); } else { @@ -394,7 +394,7 @@ function updateCities(){ hourNode.addEventListener("click", addSelectedClass, true); hourNode.addEventListener("click", hideOrShowEmailButton, true); // selectOtherCellsInRow doesn't run on click. It's still happening on the interval timer. - hourNode.addEventListener("click", selectOtherCellsInRow(index, selectedIndex), true); + hourNode.addEventListener("click", selectOtherCellsInRow(index, selectedIndex, hourNode), true); // If timezone doesn't have a half hour difference, // And it's midnight, From 79f2465d809618f029c59fdca5a57b62e69b70a3 Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Sun, 7 Sep 2014 09:37:31 +1000 Subject: [PATCH 06/11] Comment and make delay slow --- assets/app.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/assets/app.js b/assets/app.js index 8a3d2c7..16d0c26 100644 --- a/assets/app.js +++ b/assets/app.js @@ -90,7 +90,7 @@ cities = {} // Setup var defaultCities = "melbourne,sanfrancisco," -var interval = 500 +var interval = 2000 var hoursInTheFuture = 24 * 7 // Regex to match if a time difference is plus or minus 30min. // E.g. Adelaide is +0930. @@ -393,7 +393,8 @@ function updateCities(){ hourNode.addEventListener("click", addSelectedClass, true); hourNode.addEventListener("click", hideOrShowEmailButton, true); - // selectOtherCellsInRow doesn't run on click. It's still happening on the interval timer. + // `selectOtherCellsInRow` doesn't run on click. It's still happening on the interval timer. + // Where as `addSelectedClass` and `hideOrShowEmailButton` are both running instantly. hourNode.addEventListener("click", selectOtherCellsInRow(index, selectedIndex, hourNode), true); // If timezone doesn't have a half hour difference, From e6b1cd5ec2993b8dda59a0a901d52b0aef8a54e3 Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Sun, 7 Sep 2014 09:37:51 +1000 Subject: [PATCH 07/11] Remove appcache temporarily. --- index.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index f943b74..08e5b36 100644 --- a/index.html +++ b/index.html @@ -1,5 +1,6 @@ - + + From 71a07995591d09fd67a4d94315f785d57d1a9973 Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Sun, 7 Sep 2014 09:40:32 +1000 Subject: [PATCH 08/11] Autolink? --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 84bb8af..48a6958 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ If you'd like to request a city, please check out the [list of timezones in the ## Disabling Application Cache for Development in Chrome 1. Remove `manifest="homeslice.appcache"` from ``. -2. Visit [chrome://appcache-internals/](chrome://appcache-internals/) and delete the cache. +2. Visit and delete the cache. ## License From d46822bc909a76a50266430094d41ef5b5f64c70 Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Sun, 7 Sep 2014 18:38:16 +1000 Subject: [PATCH 09/11] Do what should work. --- assets/app.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/assets/app.js b/assets/app.js index 16d0c26..0ff233b 100644 --- a/assets/app.js +++ b/assets/app.js @@ -383,6 +383,9 @@ function updateCities(){ selectedIndex = index; } + hourNode.addEventListener("click", addSelectedClass, true); + hourNode.addEventListener("click", hideOrShowEmailButton, true); + function selectOtherCellsInRow(index, selectedIndex, hourNode) { if (index == selectedIndex) { hourNode.classList.add("selectedhourforsharing"); @@ -391,11 +394,7 @@ function updateCities(){ } } - hourNode.addEventListener("click", addSelectedClass, true); - hourNode.addEventListener("click", hideOrShowEmailButton, true); - // `selectOtherCellsInRow` doesn't run on click. It's still happening on the interval timer. - // Where as `addSelectedClass` and `hideOrShowEmailButton` are both running instantly. - hourNode.addEventListener("click", selectOtherCellsInRow(index, selectedIndex, hourNode), true); + hourNode.addEventListener("click", function(){ selectOtherCellsInRow(index, selectedIndex, hourNode) }, true); // If timezone doesn't have a half hour difference, // And it's midnight, From 639b1fad613dd9e5da0a59ceb1792139aff66730 Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Mon, 8 Sep 2014 15:03:57 +1000 Subject: [PATCH 10/11] Something changed --- homeslice.appcache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeslice.appcache b/homeslice.appcache index 7ad10f6..b712f34 100755 --- a/homeslice.appcache +++ b/homeslice.appcache @@ -15,4 +15,4 @@ assets/icon.png NETWORK: * -# hash: 41ca710515bfa242fc44f8c7d19c7b3de9832e34b477c227ab5fff572408f937 \ No newline at end of file +# hash: aa3e27bee5534e888fcb06fd3779dd13e9610aae2f1cc06201496e2222dc6c89 \ No newline at end of file From 61a387c8c168f19210a9e4bfe7d732d91aab03b7 Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Mon, 8 Sep 2014 15:14:33 +1000 Subject: [PATCH 11/11] Get dependencies listed better --- package.json | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index d4eefa7..9fa8be9 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,7 @@ { - "name" : "my-project", - "version" : "1.0.0", - "dependencies" : { - "gulp" : "3.8.8", - "gulp-manifest" : "0.0.6", - "gulp-connect": "2.0.6" + "devDependencies": { + "gulp": "^3.8.8", + "gulp-manifest": "^0.0.6", + "gulp-connect": "^2.0.6" } -} \ No newline at end of file +}