diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-11-23 01:45:53 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-11-23 01:45:53 -0500 |
| commit | 7d9950316368d825510588ded16e5194b4840931 (patch) | |
| tree | 294fa8647e451eae0d741cfeb88d2173b20fd940 /StoneIsland/www/js/vendor | |
| parent | 6b37f28e2dba8f191ff5df194e5215399b696faa (diff) | |
add to cart after signin..
Diffstat (limited to 'StoneIsland/www/js/vendor')
| -rw-r--r-- | StoneIsland/www/js/vendor/promise.js | 34 | ||||
| -rw-r--r-- | StoneIsland/www/js/vendor/util.js | 1 |
2 files changed, 35 insertions, 0 deletions
diff --git a/StoneIsland/www/js/vendor/promise.js b/StoneIsland/www/js/vendor/promise.js new file mode 100644 index 00000000..f458ab06 --- /dev/null +++ b/StoneIsland/www/js/vendor/promise.js @@ -0,0 +1,34 @@ +var promise = function(fn, data){ + var my_cb, my_res, error_cb, my_error + data = data || {} + data.success = function(res){ + my_res = res + if (my_cb) { + my_cb(res) + } + } + data.error = function(res){ + my_error = res + if (error_cb) { + error_cb(res) + } + else { + console.log('error!') + console.log(res) + } + } + fn(data) + var p = { + then: function(cb){ + if (my_res) cb(my_res) + else my_cb = cb + return p + }, + error: function(cb){ + if (my_error) cb(my_error) + else error_cb = cb + return p + } + } + return p +} diff --git a/StoneIsland/www/js/vendor/util.js b/StoneIsland/www/js/vendor/util.js index fede4761..6523d50e 100644 --- a/StoneIsland/www/js/vendor/util.js +++ b/StoneIsland/www/js/vendor/util.js @@ -27,6 +27,7 @@ function parse_rgba_string (s) { return s.match(/(\d+)/g).slice(0,3) } function title_case (str) { return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}); } +function pluralize (n,s,ss) { return n + " " + s + ( n == 1 ? "" : (ss || "s") ) } var E = Math.E var PI = Math.PI |
