commit 24f07b6e56a3e4b4b365e976f8d56ddbba7310d5 Author: Benjamin Renard Date: Mon Jan 6 01:46:22 2014 +0100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b72f9be --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*~ +*.swp diff --git a/favicon.png b/favicon.png new file mode 100644 index 0000000..8dabe4d Binary files /dev/null and b/favicon.png differ diff --git a/inc/lib/moment.min.js b/inc/lib/moment.min.js new file mode 100644 index 0000000..f253488 --- /dev/null +++ b/inc/lib/moment.min.js @@ -0,0 +1,6 @@ +//! moment.js +//! version : 2.5.0 +//! authors : Tim Wood, Iskren Chernev, Moment.js contributors +//! license : MIT +//! momentjs.com +(function(a){function b(a,b){return function(c){return i(a.call(this,c),b)}}function c(a,b){return function(c){return this.lang().ordinal(a.call(this,c),b)}}function d(){}function e(a){u(a),g(this,a)}function f(a){var b=o(a),c=b.year||0,d=b.month||0,e=b.week||0,f=b.day||0,g=b.hour||0,h=b.minute||0,i=b.second||0,j=b.millisecond||0;this._milliseconds=+j+1e3*i+6e4*h+36e5*g,this._days=+f+7*e,this._months=+d+12*c,this._data={},this._bubble()}function g(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return b.hasOwnProperty("toString")&&(a.toString=b.toString),b.hasOwnProperty("valueOf")&&(a.valueOf=b.valueOf),a}function h(a){return 0>a?Math.ceil(a):Math.floor(a)}function i(a,b,c){for(var d=Math.abs(a)+"",e=a>=0;d.lengthd;d++)(c&&a[d]!==b[d]||!c&&q(a[d])!==q(b[d]))&&g++;return g+f}function n(a){if(a){var b=a.toLowerCase().replace(/(.)s$/,"$1");a=Qb[a]||Rb[b]||b}return a}function o(a){var b,c,d={};for(c in a)a.hasOwnProperty(c)&&(b=n(c),b&&(d[b]=a[c]));return d}function p(b){var c,d;if(0===b.indexOf("week"))c=7,d="day";else{if(0!==b.indexOf("month"))return;c=12,d="month"}cb[b]=function(e,f){var g,h,i=cb.fn._lang[b],j=[];if("number"==typeof e&&(f=e,e=a),h=function(a){var b=cb().utc().set(d,a);return i.call(cb.fn._lang,b,e||"")},null!=f)return h(f);for(g=0;c>g;g++)j.push(h(g));return j}}function q(a){var b=+a,c=0;return 0!==b&&isFinite(b)&&(c=b>=0?Math.floor(b):Math.ceil(b)),c}function r(a,b){return new Date(Date.UTC(a,b+1,0)).getUTCDate()}function s(a){return t(a)?366:365}function t(a){return a%4===0&&a%100!==0||a%400===0}function u(a){var b;a._a&&-2===a._pf.overflow&&(b=a._a[ib]<0||a._a[ib]>11?ib:a._a[jb]<1||a._a[jb]>r(a._a[hb],a._a[ib])?jb:a._a[kb]<0||a._a[kb]>23?kb:a._a[lb]<0||a._a[lb]>59?lb:a._a[mb]<0||a._a[mb]>59?mb:a._a[nb]<0||a._a[nb]>999?nb:-1,a._pf._overflowDayOfYear&&(hb>b||b>jb)&&(b=jb),a._pf.overflow=b)}function v(a){a._pf={empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1}}function w(a){return null==a._isValid&&(a._isValid=!isNaN(a._d.getTime())&&a._pf.overflow<0&&!a._pf.empty&&!a._pf.invalidMonth&&!a._pf.nullInput&&!a._pf.invalidFormat&&!a._pf.userInvalidated,a._strict&&(a._isValid=a._isValid&&0===a._pf.charsLeftOver&&0===a._pf.unusedTokens.length)),a._isValid}function x(a){return a?a.toLowerCase().replace("_","-"):a}function y(a,b){return b._isUTC?cb(a).zone(b._offset||0):cb(a).local()}function z(a,b){return b.abbr=a,ob[a]||(ob[a]=new d),ob[a].set(b),ob[a]}function A(a){delete ob[a]}function B(a){var b,c,d,e,f=0,g=function(a){if(!ob[a]&&pb)try{require("./lang/"+a)}catch(b){}return ob[a]};if(!a)return cb.fn._lang;if(!k(a)){if(c=g(a))return c;a=[a]}for(;f0;){if(c=g(e.slice(0,b).join("-")))return c;if(d&&d.length>=b&&m(e,d,!0)>=b-1)break;b--}f++}return cb.fn._lang}function C(a){return a.match(/\[[\s\S]/)?a.replace(/^\[|\]$/g,""):a.replace(/\\/g,"")}function D(a){var b,c,d=a.match(tb);for(b=0,c=d.length;c>b;b++)d[b]=Vb[d[b]]?Vb[d[b]]:C(d[b]);return function(e){var f="";for(b=0;c>b;b++)f+=d[b]instanceof Function?d[b].call(e,a):d[b];return f}}function E(a,b){return a.isValid()?(b=F(b,a.lang()),Sb[b]||(Sb[b]=D(b)),Sb[b](a)):a.lang().invalidDate()}function F(a,b){function c(a){return b.longDateFormat(a)||a}var d=5;for(ub.lastIndex=0;d>=0&&ub.test(a);)a=a.replace(ub,c),ub.lastIndex=0,d-=1;return a}function G(a,b){var c,d=b._strict;switch(a){case"DDDD":return Gb;case"YYYY":case"GGGG":case"gggg":return d?Hb:xb;case"YYYYYY":case"YYYYY":case"GGGGG":case"ggggg":return d?Ib:yb;case"S":if(d)return Eb;case"SS":if(d)return Fb;case"SSS":case"DDD":return d?Gb:wb;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":return Ab;case"a":case"A":return B(b._l)._meridiemParse;case"X":return Db;case"Z":case"ZZ":return Bb;case"T":return Cb;case"SSSS":return zb;case"MM":case"DD":case"YY":case"GG":case"gg":case"HH":case"hh":case"mm":case"ss":case"ww":case"WW":return d?Fb:vb;case"M":case"D":case"d":case"H":case"h":case"m":case"s":case"w":case"W":case"e":case"E":return d?Eb:vb;default:return c=new RegExp(O(N(a.replace("\\","")),"i"))}}function H(a){a=a||"";var b=a.match(Bb)||[],c=b[b.length-1]||[],d=(c+"").match(Nb)||["-",0,0],e=+(60*d[1])+q(d[2]);return"+"===d[0]?-e:e}function I(a,b,c){var d,e=c._a;switch(a){case"M":case"MM":null!=b&&(e[ib]=q(b)-1);break;case"MMM":case"MMMM":d=B(c._l).monthsParse(b),null!=d?e[ib]=d:c._pf.invalidMonth=b;break;case"D":case"DD":null!=b&&(e[jb]=q(b));break;case"DDD":case"DDDD":null!=b&&(c._dayOfYear=q(b));break;case"YY":e[hb]=q(b)+(q(b)>68?1900:2e3);break;case"YYYY":case"YYYYY":case"YYYYYY":e[hb]=q(b);break;case"a":case"A":c._isPm=B(c._l).isPM(b);break;case"H":case"HH":case"h":case"hh":e[kb]=q(b);break;case"m":case"mm":e[lb]=q(b);break;case"s":case"ss":e[mb]=q(b);break;case"S":case"SS":case"SSS":case"SSSS":e[nb]=q(1e3*("0."+b));break;case"X":c._d=new Date(1e3*parseFloat(b));break;case"Z":case"ZZ":c._useUTC=!0,c._tzm=H(b);break;case"w":case"ww":case"W":case"WW":case"d":case"dd":case"ddd":case"dddd":case"e":case"E":a=a.substr(0,1);case"gg":case"gggg":case"GG":case"GGGG":case"GGGGG":a=a.substr(0,2),b&&(c._w=c._w||{},c._w[a]=b)}}function J(a){var b,c,d,e,f,g,h,i,j,k,l=[];if(!a._d){for(d=L(a),a._w&&null==a._a[jb]&&null==a._a[ib]&&(f=function(b){var c=parseInt(b,10);return b?b.length<3?c>68?1900+c:2e3+c:c:null==a._a[hb]?cb().weekYear():a._a[hb]},g=a._w,null!=g.GG||null!=g.W||null!=g.E?h=Y(f(g.GG),g.W||1,g.E,4,1):(i=B(a._l),j=null!=g.d?U(g.d,i):null!=g.e?parseInt(g.e,10)+i._week.dow:0,k=parseInt(g.w,10)||1,null!=g.d&&js(e)&&(a._pf._overflowDayOfYear=!0),c=T(e,0,a._dayOfYear),a._a[ib]=c.getUTCMonth(),a._a[jb]=c.getUTCDate()),b=0;3>b&&null==a._a[b];++b)a._a[b]=l[b]=d[b];for(;7>b;b++)a._a[b]=l[b]=null==a._a[b]?2===b?1:0:a._a[b];l[kb]+=q((a._tzm||0)/60),l[lb]+=q((a._tzm||0)%60),a._d=(a._useUTC?T:S).apply(null,l)}}function K(a){var b;a._d||(b=o(a._i),a._a=[b.year,b.month,b.day,b.hour,b.minute,b.second,b.millisecond],J(a))}function L(a){var b=new Date;return a._useUTC?[b.getUTCFullYear(),b.getUTCMonth(),b.getUTCDate()]:[b.getFullYear(),b.getMonth(),b.getDate()]}function M(a){a._a=[],a._pf.empty=!0;var b,c,d,e,f,g=B(a._l),h=""+a._i,i=h.length,j=0;for(d=F(a._f,g).match(tb)||[],b=0;b0&&a._pf.unusedInput.push(f),h=h.slice(h.indexOf(c)+c.length),j+=c.length),Vb[e]?(c?a._pf.empty=!1:a._pf.unusedTokens.push(e),I(e,c,a)):a._strict&&!c&&a._pf.unusedTokens.push(e);a._pf.charsLeftOver=i-j,h.length>0&&a._pf.unusedInput.push(h),a._isPm&&a._a[kb]<12&&(a._a[kb]+=12),a._isPm===!1&&12===a._a[kb]&&(a._a[kb]=0),J(a),u(a)}function N(a){return a.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(a,b,c,d,e){return b||c||d||e})}function O(a){return a.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function P(a){var b,c,d,e,f;if(0===a._f.length)return a._pf.invalidFormat=!0,a._d=new Date(0/0),void 0;for(e=0;ef)&&(d=f,c=b));g(a,c||b)}function Q(a){var b,c=a._i,d=Jb.exec(c);if(d){for(a._pf.iso=!0,b=4;b>0;b--)if(d[b]){a._f=Lb[b-1]+(d[6]||" ");break}for(b=0;4>b;b++)if(Mb[b][1].exec(c)){a._f+=Mb[b][0];break}c.match(Bb)&&(a._f+="Z"),M(a)}else a._d=new Date(c)}function R(b){var c=b._i,d=qb.exec(c);c===a?b._d=new Date:d?b._d=new Date(+d[1]):"string"==typeof c?Q(b):k(c)?(b._a=c.slice(0),J(b)):l(c)?b._d=new Date(+c):"object"==typeof c?K(b):b._d=new Date(c)}function S(a,b,c,d,e,f,g){var h=new Date(a,b,c,d,e,f,g);return 1970>a&&h.setFullYear(a),h}function T(a){var b=new Date(Date.UTC.apply(null,arguments));return 1970>a&&b.setUTCFullYear(a),b}function U(a,b){if("string"==typeof a)if(isNaN(a)){if(a=b.weekdaysParse(a),"number"!=typeof a)return null}else a=parseInt(a,10);return a}function V(a,b,c,d,e){return e.relativeTime(b||1,!!c,a,d)}function W(a,b,c){var d=gb(Math.abs(a)/1e3),e=gb(d/60),f=gb(e/60),g=gb(f/24),h=gb(g/365),i=45>d&&["s",d]||1===e&&["m"]||45>e&&["mm",e]||1===f&&["h"]||22>f&&["hh",f]||1===g&&["d"]||25>=g&&["dd",g]||45>=g&&["M"]||345>g&&["MM",gb(g/30)]||1===h&&["y"]||["yy",h];return i[2]=b,i[3]=a>0,i[4]=c,V.apply({},i)}function X(a,b,c){var d,e=c-b,f=c-a.day();return f>e&&(f-=7),e-7>f&&(f+=7),d=cb(a).add("d",f),{week:Math.ceil(d.dayOfYear()/7),year:d.year()}}function Y(a,b,c,d,e){var f,g,h=new Date(i(a,6,!0)+"-01-01").getUTCDay();return c=null!=c?c:e,f=e-h+(h>d?7:0),g=7*(b-1)+(c-e)+f+1,{year:g>0?a:a-1,dayOfYear:g>0?g:s(a-1)+g}}function Z(a){var b=a._i,c=a._f;return"undefined"==typeof a._pf&&v(a),null===b?cb.invalid({nullInput:!0}):("string"==typeof b&&(a._i=b=B().preparse(b)),cb.isMoment(b)?(a=g({},b),a._d=new Date(+b._d)):c?k(c)?P(a):M(a):R(a),new e(a))}function $(a,b){cb.fn[a]=cb.fn[a+"s"]=function(a){var c=this._isUTC?"UTC":"";return null!=a?(this._d["set"+c+b](a),cb.updateOffset(this),this):this._d["get"+c+b]()}}function _(a){cb.duration.fn[a]=function(){return this._data[a]}}function ab(a,b){cb.duration.fn["as"+a]=function(){return+this/b}}function bb(a){var b=!1,c=cb;"undefined"==typeof ender&&(a?(fb.moment=function(){return!b&&console&&console.warn&&(b=!0,console.warn("Accessing Moment through the global scope is deprecated, and will be removed in an upcoming release.")),c.apply(null,arguments)},g(fb.moment,c)):fb.moment=cb)}for(var cb,db,eb="2.5.0",fb=this,gb=Math.round,hb=0,ib=1,jb=2,kb=3,lb=4,mb=5,nb=6,ob={},pb="undefined"!=typeof module&&module.exports&&"undefined"!=typeof require,qb=/^\/?Date\((\-?\d+)/i,rb=/(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/,sb=/^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/,tb=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|X|zz?|ZZ?|.)/g,ub=/(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g,vb=/\d\d?/,wb=/\d{1,3}/,xb=/\d{1,4}/,yb=/[+\-]?\d{1,6}/,zb=/\d+/,Ab=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,Bb=/Z|[\+\-]\d\d:?\d\d/gi,Cb=/T/i,Db=/[\+\-]?\d+(\.\d{1,3})?/,Eb=/\d/,Fb=/\d\d/,Gb=/\d{3}/,Hb=/\d{4}/,Ib=/[+\-]?\d{6}/,Jb=/^\s*\d{4}-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Kb="YYYY-MM-DDTHH:mm:ssZ",Lb=["YYYY-MM-DD","GGGG-[W]WW","GGGG-[W]WW-E","YYYY-DDD"],Mb=[["HH:mm:ss.SSSS",/(T| )\d\d:\d\d:\d\d\.\d{1,3}/],["HH:mm:ss",/(T| )\d\d:\d\d:\d\d/],["HH:mm",/(T| )\d\d:\d\d/],["HH",/(T| )\d\d/]],Nb=/([\+\-]|\d\d)/gi,Ob="Date|Hours|Minutes|Seconds|Milliseconds".split("|"),Pb={Milliseconds:1,Seconds:1e3,Minutes:6e4,Hours:36e5,Days:864e5,Months:2592e6,Years:31536e6},Qb={ms:"millisecond",s:"second",m:"minute",h:"hour",d:"day",D:"date",w:"week",W:"isoWeek",M:"month",y:"year",DDD:"dayOfYear",e:"weekday",E:"isoWeekday",gg:"weekYear",GG:"isoWeekYear"},Rb={dayofyear:"dayOfYear",isoweekday:"isoWeekday",isoweek:"isoWeek",weekyear:"weekYear",isoweekyear:"isoWeekYear"},Sb={},Tb="DDD w W M D d".split(" "),Ub="M D H h m s w W".split(" "),Vb={M:function(){return this.month()+1},MMM:function(a){return this.lang().monthsShort(this,a)},MMMM:function(a){return this.lang().months(this,a)},D:function(){return this.date()},DDD:function(){return this.dayOfYear()},d:function(){return this.day()},dd:function(a){return this.lang().weekdaysMin(this,a)},ddd:function(a){return this.lang().weekdaysShort(this,a)},dddd:function(a){return this.lang().weekdays(this,a)},w:function(){return this.week()},W:function(){return this.isoWeek()},YY:function(){return i(this.year()%100,2)},YYYY:function(){return i(this.year(),4)},YYYYY:function(){return i(this.year(),5)},YYYYYY:function(){var a=this.year(),b=a>=0?"+":"-";return b+i(Math.abs(a),6)},gg:function(){return i(this.weekYear()%100,2)},gggg:function(){return this.weekYear()},ggggg:function(){return i(this.weekYear(),5)},GG:function(){return i(this.isoWeekYear()%100,2)},GGGG:function(){return this.isoWeekYear()},GGGGG:function(){return i(this.isoWeekYear(),5)},e:function(){return this.weekday()},E:function(){return this.isoWeekday()},a:function(){return this.lang().meridiem(this.hours(),this.minutes(),!0)},A:function(){return this.lang().meridiem(this.hours(),this.minutes(),!1)},H:function(){return this.hours()},h:function(){return this.hours()%12||12},m:function(){return this.minutes()},s:function(){return this.seconds()},S:function(){return q(this.milliseconds()/100)},SS:function(){return i(q(this.milliseconds()/10),2)},SSS:function(){return i(this.milliseconds(),3)},SSSS:function(){return i(this.milliseconds(),3)},Z:function(){var a=-this.zone(),b="+";return 0>a&&(a=-a,b="-"),b+i(q(a/60),2)+":"+i(q(a)%60,2)},ZZ:function(){var a=-this.zone(),b="+";return 0>a&&(a=-a,b="-"),b+i(q(a/60),2)+i(q(a)%60,2)},z:function(){return this.zoneAbbr()},zz:function(){return this.zoneName()},X:function(){return this.unix()},Q:function(){return this.quarter()}},Wb=["months","monthsShort","weekdays","weekdaysShort","weekdaysMin"];Tb.length;)db=Tb.pop(),Vb[db+"o"]=c(Vb[db],db);for(;Ub.length;)db=Ub.pop(),Vb[db+db]=b(Vb[db],2);for(Vb.DDDD=b(Vb.DDD,3),g(d.prototype,{set:function(a){var b,c;for(c in a)b=a[c],"function"==typeof b?this[c]=b:this["_"+c]=b},_months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),months:function(a){return this._months[a.month()]},_monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),monthsShort:function(a){return this._monthsShort[a.month()]},monthsParse:function(a){var b,c,d;for(this._monthsParse||(this._monthsParse=[]),b=0;12>b;b++)if(this._monthsParse[b]||(c=cb.utc([2e3,b]),d="^"+this.months(c,"")+"|^"+this.monthsShort(c,""),this._monthsParse[b]=new RegExp(d.replace(".",""),"i")),this._monthsParse[b].test(a))return b},_weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdays:function(a){return this._weekdays[a.day()]},_weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysShort:function(a){return this._weekdaysShort[a.day()]},_weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),weekdaysMin:function(a){return this._weekdaysMin[a.day()]},weekdaysParse:function(a){var b,c,d;for(this._weekdaysParse||(this._weekdaysParse=[]),b=0;7>b;b++)if(this._weekdaysParse[b]||(c=cb([2e3,1]).day(b),d="^"+this.weekdays(c,"")+"|^"+this.weekdaysShort(c,"")+"|^"+this.weekdaysMin(c,""),this._weekdaysParse[b]=new RegExp(d.replace(".",""),"i")),this._weekdaysParse[b].test(a))return b},_longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D YYYY",LLL:"MMMM D YYYY LT",LLLL:"dddd, MMMM D YYYY LT"},longDateFormat:function(a){var b=this._longDateFormat[a];return!b&&this._longDateFormat[a.toUpperCase()]&&(b=this._longDateFormat[a.toUpperCase()].replace(/MMMM|MM|DD|dddd/g,function(a){return a.slice(1)}),this._longDateFormat[a]=b),b},isPM:function(a){return"p"===(a+"").toLowerCase().charAt(0)},_meridiemParse:/[ap]\.?m?\.?/i,meridiem:function(a,b,c){return a>11?c?"pm":"PM":c?"am":"AM"},_calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},calendar:function(a,b){var c=this._calendar[a];return"function"==typeof c?c.apply(b):c},_relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},relativeTime:function(a,b,c,d){var e=this._relativeTime[c];return"function"==typeof e?e(a,b,c,d):e.replace(/%d/i,a)},pastFuture:function(a,b){var c=this._relativeTime[a>0?"future":"past"];return"function"==typeof c?c(b):c.replace(/%s/i,b)},ordinal:function(a){return this._ordinal.replace("%d",a)},_ordinal:"%d",preparse:function(a){return a},postformat:function(a){return a},week:function(a){return X(a,this._week.dow,this._week.doy).week},_week:{dow:0,doy:6},_invalidDate:"Invalid date",invalidDate:function(){return this._invalidDate}}),cb=function(b,c,d,e){return"boolean"==typeof d&&(e=d,d=a),Z({_i:b,_f:c,_l:d,_strict:e,_isUTC:!1})},cb.utc=function(b,c,d,e){var f;return"boolean"==typeof d&&(e=d,d=a),f=Z({_useUTC:!0,_isUTC:!0,_l:d,_i:b,_f:c,_strict:e}).utc()},cb.unix=function(a){return cb(1e3*a)},cb.duration=function(a,b){var c,d,e,g=a,h=null;return cb.isDuration(a)?g={ms:a._milliseconds,d:a._days,M:a._months}:"number"==typeof a?(g={},b?g[b]=a:g.milliseconds=a):(h=rb.exec(a))?(c="-"===h[1]?-1:1,g={y:0,d:q(h[jb])*c,h:q(h[kb])*c,m:q(h[lb])*c,s:q(h[mb])*c,ms:q(h[nb])*c}):(h=sb.exec(a))&&(c="-"===h[1]?-1:1,e=function(a){var b=a&&parseFloat(a.replace(",","."));return(isNaN(b)?0:b)*c},g={y:e(h[2]),M:e(h[3]),d:e(h[4]),h:e(h[5]),m:e(h[6]),s:e(h[7]),w:e(h[8])}),d=new f(g),cb.isDuration(a)&&a.hasOwnProperty("_lang")&&(d._lang=a._lang),d},cb.version=eb,cb.defaultFormat=Kb,cb.updateOffset=function(){},cb.lang=function(a,b){var c;return a?(b?z(x(a),b):null===b?(A(a),a="en"):ob[a]||B(a),c=cb.duration.fn._lang=cb.fn._lang=B(a),c._abbr):cb.fn._lang._abbr},cb.langData=function(a){return a&&a._lang&&a._lang._abbr&&(a=a._lang._abbr),B(a)},cb.isMoment=function(a){return a instanceof e},cb.isDuration=function(a){return a instanceof f},db=Wb.length-1;db>=0;--db)p(Wb[db]);for(cb.normalizeUnits=function(a){return n(a)},cb.invalid=function(a){var b=cb.utc(0/0);return null!=a?g(b._pf,a):b._pf.userInvalidated=!0,b},cb.parseZone=function(a){return cb(a).parseZone()},g(cb.fn=e.prototype,{clone:function(){return cb(this)},valueOf:function(){return+this._d+6e4*(this._offset||0)},unix:function(){return Math.floor(+this/1e3)},toString:function(){return this.clone().lang("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},toDate:function(){return this._offset?new Date(+this):this._d},toISOString:function(){var a=cb(this).utc();return 00:!1},parsingFlags:function(){return g({},this._pf)},invalidAt:function(){return this._pf.overflow},utc:function(){return this.zone(0)},local:function(){return this.zone(0),this._isUTC=!1,this},format:function(a){var b=E(this,a||cb.defaultFormat);return this.lang().postformat(b)},add:function(a,b){var c;return c="string"==typeof a?cb.duration(+b,a):cb.duration(a,b),j(this,c,1),this},subtract:function(a,b){var c;return c="string"==typeof a?cb.duration(+b,a):cb.duration(a,b),j(this,c,-1),this},diff:function(a,b,c){var d,e,f=y(a,this),g=6e4*(this.zone()-f.zone());return b=n(b),"year"===b||"month"===b?(d=432e5*(this.daysInMonth()+f.daysInMonth()),e=12*(this.year()-f.year())+(this.month()-f.month()),e+=(this-cb(this).startOf("month")-(f-cb(f).startOf("month")))/d,e-=6e4*(this.zone()-cb(this).startOf("month").zone()-(f.zone()-cb(f).startOf("month").zone()))/d,"year"===b&&(e/=12)):(d=this-f,e="second"===b?d/1e3:"minute"===b?d/6e4:"hour"===b?d/36e5:"day"===b?(d-g)/864e5:"week"===b?(d-g)/6048e5:d),c?e:h(e)},from:function(a,b){return cb.duration(this.diff(a)).lang(this.lang()._abbr).humanize(!b)},fromNow:function(a){return this.from(cb(),a)},calendar:function(){var a=y(cb(),this).startOf("day"),b=this.diff(a,"days",!0),c=-6>b?"sameElse":-1>b?"lastWeek":0>b?"lastDay":1>b?"sameDay":2>b?"nextDay":7>b?"nextWeek":"sameElse";return this.format(this.lang().calendar(c,this))},isLeapYear:function(){return t(this.year())},isDST:function(){return this.zone()+cb(a).startOf(b)},isBefore:function(a,b){return b="undefined"!=typeof b?b:"millisecond",+this.clone().startOf(b)<+cb(a).startOf(b)},isSame:function(a,b){return b=b||"ms",+this.clone().startOf(b)===+y(a,this).startOf(b)},min:function(a){return a=cb.apply(null,arguments),this>a?this:a},max:function(a){return a=cb.apply(null,arguments),a>this?this:a},zone:function(a){var b=this._offset||0;return null==a?this._isUTC?b:this._d.getTimezoneOffset():("string"==typeof a&&(a=H(a)),Math.abs(a)<16&&(a=60*a),this._offset=a,this._isUTC=!0,b!==a&&j(this,cb.duration(b-a,"m"),1,!0),this)},zoneAbbr:function(){return this._isUTC?"UTC":""},zoneName:function(){return this._isUTC?"Coordinated Universal Time":""},parseZone:function(){return this._tzm?this.zone(this._tzm):"string"==typeof this._i&&this.zone(this._i),this},hasAlignedHourOffset:function(a){return a=a?cb(a).zone():0,(this.zone()-a)%60===0},daysInMonth:function(){return r(this.year(),this.month())},dayOfYear:function(a){var b=gb((cb(this).startOf("day")-cb(this).startOf("year"))/864e5)+1;return null==a?b:this.add("d",a-b)},quarter:function(){return Math.ceil((this.month()+1)/3)},weekYear:function(a){var b=X(this,this.lang()._week.dow,this.lang()._week.doy).year;return null==a?b:this.add("y",a-b)},isoWeekYear:function(a){var b=X(this,1,4).year;return null==a?b:this.add("y",a-b)},week:function(a){var b=this.lang().week(this);return null==a?b:this.add("d",7*(a-b))},isoWeek:function(a){var b=X(this,1,4).week;return null==a?b:this.add("d",7*(a-b))},weekday:function(a){var b=(this.day()+7-this.lang()._week.dow)%7;return null==a?b:this.add("d",a-b)},isoWeekday:function(a){return null==a?this.day()||7:this.day(this.day()%7?a:a-7)},get:function(a){return a=n(a),this[a]()},set:function(a,b){return a=n(a),"function"==typeof this[a]&&this[a](b),this},lang:function(b){return b===a?this._lang:(this._lang=B(b),this)}}),db=0;dbAucune groupe'); + + } + else { + groups.each(function(idx,group) { + $(grouplist).prepend('
  • '+group.name+'
  • '); + }); + + $('a.group-choice').each(function(idx,a) { + $(a).bind('click',on_group_choice_click); + }); + } +} + + +/**************** + * Add group + ****************/ +on_show_add_group_modal=function(e) { + $('#add_group_modal #add_group_name').focus(); +} + +on_valid_add_group_modal=function () { + var name=$('#add_group_name')[0].value; + if (name=='') { + alert('Vous devez saisir un nom !'); + return; + } + if (groups[name]!==undefined) { + alert('Ce groupe exite déjà !'); + return; + } + groups[name]=new Group(name); + refresh_group_list(); + $('#add_group_modal').modal('hide'); + groups.save(); + view_group(groups[name]); +} + +on_close_add_group_modal=function () { + $('#add_group_name form')[0].reset(); +} + +/**************** + * Nav bars + ****************/ +on_group_choice_click=function(e) { + view_group(groups[$(e.target).html()]); +} + +/**************** + * View group + ****************/ +view_group=function(group) { + $('#view-group h1').html(group.name); + set_contributors(group); + on_contributor_change(); + $('#view-group').css('display','block'); +} + +set_contributors=function(group) { + $('#view-group #contributor option').remove(); + if(group.contributors.length==0) { + $('#view-group #contributor').append(''); + } + else { + $(group.contributors).each(function(idx,c) { + $('#view-group #contributor').append(''); + }); + } +} + +on_contributor_change=function(e) { + show_contributions(groups[$('#view-group h1').html()],$('#view-group #contributor')[0].value); +} + +show_contributions=function(group,contributor_name) { + var tbody=$($('#view-group #contributions tbody')[0]); + tbody.html(''); + total=$($('#view-group #total-value')[0]); + contributions=group.contributionsByContributorName(contributor_name); + if (contributions.length==0) { + tbody.append('Aucune contributions'); + total.html('0,00 €'); + } + else { + sum=0; + for (idx in contributions) { + col_actions='
    '; + tbody.append(''+contributions[idx].getTitle()+''+contributions[idx].cost+' €'+col_actions+''); + sum+=contributions[idx].cost; + } + total.html(sum+' €'); + } + + $('.contribution_delete_btn').bind('click',on_contribution_delete_btn_click); + $('.contribution_edit_btn').bind('click',on_contribution_edit_btn_click); +} + +/********************* + * Add contributor + *********************/ +on_click_add_contributor_btn=function() { + $('#add_contributor_modal #group_name')[0].value=$($('#view-group h1')[0]).html(); + $('#add_contributor_modal').modal('show'); +} + +on_show_add_contributor_modal=function(e) { + $('#add_contributor_modal #add_contributor_name').focus(); +} + +on_valid_add_contributor_modal=function() { + var group=groups[$('#add_contributor_modal #group_name')[0].value]; + var name=$('#add_contributor_name')[0].value; + if (name=='') { + alert('Vous devez saisir un nom !'); + return; + } + if (group.contributorByName(name)!=undefined) { + alert('Un contributor porte déjà ce nom !'); + return; + } + var email=$('#add_contributor_email')[0].value; + if (email=='') { + alert('Vous devez saisir un email !'); + return; + } + if (group.contributorByEmail(email)!=undefined) { + alert('Un contributor utilise déjà cet email !'); + return; + } + group.contributors.push(new Contributor(name,email)); + set_contributors(group); + $('#add_contributor_modal').modal('hide'); + $('#add_contributor_name')[0].value=''; + $('#add_contributor_email')[0].value=''; + groups.save(); + +} + +on_close_add_contributor_modal=function () { + $('#add_contributor_name')[0].value=''; + $('#add_contributor_email')[0].value=''; +} + +on_click_del_contributor_btn=function() { + contributor=$('#view-group #contributor')[0].value; + question='Voulez-vous vraiment supprimer '+contributor+' ?'; + myconfirm(question,on_confirm_del_contributor,null,contributor); +} + +on_confirm_del_contributor=function(contributor) { + var group=groups[$($('#view-group h1')[0]).html()]; + group.removeContributor(contributor); + set_contributors(group); + groups.save(); +} + +/******************************** + * Add/edit/delete contribution + ********************************/ +on_show_add_contribution_modal=function(e) { + var cs=$($('#add_contribution_modal #add_contribution_contributor_name')[0]); + cs.html(''); + $('#view-group #contributor option').each(function(idx,option) { + cs.append($(option).clone()); + }); + cs[0].value = $('#view-group #contributor')[0].value; + $('#add_contribution_modal #add_contribution_title').focus(); +} + +on_click_add_contribution_btn=function() { + $('#add_contribution_modal #group_name')[0].value=$($('#view-group h1')[0]).html(); + $('#add_contribution_modal #edit_id')[0].value='-1'; + $('#add_contribution_modal').modal('show'); +} + +on_valid_add_contribution_modal=function(e) { + e.preventDefault(); + var group=groups[$('#add_contribution_modal #group_name')[0].value]; + var contributor_name=$('#add_contribution_contributor_name')[0].value; + var contributor=group.contributorByName(contributor_name); + if (contributor==undefined) { + alert('Participant inconu !'); + return; + } + var title=$('#add_contribution_title')[0].value; + if (title=='') { + $('#add_contribution_title')[0].focus(); + alert('Vous devez saisir un titre !'); + return; + } + var cost=$('#add_contribution_cost')[0].value; + if (cost=='') { + $('#add_contribution_cost')[0].focus(); + alert('Vous devez saisir un coût !'); + return; + } + else if(!RegExp('^[0-9]*(,[0-9]{1,2})*$').test(cost)) { + $('#add_contribution_cost')[0].focus(); + alert('Coût incorrect !'); + return; + } + cost=parseFloat(cost.replace(',','.')); + + var date=$('#add_contribution_date')[0].value; + if (date!='') { + if(!RegExp('^[0-3][0-9]\/[0-1][0-9]\/[0-2][0-9][0-9][0-9]$').test(date)) { + $('#add_contribution_date')[0].focus(); + alert('Date incorrect !'); + return; + } + date=moment(date,'DD-MM-YYYY').toDate(); + if (jQuery.type(date)!='date') { + alert('Date non-reconnu !'); + return; + } + } + else { + date=new Date(); + } + + if($('#add_contribution_modal #edit_id')[0].value=='-1') { + group.addContribution(new Contribution(contributor,cost,title,date)); + } + else { + contribution_id=$('#add_contribution_modal #edit_id')[0].value; + group.replaceContribution(contribution_id,new Contribution(contributor,cost,title,date)); + } + show_contributions(group,contributor_name); + $('#add_contribution_modal').modal('hide'); + $('#add_contribution_modal form')[0].reset(); + groups.save(); +} + +on_close_add_contribution_modal=function () { + $('#add_contribution_modal form')[0].reset(); +} + +on_contribution_delete_btn_click=function(e) { + var group=groups[$($('#view-group h1')[0]).html()]; + contribution_id=$($(e.target).parents('div')[0]).data('id'); + contribution=group.contributions[contribution_id]; + myconfirm('Etes-vous sûre de vouloir supprimer la participation '+contribution.getTitle()+' de '+contribution.contributor.name+' ?',on_confirm_contribution_delete,null,{'group':group,'contribution_id':contribution_id, 'contribution': contribution} ); +} + +on_confirm_contribution_delete=function(data) { + delete data.group.contributions[data.contribution_id]; + groups.save(); + on_contributor_change(); +} + +on_contribution_edit_btn_click=function(e) { + var group=groups[$($('#view-group h1')[0]).html()]; + $('#add_contribution_modal #group_name')[0].value=$($('#view-group h1')[0]).html(); + contribution_id=$($(e.target).parents('div')[0]).data('id'); + contribution=group.contributions[contribution_id]; + $('#add_contribution_modal #add_contribution_contributor_name')[0].value=contribution.contributor.name; + console.log($('#add_contribution_modal #add_contribution_contributor_name')[0]); + console.log(contribution.contributor.name); + $('#add_contribution_modal #add_contribution_title')[0].value=contribution.getTitle(); + $('#add_contribution_modal #add_contribution_cost')[0].value=contribution.cost; + $('#add_contribution_modal #add_contribution_date')[0].value=moment(contribution.date).format('DD/MM/YYYY'); + $('#add_contribution_modal #edit_id')[0].value=contribution_id; + $('#add_contribution_modal').modal('show'); +} + + + +/******************** + * Clear local data + ********************/ +clear_local_data=function() { + myconfirm('Etes-vous sûre de vouloir supprimer les données locales ?',on_confirm_clear_local_data); +} + +on_confirm_clear_local_data=function(data) { + localStorage.clear(); + location.reload(); +} + +/********************* + * View balance + *********************/ + +on_display_balance_btn_click=function(e) { + group=groups[$($('#view-group h1')[0]).html()]; + display_balance(group); +} + +display_balance=function(group) { + bal=group.balance(); + tbody=$($('#display_balance_modal tbody')[0]); + tbody.html(''); + sum=0; + for (c in bal) { + tbody.append(''+c+''+bal[c]+' €'); + sum+=bal[c]; + } + $('#display_balance_modal #total-value').html(sum+' €'); + $('#display_balance_modal').modal('show'); +} + +/********************* + * Remove group + *********************/ + +on_remove_group_btn_click=function(e) { + group=groups[$($('#view-group h1')[0]).html()]; + myconfirm('Etes-vous sûre de vouloir supprimer le group '+group.name+' ?',on_confirm_remove_group,null,group); + +} + +on_confirm_remove_group=function(group) { + if(groups.removeGroup(group.name)) { + groups.save(); + location.reload(); + } + else { + alert('Erreur en supprimant le groupe '+group.name+' :('); + } +} + + +/********************* + * Activate + *********************/ +$( document ).ready( function() { + if(typeof(Storage)!=="undefined"){ + groups=new GroupList(); + groups.loadFromLocalStorage(); + refresh_group_list(); + } + else { + alert('Local storage not supported !'); + } + + $('#add_group_submit').bind('click',on_valid_add_group_modal); + $("#add_group_modal").on('shown.bs.modal',on_show_add_group_modal); + $("#add_group_modal").on('hidden.bs.modal',on_close_add_group_modal); + $("#add_group_modal form").on('submit',on_valid_add_group_modal); + + $('#clear_local_data').bind('click',clear_local_data); + + $('#view-group #contributor').bind('change',on_contributor_change); + + $('#add_contributor_btn').bind('click',on_click_add_contributor_btn); + $('#add_contributor_submit').bind('click',on_valid_add_contributor_modal); + $("#add_contributor_modal").on('shown.bs.modal',on_show_add_contributor_modal); + $("#add_contributor_modal").on('hidden.bs.modal',on_close_add_contributor_modal); + $("#add_contributor_modal form").on('submit',on_valid_add_contributor_modal); + + $('#del_contributor_btn').bind('click',on_click_del_contributor_btn); + + $('#add_contribution_btn').bind('click',on_click_add_contribution_btn); + $('#add_contribution_submit').bind('click',on_valid_add_contribution_modal); + $("#add_contribution_modal").on('shown.bs.modal',on_show_add_contribution_modal); + $("#add_contribution_modal").on('hidden.bs.modal',on_close_add_contribution_modal); + $("#add_contribution_modal form").on('submit',on_valid_add_contribution_modal); + + $("#display_balance_btn").bind('click',on_display_balance_btn_click); + + $('#remove_group_btn').bind('click',on_remove_group_btn_click); +} ); diff --git a/inc/myco_confirm.js b/inc/myco_confirm.js new file mode 100644 index 0000000..c9dbf84 --- /dev/null +++ b/inc/myco_confirm.js @@ -0,0 +1,35 @@ +var _myconfirm={ + 'onconfirm': null, + 'oncancel': null, + 'data': null +}; + +myconfirm=function(question,onconfirm,oncancel,data) { + $('#confirm_modal #question').html(question); + _myconfirm={ + 'onconfirm': onconfirm, + 'oncancel': oncancel, + 'data': data + }; + $('#confirm_modal').modal('show'); +} + +_myconfirm_on_valid_click=function(e) { + $('#confirm_modal').modal('hide'); + console.log(jQuery.type(_myconfirm.onconfirm)); + if (jQuery.type(_myconfirm.onconfirm) == 'function') { + _myconfirm.onconfirm(_myconfirm.data); + } +} + +_myconfirm_on_cancel_click=function(e) { + $('#confirm_modal').modal('hide'); + if (jQuery.type(_myconfirm.oncancel) == 'function') { + _myconfirm.oncancel(_myconfirm.data); + } +} + +$( document ).ready( function() { + $('#confirm_modal_submit').bind('click',_myconfirm_on_valid_click); + $('#confirm_modal .cancel').bind('click',_myconfirm_on_cancel_click); +}); diff --git a/inc/myco_objects.js b/inc/myco_objects.js new file mode 100644 index 0000000..b8c595c --- /dev/null +++ b/inc/myco_objects.js @@ -0,0 +1,198 @@ +function GroupList() { + + this.loadFromLocalStorage=function() { + if (localStorage.groups!==undefined) { + var groups=JSON.parse(localStorage.groups); + for (el in groups) { + this[el]=new Group(el,groups[el]); + } + } + } + + this.export=function() { + ret={}; + for (el in this) { + if (this.isGroup(this[el])) { + ret[el]=this[el].export(); + } + } + return ret; + } + + this.save=function() { + localStorage.groups=JSON.stringify(this.export()); + } + + this.each=function(fct) { + var idx=0; + for (el in this) { + if(this.isGroup(this[el])) { + fct(idx++,this[el]); + } + } + } + + this.count=function() { + len=0; + for (el in this) { + if (this.isGroup(this[el])) len=len+1; + } + return len; + } + + this.isGroup=function(el) { + return (el.isGroup!==undefined); + } + + this.removeGroup=function(name) { + if (this.isGroup(this[name])) { + delete this[name]; + return true; + } + return false; + } +} + +function Group(name,data) { + this.name=name; + this.contributors=[]; + this.contributions=[]; + + + this.isGroup=function() { + return true; + } + + this.export=function() { + var contributors=[]; + for (idx in this.contributors) { + contributors.push(this.contributors[idx].export()); + } + var contributions=[]; + for (idx in this.contributions) { + contributions.push(this.contributions[idx].export()); + } + return { + 'name': this.name, + 'contributors': contributors, + 'contributions': contributions + }; + } + + this.removeContributor=function(c) { + this.contributors=this.contributors.filter(function(v){ + return (v.name!=c); + }); + } + + this.contributorByName=function(name) { + for (c in this.contributors) { + if (this.contributors[c].name == name) return this.contributors[c]; + } + return undefined; + } + + this.contributorByEmail=function(email) { + for (c in this.contributors) { + if (this.contributors[c].email == email) return this.contributors[c]; + } + return undefined; + } + + this.contributionsByContributorName=function(name) { + var ret=[]; + for (idx in this.contributions) { + if (this.contributions[idx].contributor.name==name) { + ret.push(this.contributions[idx]); + } + } + return ret; + } + + this.addContribution=function(c) { + c.id=this.contributions.length; + this.contributions.push(c); + } + + this.replaceContribution=function(idx,c) { + c.id=idx; + this.contributions[idx]=c; + } + + + this.balance=function() { + ret={} + for (idx in this.contributors) { + sum=0; + c=this.contributors[idx].name; + cl=this.contributionsByContributorName(c); + for (idc in cl) { + sum+=cl[idc].cost; + } + ret[c]=sum; + } + return ret; + } + + if (jQuery.type(data)=='object') { + try { + this.name=data.name; + if (jQuery.type(data.contributors) == 'array') { + for (idx in data.contributors) { + this.contributors.push(new Contributor( + data.contributors[idx].name, + data.contributors[idx].email + )); + } + } + if (jQuery.type(data.contributions) == 'array') { + for (idx in data.contributions) { + this.contributions.push(new Contribution( + this.contributorByName(data.contributions[idx].contributor), + data.contributions[idx].cost, + data.contributions[idx].title, + data.contributions[idx].date, + idx + )); + } + } + } + catch (e) { + alert('Une erreur est survenue en chargeant le groupe '+this.name+' depuis le cache'); + } + } +} + +function Contributor(name,email) { + this.name=name; + this.email=email; + this.export=function() { + return { + 'name': this.name, + 'email': this.email + }; + } +} + +function Contribution(contributor,cost,title,date,id) { + this.contributor=contributor; + this.cost=cost; + this.title=title; + this.date=date; + this.id=id; + this.export=function() { + return { + 'contributor': this.contributor.name, + 'cost': this.cost, + 'title': this.title, + 'date': this.date, + }; + } + + this.getTitle=function() { + if (jQuery.type(this.title)=='string') { + return this.title; + } + return ''; + } +} diff --git a/index.html b/index.html new file mode 100644 index 0000000..6a1f256 --- /dev/null +++ b/index.html @@ -0,0 +1,296 @@ + + + + MyCo + + + + + + + + + + + + + + + + +
    + +
    +

    Noël

    +
    +
    +
    + Participant + + + + + + +
    +
    +
    +
    + + +
    + + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    DépenceCoûtActions
    Simply124,56€ +
    + + +
    +
    Total :126,56€
    +
    + + + + + + + + + + + + + +
    + + + + + + + + + +