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 07:44:03 UTC
[01/17] incubator-ponymail git commit: First batch of coffee files
Repository: incubator-ponymail
Updated Branches:
refs/heads/coffee-and-cake [created] f2cdcb474
First batch of coffee files
miscellaneous functions, DOM handling, HTTP requests
and a simple localstorage wrapper.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/6dad4bc8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/6dad4bc8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/6dad4bc8
Branch: refs/heads/coffee-and-cake
Commit: 6dad4bc8620962c90326eaa4fc2283969b5b5157
Parents: e8e5b9f
Author: Daniel Gruno <hu...@apache.org>
Authored: Thu Sep 1 16:48:57 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Thu Sep 1 16:48:57 2016 +0200
----------------------------------------------------------------------
site/js/coffee/colors.coffee | 108 ++++++++++++++++++++++++
site/js/coffee/combine.sh | 3 +
site/js/coffee/dom_utils.coffee | 101 ++++++++++++++++++++++
site/js/coffee/http_utils.coffee | 143 ++++++++++++++++++++++++++++++++
site/js/coffee/localstorage.coffee | 49 +++++++++++
site/js/coffee/misc.coffee | 18 ++++
6 files changed, 422 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/6dad4bc8/site/js/coffee/colors.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/colors.coffee b/site/js/coffee/colors.coffee
new file mode 100644
index 0000000..e843e1d
--- /dev/null
+++ b/site/js/coffee/colors.coffee
@@ -0,0 +1,108 @@
+###
+ 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.
+###
+
+hsl2rgb = (h, s, l) ->
+
+ h = h % 1;
+ s = 1 if s > 1
+ l = 1 if l > 1
+ if l <= 0.5
+ v = (l * (1 + s))
+ else
+ v = (l + s - l * s);
+ if v == 0
+ return {
+ r: 0,
+ g: 0,
+ b: 0
+ }
+
+ min = 2 * l - v;
+ sv = (v - min) / v;
+ sh = (6 * h) % 6;
+ switcher = Math.floor(sh);
+ fract = sh - switcher;
+ vsf = v * sv * fract;
+
+ switch switcher
+ when 0
+ return {
+ r: v,
+ g: min + vsf,
+ b: min
+ };
+ when 1
+ return {
+ r: v - vsf,
+ g: v,
+ b: min
+ };
+ when 2
+ return {
+ r: min,
+ g: v,
+ b: min + vsf
+ };
+ when 3
+ return {
+ r: min,
+ g: v - vsf,
+ b: v
+ };
+ when 4
+ return {
+ r: min + vsf,
+ g: min,
+ b: v
+ };
+ when 5
+ return {
+ r: v,
+ g: min,
+ b: v - vsf
+ };
+
+ return {
+ r: 0,
+ g: 0,
+ b: 0
+ };
+
+
+genColors = (numColors, saturation, lightness, hex) ->
+ cls = []
+ baseHue = 1.34;
+ for i in [1..numColors]
+ c = hsl2rgb(baseHue, saturation, lightness)
+ if (hex)
+ h = ( Math.round(c.r*255*255*255) + Math.round(c.g * 255*255) + Math.round(c.b*255) ).toString(16)
+ while h.length < 6
+ h = '0' + h
+ h = '#' + h
+ cls.push(h);
+ else
+ cls.push({
+ r: parseInt(c.r * 255),
+ g: parseInt(c.g * 255),
+ b: parseInt(c.b * 255)
+ })
+
+ baseHue -= 0.23
+ if (baseHue < 0)
+ baseHue += 1
+
+ return cls
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/6dad4bc8/site/js/coffee/combine.sh
----------------------------------------------------------------------
diff --git a/site/js/coffee/combine.sh b/site/js/coffee/combine.sh
new file mode 100644
index 0000000..4644a34
--- /dev/null
+++ b/site/js/coffee/combine.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+coffee -b --join ../ponymail.coffee.js -c *.coffee
+
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/6dad4bc8/site/js/coffee/dom_utils.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/dom_utils.coffee b/site/js/coffee/dom_utils.coffee
new file mode 100644
index 0000000..43bc815
--- /dev/null
+++ b/site/js/coffee/dom_utils.coffee
@@ -0,0 +1,101 @@
+###
+ 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.
+###
+
+# mk: DOM creator
+# args:
+# - type: HTML element type (div, table, p etc) to produce
+# - params: hash of element params to add (class, style etc)
+# - children: optional child or children objects to insert into the new element
+# Example: mk('div', { class: "footer", style: "font-weight: bold;"}, "Some text inside a div")
+mk = (type, params, children) ->
+ # create the raw element
+ r = document.createElement(type)
+
+ # If params have been passed, set them
+ if params
+ for k, v of params
+ if v
+ r.setAttribute(k, v)
+
+ # If any children have been passed, add them to the element
+ if children
+ # If string, convert to textNode using txt()
+ if typeof children == "string"
+ app(r, txt(children))
+ else
+ # If children is an array of elems, iterate and add
+ if isArray children
+ for k in children
+ # String? Convert via txt() then
+ if typeof k == "string"
+ app(r, txt(k))
+ # Plain element, add normally
+ else
+ app(r, k)
+ # Just a single element, add it
+ else
+ app(r, children)
+ return r
+
+# App: Shortcut for document.appendChild with modifications
+# - a: the element to add things to
+# - b: one or more elements to add.
+# Example: app(get('mydiv'), "Add some text to mydiv")
+app = (a,b) ->
+ # If it's a list of elems, iterate
+ if isArray b
+ for item in b
+ # String? Convert to textNode first then
+ if typeof item == "string"
+ item = txt(item)
+ # Otherwise just add it
+ a.appendChild(item)
+ # Otherwise, just add
+ else
+ # String? Convert first
+ if typeof b == "string"
+ a.appendChild(txt(b))
+ # Not a string, add normally
+ return a.appendChild(b)
+
+
+# Set: shortcut for a.setAttribute(b,c)
+set = (a, b, c) ->
+ return a.setAttribute(b,c)
+
+# txt: shortcut for creating a text node
+txt = (a) ->
+ return document.createTextNode(a)
+
+# Get: Shortcut for doc.getElementById
+get = (a) ->
+ return document.getElementById(a)
+
+
+# Cog: Loading panel for when waiting for a response
+cog = (div, size = 200) ->
+ idiv = document.createElement('div')
+ idiv.setAttribute("class", "icon")
+ idiv.setAttribute("style", "text-align: center; vertical-align: middle; height: 500px;")
+ i = document.createElement('i')
+ i.setAttribute("class", "fa fa-spin fa-cog")
+ i.setAttribute("style", "font-size: " + size + "pt !important; color: #AAB;")
+ idiv.appendChild(i)
+ idiv.appendChild(document.createElement('br'))
+ idiv.appendChild(document.createTextNode('Loading data, please wait...'))
+ div.innerHTML = ""
+ div.appendChild(idiv)
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/6dad4bc8/site/js/coffee/http_utils.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/http_utils.coffee b/site/js/coffee/http_utils.coffee
new file mode 100644
index 0000000..5101a00
--- /dev/null
+++ b/site/js/coffee/http_utils.coffee
@@ -0,0 +1,143 @@
+###
+ 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.
+###
+
+# fetch: Fetches a URL.
+# Params:
+# - url: URL to fetch
+# - xstate: JS state object to pass on to callback
+# - callback: callback function to utilize the response
+# - snap: optional callback if fetch fails (error 500)
+# - nocreds: set to True to disable sending credentials (cookies etc)
+# Example: fetch("/api/foo.lua", {pony: true}, callbackfunc, null, true)
+fetch = (url, xstate, callback, snap, nocreds) ->
+ xmlHttp = null;
+
+ # Set up request object
+ if window.XMLHttpRequest
+ xmlHttp = new XMLHttpRequest();
+ else
+ xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
+ if not nocreds
+ xmlHttp.withCredentials = true
+
+ # GET URL
+ xmlHttp.open("GET", url, true);
+ xmlHttp.send(null);
+
+ # Check for request state response change
+ xmlHttp.onreadystatechange = (state) ->
+ # Internal Server Error: Try to call snap
+ if xmlHttp.readyState == 4 and xmlHttp.status == 500
+ if snap
+ snap(xstate)
+ # 200 OK, everything is okay, try to parse JSON response
+ if xmlHttp.readyState == 4 and xmlHttp.status == 200
+ if callback
+ # Try to parse as JSON and deal with cache objects, fall back to old style parse-and-pass
+ try
+ # Parse JSON response
+ response = JSON.parse(xmlHttp.responseText)
+ # If loginRequired (rare!), redirect to oauth page
+ if response && response.loginRequired
+ location.href = "/oauth.html"
+ return
+ # Otherwise, call the callback function
+ callback(response, xstate);
+ # JSON parse failed? Pass on the response as plain text then
+ catch e
+ callback(xmlHttp.responseText, xstate)
+
+# post: like fetch, but do a POST with standard text fields
+# - url: URL to POST to
+# - args: hash of keys/vals to convert into a POST request
+# - xstate: state to pass on to callback
+# - callback: calback function for response
+# - snap: callback in case of error 500
+post = (url, args, xstate, callback, snap) ->
+ xmlHttp = null;
+ # Set up request object
+ if window.XMLHttpRequest
+ xmlHttp = new XMLHttpRequest();
+ else
+ xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
+ xmlHttp.withCredentials = true
+
+ # Construct form data string to POST.
+ ar = []
+ for k,v of args
+ if v and v != ""
+ ar.push(k + "=" + encodeURIComponent(v))
+ fdata = ar.join("&")
+
+
+ # POST URL
+ xmlHttp.open("POST", url, true);
+ xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ xmlHttp.send(fdata);
+
+ # Check for response
+ xmlHttp.onreadystatechange = (state) ->
+ # Internal Server Error: call snap function
+ if xmlHttp.readyState == 4 and xmlHttp.status == 500
+ if snap
+ snap(xstate)
+ # 200 Okay, parse response and run callback
+ if xmlHttp.readyState == 4 and xmlHttp.status == 200
+ if callback
+ # Try to parse as JSON and deal with cache objects, fall back to old style parse-and-pass
+ try
+ response = JSON.parse(xmlHttp.responseText)
+ callback(response, xstate);
+ # JSON parse failed? Try passing on as plain text
+ catch e
+ callback(xmlHttp.responseText, xstate)
+
+# postJSON: Same as post, but send vars as a JSON object
+postJSON = (url, json, xstate, callback, snap) ->
+ xmlHttp = null;
+ # Set up request object
+ if window.XMLHttpRequest
+ xmlHttp = new XMLHttpRequest();
+ else
+ xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
+ xmlHttp.withCredentials = true
+
+ # Construct form data
+ fdata = JSON.stringify(json)
+
+ # POST URL
+ xmlHttp.open("POST", url, true);
+ xmlHttp.setRequestHeader("Content-type", "application/json");
+ xmlHttp.send(fdata);
+
+ # Check for response
+ xmlHttp.onreadystatechange = (state) ->
+ # Internal Server Error: call snap!
+ if xmlHttp.readyState == 4 and xmlHttp.status == 500
+ if snap
+ snap(xstate)
+
+ # 200 Okay, parse response and pass to callback
+ if xmlHttp.readyState == 4 and xmlHttp.status == 200
+ if callback
+ # Try to parse as JSON and deal with cache objects, fall back to old style parse-and-pass
+ try
+ response = JSON.parse(xmlHttp.responseText)
+ callback(response, xstate);
+ # Fall back to plain text if parse failed
+ catch e
+ callback(xmlHttp.responseText, xstate)
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/6dad4bc8/site/js/coffee/localstorage.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/localstorage.coffee b/site/js/coffee/localstorage.coffee
new file mode 100644
index 0000000..874944e
--- /dev/null
+++ b/site/js/coffee/localstorage.coffee
@@ -0,0 +1,49 @@
+###
+ 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)
+pm_storage_available = false
+pm_storage_globvar = {}
+try
+ if typeof window.localStorage != "undefined"
+ window.localStorage.setItem("pm_test", "1")
+ pm_storage_available = true
+catch e
+ pm_storage_available = false
+
+
+# dbWrite: Store a key/val pair
+# Example: dbWrite("ponies", "They are awesome!")
+dbWrite = (key, value) ->
+ # Can we use localStorage?
+ if pm_storage_available
+ return window.localStorage.setItem(key, value)
+ # Guess not, fall back to (ineffective) global var
+ else
+ pm_storage_globvar[key] = value
+ return true
+
+# dbRead: Given a key, read the corresponding value from storage
+dbRead = (key) ->
+ # Do we have localStorage?
+ if pm_storage_available
+ return window.localStorage.getItem(key)
+ # Nope, try global var
+ else
+ return pm_storage_globvar[key]
+
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/6dad4bc8/site/js/coffee/misc.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/misc.coffee b/site/js/coffee/misc.coffee
new file mode 100644
index 0000000..92db090
--- /dev/null
+++ b/site/js/coffee/misc.coffee
@@ -0,0 +1,18 @@
+# Miscellaneous functions
+
+# Number prettification prototype:
+# Converts 1234567 into 1,234,567 etc
+Number.prototype.pretty = (fix) ->
+ if (fix)
+ return String(this.toFixed(fix)).replace(/(\d)(?=(\d{3})+\.)/g, '$1,');
+ return String(this.toFixed(0)).replace(/(\d)(?=(\d{3})+$)/g, '$1,');
+
+
+# isArray: function to detect if an object is an array
+isArray = ( value ) ->
+ value and
+ typeof value is 'object' and
+ value instanceof Array and
+ typeof value.length is 'number' and
+ typeof value.splice is 'function' and
+ not ( value.propertyIsEnumerable 'length' )
[14/17] incubator-ponymail git commit: fix function definitions
Posted by hu...@apache.org.
fix function definitions
should be using : inside a class to define methods
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/217cda6c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/217cda6c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/217cda6c
Branch: refs/heads/coffee-and-cake
Commit: 217cda6c07232cd15aad5ce9a57a2d9025373944
Parents: effc172
Author: Daniel Gruno <hu...@apache.org>
Authored: Fri Sep 2 09:21:46 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Fri Sep 2 09:21:46 2016 +0200
----------------------------------------------------------------------
site/js/coffee/http_utils.coffee | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/217cda6c/site/js/coffee/http_utils.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/http_utils.coffee b/site/js/coffee/http_utils.coffee
index fd95e7d..be41c52 100644
--- a/site/js/coffee/http_utils.coffee
+++ b/site/js/coffee/http_utils.coffee
@@ -44,7 +44,7 @@
# })
class HTTPRequest
- constructor = (@url, @args) ->
+ constructor: (@url, @args) ->
# Set internal class data, determine request type
@state = @args.state
@method = if @args.data then 'POST' else 'GET'
@@ -95,9 +95,10 @@ class HTTPRequest
@request.onreadystatechange = @onchange
# all done!
+ return this
# HTTPRequest state change calback
- onchange = () ->
+ onchange: () ->
# Internal Server Error: Try to call snap
if @request.readyState == 4 and @request.status == 500
if @snap
@@ -120,7 +121,7 @@ class HTTPRequest
@callback(@request.responseText, @state)
# Standard form data joiner for POST data
- formdata = (kv) ->
+ formdata: (kv) ->
ar = []
# For each key/value pair
for k,v of kv
[02/17] incubator-ponymail git commit: allow for hash-type element
parameters
Posted by hu...@apache.org.
allow for hash-type element parameters
this will enable things like styles to be set
using a hash instead of a long string.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/b43dd969
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/b43dd969
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/b43dd969
Branch: refs/heads/coffee-and-cake
Commit: b43dd96981599876f472841b85a3c15aa8ec93de
Parents: 6dad4bc
Author: Daniel Gruno <hu...@apache.org>
Authored: Thu Sep 1 16:58:41 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Thu Sep 1 16:58:41 2016 +0200
----------------------------------------------------------------------
site/js/coffee/dom_utils.coffee | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/b43dd969/site/js/coffee/dom_utils.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/dom_utils.coffee b/site/js/coffee/dom_utils.coffee
index 43bc815..3419119 100644
--- a/site/js/coffee/dom_utils.coffee
+++ b/site/js/coffee/dom_utils.coffee
@@ -20,7 +20,7 @@
# - type: HTML element type (div, table, p etc) to produce
# - params: hash of element params to add (class, style etc)
# - children: optional child or children objects to insert into the new element
-# Example: mk('div', { class: "footer", style: "font-weight: bold;"}, "Some text inside a div")
+# Example: mk('div', { class: "footer", style: {fontWeight: "bold"}}, "Some text inside a div")
mk = (type, params, children) ->
# create the raw element
r = document.createElement(type)
@@ -28,8 +28,13 @@ mk = (type, params, children) ->
# If params have been passed, set them
if params
for k, v of params
- if v
+ # Standard string value?
+ if typeof v == "string"
r.setAttribute(k, v)
+ # Are we trying to set multiple sub elements, like a style?
+ else if typeof(v) == "object" and not isArray(v)
+ for x,y of v
+ r[k][x] = y
# If any children have been passed, add them to the element
if children
[07/17] incubator-ponymail git commit: rename output file (bug in
coffee?)
Posted by hu...@apache.org.
rename output file (bug in coffee?)
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/9169483a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/9169483a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/9169483a
Branch: refs/heads/coffee-and-cake
Commit: 9169483a8ea692258f6b54c2368020cb2a9d842f
Parents: d1f577b
Author: Daniel Gruno <hu...@apache.org>
Authored: Thu Sep 1 17:11:22 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Thu Sep 1 17:11:22 2016 +0200
----------------------------------------------------------------------
site/js/coffee/combine.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/9169483a/site/js/coffee/combine.sh
----------------------------------------------------------------------
diff --git a/site/js/coffee/combine.sh b/site/js/coffee/combine.sh
index 4644a34..9585396 100644
--- a/site/js/coffee/combine.sh
+++ b/site/js/coffee/combine.sh
@@ -1,3 +1,3 @@
#!/bin/bash
-coffee -b --join ../ponymail.coffee.js -c *.coffee
+coffee -b --join ../ponymail-coffee.js -c *.coffee
[06/17] incubator-ponymail git commit: fix missing brackets
Posted by hu...@apache.org.
fix missing brackets
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/d1f577b4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/d1f577b4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/d1f577b4
Branch: refs/heads/coffee-and-cake
Commit: d1f577b479203dad861324e6024d3ee304736b3b
Parents: 8b7e9c4
Author: Daniel Gruno <hu...@apache.org>
Authored: Thu Sep 1 17:09:19 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Thu Sep 1 17:09:19 2016 +0200
----------------------------------------------------------------------
site/js/coffee/dom_utils.coffee | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/d1f577b4/site/js/coffee/dom_utils.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/dom_utils.coffee b/site/js/coffee/dom_utils.coffee
index 5ac2692..66dbe06 100644
--- a/site/js/coffee/dom_utils.coffee
+++ b/site/js/coffee/dom_utils.coffee
@@ -105,13 +105,13 @@ cog = (div, size = 200) ->
verticalAlign: 'middle',
height: '500px'
}
- )
+ })
i = mk('i', { class: 'fa fa-spin fa-cog', style: {
fontSize: size+'pt !important',
color: '#AAB'
}
- )
+ })
app(idiv, [i, mk('br'), "Loading data, please wait..."])
div.innerHTML = ""
div.appendChild(idiv)
[16/17] incubator-ponymail git commit: make sure comments make it to
JS
Posted by hu...@apache.org.
make sure comments make it to 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/22b3b8a0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/22b3b8a0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/22b3b8a0
Branch: refs/heads/coffee-and-cake
Commit: 22b3b8a0e662279a2db97db013eb68383d96f2d5
Parents: 4b68337
Author: Daniel Gruno <hu...@apache.org>
Authored: Fri Sep 2 09:30:49 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Fri Sep 2 09:30:49 2016 +0200
----------------------------------------------------------------------
site/js/coffee/dom_utils.coffee | 40 ++++++++++++++------------
site/js/coffee/http_utils.coffee | 50 ++++++++++++++++-----------------
site/js/coffee/localstorage.coffee | 14 +++++----
site/js/coffee/misc.coffee | 7 ++++-
4 files changed, 62 insertions(+), 49 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/22b3b8a0/site/js/coffee/dom_utils.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/dom_utils.coffee b/site/js/coffee/dom_utils.coffee
index 66dbe06..afd291e 100644
--- a/site/js/coffee/dom_utils.coffee
+++ b/site/js/coffee/dom_utils.coffee
@@ -19,17 +19,19 @@
# This is dom_utils.coffee: DOM handling utilities #
####################################################
+###*
# mk: DOM creator
# args:
# - type: HTML element type (div, table, p etc) to produce
# - params: hash of element params to add (class, style etc)
# - children: optional child or children objects to insert into the new element
# Example: mk('div', { class: "footer", style: {fontWeight: "bold"}}, "Some text inside a div")
+###
mk = (type, params, children) ->
- # create the raw element
+ ### create the raw element ###
r = document.createElement(type)
- # If params have been passed, set them
+ ### If params have been passed, set them ###
if params
for k, v of params
# Standard string value?
@@ -43,62 +45,64 @@ mk = (type, params, children) ->
for x,y of v
r[k][x] = y
- # If any children have been passed, add them to the element
+ ### If any children have been passed, add them to the element ###
if children
- # If string, convert to textNode using txt()
+ ### If string, convert to textNode using txt() ###
if typeof children is "string"
app(r, txt(children))
else
- # If children is an array of elems, iterate and add
+ ### If children is an array of elems, iterate and add ###
if isArray children
for k in children
- # String? Convert via txt() then
+ ### String? Convert via txt() then ###
if typeof k is "string"
app(r, txt(k))
- # Plain element, add normally
+ ### Plain element, add normally ###
else
app(r, k)
- # Just a single element, add it
+ ### Just a single element, add it ###
else
app(r, children)
return r
+###*
# App: Shortcut for document.appendChild with modifications
# - a: the element to add things to
# - b: one or more elements to add.
# Example: app(get('mydiv'), "Add some text to mydiv")
+###
app = (a,b) ->
- # If it's a list of elems, iterate
+ ### If it's a list of elems, iterate ###
if isArray b
for item in b
- # String? Convert to textNode first then
+ ### String? Convert to textNode first then ###
if typeof item is "string"
item = txt(item)
- # Otherwise just add it
+ ### Otherwise just add it ###
a.appendChild(item)
- # Otherwise, just add
+ ### Otherwise, just add ###
else
- # String? Convert first
+ ### String? Convert first ###
if typeof b is "string"
a.appendChild(txt(b))
- # Not a string, add normally
+ ### Not a string, add normally ###
return a.appendChild(b)
-# Set: shortcut for a.setAttribute(b,c)
+### Set: shortcut for a.setAttribute(b,c) ###
set = (a, b, c) ->
return a.setAttribute(b,c)
-# txt: shortcut for creating a text node
+### txt: shortcut for creating a text node ###
txt = (a) ->
return document.createTextNode(a)
-# Get: Shortcut for doc.getElementById
+### Get: Shortcut for doc.getElementById ###
get = (a) ->
return document.getElementById(a)
-# Cog: Loading panel for when waiting for a response
+### Cog: Loading panel for when waiting for a response ###
cog = (div, size = 200) ->
idiv = mk('div', { class: "icon", style: {
texAlign: 'center',
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/22b3b8a0/site/js/coffee/http_utils.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/http_utils.coffee b/site/js/coffee/http_utils.coffee
index 91de289..4b5675e 100644
--- a/site/js/coffee/http_utils.coffee
+++ b/site/js/coffee/http_utils.coffee
@@ -47,7 +47,7 @@
class HTTPRequest
constructor: (@url, @args) ->
- # Set internal class data, determine request type
+ ### Set internal class data, determine request type ###
@state = @args.state
@method = if @args.data then 'POST' else 'GET'
@data = @args.data
@@ -57,17 +57,17 @@ class HTTPRequest
@snap = @args.snap || pm_snap
@nocreds = @args.nocreds || false
- # Construct request object
+ ### Construct request object ###
if window.XMLHttpRequest
@request = new XMLHttpRequest();
else
@request = new ActiveXObject("Microsoft.XMLHTTP");
- # Default to sending credentials
+ ### Default to sending credentials ###
if not @nocreds
@request.withCredentials = true
- # Determine what to send as data (if anything)
+ ### Determine what to send as data (if anything) ###
@rdata = null
if @method is 'POST'
if @datatype == 'json'
@@ -75,61 +75,61 @@ class HTTPRequest
else
@rdata = @formdata(@data)
- # If tasked with appending data to the URL, do so
+ ### If tasked with appending data to the URL, do so ###
if @getdata
tmp = @formdata(@getdata)
if tmp.length > 0
- # Do we have form data here aleady? if so, append the new
- # by adding an ampersand first
+ ### Do we have form data here aleady? if so, append the new ###
+ ### by adding an ampersand first ###
if @url.match(/\?/)
@url += "&" + tmp
- # No form data yet, add a ? and then the data
+ ### No form data yet, add a ? and then the data ###
else
@url += "?" + tmp
- # Use @method on URL
+ ### Use @method on URL ###
@request.open(@method, @url, true)
- # Send data
+ ### Send data ###
@request.send(@rdata)
- # Set onChange behavior
+ ### Set onChange behavior ###
@request.onreadystatechange = @onchange
- # all done!
+ ### all done! ###
return this
- # HTTPRequest state change calback
+ ### HTTPRequest state change calback ###
onchange: () ->
- # Internal Server Error: Try to call snap
+ ### 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
+ ### 200 OK, everything is okay, try to parse JSON response ###
if @request.readyState == 4 and @request.status == 200
if @callback
- # Try to parse as JSON and deal with cache objects, fall back to old style parse-and-pass
+ ### Try to parse as JSON and deal with cache objects, fall back to old style parse-and-pass ###
try
- # Parse JSON response
+ ### Parse JSON response ###
@response = JSON.parse(@request.responseText)
- # If loginRequired (rare!), redirect to oauth page
+ ### If loginRequired (rare!), redirect to oauth page ###
if @response && @response.loginRequired
location.href = "/oauth.html"
return
- # Otherwise, call the callback function
+ ### Otherwise, call the callback function ###
@callback(@response, @state);
- # JSON parse failed? Pass on the response as plain text then
+ ### JSON parse failed? Pass on the response as plain text then ###
catch e
@callback(@request.responseText, @state)
- # Standard form data joiner for POST data
+ ### Standard form data joiner for POST data ###
formdata: (kv) ->
ar = []
- # For each key/value pair
+ ### For each key/value pair ###
for k,v of kv
- # Only append if the value is non-empty
+ ### Only append if the value is non-empty ###
if v and v != ""
- # URI-Encode value and add to an array
+ ### URI-Encode value and add to an array ###
ar.push(k + "=" + encodeURIComponent(v))
- # Join the array with ampersands, so we get "foo=bar&foo2=baz"
+ ### Join the array with ampersands, so we get "foo=bar&foo2=baz" ###
return ar.join("&")
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/22b3b8a0/site/js/coffee/localstorage.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/localstorage.coffee b/site/js/coffee/localstorage.coffee
index 874944e..bcd9128 100644
--- a/site/js/coffee/localstorage.coffee
+++ b/site/js/coffee/localstorage.coffee
@@ -15,8 +15,10 @@
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)
+###
pm_storage_available = false
pm_storage_globvar = {}
try
@@ -27,23 +29,25 @@ catch e
pm_storage_available = false
+###*
# dbWrite: Store a key/val pair
# Example: dbWrite("ponies", "They are awesome!")
+###
dbWrite = (key, value) ->
- # Can we use localStorage?
+ ### Can we use localStorage? ###
if pm_storage_available
return window.localStorage.setItem(key, value)
- # Guess not, fall back to (ineffective) global var
+ ### Guess not, fall back to (ineffective) global var ###
else
pm_storage_globvar[key] = value
return true
-# dbRead: Given a key, read the corresponding value from storage
+### dbRead: Given a key, read the corresponding value from storage ###
dbRead = (key) ->
- # Do we have localStorage?
+ ### Do we have localStorage? ###
if pm_storage_available
return window.localStorage.getItem(key)
- # Nope, try global var
+ ### Nope, try global var ###
else
return pm_storage_globvar[key]
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/22b3b8a0/site/js/coffee/misc.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/misc.coffee b/site/js/coffee/misc.coffee
index 6d187dd..8a6e5af 100644
--- a/site/js/coffee/misc.coffee
+++ b/site/js/coffee/misc.coffee
@@ -20,23 +20,28 @@
# This is misc.coffee: Miscellaneous utility functions #
########################################################
+###*
# Number prettification prototype:
# Converts 1234567 into 1,234,567 etc
+###
Number.prototype.pretty = (fix) ->
if (fix)
return String(this.toFixed(fix)).replace(/(\d)(?=(\d{3})+\.)/g, '$1,');
return String(this.toFixed(0)).replace(/(\d)(?=(\d{3})+$)/g, '$1,');
+###*
# Number padding
# usage: 123.pad(6) -> 000123
+###
Number.prototype.pad = (n) ->
str = String(this)
+ ### Do we need to pad? if so, do it using String.repeat ###
if str.length < n
str = "0".repeat(n-str.length) + str
return str
-# isArray: function to detect if an object is an array
+### isArray: function to detect if an object is an array ###
isArray = ( value ) ->
value and
typeof value is 'object' and
[08/17] incubator-ponymail git commit: add number padding function
Posted by hu...@apache.org.
add number padding function
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/7b308dea
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/7b308dea
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/7b308dea
Branch: refs/heads/coffee-and-cake
Commit: 7b308dea22b9068d2e551680fe4c87621aa31260
Parents: 9169483
Author: Daniel Gruno <hu...@apache.org>
Authored: Thu Sep 1 17:16:38 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Thu Sep 1 17:16:38 2016 +0200
----------------------------------------------------------------------
site/js/coffee/misc.coffee | 8 ++++++++
1 file changed, 8 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/7b308dea/site/js/coffee/misc.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/misc.coffee b/site/js/coffee/misc.coffee
index e4a9e69..6d187dd 100644
--- a/site/js/coffee/misc.coffee
+++ b/site/js/coffee/misc.coffee
@@ -27,6 +27,14 @@ Number.prototype.pretty = (fix) ->
return String(this.toFixed(fix)).replace(/(\d)(?=(\d{3})+\.)/g, '$1,');
return String(this.toFixed(0)).replace(/(\d)(?=(\d{3})+$)/g, '$1,');
+# Number padding
+# usage: 123.pad(6) -> 000123
+Number.prototype.pad = (n) ->
+ str = String(this)
+ if str.length < n
+ str = "0".repeat(n-str.length) + str
+ return str
+
# isArray: function to detect if an object is an array
isArray = ( value ) ->
[15/17] incubator-ponymail git commit: make sure comments make it to
the JS
Posted by hu...@apache.org.
make sure comments make it to the 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/4b68337c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/4b68337c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/4b68337c
Branch: refs/heads/coffee-and-cake
Commit: 4b68337c94a9b1991b29183adca75a5a4737cdca
Parents: 217cda6
Author: Daniel Gruno <hu...@apache.org>
Authored: Fri Sep 2 09:24:24 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Fri Sep 2 09:24:24 2016 +0200
----------------------------------------------------------------------
site/js/coffee/http_utils.coffee | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/4b68337c/site/js/coffee/http_utils.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/http_utils.coffee b/site/js/coffee/http_utils.coffee
index be41c52..91de289 100644
--- a/site/js/coffee/http_utils.coffee
+++ b/site/js/coffee/http_utils.coffee
@@ -19,6 +19,7 @@
# This is http_utils.coffee: HTTP Request library #
####################################################
+###*
# HTTPRequest: Fire off a HTTP request.
# Args:
# - url: The URL to request (may be relative or absolute)
@@ -42,6 +43,7 @@
# list: "foo.bar"
# }
# })
+###
class HTTPRequest
constructor: (@url, @args) ->
[05/17] incubator-ponymail git commit: refactor cog function using
the new DOM tools
Posted by hu...@apache.org.
refactor cog function using the new DOM tools
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/8b7e9c41
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/8b7e9c41
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/8b7e9c41
Branch: refs/heads/coffee-and-cake
Commit: 8b7e9c415556ed7916ade077d947c8cfde158ca9
Parents: f36d556
Author: Daniel Gruno <hu...@apache.org>
Authored: Thu Sep 1 17:07:15 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Thu Sep 1 17:07:15 2016 +0200
----------------------------------------------------------------------
site/js/coffee/dom_utils.coffee | 34 +++++++++++++++++++---------------
1 file changed, 19 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/8b7e9c41/site/js/coffee/dom_utils.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/dom_utils.coffee b/site/js/coffee/dom_utils.coffee
index 847dc1e..5ac2692 100644
--- a/site/js/coffee/dom_utils.coffee
+++ b/site/js/coffee/dom_utils.coffee
@@ -33,27 +33,27 @@ mk = (type, params, children) ->
if params
for k, v of params
# Standard string value?
- if typeof v == "string"
+ if typeof v is "string"
r.setAttribute(k, v)
# Are we passing a list of data to set? concatenate then
else if isArray(v)
r.setAttribute(k, v.join(" "))
# Are we trying to set multiple sub elements, like a style?
- else if typeof(v) == "object"
+ else if typeof(v) is "object"
for x,y of v
r[k][x] = y
# If any children have been passed, add them to the element
if children
# If string, convert to textNode using txt()
- if typeof children == "string"
+ if typeof children is "string"
app(r, txt(children))
else
# If children is an array of elems, iterate and add
if isArray children
for k in children
# String? Convert via txt() then
- if typeof k == "string"
+ if typeof k is "string"
app(r, txt(k))
# Plain element, add normally
else
@@ -72,14 +72,14 @@ app = (a,b) ->
if isArray b
for item in b
# String? Convert to textNode first then
- if typeof item == "string"
+ if typeof item is "string"
item = txt(item)
# Otherwise just add it
a.appendChild(item)
# Otherwise, just add
else
# String? Convert first
- if typeof b == "string"
+ if typeof b is "string"
a.appendChild(txt(b))
# Not a string, add normally
return a.appendChild(b)
@@ -100,14 +100,18 @@ get = (a) ->
# Cog: Loading panel for when waiting for a response
cog = (div, size = 200) ->
- idiv = document.createElement('div')
- idiv.setAttribute("class", "icon")
- idiv.setAttribute("style", "text-align: center; vertical-align: middle; height: 500px;")
- i = document.createElement('i')
- i.setAttribute("class", "fa fa-spin fa-cog")
- i.setAttribute("style", "font-size: " + size + "pt !important; color: #AAB;")
- idiv.appendChild(i)
- idiv.appendChild(document.createElement('br'))
- idiv.appendChild(document.createTextNode('Loading data, please wait...'))
+ idiv = mk('div', { class: "icon", style: {
+ texAlign: 'center',
+ verticalAlign: 'middle',
+ height: '500px'
+ }
+ )
+
+ i = mk('i', { class: 'fa fa-spin fa-cog', style: {
+ fontSize: size+'pt !important',
+ color: '#AAB'
+ }
+ )
+ app(idiv, [i, mk('br'), "Loading data, please wait..."])
div.innerHTML = ""
div.appendChild(idiv)
[13/17] incubator-ponymail git commit: cleanup var names and comments
Posted by hu...@apache.org.
cleanup var names and comments
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/effc1724
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/effc1724
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/effc1724
Branch: refs/heads/coffee-and-cake
Commit: effc1724c19b76768323218565ea6513f91e2660
Parents: 16ad6c0
Author: Daniel Gruno <hu...@apache.org>
Authored: Fri Sep 2 09:18:19 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Fri Sep 2 09:18:19 2016 +0200
----------------------------------------------------------------------
site/js/coffee/http_utils.coffee | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/effc1724/site/js/coffee/http_utils.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/http_utils.coffee b/site/js/coffee/http_utils.coffee
index 23bc447..fd95e7d 100644
--- a/site/js/coffee/http_utils.coffee
+++ b/site/js/coffee/http_utils.coffee
@@ -45,6 +45,7 @@
class HTTPRequest
constructor = (@url, @args) ->
+ # Set internal class data, determine request type
@state = @args.state
@method = if @args.data then 'POST' else 'GET'
@data = @args.data
@@ -85,28 +86,29 @@ class HTTPRequest
@url += "?" + tmp
# Use @method on URL
- @requestobj.open(@method, @url, true)
+ @request.open(@method, @url, true)
# Send data
- @requestobj.send(@rdata)
+ @request.send(@rdata)
# Set onChange behavior
- @requestobj.onreadystatechange = @onchange
+ @request.onreadystatechange = @onchange
# all done!
+ # HTTPRequest state change calback
onchange = () ->
# Internal Server Error: Try to call snap
- if @requestobj.readyState == 4 and @requestobj.status == 500
+ if @request.readyState == 4 and @request.status == 500
if @snap
@snap(@state)
# 200 OK, everything is okay, try to parse JSON response
- if @requestobj.readyState == 4 and @requestobj.status == 200
+ if @request.readyState == 4 and @request.status == 200
if @callback
# Try to parse as JSON and deal with cache objects, fall back to old style parse-and-pass
try
# Parse JSON response
- @response = JSON.parse(xmlHttp.responseText)
+ @response = JSON.parse(@request.responseText)
# If loginRequired (rare!), redirect to oauth page
if @response && @response.loginRequired
location.href = "/oauth.html"
@@ -115,7 +117,7 @@ class HTTPRequest
@callback(@response, @state);
# JSON parse failed? Pass on the response as plain text then
catch e
- @callback(@requestobj.responseText, @state)
+ @callback(@request.responseText, @state)
# Standard form data joiner for POST data
formdata = (kv) ->
[03/17] incubator-ponymail git commit: allow an array-like parameter
value
Posted by hu...@apache.org.
allow an array-like parameter value
concatenate with spaces. useful for things like classes
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/3e672bc5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/3e672bc5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/3e672bc5
Branch: refs/heads/coffee-and-cake
Commit: 3e672bc50f51c69e0bcbc8b8fff9101f1d221cf9
Parents: b43dd96
Author: Daniel Gruno <hu...@apache.org>
Authored: Thu Sep 1 17:00:16 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Thu Sep 1 17:00:16 2016 +0200
----------------------------------------------------------------------
site/js/coffee/dom_utils.coffee | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/3e672bc5/site/js/coffee/dom_utils.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/dom_utils.coffee b/site/js/coffee/dom_utils.coffee
index 3419119..1a9286c 100644
--- a/site/js/coffee/dom_utils.coffee
+++ b/site/js/coffee/dom_utils.coffee
@@ -31,8 +31,11 @@ mk = (type, params, children) ->
# Standard string value?
if typeof v == "string"
r.setAttribute(k, v)
+ # Are we passing a list of data to set? concatenate then
+ else if isArray(v)
+ r.setAttribute(k, v.join(" "))
# Are we trying to set multiple sub elements, like a style?
- else if typeof(v) == "object" and not isArray(v)
+ else if typeof(v) == "object"
for x,y of v
r[k][x] = y
[11/17] incubator-ponymail git commit: rewrite http lib,
unify functions into one
Posted by hu...@apache.org.
rewrite http lib, unify functions into one
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/07f3780d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/07f3780d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/07f3780d
Branch: refs/heads/coffee-and-cake
Commit: 07f3780da0ae25f2cb26fa811af6b46c2c4282ad
Parents: b3a9ba7
Author: Daniel Gruno <hu...@apache.org>
Authored: Fri Sep 2 09:10:43 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Fri Sep 2 09:10:43 2016 +0200
----------------------------------------------------------------------
site/js/coffee/http_utils.coffee | 204 ++++++++++++++--------------------
1 file changed, 86 insertions(+), 118 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/07f3780d/site/js/coffee/http_utils.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/http_utils.coffee b/site/js/coffee/http_utils.coffee
index 5a9683b..eefc7fd 100644
--- a/site/js/coffee/http_utils.coffee
+++ b/site/js/coffee/http_utils.coffee
@@ -19,132 +19,100 @@
# This is http_utils.coffee: HTTP Request library #
####################################################
-# fetch: Fetches a URL.
-# Params:
-# - url: URL to fetch
-# - xstate: JS state object to pass on to callback
-# - callback: callback function to utilize the response
-# - snap: optional callback if fetch fails (error 500)
-# - nocreds: set to True to disable sending credentials (cookies etc)
-# Example: fetch("/api/foo.lua", {pony: true}, callbackfunc, null, true)
-fetch = (url, xstate, callback, snap, nocreds) ->
- xmlHttp = null;
-
- # Set up request object
- if window.XMLHttpRequest
- xmlHttp = new XMLHttpRequest();
- else
- xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
- if not nocreds
- xmlHttp.withCredentials = true
-
- # GET URL
- xmlHttp.open("GET", url, true);
- xmlHttp.send(null);
-
- # Check for request state response change
- xmlHttp.onreadystatechange = (state) ->
+# HTTPRequest: Fire off a HTTP request.
+# Args:
+# - url: The URL to request (may be relative or absolute)
+# - args:
+# - - state: A callback stateful object
+# - - data: Any form/JSON data to send along if POST (method is derived
+# from whether data is attached or not)
+# - - getdata: Any form vars to append to the URL as URI-encoded formdata
+# - - datatype: 'form' or 'json' data?
+# - - callback: function to call when request has returned a response
+# - - snap: snap function in case of internal server error or similar
+# - - nocreds: don't pass on cookies?
+class HTTPRequest
+ constructor = (@url, @args) ->
+ @state = @args.state
+ @method = if @args.data then 'POST' else 'GET'
+ @data = @args.data
+ @getdata = @args.get
+ @datatype = @args.datatype || 'form'
+ @callback = @args.callback
+ @snap = @args.snap || pm_snap
+ @nocreds = @args.nocreds || false
+
+ # Construct request object
+ if window.XMLHttpRequest
+ @request = new XMLHttpRequest();
+ else
+ @request = new ActiveXObject("Microsoft.XMLHTTP");
+
+ # Default to sending credentials
+ if not @nocreds
+ @request.withCredentials = true
+
+ # Determine what to send as data (if anything)
+ @rdata = null
+ if @method is 'POST'
+ if @datatype == 'json'
+ @rdata = JSON.stringify(@data)
+ else
+ @rdata = @formdata(@data)
+
+ # If tasked with appending data to the URL, do so
+ if @getdata
+ tmp = @formdata(@getdata)
+ if tmp.length > 0
+ # Do we have form data here aleady? if so, append the new
+ # by adding an ampersand first
+ if @url.match(/\?/)
+ @url += "&" + tmp
+ # No form data yet, add a ? and then the data
+ else
+ @url += "?" + tmp
+
+ # Use @method on URL
+ @requestobj.open(@method, @url, true)
+
+ # Send data
+ @requestobj.send(@rdata)
+
+ # Set onChange behavior
+ @requestobj.onreadystatechange = @onchange
+
+ # all done!
+
+ onchange = () ->
# Internal Server Error: Try to call snap
- if xmlHttp.readyState == 4 and xmlHttp.status == 500
- if snap
- snap(xstate)
+ if @requestobj.readyState == 4 and @requestobj.status == 500
+ if @snap
+ @snap(@state)
# 200 OK, everything is okay, try to parse JSON response
- if xmlHttp.readyState == 4 and xmlHttp.status == 200
- if callback
+ if @requestobj.readyState == 4 and @requestobj.status == 200
+ if @callback
# Try to parse as JSON and deal with cache objects, fall back to old style parse-and-pass
try
# Parse JSON response
- response = JSON.parse(xmlHttp.responseText)
+ @response = JSON.parse(xmlHttp.responseText)
# If loginRequired (rare!), redirect to oauth page
- if response && response.loginRequired
+ if @response && @response.loginRequired
location.href = "/oauth.html"
return
# Otherwise, call the callback function
- callback(response, xstate);
+ @callback(@response, @state);
# JSON parse failed? Pass on the response as plain text then
catch e
- callback(xmlHttp.responseText, xstate)
- return
-
-# post: like fetch, but do a POST with standard text fields
-# - url: URL to POST to
-# - args: hash of keys/vals to convert into a POST request
-# - xstate: state to pass on to callback
-# - callback: calback function for response
-# - snap: callback in case of error 500
-post = (url, args, xstate, callback, snap) ->
- xmlHttp = null;
- # Set up request object
- if window.XMLHttpRequest
- xmlHttp = new XMLHttpRequest();
- else
- xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
- xmlHttp.withCredentials = true
-
- # Construct form data string to POST.
- ar = []
- for k,v of args
- if v and v != ""
- ar.push(k + "=" + encodeURIComponent(v))
- fdata = ar.join("&")
-
-
- # POST URL
- xmlHttp.open("POST", url, true);
- xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
- xmlHttp.send(fdata);
-
- # Check for response
- xmlHttp.onreadystatechange = (state) ->
- # Internal Server Error: call snap function
- if xmlHttp.readyState == 4 and xmlHttp.status == 500
- if snap
- snap(xstate)
- # 200 Okay, parse response and run callback
- if xmlHttp.readyState == 4 and xmlHttp.status == 200
- if callback
- # Try to parse as JSON and deal with cache objects, fall back to old style parse-and-pass
- try
- response = JSON.parse(xmlHttp.responseText)
- callback(response, xstate);
- # JSON parse failed? Try passing on as plain text
- catch e
- callback(xmlHttp.responseText, xstate)
- return
-
-# postJSON: Same as post, but send vars as a JSON object
-postJSON = (url, json, xstate, callback, snap) ->
- xmlHttp = null;
- # Set up request object
- if window.XMLHttpRequest
- xmlHttp = new XMLHttpRequest();
- else
- xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
- xmlHttp.withCredentials = true
-
- # Construct form data
- fdata = JSON.stringify(json)
-
- # POST URL
- xmlHttp.open("POST", url, true);
- xmlHttp.setRequestHeader("Content-type", "application/json");
- xmlHttp.send(fdata);
-
- # Check for response
- xmlHttp.onreadystatechange = (state) ->
- # Internal Server Error: call snap!
- if xmlHttp.readyState == 4 and xmlHttp.status == 500
- if snap
- snap(xstate)
-
- # 200 Okay, parse response and pass to callback
- if xmlHttp.readyState == 4 and xmlHttp.status == 200
- if callback
- # Try to parse as JSON and deal with cache objects, fall back to old style parse-and-pass
- try
- response = JSON.parse(xmlHttp.responseText)
- callback(response, xstate);
- # Fall back to plain text if parse failed
- catch e
- callback(xmlHttp.responseText, xstate)
- return
+ @callback(@requestobj.responseText, @state)
+
+ # Standard form data joiner for POST data
+ formdata = (kv) ->
+ ar = []
+ # For each key/value pair
+ for k,v of kv
+ # Only append if the value is non-empty
+ if v and v != ""
+ # URI-Encode value and add to an array
+ ar.push(k + "=" + encodeURIComponent(v))
+ # Join the array with ampersands, so we get "foo=bar&foo2=baz"
+ return ar.join("&")
[12/17] incubator-ponymail git commit: add example function call
Posted by hu...@apache.org.
add example function call
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/16ad6c0b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/16ad6c0b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/16ad6c0b
Branch: refs/heads/coffee-and-cake
Commit: 16ad6c0b8bed8a32e15c3de2da6750ee5c486c11
Parents: 07f3780
Author: Daniel Gruno <hu...@apache.org>
Authored: Fri Sep 2 09:15:52 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Fri Sep 2 09:15:52 2016 +0200
----------------------------------------------------------------------
site/js/coffee/http_utils.coffee | 12 ++++++++++++
1 file changed, 12 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/16ad6c0b/site/js/coffee/http_utils.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/http_utils.coffee b/site/js/coffee/http_utils.coffee
index eefc7fd..23bc447 100644
--- a/site/js/coffee/http_utils.coffee
+++ b/site/js/coffee/http_utils.coffee
@@ -31,6 +31,18 @@
# - - callback: function to call when request has returned a response
# - - snap: snap function in case of internal server error or similar
# - - nocreds: don't pass on cookies?
+
+# Example POST request:
+# HTTPRequest("/api/foo.lua", {
+# state: {
+# ponies: true
+# },
+# callback: foofunc,
+# data: {
+# list: "foo.bar"
+# }
+# })
+
class HTTPRequest
constructor = (@url, @args) ->
@state = @args.state
[09/17] incubator-ponymail git commit: add a readme for coffe-and-cake
Posted by hu...@apache.org.
add a readme for coffe-and-cake
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/47a22fc1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/47a22fc1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/47a22fc1
Branch: refs/heads/coffee-and-cake
Commit: 47a22fc1f46fe4fa04041ee699bc12ed8fd24cce
Parents: 7b308de
Author: Daniel Gruno <hu...@apache.org>
Authored: Thu Sep 1 17:43:51 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Thu Sep 1 17:43:51 2016 +0200
----------------------------------------------------------------------
site/js/coffee/README.md | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/47a22fc1/site/js/coffee/README.md
----------------------------------------------------------------------
diff --git a/site/js/coffee/README.md b/site/js/coffee/README.md
new file mode 100644
index 0000000..62db6b9
--- /dev/null
+++ b/site/js/coffee/README.md
@@ -0,0 +1,19 @@
+# Building Pony Mail Coffee-and-Cake for Production #
+Most of Pony Mail is ready-for-deployment files that just need to be checked out
+in order to work. Some areas, such as the CofeeScript needs to be compiled and combined
+by a script, as they have been split into several smaller files to make it easier to
+find and work on various elements of the rendering process.
+
+### Building the JavaScript amalgamation ###
+All edits should be done to the `site/js/coffee/*.coffee` files.
+Once done, you should run combine.sh in the `site/js/coffee` directory
+to generate ponymail-coffee.js from the scripts in the dev dir:
+
+ $cd site/js/coffee
+ $bash combine.sh
+ (coffeescript output goes here...)
+ Done!
+ $
+
+You may choose to commit the initial Coffee changes first before
+committing the new amalgamated JS, but that's up to you.
[10/17] incubator-ponymail git commit: add returns
Posted by hu...@apache.org.
add returns
mostly so it looks neater
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/b3a9ba7a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/b3a9ba7a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/b3a9ba7a
Branch: refs/heads/coffee-and-cake
Commit: b3a9ba7af746393606a38590f2e21d51134e274f
Parents: 47a22fc
Author: Daniel Gruno <hu...@apache.org>
Authored: Thu Sep 1 17:49:44 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Thu Sep 1 17:49:44 2016 +0200
----------------------------------------------------------------------
site/js/coffee/http_utils.coffee | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/b3a9ba7a/site/js/coffee/http_utils.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/http_utils.coffee b/site/js/coffee/http_utils.coffee
index 52bd8a8..5a9683b 100644
--- a/site/js/coffee/http_utils.coffee
+++ b/site/js/coffee/http_utils.coffee
@@ -64,6 +64,7 @@ fetch = (url, xstate, callback, snap, nocreds) ->
# JSON parse failed? Pass on the response as plain text then
catch e
callback(xmlHttp.responseText, xstate)
+ return
# post: like fetch, but do a POST with standard text fields
# - url: URL to POST to
@@ -109,6 +110,7 @@ post = (url, args, xstate, callback, snap) ->
# JSON parse failed? Try passing on as plain text
catch e
callback(xmlHttp.responseText, xstate)
+ return
# postJSON: Same as post, but send vars as a JSON object
postJSON = (url, json, xstate, callback, snap) ->
@@ -145,3 +147,4 @@ postJSON = (url, json, xstate, callback, snap) ->
# Fall back to plain text if parse failed
catch e
callback(xmlHttp.responseText, xstate)
+ return
[17/17] incubator-ponymail git commit: rerig comments a bit
Posted by hu...@apache.org.
rerig comments a bit
coffee doesn't always like it when you indent comments
"incorrectly" near if/else statements.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/f2cdcb47
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/f2cdcb47
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/f2cdcb47
Branch: refs/heads/coffee-and-cake
Commit: f2cdcb47431414a43ccf86b4e0142ebafcce1c2f
Parents: 22b3b8a
Author: Daniel Gruno <hu...@apache.org>
Authored: Fri Sep 2 09:42:02 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Fri Sep 2 09:42:02 2016 +0200
----------------------------------------------------------------------
site/js/coffee/dom_utils.coffee | 14 +++++++-------
site/js/coffee/http_utils.coffee | 4 ++--
site/js/coffee/localstorage.coffee | 4 ++--
3 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/f2cdcb47/site/js/coffee/dom_utils.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/dom_utils.coffee b/site/js/coffee/dom_utils.coffee
index afd291e..c033a14 100644
--- a/site/js/coffee/dom_utils.coffee
+++ b/site/js/coffee/dom_utils.coffee
@@ -34,14 +34,14 @@ mk = (type, params, children) ->
### If params have been passed, set them ###
if params
for k, v of params
- # Standard string value?
+ ### Standard string value? ###
if typeof v is "string"
r.setAttribute(k, v)
- # Are we passing a list of data to set? concatenate then
else if isArray(v)
+ ### Are we passing a list of data to set? concatenate then ###
r.setAttribute(k, v.join(" "))
- # Are we trying to set multiple sub elements, like a style?
else if typeof(v) is "object"
+ ### Are we trying to set multiple sub elements, like a style? ###
for x,y of v
r[k][x] = y
@@ -57,11 +57,11 @@ mk = (type, params, children) ->
### String? Convert via txt() then ###
if typeof k is "string"
app(r, txt(k))
- ### Plain element, add normally ###
else
+ ### Plain element, add normally ###
app(r, k)
- ### Just a single element, add it ###
else
+ ### Just a single element, add it ###
app(r, children)
return r
@@ -78,10 +78,10 @@ app = (a,b) ->
### String? Convert to textNode first then ###
if typeof item is "string"
item = txt(item)
- ### Otherwise just add it ###
+ ### In any case, add it now ###
a.appendChild(item)
- ### Otherwise, just add ###
else
+ ### Otherwise, just add ###
### String? Convert first ###
if typeof b is "string"
a.appendChild(txt(b))
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/f2cdcb47/site/js/coffee/http_utils.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/http_utils.coffee b/site/js/coffee/http_utils.coffee
index 4b5675e..60d8e13 100644
--- a/site/js/coffee/http_utils.coffee
+++ b/site/js/coffee/http_utils.coffee
@@ -83,7 +83,7 @@ class HTTPRequest
### by adding an ampersand first ###
if @url.match(/\?/)
@url += "&" + tmp
- ### No form data yet, add a ? and then the data ###
+ #### No form data yet, add a ? and then the data ###
else
@url += "?" + tmp
@@ -118,7 +118,7 @@ class HTTPRequest
return
### Otherwise, call the callback function ###
@callback(@response, @state);
- ### JSON parse failed? Pass on the response as plain text then ###
+ #### JSON parse failed? Pass on the response as plain text then ###
catch e
@callback(@request.responseText, @state)
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/f2cdcb47/site/js/coffee/localstorage.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/localstorage.coffee b/site/js/coffee/localstorage.coffee
index bcd9128..d4339ab 100644
--- a/site/js/coffee/localstorage.coffee
+++ b/site/js/coffee/localstorage.coffee
@@ -37,8 +37,8 @@ dbWrite = (key, value) ->
### Can we use localStorage? ###
if pm_storage_available
return window.localStorage.setItem(key, value)
- ### Guess not, fall back to (ineffective) global var ###
else
+ ### Guess not, fall back to (ineffective) global var ###
pm_storage_globvar[key] = value
return true
@@ -47,7 +47,7 @@ dbRead = (key) ->
### Do we have localStorage? ###
if pm_storage_available
return window.localStorage.getItem(key)
- ### Nope, try global var ###
else
+ ### Nope, try global var ###
return pm_storage_globvar[key]
[04/17] incubator-ponymail git commit: fix headers
Posted by hu...@apache.org.
fix headers
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/f36d5560
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/f36d5560
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/f36d5560
Branch: refs/heads/coffee-and-cake
Commit: f36d5560b2887f62f246bebbf8180d270930d88c
Parents: 3e672bc
Author: Daniel Gruno <hu...@apache.org>
Authored: Thu Sep 1 17:03:01 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Thu Sep 1 17:03:01 2016 +0200
----------------------------------------------------------------------
site/js/coffee/dom_utils.coffee | 4 ++++
site/js/coffee/http_utils.coffee | 4 ++++
site/js/coffee/misc.coffee | 22 +++++++++++++++++++++-
3 files changed, 29 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/f36d5560/site/js/coffee/dom_utils.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/dom_utils.coffee b/site/js/coffee/dom_utils.coffee
index 1a9286c..847dc1e 100644
--- a/site/js/coffee/dom_utils.coffee
+++ b/site/js/coffee/dom_utils.coffee
@@ -15,6 +15,10 @@
limitations under the License.
###
+####################################################
+# This is dom_utils.coffee: DOM handling utilities #
+####################################################
+
# mk: DOM creator
# args:
# - type: HTML element type (div, table, p etc) to produce
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/f36d5560/site/js/coffee/http_utils.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/http_utils.coffee b/site/js/coffee/http_utils.coffee
index 5101a00..52bd8a8 100644
--- a/site/js/coffee/http_utils.coffee
+++ b/site/js/coffee/http_utils.coffee
@@ -15,6 +15,10 @@
limitations under the License.
###
+####################################################
+# This is http_utils.coffee: HTTP Request library #
+####################################################
+
# fetch: Fetches a URL.
# Params:
# - url: URL to fetch
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/f36d5560/site/js/coffee/misc.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/misc.coffee b/site/js/coffee/misc.coffee
index 92db090..e4a9e69 100644
--- a/site/js/coffee/misc.coffee
+++ b/site/js/coffee/misc.coffee
@@ -1,4 +1,24 @@
-# Miscellaneous functions
+###
+ 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 misc.coffee: Miscellaneous utility functions #
+########################################################
# Number prettification prototype:
# Converts 1234567 into 1,234,567 etc