diff --git a/ajax/libs/angularSubkit/1.0.1/angularsubkit.js b/ajax/libs/angularSubkit/1.0.1/angularsubkit.js new file mode 100644 index 000000000..f6d2e3fde --- /dev/null +++ b/ajax/libs/angularSubkit/1.0.1/angularsubkit.js @@ -0,0 +1,3408 @@ +// angularsubkit.js - 1.0.1 +// https://github.com/subkit +// Copyright 2012 - 2014 http://subkit.io +// MIT License + +!function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.Subkit=e():"undefined"!=typeof global?global.Subkit=e():"undefined"!=typeof self&&(self.Subkit=e())}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 127) && (c < 2048)) { + result += String.fromCharCode((c >> 6) | 192); + result += String.fromCharCode((c & 63) | 128); + } else { + result += String.fromCharCode((c >> 12) | 224); + result += String.fromCharCode(((c >> 6) & 63) | 128); + result += String.fromCharCode((c & 63) | 128); + } + } + + return result; + }; + var base64 = function (text) { + var keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + + text = utf8(text); + var result = '', + chr1, chr2, chr3, + enc1, enc2, enc3, enc4, + i = 0; + + do { + chr1 = text.charCodeAt(i++); + chr2 = text.charCodeAt(i++); + chr3 = text.charCodeAt(i++); + + enc1 = chr1 >> 2; + enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); + enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); + enc4 = chr3 & 63; + + if(isNaN(chr2)) { + enc3 = enc4 = 64; + } else if(isNaN(chr3)) { + enc4 = 64; + } + + result += + keyStr.charAt(enc1) + + keyStr.charAt(enc2) + + keyStr.charAt(enc3) + + keyStr.charAt(enc4); + chr1 = chr2 = chr3 = ''; + enc1 = enc2 = enc3 = enc4 = ''; + } while(i < text.length); + + return result; + }; + var mergeHeaders = function () { + var result = arguments[0]; + for(var i = 1; i < arguments.length; i++) { + var currentHeaders = arguments[i]; + for(var header in currentHeaders) { + if(currentHeaders.hasOwnProperty(header)) { + result[header] = currentHeaders[header]; + } + } + } + return result; + }; + var ajax = function (method, url, options, callback, logCallback) { + if(typeof options === 'function') { + callback = options; + options = {}; + } + options.cache = options.cache || true; + options.headers = options.headers || {}; + options.jsonp = options.jsonp || false; + + var headers = mergeHeaders({ + 'accept': '*/*', + 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8', + 'x-auth-token': options.apiKey + }, ajax.headers, options.headers); + var payload; + + if(options.data) { + if ((method === 'GET') && (headers['Content-Type'] === 'application/json')) { + payload = encodeUsingUrlEncoding(options.data); + } + else if (headers['Content-Type'] === 'application/json') { + payload = JSON.stringify(options.data); + } + else if(headers['Content-Type'].indexOf('application/octed-stream') !== -1){ + payload = options.data; + } + else { + payload = encodeUsingUrlEncoding(options.data); + } + } + + if(method === 'GET') { + var queryString = []; + if(payload) { + queryString.push(payload); + payload = null; + } + + if(!options.cache) { + queryString.push('_=' + (new Date()).getTime()); + } + + if(options.jsonp) { + queryString.push('callback=' + options.jsonp); + queryString.push('jsonp=' + options.jsonp); + } + + queryString = '?' + queryString.join('&'); + url += queryString !== '?' ? queryString : ''; + + if(options.jsonp) { + var head = document.getElementsByTagName('head')[0]; + var script = document.createElement('script'); + script.type = 'text/javascript'; + script.src = url; + head.appendChild(script); + return; + } + } + var xhrRef = null; + getXhr(function (err, xhr) { + xhrRef = xhr; + if(err) return callback(err); + xhr.open(method, url, options.async || true); + for(var header in headers) { + if(headers.hasOwnProperty(header)) { + xhr.setRequestHeader(header, headers[header]); + } + } + xhr.onerror = function(){ + callback(xhr.status, { + text: function () { + return xhr.statusText; + } + }); + }; + xhr.onreadystatechange = function () { + if(xhr.readyState === 4 && xhr.status !== 0) { + var log = this.getResponseHeader('subkit-log'); + if(logCallback) logCallback(log); + + if(!callback) return; + var data = xhr.responseText || ''; + callback(xhr.status, { + text: function () { + return data; + }, + json: function () { + if(data) return JSON.parse(data); + return {}; + }, + headers: function(){ + return xhr.getAllResponseHeaders(); + } + }); + } + }; + + xhr.send(payload); + }); + return xhrRef; + }; + var httpRequest = { + authBasic: function (username, password) { + httpRequest.headers({}); + ajax.headers['Authorization'] = 'Basic ' + base64(username + ':' + password); + }, + connect: function (url, options, callback, logCallback) { + return ajax('CONNECT', url, options, callback, logCallback); + }, + del: function (url, options, callback, logCallback) { + return ajax('DELETE', url, options, callback, logCallback); + }, + get: function (url, options, callback, logCallback) { + return ajax('GET', url, options, callback, logCallback); + }, + head: function (url, options, callback, logCallback) { + return ajax('HEAD', url, options, callback, logCallback); + }, + headers: function (headers) { + ajax.headers = headers || {}; + }, + isAllowed: function (url, verb, callback, logCallback) { + this.options(url, function (status, data) { + callback(data.text().indexOf(verb) !== -1); + }, logCallback); + }, + options: function (url, options, callback, logCallback) { + return ajax('OPTIONS', url, options, callback, logCallback); + }, + patch: function (url, options, callback, logCallback) { + return ajax('PATCH', url, options, callback, logCallback); + }, + post: function (url, options, callback, logCallback) { + return ajax('POST', url, options, callback, logCallback); + }, + put: function (url, options, callback, logCallback) { + return ajax('PUT', url, options, callback, logCallback); + }, + trace: function (url, options, callback, logCallback) { + return ajax('TRACE', url, options, callback, logCallback); + } + }; + var _init = function(){ + var clientId = window.sessionStorage.getItem('clientId'); + if(!clientId) { + clientId = self.UUID(); + window.sessionStorage.setItem('clientId', clientId); + } + return clientId; + }; + self.clientId = config.clientId || _init(); + self.baseUrl = config.baseUrl || ((window.location.origin.indexOf('http') !== -1) ? window.location.origin : 'https://localhost:8080'); + self.options = { + apiKey: config.apiKey || '', + username: config.username || '', + password: config.password || '', + headers : { + 'Content-Type': 'application/json' + } + }; + var statusListeners = []; + self.subscribed = {}; + var _changeStatus = function(status){ + if(status.json) status = status.json(); + + statusListeners.forEach(function(listener){ + listener(status); + }); + }; + self.httpRequest = httpRequest; + + var _poll = function(channel, clientId, callback) { + var subscribeUrl = self.baseUrl + '/pubsub/subscribe/' + channel + '/' + clientId; + var request = null; + var count = 1; + + (function _pollRef(){ + request = httpRequest.get(subscribeUrl, self.options, function(status, result){ + if(status !== 200) { + if(self.subscribed[channel]){ + callback({message: 'subscription error - retry'}); + setTimeout(function(){_pollRef(channel, clientId, callback);},300*count++); + } + }else{ + count = 1; + result.json().forEach(function(item){ + callback(null, item.value); + }); + if(self.subscribed[channel]) _pollRef(channel, clientId, callback); + } + }); + })(); + + return function(){ + return request; + }; + }; +}; +},{"./plugins/baas":1,"./plugins/email":2,"./plugins/file":3,"./plugins/flow":4,"./plugins/geolocation":5,"./plugins/task":6,"./plugins/template":7,"./plugins/user":8,"q":11}],10:[function(require,module,exports){ +// shim for using process in browser + +var process = module.exports = {}; + +process.nextTick = (function () { + var canSetImmediate = typeof window !== 'undefined' + && window.setImmediate; + var canPost = typeof window !== 'undefined' + && window.postMessage && window.addEventListener + ; + + if (canSetImmediate) { + return function (f) { return window.setImmediate(f) }; + } + + if (canPost) { + var queue = []; + window.addEventListener('message', function (ev) { + var source = ev.source; + if ((source === window || source === null) && ev.data === 'process-tick') { + ev.stopPropagation(); + if (queue.length > 0) { + var fn = queue.shift(); + fn(); + } + } + }, true); + + return function nextTick(fn) { + queue.push(fn); + window.postMessage('process-tick', '*'); + }; + } + + return function nextTick(fn) { + setTimeout(fn, 0); + }; +})(); + +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +} + +// TODO(shtylman) +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; + +},{}],11:[function(require,module,exports){ +var process=require("__browserify_process");// vim:ts=4:sts=4:sw=4: +/*! + * + * Copyright 2009-2012 Kris Kowal under the terms of the MIT + * license found at http://github.com/kriskowal/q/raw/master/LICENSE + * + * With parts by Tyler Close + * Copyright 2007-2009 Tyler Close under the terms of the MIT X license found + * at http://www.opensource.org/licenses/mit-license.html + * Forked at ref_send.js version: 2009-05-11 + * + * With parts by Mark Miller + * Copyright (C) 2011 Google Inc. + * + * Licensed 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. + * + */ + +(function (definition) { + // Turn off strict mode for this function so we can assign to global.Q + /* jshint strict: false */ + + // This file will function properly as a