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:42 UTC
[4/7] incubator-ponymail git commit: start work on the initial
listview functions
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