You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by hu...@apache.org on 2016/09/02 19:17:39 UTC
[1/7] incubator-ponymail git commit: ensure uniqueness
Repository: incubator-ponymail
Updated Branches:
refs/heads/coffee-and-cake a2c1b83f5 -> 5cc211735
ensure uniqueness
this allows us to (potentially) add multiple calendar
objects to the same page.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/c8555092
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/c8555092
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/c8555092
Branch: refs/heads/coffee-and-cake
Commit: c855509243063a6399bb039eda2c3705d3e16429
Parents: a2c1b83
Author: Daniel Gruno <hu...@apache.org>
Authored: Fri Sep 2 20:23:48 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Fri Sep 2 20:23:48 2016 +0200
----------------------------------------------------------------------
site/js/coffee/calendar.coffee | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/c8555092/site/js/coffee/calendar.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/calendar.coffee b/site/js/coffee/calendar.coffee
index b8eb76a..a0242ae 100644
--- a/site/js/coffee/calendar.coffee
+++ b/site/js/coffee/calendar.coffee
@@ -22,6 +22,7 @@ calendar_months = [
class Calendar
constructor: (start, end, jumpTo) ->
now = new Date()
+ uid = parseInt(Math.random()*100000000).toString(16)
### Split start and end into years and months ###
[sYear, sMonth] = String(start).split("-")
@@ -42,7 +43,7 @@ class Calendar
years = []
for year in [parseInt(sYear)..parseInt(eYear)]
yDiv = new HTML('div', {
- id: "calendar_year_" + year
+ id: "calendar_year_#{uid}_" + year
data: String(year)
class: "calendar_year"
onclick: "toggleYear(this);"
@@ -58,7 +59,7 @@ class Calendar
else "none",
}
class: "calendar_months"
- id: "calendar_months_" + year
+ id: "calendar_months_#{uid}_" + year
})
### For each month, make a div ###
@@ -67,7 +68,7 @@ class Calendar
if (year > sYear or month >= sMonth) and (year < eYear or month <= eMonth)
monthDiv = new HTML('div', {
class: "calendar_month"
- id: "calendar_month_#{year}-#{month}"
+ id: "calendar_month_#{uid}_#{year}-#{month}"
data: "#{year}-#{month}"
onclick: "toggleMonth(this)"
}, calendar_months[month-1])
@@ -80,6 +81,7 @@ class Calendar
### Return a combined div ###
div = new HTML('div', {
class: "calendar"
+ id: uid
data: sYear + "-" + eYear
}, years)
@@ -92,13 +94,16 @@ toggleYear = (div) ->
### Get the year we clicked on ###
year = parseInt(div.getAttribute("data"))
+
+ ## Get Calendar UID
+ uid = div.parentNode.getAttribute("id")
### For each year, hide if not this year, else show ###
for y in [parseInt(sYear)..parseInt(eYear)]
if y == year
- get('calendar_months_' + y).show(true)
+ get("calendar_months_#{uid}_#{y}").show(true)
else
- get('calendar_months_' + y).show(false)
+ get("calendar_months_#{uid}_#{y}").show(false)
toggleMonth = (div) ->
#### TODO later... ###
[5/7] incubator-ponymail git commit: add license header
Posted by hu...@apache.org.
add license header
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/f3447500
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/f3447500
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/f3447500
Branch: refs/heads/coffee-and-cake
Commit: f344750072a26d997a1ba45bc4647871aa0f7868
Parents: 344ebc1
Author: Daniel Gruno <hu...@apache.org>
Authored: Fri Sep 2 21:16:49 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Fri Sep 2 21:16:49 2016 +0200
----------------------------------------------------------------------
site/js/coffee/listview.coffee | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/f3447500/site/js/coffee/listview.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/listview.coffee b/site/js/coffee/listview.coffee
index 21fa32b..da74ba1 100644
--- a/site/js/coffee/listview.coffee
+++ b/site/js/coffee/listview.coffee
@@ -1,3 +1,24 @@
+###
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+###
+
+###*
+# This is the listview basic library
+###
+
### Generally, popping a window state should run a listView update ###
window.onpopstate = (event) ->
listView(null, true)
[3/7] incubator-ponymail git commit: clicking a month should call a
listview update
Posted by hu...@apache.org.
clicking a month should call a listview update
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/71513ddf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/71513ddf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/71513ddf
Branch: refs/heads/coffee-and-cake
Commit: 71513ddfad7d3122004862847b9e67b9387c5300
Parents: 26a7097
Author: Daniel Gruno <hu...@apache.org>
Authored: Fri Sep 2 21:01:27 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Fri Sep 2 21:01:27 2016 +0200
----------------------------------------------------------------------
site/js/coffee/calendar.coffee | 8 ++++++++
1 file changed, 8 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/71513ddf/site/js/coffee/calendar.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/calendar.coffee b/site/js/coffee/calendar.coffee
index a0242ae..22b6909 100644
--- a/site/js/coffee/calendar.coffee
+++ b/site/js/coffee/calendar.coffee
@@ -107,4 +107,12 @@ toggleYear = (div) ->
toggleMonth = (div) ->
#### TODO later... ###
+ m = div.getAttribute("data")
+ [year, month] = m.split("-")
+
+ ### Update the list view using the new month ###
+ listView({
+ month: m
+ })
+
\ No newline at end of file
[6/7] incubator-ponymail git commit: start work on basic scaffolding
for listview
Posted by hu...@apache.org.
start work on basic scaffolding for listview
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/ff2ab2f2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/ff2ab2f2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/ff2ab2f2
Branch: refs/heads/coffee-and-cake
Commit: ff2ab2f294bdb0a8dcee88f528d7144ca6466684
Parents: f344750
Author: Daniel Gruno <hu...@apache.org>
Authored: Fri Sep 2 21:17:13 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Fri Sep 2 21:17:13 2016 +0200
----------------------------------------------------------------------
site/css/ponymail2.css | 17 +++++++++
site/js/coffee/scaffolding.coffee | 67 ++++++++++++++++++++++++++++++++++
site/list2.html | 6 +--
3 files changed, 86 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/ff2ab2f2/site/css/ponymail2.css
----------------------------------------------------------------------
diff --git a/site/css/ponymail2.css b/site/css/ponymail2.css
index 846f4b2..eec12d4 100644
--- a/site/css/ponymail2.css
+++ b/site/css/ponymail2.css
@@ -113,3 +113,20 @@ body, html {
}
+
+
+#header {
+ text-align: center;
+ font-family: sans-serif;
+ font-size: 15pt;
+}
+
+#calendar {
+ width: 140px;
+ float: left;
+}
+
+#listview {
+ width: calc(95% - 160px);
+ float: left;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/ff2ab2f2/site/js/coffee/scaffolding.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/scaffolding.coffee b/site/js/coffee/scaffolding.coffee
new file mode 100644
index 0000000..07af4e7
--- /dev/null
+++ b/site/js/coffee/scaffolding.coffee
@@ -0,0 +1,67 @@
+###
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+###
+
+### This is the basic scaffolding for all pages ###
+
+listviewScaffolding = () ->
+ ### Start off by making the top menu ###
+ menu = new HTML('div', { id: "topMenu"})
+ document.body.inject(menu)
+
+ # Add menu points
+ ul = new HTML('ul')
+
+ # Add logo first
+ logo = new HTML('li', {
+ class: 'logo'
+ }, new HTML('a', {
+ href: "./"
+ }, new HTML('img', {
+ src: "images/logo.png",
+ style: {
+ paddingRight: "10px",
+ height: "38px",
+ width: "auto"
+ }
+ })))
+ ul.inject(logo)
+
+ # Menu points
+ for item in ['Home', 'Lists', 'Third item']
+ li = new HTML('li', {}, item)
+ ul.inject(li)
+ menu.inject(ul)
+
+ ### Now, make the base div ###
+ mainDiv = new HTML('div', { id: "contents"})
+ document.body.inject(mainDiv)
+
+ ### Make the title ###
+ header = new HTML('h2', {id: "header"}, "Loading list data...")
+ mainDiv.inject(header)
+
+ ### Then make the calendar placeholder ###
+ calHolder = new HTML('div', { id: "calendar"})
+ mainDiv.inject(calHolder)
+
+ ### TEST: Insert fake calendar ###
+ cal = new Calendar(2010)
+ calHolder.inject(cal)
+
+ ### Finally, make the list view placeholder ###
+ listDiv = new HTML('div', { id: "listview", class: "sbox"})
+ mainDiv.inject(listDiv)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/ff2ab2f2/site/list2.html
----------------------------------------------------------------------
diff --git a/site/list2.html b/site/list2.html
index deba3c5..15854b1 100644
--- a/site/list2.html
+++ b/site/list2.html
@@ -20,10 +20,8 @@ the License. -->
<link rel="stylesheet" href="css/ponymail2.css"/>
<title>Pony Mail!</title>
</head>
- <body onLoad="testCoffee();">
- <div id="testdiv">
-
- </div>
+ <body onLoad="listviewScaffolding();">
+ <script type="text/javascript" src="js/config.js"></script>
<script type="text/javascript" src="js/ponymail-coffee.js"></script>
</body>
</html>
\ No newline at end of file
[7/7] incubator-ponymail git commit: regen JS
Posted by hu...@apache.org.
regen JS
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/5cc21173
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/5cc21173
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/5cc21173
Branch: refs/heads/coffee-and-cake
Commit: 5cc2117355a78b541955969efaea3d1c2b80d552
Parents: ff2ab2f
Author: Daniel Gruno <hu...@apache.org>
Authored: Fri Sep 2 21:17:24 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Fri Sep 2 21:17:24 2016 +0200
----------------------------------------------------------------------
site/js/ponymail-coffee.js | 292 +++++++++++++++++++++++++++++++++++++---
1 file changed, 275 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/5cc21173/site/js/ponymail-coffee.js
----------------------------------------------------------------------
diff --git a/site/js/ponymail-coffee.js b/site/js/ponymail-coffee.js
index 714a957..d704781 100644
--- a/site/js/ponymail-coffee.js
+++ b/site/js/ponymail-coffee.js
@@ -1,5 +1,5 @@
// Generated by CoffeeScript 1.9.3
-var Calendar, HTML, HTTPRequest, calendar_months, cog, dbRead, dbWrite, e, genColors, get, hsl2rgb, isArray, isHash, pm_storage_available, pm_storage_globvar, set, testCoffee, testToggle, toggleMonth, toggleYear, txt;
+var Calendar, HTML, HTTPRequest, calendar_months, cog, dbRead, dbWrite, e, genColors, get, hsl2rgb, isArray, isHash, listView, listviewScaffolding, pendingURLStatus, pending_url_operations, pm_storage_available, pm_storage_globvar, set, testCoffee, testToggle, toggleMonth, toggleYear, txt;
calendar_months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
@@ -13,23 +13,32 @@ calendar_months = ['January', 'February', 'March', 'April', 'May', 'June', 'July
Calendar = (function() {
function Calendar(start, end, jumpTo) {
- var div, eMonth, eYear, j, m, month, monthDiv, monthsDiv, now, ref, ref1, ref2, ref3, ref4, sMonth, sYear, yDiv, year, years;
+ var div, eMonth, eYear, j, month, monthDiv, monthsDiv, now, o, ref, ref1, ref2, ref3, ref4, sMonth, sYear, uid, yDiv, year, years;
now = new Date();
+ uid = parseInt(Math.random() * 100000000).toString(16);
/* Split start and end into years and months */
- ref = start.split("-"), sYear = ref[0], sMonth = ref[1];
+ ref = String(start).split("-"), sYear = ref[0], sMonth = ref[1];
ref1 = [now.getFullYear(), now.getMonth() + 1], eYear = ref1[0], eMonth = ref1[1];
/* If end year+month given, use it */
if (end) {
- ref2 = end.split("-"), eYear = ref2[0], eMonth = ref2[1];
+ ref2 = String(end).split("-"), eYear = ref2[0], eMonth = ref2[1];
+ }
+
+ /* Make sure months are there, otherwise set them */
+ if (!sMonth) {
+ sMonth = 1;
+ }
+ if (!eMonth) {
+ eMonth = 12;
}
/* For each year, construct the year div to hold months */
years = [];
for (year = j = ref3 = parseInt(sYear), ref4 = parseInt(eYear); ref3 <= ref4 ? j <= ref4 : j >= ref4; year = ref3 <= ref4 ? ++j : --j) {
yDiv = new HTML('div', {
- id: "calendar_year_" + year,
+ id: ("calendar_year_" + uid + "_") + year,
data: String(year),
"class": "calendar_year",
onclick: "toggleYear(this);"
@@ -43,17 +52,17 @@ Calendar = (function() {
display: (jumpTo && jumpTo === year) || (!jumpTo && year === parseInt(eYear)) ? "block" : "none"
},
"class": "calendar_months",
- id: "calendar_months_" + year
+ id: ("calendar_months_" + uid + "_") + year
});
/* For each month, make a div */
- for (month = m = 12; m >= 1; month = --m) {
+ for (month = o = 12; o >= 1; month = --o) {
/* Make sure this is within the start<->end range */
if ((year > sYear || month >= sMonth) && (year < eYear || month <= eMonth)) {
monthDiv = new HTML('div', {
"class": "calendar_month",
- id: "calendar_month_" + year + "-" + month,
+ id: "calendar_month_" + uid + "_" + year + "-" + month,
data: year + "-" + month,
onclick: "toggleMonth(this)"
}, calendar_months[month - 1]);
@@ -69,6 +78,7 @@ Calendar = (function() {
/* Return a combined div */
div = new HTML('div', {
"class": "calendar",
+ id: uid,
data: sYear + "-" + eYear
}, years);
return div;
@@ -81,25 +91,35 @@ Calendar = (function() {
toggleYear = function(div) {
/* Get the start and end year from the parent div */
- var eYear, j, ref, ref1, ref2, results, sYear, y, year;
+ var eYear, j, ref, ref1, ref2, results, sYear, uid, y, year;
ref = div.parentNode.getAttribute('data').split("-"), sYear = ref[0], eYear = ref[1];
/* Get the year we clicked on */
year = parseInt(div.getAttribute("data"));
+ uid = div.parentNode.getAttribute("id");
/* For each year, hide if not this year, else show */
results = [];
for (y = j = ref1 = parseInt(sYear), ref2 = parseInt(eYear); ref1 <= ref2 ? j <= ref2 : j >= ref2; y = ref1 <= ref2 ? ++j : --j) {
if (y === year) {
- results.push(get('calendar_months_' + y).show(true));
+ results.push(get("calendar_months_" + uid + "_" + y).show(true));
} else {
- results.push(get('calendar_months_' + y).show(false));
+ results.push(get("calendar_months_" + uid + "_" + y).show(false));
}
}
return results;
};
-toggleMonth = function(div) {};
+toggleMonth = function(div) {
+ var m, month, ref, year;
+ m = div.getAttribute("data");
+ ref = m.split("-"), year = ref[0], month = ref[1];
+
+ /* Update the list view using the new month */
+ return listView({
+ month: m
+ });
+};
/*
@@ -434,6 +454,51 @@ cog = function(div, size) {
/**
+ * Pending URLs watcher:
+ * Wathes which URLs have been pending a result for a while
+ * and shows the spinner if things are taking too long.
+ */
+
+pending_url_operations = {};
+
+pendingURLStatus = function() {
+ var div, now, pending, time, url;
+ pending = 0;
+ now = new Date().getTime();
+ for (url in pending_url_operations) {
+ time = pending_url_operations[url];
+
+ /* Is something taking too long?? */
+ if ((now - time) > 1500) {
+ pending++;
+ div = get('loading');
+ if (!div) {
+ div = new HTML('div', {
+ "class": "spinner"
+ }, [
+ new HTML('img', {
+ src: "images/spinner.gif"
+ }), new HTML('br'), "Loading, please wait..."
+ ]);
+ document.body.inject(div);
+ }
+ div.style.display = "block";
+ }
+ }
+
+ /* If no pending operations, hide the spnner */
+ if (pending === 0) {
+ div = get('loading');
+ if (div) {
+ return div.style.display = "none";
+ }
+ }
+};
+
+window.setInterval(pendingURLStatus, 500);
+
+
+/**
* HTTPRequest: Fire off a HTTP request.
* Args:
* - url: The URL to request (may be relative or absolute)
@@ -460,10 +525,10 @@ cog = function(div, size) {
*/
HTTPRequest = (function() {
- function HTTPRequest(url, args) {
+ function HTTPRequest(url1, args1) {
var tmp;
- this.url = url;
- this.args = args;
+ this.url = url1;
+ this.args = args1;
/* Set internal class data, determine request type */
this.state = this.args.state;
@@ -474,6 +539,7 @@ HTTPRequest = (function() {
this.callback = this.args.callback;
this.snap = this.args.snap || pm_snap;
this.nocreds = this.args.nocreds || false;
+ this.uid = parseInt(Math.random() * 10000000).toString(16);
/* Construct request object */
if (window.XMLHttpRequest) {
@@ -513,6 +579,9 @@ HTTPRequest = (function() {
}
}
+ /* Mark operation as pending result */
+ pending_url_operations[this.uid] = new Date().getTime();
+
/* Use @method on URL */
this.request.open(this.method, this.url, true);
@@ -531,8 +600,13 @@ HTTPRequest = (function() {
HTTPRequest.prototype.onchange = function() {
- /* Internal Server Error: Try to call snap */
+ /* Mark operation as done */
var e;
+ if (this.request.readyState === 4) {
+ delete pending_url_operations[this.uid];
+ }
+
+ /* Internal Server Error: Try to call snap */
if (this.request.readyState === 4 && this.request.status === 500) {
if (this.snap) {
this.snap(this.state);
@@ -614,6 +688,109 @@ HTTPRequest = (function() {
/**
+ * This is the listview basic library
+ */
+
+
+/* Generally, popping a window state should run a listView update */
+
+window.onpopstate = function(event) {
+ return listView(null, true);
+};
+
+listView = function(hash, reParse) {
+
+ /* Get the HTML filename */
+ var args, d, etc, htmlfile, ponymail_list, ponymail_month, ponymail_query, r, ref;
+ ref = location.href.split("?"), htmlfile = ref[0], etc = ref[1];
+
+ /* Do we need to call the URL parser here? */
+ if (reParse) {
+ parseURL();
+ }
+
+ /* Any new settings passed along? */
+ if (isHash(hash)) {
+ if (hash.month) {
+ ponymail_month = hash.month;
+ }
+ if (hash.list) {
+ ponymail_list = hash.list;
+ }
+ if (hash.query) {
+ ponymail_query = hash.query;
+ }
+ }
+
+ /* First, check that we have a list to view! */
+ if (!(ponymail_list && ponymail_list.match(/.+@.+/))) {
+
+ /* Do we at least have a domain part? */
+ if (ponymail_list && ponymail_list.match(/.+?\..+/)) {
+
+ /* Check if there's a $default list in this domain */
+ d = ponymail_list;
+
+ /* Do we have this domain listed? If not, redirect to front page */
+ if (!ponymail_domains[d]) {
+ location.href = "./";
+ return;
+ }
+ if (ponymail_domains[d] && ponymail_domains[d][pm_config.default_list]) {
+
+ /* Redirect to this list then ... */
+ location.href = htmlfile + "?" + pm_config.default_list + "@" + d;
+ return;
+ }
+ } else {
+
+ /* No domain specified, redirect to front page */
+ location.href = "./";
+ return;
+ }
+ }
+
+ /* Construct arg list for URL */
+ args = "";
+ if (ponymail_list && ponymail_list.length > 0) {
+ args += ponymail_list;
+ }
+ if (ponymail_month && ponymail_month.length > 0) {
+ args += ":" + ponymail_month;
+ }
+ if (ponymail_query && ponymail_query.length > 0) {
+ args += ":" + ponymail_query;
+ }
+
+ /* Push a new history state using new args */
+ window.history.pushState({}, "", htmlfile + "?" + args);
+
+ /* Request month view from API, send to list view callback */
+ return r = new HTTPRequest("api/stats.lua?list=" + ponymail_list + "&d=" + ponymail_month, {
+ callback: renderListView
+ });
+};
+
+
+/*
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+
+/**
* Init: Test if localStorage is available or not
* If not, fall back to plain global var storage (not effective, but meh)
*/
@@ -728,6 +905,87 @@ isHash = function(value) {
return value && typeof value === 'object' && !isArray(value);
};
+
+/*
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+
+/* This is the basic scaffolding for all pages */
+
+listviewScaffolding = function() {
+
+ /* Start off by making the top menu */
+ var cal, calHolder, header, item, j, len, li, listDiv, logo, mainDiv, menu, ref, ul;
+ menu = new HTML('div', {
+ id: "topMenu"
+ });
+ document.body.inject(menu);
+ ul = new HTML('ul');
+ logo = new HTML('li', {
+ "class": 'logo'
+ }, new HTML('a', {
+ href: "./"
+ }, new HTML('img', {
+ src: "images/logo.png",
+ style: {
+ paddingRight: "10px",
+ height: "38px",
+ width: "auto"
+ }
+ })));
+ ul.inject(logo);
+ ref = ['Home', 'Lists', 'Third item'];
+ for (j = 0, len = ref.length; j < len; j++) {
+ item = ref[j];
+ li = new HTML('li', {}, item);
+ ul.inject(li);
+ }
+ menu.inject(ul);
+
+ /* Now, make the base div */
+ mainDiv = new HTML('div', {
+ id: "contents"
+ });
+ document.body.inject(mainDiv);
+
+ /* Make the title */
+ header = new HTML('h2', {
+ id: "header"
+ }, "Loading list data...");
+ mainDiv.inject(header);
+
+ /* Then make the calendar placeholder */
+ calHolder = new HTML('div', {
+ id: "calendar"
+ });
+ mainDiv.inject(calHolder);
+
+ /* TEST: Insert fake calendar */
+ cal = new Calendar(2010);
+ calHolder.inject(cal);
+
+ /* Finally, make the list view placeholder */
+ listDiv = new HTML('div', {
+ id: "listview",
+ "class": "sbox"
+ });
+ return mainDiv.inject(listDiv);
+};
+
testCoffee = function() {
/* Get main div from HTML */
@@ -762,7 +1020,7 @@ testCoffee = function() {
"class": "sbox"
});
parent.inject(div);
- cal = new Calendar('2010-5', '2016-9');
+ cal = new Calendar(2010, '2016-9');
div.inject(cal);
p = new HTML('p', {
"class": "foo",
[2/7] incubator-ponymail git commit: add a spinner if things are
taking too long
Posted by hu...@apache.org.
add a spinner if things are taking too long
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/26a70978
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/26a70978
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/26a70978
Branch: refs/heads/coffee-and-cake
Commit: 26a709780672866742b12817453114b49a6c0731
Parents: c855509
Author: Daniel Gruno <hu...@apache.org>
Authored: Fri Sep 2 21:00:59 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Fri Sep 2 21:00:59 2016 +0200
----------------------------------------------------------------------
site/js/coffee/http_utils.coffee | 49 +++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/26a70978/site/js/coffee/http_utils.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/http_utils.coffee b/site/js/coffee/http_utils.coffee
index 3194a25..20daeaa 100644
--- a/site/js/coffee/http_utils.coffee
+++ b/site/js/coffee/http_utils.coffee
@@ -19,6 +19,44 @@
# This is http_utils.coffee: HTTP Request library #
####################################################
+
+###*
+# Pending URLs watcher:
+# Wathes which URLs have been pending a result for a while
+# and shows the spinner if things are taking too long.
+###
+pending_url_operations = {}
+
+pendingURLStatus = () ->
+ pending = 0
+ now = new Date().getTime()
+ for url, time of pending_url_operations
+ ### Is something taking too long?? ###
+ if (now - time) > 1500
+ pending++
+ div = get('loading')
+ if not div
+ div = new HTML('div', {
+ class: "spinner"
+ },
+ [
+ new HTML('img', {src: "images/spinner.gif"}),
+ new HTML('br'),
+ "Loading, please wait..."
+ ]
+ )
+ document.body.inject(div)
+ div.style.display = "block"
+
+ ### If no pending operations, hide the spnner ###
+ if pending == 0
+ div = get('loading')
+ if div
+ div.style.display = "none"
+
+window.setInterval(pendingURLStatus, 500)
+
+
###*
# HTTPRequest: Fire off a HTTP request.
# Args:
@@ -45,6 +83,7 @@
# })
###
+
class HTTPRequest
constructor: (@url, @args) ->
### Set internal class data, determine request type ###
@@ -56,6 +95,7 @@ class HTTPRequest
@callback = @args.callback
@snap = @args.snap || pm_snap
@nocreds = @args.nocreds || false
+ @uid = parseInt(Math.random()*10000000).toString(16)
### Construct request object ###
if window.XMLHttpRequest
@@ -87,6 +127,9 @@ class HTTPRequest
else
@url += "?" + tmp
+ ### Mark operation as pending result ###
+ pending_url_operations[@uid] = new Date().getTime()
+
### Use @method on URL ###
@request.open(@method, @url, true)
@@ -101,10 +144,16 @@ class HTTPRequest
### HTTPRequest state change calback ###
onchange: () ->
+
+ ### Mark operation as done ###
+ if @request.readyState == 4
+ delete pending_url_operations[@uid]
+
### Internal Server Error: Try to call snap ###
if @request.readyState == 4 and @request.status == 500
if @snap
@snap(@state)
+
### 200 OK, everything is okay, try to parse JSON response ###
if @request.readyState == 4 and @request.status == 200
if @callback
[4/7] incubator-ponymail git commit: start work on the initial
listview functions
Posted by hu...@apache.org.
start work on the initial listview functions
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/344ebc11
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/344ebc11
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/344ebc11
Branch: refs/heads/coffee-and-cake
Commit: 344ebc11bb6d908a6db94eec9ed048da8c733c11
Parents: 71513dd
Author: Daniel Gruno <hu...@apache.org>
Authored: Fri Sep 2 21:01:38 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Fri Sep 2 21:01:38 2016 +0200
----------------------------------------------------------------------
site/js/coffee/listview.coffee | 63 +++++++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/344ebc11/site/js/coffee/listview.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/listview.coffee b/site/js/coffee/listview.coffee
new file mode 100644
index 0000000..21fa32b
--- /dev/null
+++ b/site/js/coffee/listview.coffee
@@ -0,0 +1,63 @@
+### Generally, popping a window state should run a listView update ###
+window.onpopstate = (event) ->
+ listView(null, true)
+
+
+
+listView = (hash, reParse) ->
+ ### Get the HTML filename ###
+ [htmlfile, etc] = location.href.split("?")
+
+ ### Do we need to call the URL parser here? ###
+ if reParse
+ parseURL()
+
+ ### Any new settings passed along? ###
+ if isHash(hash)
+ if hash.month
+ ponymail_month = hash.month
+ if hash.list
+ ponymail_list = hash.list
+ if hash.query
+ ponymail_query = hash.query
+
+ ### First, check that we have a list to view! ###
+ if not (ponymail_list and ponymail_list.match(/.+@.+/))
+ ### Do we at least have a domain part? ###
+ if ponymail_list and ponymail_list.match(/.+?\..+/)
+ ### Check if there's a $default list in this domain ###
+ d = ponymail_list
+ ### Do we have this domain listed? If not, redirect to front page ###
+ if not ponymail_domains[d]
+ location.href = "./"
+ return
+
+ if ponymail_domains[d] and ponymail_domains[d][pm_config.default_list]
+ ### Redirect to this list then ... ###
+ location.href = "#{htmlfile}?#{pm_config.default_list}@#{d}"
+ return
+ else
+ ### No domain specified, redirect to front page ###
+ location.href = "./"
+ return
+
+ ### Construct arg list for URL ###
+ args = ""
+ if ponymail_list and ponymail_list.length > 0
+ args += ponymail_list
+ if ponymail_month and ponymail_month.length > 0
+ args += ":" + ponymail_month
+ if ponymail_query and ponymail_query.length > 0
+ args += ":" + ponymail_query
+
+ ### Push a new history state using new args ###
+ window.history.pushState({}, "", "#{htmlfile}?#{args}")
+
+ ### Request month view from API, send to list view callback ###
+ r = new HTTPRequest(
+ "api/stats.lua?list=#{ponymail_list}&d=#{ponymail_month}",
+ {
+ callback: renderListView
+ }
+ )
+
\ No newline at end of file