sportdb 1.8.27 → 1.8.28
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +0 -21
- data/lib/sportdb/calc.rb +96 -26
- data/lib/sportdb/models/stats/alltime_standing.rb +5 -3
- data/lib/sportdb/schema.rb +2 -1
- data/lib/sportdb/service.rb +9 -21
- data/lib/sportdb/service/public/style.css +0 -17
- data/lib/sportdb/service/public/style.css.scss +1 -27
- data/lib/sportdb/service/server.rb +10 -6
- data/lib/sportdb/service/views/_version.erb +2 -3
- data/lib/sportdb/service/views/index.erb +1 -141
- data/lib/sportdb/service/views/layout.erb +1 -4
- data/lib/sportdb/version.rb +1 -1
- data/test/test_standings.rb +30 -1
- metadata +26 -47
- data/lib/sportdb/service/public/football/js/football/api.js +0 -63
- data/lib/sportdb/service/public/football/js/football/plugin.js +0 -36
- data/lib/sportdb/service/public/football/js/football/widget.js +0 -169
- data/lib/sportdb/service/public/football/js/libs/jquery-2.0.2.min.js +0 -6
- data/lib/sportdb/service/public/football/js/libs/require-2.1.6.js +0 -2045
- data/lib/sportdb/service/public/football/js/libs/underscore-1.4.4.min.js +0 -1
- data/lib/sportdb/service/public/football/js/text.js +0 -373
- data/lib/sportdb/service/public/football/js/utils.js +0 -80
- data/lib/sportdb/service/public/football/matchday-jquery.html +0 -57
- data/lib/sportdb/service/public/football/matchday-template.html +0 -106
- data/lib/sportdb/service/public/football/matchday.html +0 -76
- data/lib/sportdb/service/public/football/templates/event.html +0 -6
- data/lib/sportdb/service/public/football/templates/games.html +0 -29
- data/lib/sportdb/service/public/football/templates/rounds-long.html +0 -11
- data/lib/sportdb/service/public/football/templates/rounds-short.html +0 -16
- data/lib/sportdb/service/public/football/templates/rounds-today.html +0 -8
- data/lib/sportdb/service/version.rb +0 -6
- data/lib/sportdb/service/views/_football_head.erb +0 -21
- data/lib/sportdb/service/views/_football_live.erb +0 -32
- data/lib/sportdb/service/views/_football_today.erb +0 -20
- data/lib/sportdb/service/views/_usage.erb +0 -25
@@ -1 +0,0 @@
|
|
1
|
-
(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,h=e.reduce,v=e.reduceRight,d=e.filter,g=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,j=i.bind,w=function(n){return n instanceof w?n:this instanceof w?(this._wrapped=n,void 0):new w(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=w),exports._=w):n._=w,w.VERSION="1.4.4";var A=w.each=w.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(w.has(n,a)&&t.call(e,n[a],a,n)===r)return};w.map=w.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e[e.length]=t.call(r,n,u,i)}),e)};var O="Reduce of empty array with no initial value";w.reduce=w.foldl=w.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduce===h)return e&&(t=w.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},w.reduceRight=w.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduceRight===v)return e&&(t=w.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=w.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},w.find=w.detect=function(n,t,r){var e;return E(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},w.filter=w.select=function(n,t,r){var e=[];return null==n?e:d&&n.filter===d?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&(e[e.length]=n)}),e)},w.reject=function(n,t,r){return w.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},w.every=w.all=function(n,t,e){t||(t=w.identity);var u=!0;return null==n?u:g&&n.every===g?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var E=w.some=w.any=function(n,t,e){t||(t=w.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};w.contains=w.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:E(n,function(n){return n===t})},w.invoke=function(n,t){var r=o.call(arguments,2),e=w.isFunction(t);return w.map(n,function(n){return(e?t:n[t]).apply(n,r)})},w.pluck=function(n,t){return w.map(n,function(n){return n[t]})},w.where=function(n,t,r){return w.isEmpty(t)?r?null:[]:w[r?"find":"filter"](n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},w.findWhere=function(n,t){return w.where(n,t,!0)},w.max=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.max.apply(Math,n);if(!t&&w.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>=e.computed&&(e={value:n,computed:a})}),e.value},w.min=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.min.apply(Math,n);if(!t&&w.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;e.computed>a&&(e={value:n,computed:a})}),e.value},w.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=w.random(r++),e[r-1]=e[t],e[t]=n}),e};var k=function(n){return w.isFunction(n)?n:function(t){return t[n]}};w.sortBy=function(n,t,r){var e=k(t);return w.pluck(w.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index<t.index?-1:1}),"value")};var F=function(n,t,r,e){var u={},i=k(t||w.identity);return A(n,function(t,a){var o=i.call(r,t,a,n);e(u,o,t)}),u};w.groupBy=function(n,t,r){return F(n,t,r,function(n,t,r){(w.has(n,t)?n[t]:n[t]=[]).push(r)})},w.countBy=function(n,t,r){return F(n,t,r,function(n,t){w.has(n,t)||(n[t]=0),n[t]++})},w.sortedIndex=function(n,t,r,e){r=null==r?w.identity:k(r);for(var u=r.call(e,t),i=0,a=n.length;a>i;){var o=i+a>>>1;u>r.call(e,n[o])?i=o+1:a=o}return i},w.toArray=function(n){return n?w.isArray(n)?o.call(n):n.length===+n.length?w.map(n,w.identity):w.values(n):[]},w.size=function(n){return null==n?0:n.length===+n.length?n.length:w.keys(n).length},w.first=w.head=w.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},w.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},w.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},w.rest=w.tail=w.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},w.compact=function(n){return w.filter(n,w.identity)};var R=function(n,t,r){return A(n,function(n){w.isArray(n)?t?a.apply(r,n):R(n,t,r):r.push(n)}),r};w.flatten=function(n,t){return R(n,t,[])},w.without=function(n){return w.difference(n,o.call(arguments,1))},w.uniq=w.unique=function(n,t,r,e){w.isFunction(t)&&(e=r,r=t,t=!1);var u=r?w.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:w.contains(a,r))||(a.push(r),i.push(n[e]))}),i},w.union=function(){return w.uniq(c.apply(e,arguments))},w.intersection=function(n){var t=o.call(arguments,1);return w.filter(w.uniq(n),function(n){return w.every(t,function(t){return w.indexOf(t,n)>=0})})},w.difference=function(n){var t=c.apply(e,o.call(arguments,1));return w.filter(n,function(n){return!w.contains(t,n)})},w.zip=function(){for(var n=o.call(arguments),t=w.max(w.pluck(n,"length")),r=Array(t),e=0;t>e;e++)r[e]=w.pluck(n,""+e);return r},w.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},w.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=w.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},w.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},w.range=function(n,t,r){1>=arguments.length&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=Array(e);e>u;)i[u++]=n,n+=r;return i},w.bind=function(n,t){if(n.bind===j&&j)return j.apply(n,o.call(arguments,1));var r=o.call(arguments,2);return function(){return n.apply(t,r.concat(o.call(arguments)))}},w.partial=function(n){var t=o.call(arguments,1);return function(){return n.apply(this,t.concat(o.call(arguments)))}},w.bindAll=function(n){var t=o.call(arguments,1);return 0===t.length&&(t=w.functions(n)),A(t,function(t){n[t]=w.bind(n[t],n)}),n},w.memoize=function(n,t){var r={};return t||(t=w.identity),function(){var e=t.apply(this,arguments);return w.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},w.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},w.defer=function(n){return w.delay.apply(w,[n,1].concat(o.call(arguments,1)))},w.throttle=function(n,t){var r,e,u,i,a=0,o=function(){a=new Date,u=null,i=n.apply(r,e)};return function(){var c=new Date,l=t-(c-a);return r=this,e=arguments,0>=l?(clearTimeout(u),u=null,a=c,i=n.apply(r,e)):u||(u=setTimeout(o,l)),i}},w.debounce=function(n,t,r){var e,u;return function(){var i=this,a=arguments,o=function(){e=null,r||(u=n.apply(i,a))},c=r&&!e;return clearTimeout(e),e=setTimeout(o,t),c&&(u=n.apply(i,a)),u}},w.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},w.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},w.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},w.after=function(n,t){return 0>=n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},w.keys=_||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)w.has(n,r)&&(t[t.length]=r);return t},w.values=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push(n[r]);return t},w.pairs=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push([r,n[r]]);return t},w.invert=function(n){var t={};for(var r in n)w.has(n,r)&&(t[n[r]]=r);return t},w.functions=w.methods=function(n){var t=[];for(var r in n)w.isFunction(n[r])&&t.push(r);return t.sort()},w.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},w.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},w.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)w.contains(r,u)||(t[u]=n[u]);return t},w.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)null==n[r]&&(n[r]=t[r])}),n},w.clone=function(n){return w.isObject(n)?w.isArray(n)?n.slice():w.extend({},n):n},w.tap=function(n,t){return t(n),n};var I=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof w&&(n=n._wrapped),t instanceof w&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==t+"";case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;r.push(n),e.push(t);var a=0,o=!0;if("[object Array]"==u){if(a=n.length,o=a==t.length)for(;a--&&(o=I(n[a],t[a],r,e)););}else{var c=n.constructor,f=t.constructor;if(c!==f&&!(w.isFunction(c)&&c instanceof c&&w.isFunction(f)&&f instanceof f))return!1;for(var s in n)if(w.has(n,s)&&(a++,!(o=w.has(t,s)&&I(n[s],t[s],r,e))))break;if(o){for(s in t)if(w.has(t,s)&&!a--)break;o=!a}}return r.pop(),e.pop(),o};w.isEqual=function(n,t){return I(n,t,[],[])},w.isEmpty=function(n){if(null==n)return!0;if(w.isArray(n)||w.isString(n))return 0===n.length;for(var t in n)if(w.has(n,t))return!1;return!0},w.isElement=function(n){return!(!n||1!==n.nodeType)},w.isArray=x||function(n){return"[object Array]"==l.call(n)},w.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){w["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),w.isArguments(arguments)||(w.isArguments=function(n){return!(!n||!w.has(n,"callee"))}),"function"!=typeof/./&&(w.isFunction=function(n){return"function"==typeof n}),w.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},w.isNaN=function(n){return w.isNumber(n)&&n!=+n},w.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},w.isNull=function(n){return null===n},w.isUndefined=function(n){return n===void 0},w.has=function(n,t){return f.call(n,t)},w.noConflict=function(){return n._=t,this},w.identity=function(n){return n},w.times=function(n,t,r){for(var e=Array(n),u=0;n>u;u++)e[u]=t.call(r,u);return e},w.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))};var M={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};M.unescape=w.invert(M.escape);var S={escape:RegExp("["+w.keys(M.escape).join("")+"]","g"),unescape:RegExp("("+w.keys(M.unescape).join("|")+")","g")};w.each(["escape","unescape"],function(n){w[n]=function(t){return null==t?"":(""+t).replace(S[n],function(t){return M[n][t]})}}),w.result=function(n,t){if(null==n)return null;var r=n[t];return w.isFunction(r)?r.call(n):r},w.mixin=function(n){A(w.functions(n),function(t){var r=w[t]=n[t];w.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),D.call(this,r.apply(w,n))}})};var N=0;w.uniqueId=function(n){var t=++N+"";return n?n+t:t},w.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var T=/(.)^/,q={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},B=/\\|'|\r|\n|\t|\u2028|\u2029/g;w.template=function(n,t,r){var e;r=w.defaults({},r,w.templateSettings);var u=RegExp([(r.escape||T).source,(r.interpolate||T).source,(r.evaluate||T).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(B,function(n){return"\\"+q[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,w);var c=function(n){return e.call(this,n,w)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},w.chain=function(n){return w(n).chain()};var D=function(n){return this._chain?w(n).chain():n};w.mixin(w),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];w.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],D.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];w.prototype[n]=function(){return D.call(this,t.apply(this._wrapped,arguments))}}),w.extend(w.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this);
|
@@ -1,373 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @license RequireJS text 2.0.7 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
|
3
|
-
* Available via the MIT or new BSD license.
|
4
|
-
* see: http://github.com/requirejs/text for details
|
5
|
-
*/
|
6
|
-
/*jslint regexp: true */
|
7
|
-
/*global require, XMLHttpRequest, ActiveXObject,
|
8
|
-
define, window, process, Packages,
|
9
|
-
java, location, Components, FileUtils */
|
10
|
-
|
11
|
-
define(['module'], function (module) {
|
12
|
-
'use strict';
|
13
|
-
|
14
|
-
var text, fs, Cc, Ci,
|
15
|
-
progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'],
|
16
|
-
xmlRegExp = /^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im,
|
17
|
-
bodyRegExp = /<body[^>]*>\s*([\s\S]+)\s*<\/body>/im,
|
18
|
-
hasLocation = typeof location !== 'undefined' && location.href,
|
19
|
-
defaultProtocol = hasLocation && location.protocol && location.protocol.replace(/\:/, ''),
|
20
|
-
defaultHostName = hasLocation && location.hostname,
|
21
|
-
defaultPort = hasLocation && (location.port || undefined),
|
22
|
-
buildMap = {},
|
23
|
-
masterConfig = (module.config && module.config()) || {};
|
24
|
-
|
25
|
-
text = {
|
26
|
-
version: '2.0.7',
|
27
|
-
|
28
|
-
strip: function (content) {
|
29
|
-
//Strips <?xml ...?> declarations so that external SVG and XML
|
30
|
-
//documents can be added to a document without worry. Also, if the string
|
31
|
-
//is an HTML document, only the part inside the body tag is returned.
|
32
|
-
if (content) {
|
33
|
-
content = content.replace(xmlRegExp, "");
|
34
|
-
var matches = content.match(bodyRegExp);
|
35
|
-
if (matches) {
|
36
|
-
content = matches[1];
|
37
|
-
}
|
38
|
-
} else {
|
39
|
-
content = "";
|
40
|
-
}
|
41
|
-
return content;
|
42
|
-
},
|
43
|
-
|
44
|
-
jsEscape: function (content) {
|
45
|
-
return content.replace(/(['\\])/g, '\\$1')
|
46
|
-
.replace(/[\f]/g, "\\f")
|
47
|
-
.replace(/[\b]/g, "\\b")
|
48
|
-
.replace(/[\n]/g, "\\n")
|
49
|
-
.replace(/[\t]/g, "\\t")
|
50
|
-
.replace(/[\r]/g, "\\r")
|
51
|
-
.replace(/[\u2028]/g, "\\u2028")
|
52
|
-
.replace(/[\u2029]/g, "\\u2029");
|
53
|
-
},
|
54
|
-
|
55
|
-
createXhr: masterConfig.createXhr || function () {
|
56
|
-
//Would love to dump the ActiveX crap in here. Need IE 6 to die first.
|
57
|
-
var xhr, i, progId;
|
58
|
-
if (typeof XMLHttpRequest !== "undefined") {
|
59
|
-
return new XMLHttpRequest();
|
60
|
-
} else if (typeof ActiveXObject !== "undefined") {
|
61
|
-
for (i = 0; i < 3; i += 1) {
|
62
|
-
progId = progIds[i];
|
63
|
-
try {
|
64
|
-
xhr = new ActiveXObject(progId);
|
65
|
-
} catch (e) {}
|
66
|
-
|
67
|
-
if (xhr) {
|
68
|
-
progIds = [progId]; // so faster next time
|
69
|
-
break;
|
70
|
-
}
|
71
|
-
}
|
72
|
-
}
|
73
|
-
|
74
|
-
return xhr;
|
75
|
-
},
|
76
|
-
|
77
|
-
/**
|
78
|
-
* Parses a resource name into its component parts. Resource names
|
79
|
-
* look like: module/name.ext!strip, where the !strip part is
|
80
|
-
* optional.
|
81
|
-
* @param {String} name the resource name
|
82
|
-
* @returns {Object} with properties "moduleName", "ext" and "strip"
|
83
|
-
* where strip is a boolean.
|
84
|
-
*/
|
85
|
-
parseName: function (name) {
|
86
|
-
var modName, ext, temp,
|
87
|
-
strip = false,
|
88
|
-
index = name.indexOf("."),
|
89
|
-
isRelative = name.indexOf('./') === 0 ||
|
90
|
-
name.indexOf('../') === 0;
|
91
|
-
|
92
|
-
if (index !== -1 && (!isRelative || index > 1)) {
|
93
|
-
modName = name.substring(0, index);
|
94
|
-
ext = name.substring(index + 1, name.length);
|
95
|
-
} else {
|
96
|
-
modName = name;
|
97
|
-
}
|
98
|
-
|
99
|
-
temp = ext || modName;
|
100
|
-
index = temp.indexOf("!");
|
101
|
-
if (index !== -1) {
|
102
|
-
//Pull off the strip arg.
|
103
|
-
strip = temp.substring(index + 1) === "strip";
|
104
|
-
temp = temp.substring(0, index);
|
105
|
-
if (ext) {
|
106
|
-
ext = temp;
|
107
|
-
} else {
|
108
|
-
modName = temp;
|
109
|
-
}
|
110
|
-
}
|
111
|
-
|
112
|
-
return {
|
113
|
-
moduleName: modName,
|
114
|
-
ext: ext,
|
115
|
-
strip: strip
|
116
|
-
};
|
117
|
-
},
|
118
|
-
|
119
|
-
xdRegExp: /^((\w+)\:)?\/\/([^\/\\]+)/,
|
120
|
-
|
121
|
-
/**
|
122
|
-
* Is an URL on another domain. Only works for browser use, returns
|
123
|
-
* false in non-browser environments. Only used to know if an
|
124
|
-
* optimized .js version of a text resource should be loaded
|
125
|
-
* instead.
|
126
|
-
* @param {String} url
|
127
|
-
* @returns Boolean
|
128
|
-
*/
|
129
|
-
useXhr: function (url, protocol, hostname, port) {
|
130
|
-
var uProtocol, uHostName, uPort,
|
131
|
-
match = text.xdRegExp.exec(url);
|
132
|
-
if (!match) {
|
133
|
-
return true;
|
134
|
-
}
|
135
|
-
uProtocol = match[2];
|
136
|
-
uHostName = match[3];
|
137
|
-
|
138
|
-
uHostName = uHostName.split(':');
|
139
|
-
uPort = uHostName[1];
|
140
|
-
uHostName = uHostName[0];
|
141
|
-
|
142
|
-
return (!uProtocol || uProtocol === protocol) &&
|
143
|
-
(!uHostName || uHostName.toLowerCase() === hostname.toLowerCase()) &&
|
144
|
-
((!uPort && !uHostName) || uPort === port);
|
145
|
-
},
|
146
|
-
|
147
|
-
finishLoad: function (name, strip, content, onLoad) {
|
148
|
-
content = strip ? text.strip(content) : content;
|
149
|
-
if (masterConfig.isBuild) {
|
150
|
-
buildMap[name] = content;
|
151
|
-
}
|
152
|
-
onLoad(content);
|
153
|
-
},
|
154
|
-
|
155
|
-
load: function (name, req, onLoad, config) {
|
156
|
-
//Name has format: some.module.filext!strip
|
157
|
-
//The strip part is optional.
|
158
|
-
//if strip is present, then that means only get the string contents
|
159
|
-
//inside a body tag in an HTML string. For XML/SVG content it means
|
160
|
-
//removing the <?xml ...?> declarations so the content can be inserted
|
161
|
-
//into the current doc without problems.
|
162
|
-
|
163
|
-
// Do not bother with the work if a build and text will
|
164
|
-
// not be inlined.
|
165
|
-
if (config.isBuild && !config.inlineText) {
|
166
|
-
onLoad();
|
167
|
-
return;
|
168
|
-
}
|
169
|
-
|
170
|
-
masterConfig.isBuild = config.isBuild;
|
171
|
-
|
172
|
-
var parsed = text.parseName(name),
|
173
|
-
nonStripName = parsed.moduleName +
|
174
|
-
(parsed.ext ? '.' + parsed.ext : ''),
|
175
|
-
url = req.toUrl(nonStripName),
|
176
|
-
useXhr = (masterConfig.useXhr) ||
|
177
|
-
text.useXhr;
|
178
|
-
|
179
|
-
//Load the text. Use XHR if possible and in a browser.
|
180
|
-
if (!hasLocation || useXhr(url, defaultProtocol, defaultHostName, defaultPort)) {
|
181
|
-
text.get(url, function (content) {
|
182
|
-
text.finishLoad(name, parsed.strip, content, onLoad);
|
183
|
-
}, function (err) {
|
184
|
-
if (onLoad.error) {
|
185
|
-
onLoad.error(err);
|
186
|
-
}
|
187
|
-
});
|
188
|
-
} else {
|
189
|
-
//Need to fetch the resource across domains. Assume
|
190
|
-
//the resource has been optimized into a JS module. Fetch
|
191
|
-
//by the module name + extension, but do not include the
|
192
|
-
//!strip part to avoid file system issues.
|
193
|
-
req([nonStripName], function (content) {
|
194
|
-
text.finishLoad(parsed.moduleName + '.' + parsed.ext,
|
195
|
-
parsed.strip, content, onLoad);
|
196
|
-
});
|
197
|
-
}
|
198
|
-
},
|
199
|
-
|
200
|
-
write: function (pluginName, moduleName, write, config) {
|
201
|
-
if (buildMap.hasOwnProperty(moduleName)) {
|
202
|
-
var content = text.jsEscape(buildMap[moduleName]);
|
203
|
-
write.asModule(pluginName + "!" + moduleName,
|
204
|
-
"define(function () { return '" +
|
205
|
-
content +
|
206
|
-
"';});\n");
|
207
|
-
}
|
208
|
-
},
|
209
|
-
|
210
|
-
writeFile: function (pluginName, moduleName, req, write, config) {
|
211
|
-
var parsed = text.parseName(moduleName),
|
212
|
-
extPart = parsed.ext ? '.' + parsed.ext : '',
|
213
|
-
nonStripName = parsed.moduleName + extPart,
|
214
|
-
//Use a '.js' file name so that it indicates it is a
|
215
|
-
//script that can be loaded across domains.
|
216
|
-
fileName = req.toUrl(parsed.moduleName + extPart) + '.js';
|
217
|
-
|
218
|
-
//Leverage own load() method to load plugin value, but only
|
219
|
-
//write out values that do not have the strip argument,
|
220
|
-
//to avoid any potential issues with ! in file names.
|
221
|
-
text.load(nonStripName, req, function (value) {
|
222
|
-
//Use own write() method to construct full module value.
|
223
|
-
//But need to create shell that translates writeFile's
|
224
|
-
//write() to the right interface.
|
225
|
-
var textWrite = function (contents) {
|
226
|
-
return write(fileName, contents);
|
227
|
-
};
|
228
|
-
textWrite.asModule = function (moduleName, contents) {
|
229
|
-
return write.asModule(moduleName, fileName, contents);
|
230
|
-
};
|
231
|
-
|
232
|
-
text.write(pluginName, nonStripName, textWrite, config);
|
233
|
-
}, config);
|
234
|
-
}
|
235
|
-
};
|
236
|
-
|
237
|
-
if (masterConfig.env === 'node' || (!masterConfig.env &&
|
238
|
-
typeof process !== "undefined" &&
|
239
|
-
process.versions &&
|
240
|
-
!!process.versions.node)) {
|
241
|
-
//Using special require.nodeRequire, something added by r.js.
|
242
|
-
fs = require.nodeRequire('fs');
|
243
|
-
|
244
|
-
text.get = function (url, callback, errback) {
|
245
|
-
try {
|
246
|
-
var file = fs.readFileSync(url, 'utf8');
|
247
|
-
//Remove BOM (Byte Mark Order) from utf8 files if it is there.
|
248
|
-
if (file.indexOf('\uFEFF') === 0) {
|
249
|
-
file = file.substring(1);
|
250
|
-
}
|
251
|
-
callback(file);
|
252
|
-
} catch (e) {
|
253
|
-
errback(e);
|
254
|
-
}
|
255
|
-
};
|
256
|
-
} else if (masterConfig.env === 'xhr' || (!masterConfig.env &&
|
257
|
-
text.createXhr())) {
|
258
|
-
text.get = function (url, callback, errback, headers) {
|
259
|
-
var xhr = text.createXhr(), header;
|
260
|
-
xhr.open('GET', url, true);
|
261
|
-
|
262
|
-
//Allow plugins direct access to xhr headers
|
263
|
-
if (headers) {
|
264
|
-
for (header in headers) {
|
265
|
-
if (headers.hasOwnProperty(header)) {
|
266
|
-
xhr.setRequestHeader(header.toLowerCase(), headers[header]);
|
267
|
-
}
|
268
|
-
}
|
269
|
-
}
|
270
|
-
|
271
|
-
//Allow overrides specified in config
|
272
|
-
if (masterConfig.onXhr) {
|
273
|
-
masterConfig.onXhr(xhr, url);
|
274
|
-
}
|
275
|
-
|
276
|
-
xhr.onreadystatechange = function (evt) {
|
277
|
-
var status, err;
|
278
|
-
//Do not explicitly handle errors, those should be
|
279
|
-
//visible via console output in the browser.
|
280
|
-
if (xhr.readyState === 4) {
|
281
|
-
status = xhr.status;
|
282
|
-
if (status > 399 && status < 600) {
|
283
|
-
//An http 4xx or 5xx error. Signal an error.
|
284
|
-
err = new Error(url + ' HTTP status: ' + status);
|
285
|
-
err.xhr = xhr;
|
286
|
-
errback(err);
|
287
|
-
} else {
|
288
|
-
callback(xhr.responseText);
|
289
|
-
}
|
290
|
-
|
291
|
-
if (masterConfig.onXhrComplete) {
|
292
|
-
masterConfig.onXhrComplete(xhr, url);
|
293
|
-
}
|
294
|
-
}
|
295
|
-
};
|
296
|
-
xhr.send(null);
|
297
|
-
};
|
298
|
-
} else if (masterConfig.env === 'rhino' || (!masterConfig.env &&
|
299
|
-
typeof Packages !== 'undefined' && typeof java !== 'undefined')) {
|
300
|
-
//Why Java, why is this so awkward?
|
301
|
-
text.get = function (url, callback) {
|
302
|
-
var stringBuffer, line,
|
303
|
-
encoding = "utf-8",
|
304
|
-
file = new java.io.File(url),
|
305
|
-
lineSeparator = java.lang.System.getProperty("line.separator"),
|
306
|
-
input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(file), encoding)),
|
307
|
-
content = '';
|
308
|
-
try {
|
309
|
-
stringBuffer = new java.lang.StringBuffer();
|
310
|
-
line = input.readLine();
|
311
|
-
|
312
|
-
// Byte Order Mark (BOM) - The Unicode Standard, version 3.0, page 324
|
313
|
-
// http://www.unicode.org/faq/utf_bom.html
|
314
|
-
|
315
|
-
// Note that when we use utf-8, the BOM should appear as "EF BB BF", but it doesn't due to this bug in the JDK:
|
316
|
-
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4508058
|
317
|
-
if (line && line.length() && line.charAt(0) === 0xfeff) {
|
318
|
-
// Eat the BOM, since we've already found the encoding on this file,
|
319
|
-
// and we plan to concatenating this buffer with others; the BOM should
|
320
|
-
// only appear at the top of a file.
|
321
|
-
line = line.substring(1);
|
322
|
-
}
|
323
|
-
|
324
|
-
if (line !== null) {
|
325
|
-
stringBuffer.append(line);
|
326
|
-
}
|
327
|
-
|
328
|
-
while ((line = input.readLine()) !== null) {
|
329
|
-
stringBuffer.append(lineSeparator);
|
330
|
-
stringBuffer.append(line);
|
331
|
-
}
|
332
|
-
//Make sure we return a JavaScript string and not a Java string.
|
333
|
-
content = String(stringBuffer.toString()); //String
|
334
|
-
} finally {
|
335
|
-
input.close();
|
336
|
-
}
|
337
|
-
callback(content);
|
338
|
-
};
|
339
|
-
} else if (masterConfig.env === 'xpconnect' || (!masterConfig.env &&
|
340
|
-
typeof Components !== 'undefined' && Components.classes &&
|
341
|
-
Components.interfaces)) {
|
342
|
-
//Avert your gaze!
|
343
|
-
Cc = Components.classes,
|
344
|
-
Ci = Components.interfaces;
|
345
|
-
Components.utils['import']('resource://gre/modules/FileUtils.jsm');
|
346
|
-
|
347
|
-
text.get = function (url, callback) {
|
348
|
-
var inStream, convertStream,
|
349
|
-
readData = {},
|
350
|
-
fileObj = new FileUtils.File(url);
|
351
|
-
|
352
|
-
//XPCOM, you so crazy
|
353
|
-
try {
|
354
|
-
inStream = Cc['@mozilla.org/network/file-input-stream;1']
|
355
|
-
.createInstance(Ci.nsIFileInputStream);
|
356
|
-
inStream.init(fileObj, 1, 0, false);
|
357
|
-
|
358
|
-
convertStream = Cc['@mozilla.org/intl/converter-input-stream;1']
|
359
|
-
.createInstance(Ci.nsIConverterInputStream);
|
360
|
-
convertStream.init(inStream, "utf-8", inStream.available(),
|
361
|
-
Ci.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER);
|
362
|
-
|
363
|
-
convertStream.readString(inStream.available(), readData);
|
364
|
-
convertStream.close();
|
365
|
-
inStream.close();
|
366
|
-
callback(readData.value);
|
367
|
-
} catch (e) {
|
368
|
-
throw new Error((fileObj && fileObj.path || '') + ': ' + e);
|
369
|
-
}
|
370
|
-
};
|
371
|
-
}
|
372
|
-
return text;
|
373
|
-
});
|
@@ -1,80 +0,0 @@
|
|
1
|
-
define( function(require) {
|
2
|
-
|
3
|
-
//////////////////////////////////////////
|
4
|
-
// debug utils
|
5
|
-
|
6
|
-
function puts( msg ) {
|
7
|
-
if( window.console && window.console.log )
|
8
|
-
window.console.log( msg );
|
9
|
-
}
|
10
|
-
|
11
|
-
function pp( obj ) {
|
12
|
-
if( window.console && window.console.dir )
|
13
|
-
window.console.dir( obj );
|
14
|
-
}
|
15
|
-
|
16
|
-
function debug( msg ) {
|
17
|
-
puts( '[debug] '+msg );
|
18
|
-
}
|
19
|
-
|
20
|
-
|
21
|
-
////////////////////////////
|
22
|
-
// date utils
|
23
|
-
|
24
|
-
function cmp_date( date1, date2 ) {
|
25
|
-
if( date1.getDate() === date2.getDate() &&
|
26
|
-
date1.getMonth() === date2.getMonth() &&
|
27
|
-
date1.getFullYear() === date2.getFullYear() )
|
28
|
-
return 0;
|
29
|
-
else
|
30
|
-
return 1; // todo: return -1 or 1 if greater or smaller
|
31
|
-
}
|
32
|
-
|
33
|
-
|
34
|
-
var month_names = [
|
35
|
-
'January',
|
36
|
-
'February',
|
37
|
-
'March',
|
38
|
-
'April',
|
39
|
-
'May',
|
40
|
-
'June',
|
41
|
-
'July',
|
42
|
-
'August',
|
43
|
-
'September',
|
44
|
-
'October',
|
45
|
-
'November',
|
46
|
-
'December' ];
|
47
|
-
|
48
|
-
var day_names = [
|
49
|
-
'Sunday',
|
50
|
-
'Monday',
|
51
|
-
'Tuesday',
|
52
|
-
'Wednesday',
|
53
|
-
'Thursday',
|
54
|
-
'Friday',
|
55
|
-
'Saturday' ];
|
56
|
-
|
57
|
-
function fmt_date( date ) {
|
58
|
-
|
59
|
-
return day_names[ date.getDay()] +
|
60
|
-
", " +
|
61
|
-
month_names[ date.getMonth()] +
|
62
|
-
" " +
|
63
|
-
date.getDate() +
|
64
|
-
" " +
|
65
|
-
date.getFullYear();
|
66
|
-
}
|
67
|
-
|
68
|
-
//////////////////////////////////////////
|
69
|
-
// exports (global functions)
|
70
|
-
|
71
|
-
debug( 'export utils globals (that is, attach functions to global obj)' );
|
72
|
-
|
73
|
-
// NB: assumes this is global object e.g. window
|
74
|
-
this.puts = puts;
|
75
|
-
this.pp = pp;
|
76
|
-
this.debug = debug;
|
77
|
-
this.cmp_date = cmp_date;
|
78
|
-
this.fmt_date = fmt_date;
|
79
|
-
|
80
|
-
}); // end define
|