")
+ .appendTo($('#testSuite'));
+ }
+ };
+};
+
+var expect = chai.expect;
+
+
+var reassembleTest = function(test, data) {
+ var lineNum = test.line;
+ var regexp = new RegExp("\/\/" + lineNum + testSalt);
+ return data.input.replace(regexp, test.text);
+};
+
+var runTests = function(err, data) {
+ var allTestsPassed = true;
+ pushed = false;
+ $('#testSuite').children().remove();
+ if (err && userTests.length > 0) {
+ userTests= [{text:"Program Execution Failure", err: "No user tests were run."}];
+ createTestDisplay();
+ } else if (userTests) {
+ userTests.push(false);
+ pushed = true;
+ userTests.forEach(function(test, ix, arr){
+ try {
+ if (test) {
+ var output = eval(reassembleTest(test, data));
+ }
+ } catch(error) {
+ allTestsPassed = false;
+ arr[ix].err = error.name + ":" + error.message;
+ } finally {
+ if (!test) {
+ createTestDisplay();
+ }
+ }
+ });
+
+ if (allTestsPassed) {
+ allTestsPassed = false;
+ showCompletion();
+ }
+
+ }
+};
+
+function showCompletion() {
+ var time = Math.floor(Date.now() / 1000) - started;
+ ga('send', 'event', 'Challenge', 'solved', challengeName + ', Time: ' + time +', Attempts: ' + attempts);
+ $('#complete-courseware-dialog').modal('show');
+ $('#complete-courseware-dialog').keydown(function(e) {
+ if (e.ctrlKey && e.keyCode == 13) {
+ $('.next-bonfire-button').click();
+ }
+ });
+}
\ No newline at end of file
diff --git a/public/js/lib/coursewares/iFrameScripts.js b/public/js/lib/coursewares/iFrameScripts.js
index 325b34af69..86ac7cff28 100644
--- a/public/js/lib/coursewares/iFrameScripts.js
+++ b/public/js/lib/coursewares/iFrameScripts.js
@@ -1,14 +1,19 @@
(function() {
- var allTestsGood = true;
var expect = chai.expect;
+ var tests = parent.tests;
- try {
- eval(parent.allTests);
- } catch (err) {
- allTestsGood = false;
- } finally {
- if (allTestsGood) {
- parent.postMessage('CompleteAwesomeSauce', parent.nodeEnv);
+ for (var i = 0; i < tests.length; i++) {
+ var thisTest = true;
+ try {
+ eval(parent.tests[i]);
+ } catch (err) {
+ allTestsGood = false;
+ thisTest = false;
+ parent.postError(JSON.stringify(tests[i]));
+ } finally {
+ if (thisTest) {
+ parent.postSuccess(JSON.stringify(tests[i]));
+ }
}
}
})();
\ No newline at end of file
diff --git a/public/js/lib/moment/moment.js b/public/js/lib/moment/moment.js
new file mode 100644
index 0000000000..001e00c693
--- /dev/null
+++ b/public/js/lib/moment/moment.js
@@ -0,0 +1,3046 @@
+/**
+ * Created by jason on 2/11/15.
+ */
+//! moment.js
+//! version : 2.9.0
+//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
+//! license : MIT
+//! momentjs.com
+
+(function (undefined) {
+ /************************************
+ Constants
+ ************************************/
+
+ var moment,
+ VERSION = '2.9.0',
+ // the global-scope this is NOT the global object in Node.js
+ globalScope = (typeof global !== 'undefined' && (typeof window === 'undefined' || window === global.window)) ? global : this,
+ oldGlobalMoment,
+ round = Math.round,
+ hasOwnProperty = Object.prototype.hasOwnProperty,
+ i,
+
+ YEAR = 0,
+ MONTH = 1,
+ DATE = 2,
+ HOUR = 3,
+ MINUTE = 4,
+ SECOND = 5,
+ MILLISECOND = 6,
+
+ // internal storage for locale config files
+ locales = {},
+
+ // extra moment internal properties (plugins register props here)
+ momentProperties = [],
+
+ // check for nodeJS
+ hasModule = (typeof module !== 'undefined' && module && module.exports),
+
+ // ASP.NET json date format regex
+ aspNetJsonRegex = /^\/?Date\((\-?\d+)/i,
+ aspNetTimeSpanJsonRegex = /(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/,
+
+ // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
+ // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
+ isoDurationRegex = /^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/,
+
+ // format tokens
+ formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|x|X|zz?|ZZ?|.)/g,
+ localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,
+
+ // parsing token regexes
+ parseTokenOneOrTwoDigits = /\d\d?/, // 0 - 99
+ parseTokenOneToThreeDigits = /\d{1,3}/, // 0 - 999
+ parseTokenOneToFourDigits = /\d{1,4}/, // 0 - 9999
+ parseTokenOneToSixDigits = /[+\-]?\d{1,6}/, // -999,999 - 999,999
+ parseTokenDigits = /\d+/, // nonzero number of digits
+ parseTokenWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i, // any word (or two) characters or numbers including two/three word month in arabic.
+ parseTokenTimezone = /Z|[\+\-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z
+ parseTokenT = /T/i, // T (ISO separator)
+ parseTokenOffsetMs = /[\+\-]?\d+/, // 1234567890123
+ parseTokenTimestampMs = /[\+\-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123
+
+ //strict parsing regexes
+ parseTokenOneDigit = /\d/, // 0 - 9
+ parseTokenTwoDigits = /\d\d/, // 00 - 99
+ parseTokenThreeDigits = /\d{3}/, // 000 - 999
+ parseTokenFourDigits = /\d{4}/, // 0000 - 9999
+ parseTokenSixDigits = /[+-]?\d{6}/, // -999,999 - 999,999
+ parseTokenSignedNumber = /[+-]?\d+/, // -inf - inf
+
+ // iso 8601 regex
+ // 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)
+ isoRegex = /^\s*(?:[+-]\d{6}|\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)?)?$/,
+
+ isoFormat = 'YYYY-MM-DDTHH:mm:ssZ',
+
+ isoDates = [
+ ['YYYYYY-MM-DD', /[+-]\d{6}-\d{2}-\d{2}/],
+ ['YYYY-MM-DD', /\d{4}-\d{2}-\d{2}/],
+ ['GGGG-[W]WW-E', /\d{4}-W\d{2}-\d/],
+ ['GGGG-[W]WW', /\d{4}-W\d{2}/],
+ ['YYYY-DDD', /\d{4}-\d{3}/]
+ ],
+
+ // iso time formats and regexes
+ isoTimes = [
+ ['HH:mm:ss.SSSS', /(T| )\d\d:\d\d:\d\d\.\d+/],
+ ['HH:mm:ss', /(T| )\d\d:\d\d:\d\d/],
+ ['HH:mm', /(T| )\d\d:\d\d/],
+ ['HH', /(T| )\d\d/]
+ ],
+
+ // timezone chunker '+10:00' > ['10', '00'] or '-1530' > ['-', '15', '30']
+ parseTimezoneChunker = /([\+\-]|\d\d)/gi,
+
+ // getter and setter names
+ proxyGettersAndSetters = 'Date|Hours|Minutes|Seconds|Milliseconds'.split('|'),
+ unitMillisecondFactors = {
+ 'Milliseconds' : 1,
+ 'Seconds' : 1e3,
+ 'Minutes' : 6e4,
+ 'Hours' : 36e5,
+ 'Days' : 864e5,
+ 'Months' : 2592e6,
+ 'Years' : 31536e6
+ },
+
+ unitAliases = {
+ ms : 'millisecond',
+ s : 'second',
+ m : 'minute',
+ h : 'hour',
+ d : 'day',
+ D : 'date',
+ w : 'week',
+ W : 'isoWeek',
+ M : 'month',
+ Q : 'quarter',
+ y : 'year',
+ DDD : 'dayOfYear',
+ e : 'weekday',
+ E : 'isoWeekday',
+ gg: 'weekYear',
+ GG: 'isoWeekYear'
+ },
+
+ camelFunctions = {
+ dayofyear : 'dayOfYear',
+ isoweekday : 'isoWeekday',
+ isoweek : 'isoWeek',
+ weekyear : 'weekYear',
+ isoweekyear : 'isoWeekYear'
+ },
+
+ // format function strings
+ formatFunctions = {},
+
+ // default relative time thresholds
+ relativeTimeThresholds = {
+ s: 45, // seconds to minute
+ m: 45, // minutes to hour
+ h: 22, // hours to day
+ d: 26, // days to month
+ M: 11 // months to year
+ },
+
+ // tokens to ordinalize and pad
+ ordinalizeTokens = 'DDD w W M D d'.split(' '),
+ paddedTokens = 'M D H h m s w W'.split(' '),
+
+ formatTokenFunctions = {
+ M : function () {
+ return this.month() + 1;
+ },
+ MMM : function (format) {
+ return this.localeData().monthsShort(this, format);
+ },
+ MMMM : function (format) {
+ return this.localeData().months(this, format);
+ },
+ D : function () {
+ return this.date();
+ },
+ DDD : function () {
+ return this.dayOfYear();
+ },
+ d : function () {
+ return this.day();
+ },
+ dd : function (format) {
+ return this.localeData().weekdaysMin(this, format);
+ },
+ ddd : function (format) {
+ return this.localeData().weekdaysShort(this, format);
+ },
+ dddd : function (format) {
+ return this.localeData().weekdays(this, format);
+ },
+ w : function () {
+ return this.week();
+ },
+ W : function () {
+ return this.isoWeek();
+ },
+ YY : function () {
+ return leftZeroFill(this.year() % 100, 2);
+ },
+ YYYY : function () {
+ return leftZeroFill(this.year(), 4);
+ },
+ YYYYY : function () {
+ return leftZeroFill(this.year(), 5);
+ },
+ YYYYYY : function () {
+ var y = this.year(), sign = y >= 0 ? '+' : '-';
+ return sign + leftZeroFill(Math.abs(y), 6);
+ },
+ gg : function () {
+ return leftZeroFill(this.weekYear() % 100, 2);
+ },
+ gggg : function () {
+ return leftZeroFill(this.weekYear(), 4);
+ },
+ ggggg : function () {
+ return leftZeroFill(this.weekYear(), 5);
+ },
+ GG : function () {
+ return leftZeroFill(this.isoWeekYear() % 100, 2);
+ },
+ GGGG : function () {
+ return leftZeroFill(this.isoWeekYear(), 4);
+ },
+ GGGGG : function () {
+ return leftZeroFill(this.isoWeekYear(), 5);
+ },
+ e : function () {
+ return this.weekday();
+ },
+ E : function () {
+ return this.isoWeekday();
+ },
+ a : function () {
+ return this.localeData().meridiem(this.hours(), this.minutes(), true);
+ },
+ A : function () {
+ return this.localeData().meridiem(this.hours(), this.minutes(), false);
+ },
+ 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 toInt(this.milliseconds() / 100);
+ },
+ SS : function () {
+ return leftZeroFill(toInt(this.milliseconds() / 10), 2);
+ },
+ SSS : function () {
+ return leftZeroFill(this.milliseconds(), 3);
+ },
+ SSSS : function () {
+ return leftZeroFill(this.milliseconds(), 3);
+ },
+ Z : function () {
+ var a = this.utcOffset(),
+ b = '+';
+ if (a < 0) {
+ a = -a;
+ b = '-';
+ }
+ return b + leftZeroFill(toInt(a / 60), 2) + ':' + leftZeroFill(toInt(a) % 60, 2);
+ },
+ ZZ : function () {
+ var a = this.utcOffset(),
+ b = '+';
+ if (a < 0) {
+ a = -a;
+ b = '-';
+ }
+ return b + leftZeroFill(toInt(a / 60), 2) + leftZeroFill(toInt(a) % 60, 2);
+ },
+ z : function () {
+ return this.zoneAbbr();
+ },
+ zz : function () {
+ return this.zoneName();
+ },
+ x : function () {
+ return this.valueOf();
+ },
+ X : function () {
+ return this.unix();
+ },
+ Q : function () {
+ return this.quarter();
+ }
+ },
+
+ deprecations = {},
+
+ lists = ['months', 'monthsShort', 'weekdays', 'weekdaysShort', 'weekdaysMin'],
+
+ updateInProgress = false;
+
+ // Pick the first defined of two or three arguments. dfl comes from
+ // default.
+ function dfl(a, b, c) {
+ switch (arguments.length) {
+ case 2: return a != null ? a : b;
+ case 3: return a != null ? a : b != null ? b : c;
+ default: throw new Error('Implement me');
+ }
+ }
+
+ function hasOwnProp(a, b) {
+ return hasOwnProperty.call(a, b);
+ }
+
+ function defaultParsingFlags() {
+ // We need to deep clone this object, and es5 standard is not very
+ // helpful.
+ return {
+ empty : false,
+ unusedTokens : [],
+ unusedInput : [],
+ overflow : -2,
+ charsLeftOver : 0,
+ nullInput : false,
+ invalidMonth : null,
+ invalidFormat : false,
+ userInvalidated : false,
+ iso: false
+ };
+ }
+
+ function printMsg(msg) {
+ if (moment.suppressDeprecationWarnings === false &&
+ typeof console !== 'undefined' && console.warn) {
+ console.warn('Deprecation warning: ' + msg);
+ }
+ }
+
+ function deprecate(msg, fn) {
+ var firstTime = true;
+ return extend(function () {
+ if (firstTime) {
+ printMsg(msg);
+ firstTime = false;
+ }
+ return fn.apply(this, arguments);
+ }, fn);
+ }
+
+ function deprecateSimple(name, msg) {
+ if (!deprecations[name]) {
+ printMsg(msg);
+ deprecations[name] = true;
+ }
+ }
+
+ function padToken(func, count) {
+ return function (a) {
+ return leftZeroFill(func.call(this, a), count);
+ };
+ }
+ function ordinalizeToken(func, period) {
+ return function (a) {
+ return this.localeData().ordinal(func.call(this, a), period);
+ };
+ }
+
+ function monthDiff(a, b) {
+ // difference in months
+ var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()),
+ // b is in (anchor - 1 month, anchor + 1 month)
+ anchor = a.clone().add(wholeMonthDiff, 'months'),
+ anchor2, adjust;
+
+ if (b - anchor < 0) {
+ anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
+ // linear across the month
+ adjust = (b - anchor) / (anchor - anchor2);
+ } else {
+ anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
+ // linear across the month
+ adjust = (b - anchor) / (anchor2 - anchor);
+ }
+
+ return -(wholeMonthDiff + adjust);
+ }
+
+ while (ordinalizeTokens.length) {
+ i = ordinalizeTokens.pop();
+ formatTokenFunctions[i + 'o'] = ordinalizeToken(formatTokenFunctions[i], i);
+ }
+ while (paddedTokens.length) {
+ i = paddedTokens.pop();
+ formatTokenFunctions[i + i] = padToken(formatTokenFunctions[i], 2);
+ }
+ formatTokenFunctions.DDDD = padToken(formatTokenFunctions.DDD, 3);
+
+
+ function meridiemFixWrap(locale, hour, meridiem) {
+ var isPm;
+
+ if (meridiem == null) {
+ // nothing to do
+ return hour;
+ }
+ if (locale.meridiemHour != null) {
+ return locale.meridiemHour(hour, meridiem);
+ } else if (locale.isPM != null) {
+ // Fallback
+ isPm = locale.isPM(meridiem);
+ if (isPm && hour < 12) {
+ hour += 12;
+ }
+ if (!isPm && hour === 12) {
+ hour = 0;
+ }
+ return hour;
+ } else {
+ // thie is not supposed to happen
+ return hour;
+ }
+ }
+
+ /************************************
+ Constructors
+ ************************************/
+
+ function Locale() {
+ }
+
+ // Moment prototype object
+ function Moment(config, skipOverflow) {
+ if (skipOverflow !== false) {
+ checkOverflow(config);
+ }
+ copyConfig(this, config);
+ this._d = new Date(+config._d);
+ // Prevent infinite loop in case updateOffset creates new moment
+ // objects.
+ if (updateInProgress === false) {
+ updateInProgress = true;
+ moment.updateOffset(this);
+ updateInProgress = false;
+ }
+ }
+
+ // Duration Constructor
+ function Duration(duration) {
+ var normalizedInput = normalizeObjectUnits(duration),
+ years = normalizedInput.year || 0,
+ quarters = normalizedInput.quarter || 0,
+ months = normalizedInput.month || 0,
+ weeks = normalizedInput.week || 0,
+ days = normalizedInput.day || 0,
+ hours = normalizedInput.hour || 0,
+ minutes = normalizedInput.minute || 0,
+ seconds = normalizedInput.second || 0,
+ milliseconds = normalizedInput.millisecond || 0;
+
+ // representation for dateAddRemove
+ this._milliseconds = +milliseconds +
+ seconds * 1e3 + // 1000
+ minutes * 6e4 + // 1000 * 60
+ hours * 36e5; // 1000 * 60 * 60
+ // Because of dateAddRemove treats 24 hours as different from a
+ // day when working around DST, we need to store them separately
+ this._days = +days +
+ weeks * 7;
+ // It is impossible translate months into days without knowing
+ // which months you are are talking about, so we have to store
+ // it separately.
+ this._months = +months +
+ quarters * 3 +
+ years * 12;
+
+ this._data = {};
+
+ this._locale = moment.localeData();
+
+ this._bubble();
+ }
+
+ /************************************
+ Helpers
+ ************************************/
+
+
+ function extend(a, b) {
+ for (var i in b) {
+ if (hasOwnProp(b, i)) {
+ a[i] = b[i];
+ }
+ }
+
+ if (hasOwnProp(b, 'toString')) {
+ a.toString = b.toString;
+ }
+
+ if (hasOwnProp(b, 'valueOf')) {
+ a.valueOf = b.valueOf;
+ }
+
+ return a;
+ }
+
+ function copyConfig(to, from) {
+ var i, prop, val;
+
+ if (typeof from._isAMomentObject !== 'undefined') {
+ to._isAMomentObject = from._isAMomentObject;
+ }
+ if (typeof from._i !== 'undefined') {
+ to._i = from._i;
+ }
+ if (typeof from._f !== 'undefined') {
+ to._f = from._f;
+ }
+ if (typeof from._l !== 'undefined') {
+ to._l = from._l;
+ }
+ if (typeof from._strict !== 'undefined') {
+ to._strict = from._strict;
+ }
+ if (typeof from._tzm !== 'undefined') {
+ to._tzm = from._tzm;
+ }
+ if (typeof from._isUTC !== 'undefined') {
+ to._isUTC = from._isUTC;
+ }
+ if (typeof from._offset !== 'undefined') {
+ to._offset = from._offset;
+ }
+ if (typeof from._pf !== 'undefined') {
+ to._pf = from._pf;
+ }
+ if (typeof from._locale !== 'undefined') {
+ to._locale = from._locale;
+ }
+
+ if (momentProperties.length > 0) {
+ for (i in momentProperties) {
+ prop = momentProperties[i];
+ val = from[prop];
+ if (typeof val !== 'undefined') {
+ to[prop] = val;
+ }
+ }
+ }
+
+ return to;
+ }
+
+ function absRound(number) {
+ if (number < 0) {
+ return Math.ceil(number);
+ } else {
+ return Math.floor(number);
+ }
+ }
+
+ // left zero fill a number
+ // see http://jsperf.com/left-zero-filling for performance comparison
+ function leftZeroFill(number, targetLength, forceSign) {
+ var output = '' + Math.abs(number),
+ sign = number >= 0;
+
+ while (output.length < targetLength) {
+ output = '0' + output;
+ }
+ return (sign ? (forceSign ? '+' : '') : '-') + output;
+ }
+
+ function positiveMomentsDifference(base, other) {
+ var res = {milliseconds: 0, months: 0};
+
+ res.months = other.month() - base.month() +
+ (other.year() - base.year()) * 12;
+ if (base.clone().add(res.months, 'M').isAfter(other)) {
+ --res.months;
+ }
+
+ res.milliseconds = +other - +(base.clone().add(res.months, 'M'));
+
+ return res;
+ }
+
+ function momentsDifference(base, other) {
+ var res;
+ other = makeAs(other, base);
+ if (base.isBefore(other)) {
+ res = positiveMomentsDifference(base, other);
+ } else {
+ res = positiveMomentsDifference(other, base);
+ res.milliseconds = -res.milliseconds;
+ res.months = -res.months;
+ }
+
+ return res;
+ }
+
+ // TODO: remove 'name' arg after deprecation is removed
+ function createAdder(direction, name) {
+ return function (val, period) {
+ var dur, tmp;
+ //invert the arguments, but complain about it
+ if (period !== null && !isNaN(+period)) {
+ deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period).');
+ tmp = val; val = period; period = tmp;
+ }
+
+ val = typeof val === 'string' ? +val : val;
+ dur = moment.duration(val, period);
+ addOrSubtractDurationFromMoment(this, dur, direction);
+ return this;
+ };
+ }
+
+ function addOrSubtractDurationFromMoment(mom, duration, isAdding, updateOffset) {
+ var milliseconds = duration._milliseconds,
+ days = duration._days,
+ months = duration._months;
+ updateOffset = updateOffset == null ? true : updateOffset;
+
+ if (milliseconds) {
+ mom._d.setTime(+mom._d + milliseconds * isAdding);
+ }
+ if (days) {
+ rawSetter(mom, 'Date', rawGetter(mom, 'Date') + days * isAdding);
+ }
+ if (months) {
+ rawMonthSetter(mom, rawGetter(mom, 'Month') + months * isAdding);
+ }
+ if (updateOffset) {
+ moment.updateOffset(mom, days || months);
+ }
+ }
+
+ // check if is an array
+ function isArray(input) {
+ return Object.prototype.toString.call(input) === '[object Array]';
+ }
+
+ function isDate(input) {
+ return Object.prototype.toString.call(input) === '[object Date]' ||
+ input instanceof Date;
+ }
+
+ // compare two arrays, return the number of differences
+ function compareArrays(array1, array2, dontConvert) {
+ var len = Math.min(array1.length, array2.length),
+ lengthDiff = Math.abs(array1.length - array2.length),
+ diffs = 0,
+ i;
+ for (i = 0; i < len; i++) {
+ if ((dontConvert && array1[i] !== array2[i]) ||
+ (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {
+ diffs++;
+ }
+ }
+ return diffs + lengthDiff;
+ }
+
+ function normalizeUnits(units) {
+ if (units) {
+ var lowered = units.toLowerCase().replace(/(.)s$/, '$1');
+ units = unitAliases[units] || camelFunctions[lowered] || lowered;
+ }
+ return units;
+ }
+
+ function normalizeObjectUnits(inputObject) {
+ var normalizedInput = {},
+ normalizedProp,
+ prop;
+
+ for (prop in inputObject) {
+ if (hasOwnProp(inputObject, prop)) {
+ normalizedProp = normalizeUnits(prop);
+ if (normalizedProp) {
+ normalizedInput[normalizedProp] = inputObject[prop];
+ }
+ }
+ }
+
+ return normalizedInput;
+ }
+
+ function makeList(field) {
+ var count, setter;
+
+ if (field.indexOf('week') === 0) {
+ count = 7;
+ setter = 'day';
+ }
+ else if (field.indexOf('month') === 0) {
+ count = 12;
+ setter = 'month';
+ }
+ else {
+ return;
+ }
+
+ moment[field] = function (format, index) {
+ var i, getter,
+ method = moment._locale[field],
+ results = [];
+
+ if (typeof format === 'number') {
+ index = format;
+ format = undefined;
+ }
+
+ getter = function (i) {
+ var m = moment().utc().set(setter, i);
+ return method.call(moment._locale, m, format || '');
+ };
+
+ if (index != null) {
+ return getter(index);
+ }
+ else {
+ for (i = 0; i < count; i++) {
+ results.push(getter(i));
+ }
+ return results;
+ }
+ };
+ }
+
+ function toInt(argumentForCoercion) {
+ var coercedNumber = +argumentForCoercion,
+ value = 0;
+
+ if (coercedNumber !== 0 && isFinite(coercedNumber)) {
+ if (coercedNumber >= 0) {
+ value = Math.floor(coercedNumber);
+ } else {
+ value = Math.ceil(coercedNumber);
+ }
+ }
+
+ return value;
+ }
+
+ function daysInMonth(year, month) {
+ return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
+ }
+
+ function weeksInYear(year, dow, doy) {
+ return weekOfYear(moment([year, 11, 31 + dow - doy]), dow, doy).week;
+ }
+
+ function daysInYear(year) {
+ return isLeapYear(year) ? 366 : 365;
+ }
+
+ function isLeapYear(year) {
+ return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
+ }
+
+ function checkOverflow(m) {
+ var overflow;
+ if (m._a && m._pf.overflow === -2) {
+ overflow =
+ m._a[MONTH] < 0 || m._a[MONTH] > 11 ? MONTH :
+ m._a[DATE] < 1 || m._a[DATE] > daysInMonth(m._a[YEAR], m._a[MONTH]) ? DATE :
+ m._a[HOUR] < 0 || m._a[HOUR] > 24 ||
+ (m._a[HOUR] === 24 && (m._a[MINUTE] !== 0 ||
+ m._a[SECOND] !== 0 ||
+ m._a[MILLISECOND] !== 0)) ? HOUR :
+ m._a[MINUTE] < 0 || m._a[MINUTE] > 59 ? MINUTE :
+ m._a[SECOND] < 0 || m._a[SECOND] > 59 ? SECOND :
+ m._a[MILLISECOND] < 0 || m._a[MILLISECOND] > 999 ? MILLISECOND :
+ -1;
+
+ if (m._pf._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
+ overflow = DATE;
+ }
+
+ m._pf.overflow = overflow;
+ }
+ }
+
+ function isValid(m) {
+ if (m._isValid == null) {
+ m._isValid = !isNaN(m._d.getTime()) &&
+ m._pf.overflow < 0 &&
+ !m._pf.empty &&
+ !m._pf.invalidMonth &&
+ !m._pf.nullInput &&
+ !m._pf.invalidFormat &&
+ !m._pf.userInvalidated;
+
+ if (m._strict) {
+ m._isValid = m._isValid &&
+ m._pf.charsLeftOver === 0 &&
+ m._pf.unusedTokens.length === 0 &&
+ m._pf.bigHour === undefined;
+ }
+ }
+ return m._isValid;
+ }
+
+ function normalizeLocale(key) {
+ return key ? key.toLowerCase().replace('_', '-') : key;
+ }
+
+ // pick the locale from the array
+ // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
+ // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
+ function chooseLocale(names) {
+ var i = 0, j, next, locale, split;
+
+ while (i < names.length) {
+ split = normalizeLocale(names[i]).split('-');
+ j = split.length;
+ next = normalizeLocale(names[i + 1]);
+ next = next ? next.split('-') : null;
+ while (j > 0) {
+ locale = loadLocale(split.slice(0, j).join('-'));
+ if (locale) {
+ return locale;
+ }
+ if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
+ //the next array item is better than a shallower substring of this one
+ break;
+ }
+ j--;
+ }
+ i++;
+ }
+ return null;
+ }
+
+ function loadLocale(name) {
+ var oldLocale = null;
+ if (!locales[name] && hasModule) {
+ try {
+ oldLocale = moment.locale();
+ require('./locale/' + name);
+ // because defineLocale currently also sets the global locale, we want to undo that for lazy loaded locales
+ moment.locale(oldLocale);
+ } catch (e) { }
+ }
+ return locales[name];
+ }
+
+ // Return a moment from input, that is local/utc/utcOffset equivalent to
+ // model.
+ function makeAs(input, model) {
+ var res, diff;
+ if (model._isUTC) {
+ res = model.clone();
+ diff = (moment.isMoment(input) || isDate(input) ?
+ +input : +moment(input)) - (+res);
+ // Use low-level api, because this fn is low-level api.
+ res._d.setTime(+res._d + diff);
+ moment.updateOffset(res, false);
+ return res;
+ } else {
+ return moment(input).local();
+ }
+ }
+
+ /************************************
+ Locale
+ ************************************/
+
+
+ extend(Locale.prototype, {
+
+ set : function (config) {
+ var prop, i;
+ for (i in config) {
+ prop = config[i];
+ if (typeof prop === 'function') {
+ this[i] = prop;
+ } else {
+ this['_' + i] = prop;
+ }
+ }
+ // Lenient ordinal parsing accepts just a number in addition to
+ // number + (possibly) stuff coming from _ordinalParseLenient.
+ this._ordinalParseLenient = new RegExp(this._ordinalParse.source + '|' + /\d{1,2}/.source);
+ },
+
+ _months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
+ months : function (m) {
+ return this._months[m.month()];
+ },
+
+ _monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
+ monthsShort : function (m) {
+ return this._monthsShort[m.month()];
+ },
+
+ monthsParse : function (monthName, format, strict) {
+ var i, mom, regex;
+
+ if (!this._monthsParse) {
+ this._monthsParse = [];
+ this._longMonthsParse = [];
+ this._shortMonthsParse = [];
+ }
+
+ for (i = 0; i < 12; i++) {
+ // make the regex if we don't have it already
+ mom = moment.utc([2000, i]);
+ if (strict && !this._longMonthsParse[i]) {
+ this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
+ this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
+ }
+ if (!strict && !this._monthsParse[i]) {
+ regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
+ this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
+ }
+ // test the regex
+ if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
+ return i;
+ } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
+ return i;
+ } else if (!strict && this._monthsParse[i].test(monthName)) {
+ return i;
+ }
+ }
+ },
+
+ _weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
+ weekdays : function (m) {
+ return this._weekdays[m.day()];
+ },
+
+ _weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
+ weekdaysShort : function (m) {
+ return this._weekdaysShort[m.day()];
+ },
+
+ _weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
+ weekdaysMin : function (m) {
+ return this._weekdaysMin[m.day()];
+ },
+
+ weekdaysParse : function (weekdayName) {
+ var i, mom, regex;
+
+ if (!this._weekdaysParse) {
+ this._weekdaysParse = [];
+ }
+
+ for (i = 0; i < 7; i++) {
+ // make the regex if we don't have it already
+ if (!this._weekdaysParse[i]) {
+ mom = moment([2000, 1]).day(i);
+ regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
+ this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
+ }
+ // test the regex
+ if (this._weekdaysParse[i].test(weekdayName)) {
+ return i;
+ }
+ }
+ },
+
+ _longDateFormat : {
+ LTS : 'h:mm:ss A',
+ 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 (key) {
+ var output = this._longDateFormat[key];
+ if (!output && this._longDateFormat[key.toUpperCase()]) {
+ output = this._longDateFormat[key.toUpperCase()].replace(/MMMM|MM|DD|dddd/g, function (val) {
+ return val.slice(1);
+ });
+ this._longDateFormat[key] = output;
+ }
+ return output;
+ },
+
+ isPM : function (input) {
+ // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
+ // Using charAt should be more compatible.
+ return ((input + '').toLowerCase().charAt(0) === 'p');
+ },
+
+ _meridiemParse : /[ap]\.?m?\.?/i,
+ meridiem : function (hours, minutes, isLower) {
+ if (hours > 11) {
+ return isLower ? 'pm' : 'PM';
+ } else {
+ return isLower ? '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 (key, mom, now) {
+ var output = this._calendar[key];
+ return typeof output === 'function' ? output.apply(mom, [now]) : output;
+ },
+
+ _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 (number, withoutSuffix, string, isFuture) {
+ var output = this._relativeTime[string];
+ return (typeof output === 'function') ?
+ output(number, withoutSuffix, string, isFuture) :
+ output.replace(/%d/i, number);
+ },
+
+ pastFuture : function (diff, output) {
+ var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
+ return typeof format === 'function' ? format(output) : format.replace(/%s/i, output);
+ },
+
+ ordinal : function (number) {
+ return this._ordinal.replace('%d', number);
+ },
+ _ordinal : '%d',
+ _ordinalParse : /\d{1,2}/,
+
+ preparse : function (string) {
+ return string;
+ },
+
+ postformat : function (string) {
+ return string;
+ },
+
+ week : function (mom) {
+ return weekOfYear(mom, this._week.dow, this._week.doy).week;
+ },
+
+ _week : {
+ dow : 0, // Sunday is the first day of the week.
+ doy : 6 // The week that contains Jan 1st is the first week of the year.
+ },
+
+ firstDayOfWeek : function () {
+ return this._week.dow;
+ },
+
+ firstDayOfYear : function () {
+ return this._week.doy;
+ },
+
+ _invalidDate: 'Invalid date',
+ invalidDate: function () {
+ return this._invalidDate;
+ }
+ });
+
+ /************************************
+ Formatting
+ ************************************/
+
+
+ function removeFormattingTokens(input) {
+ if (input.match(/\[[\s\S]/)) {
+ return input.replace(/^\[|\]$/g, '');
+ }
+ return input.replace(/\\/g, '');
+ }
+
+ function makeFormatFunction(format) {
+ var array = format.match(formattingTokens), i, length;
+
+ for (i = 0, length = array.length; i < length; i++) {
+ if (formatTokenFunctions[array[i]]) {
+ array[i] = formatTokenFunctions[array[i]];
+ } else {
+ array[i] = removeFormattingTokens(array[i]);
+ }
+ }
+
+ return function (mom) {
+ var output = '';
+ for (i = 0; i < length; i++) {
+ output += array[i] instanceof Function ? array[i].call(mom, format) : array[i];
+ }
+ return output;
+ };
+ }
+
+ // format date using native date object
+ function formatMoment(m, format) {
+ if (!m.isValid()) {
+ return m.localeData().invalidDate();
+ }
+
+ format = expandFormat(format, m.localeData());
+
+ if (!formatFunctions[format]) {
+ formatFunctions[format] = makeFormatFunction(format);
+ }
+
+ return formatFunctions[format](m);
+ }
+
+ function expandFormat(format, locale) {
+ var i = 5;
+
+ function replaceLongDateFormatTokens(input) {
+ return locale.longDateFormat(input) || input;
+ }
+
+ localFormattingTokens.lastIndex = 0;
+ while (i >= 0 && localFormattingTokens.test(format)) {
+ format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
+ localFormattingTokens.lastIndex = 0;
+ i -= 1;
+ }
+
+ return format;
+ }
+
+
+ /************************************
+ Parsing
+ ************************************/
+
+
+ // get the regex to find the next token
+ function getParseRegexForToken(token, config) {
+ var a, strict = config._strict;
+ switch (token) {
+ case 'Q':
+ return parseTokenOneDigit;
+ case 'DDDD':
+ return parseTokenThreeDigits;
+ case 'YYYY':
+ case 'GGGG':
+ case 'gggg':
+ return strict ? parseTokenFourDigits : parseTokenOneToFourDigits;
+ case 'Y':
+ case 'G':
+ case 'g':
+ return parseTokenSignedNumber;
+ case 'YYYYYY':
+ case 'YYYYY':
+ case 'GGGGG':
+ case 'ggggg':
+ return strict ? parseTokenSixDigits : parseTokenOneToSixDigits;
+ case 'S':
+ if (strict) {
+ return parseTokenOneDigit;
+ }
+ /* falls through */
+ case 'SS':
+ if (strict) {
+ return parseTokenTwoDigits;
+ }
+ /* falls through */
+ case 'SSS':
+ if (strict) {
+ return parseTokenThreeDigits;
+ }
+ /* falls through */
+ case 'DDD':
+ return parseTokenOneToThreeDigits;
+ case 'MMM':
+ case 'MMMM':
+ case 'dd':
+ case 'ddd':
+ case 'dddd':
+ return parseTokenWord;
+ case 'a':
+ case 'A':
+ return config._locale._meridiemParse;
+ case 'x':
+ return parseTokenOffsetMs;
+ case 'X':
+ return parseTokenTimestampMs;
+ case 'Z':
+ case 'ZZ':
+ return parseTokenTimezone;
+ case 'T':
+ return parseTokenT;
+ case 'SSSS':
+ return parseTokenDigits;
+ case 'MM':
+ case 'DD':
+ case 'YY':
+ case 'GG':
+ case 'gg':
+ case 'HH':
+ case 'hh':
+ case 'mm':
+ case 'ss':
+ case 'ww':
+ case 'WW':
+ return strict ? parseTokenTwoDigits : parseTokenOneOrTwoDigits;
+ case 'M':
+ case 'D':
+ case 'd':
+ case 'H':
+ case 'h':
+ case 'm':
+ case 's':
+ case 'w':
+ case 'W':
+ case 'e':
+ case 'E':
+ return parseTokenOneOrTwoDigits;
+ case 'Do':
+ return strict ? config._locale._ordinalParse : config._locale._ordinalParseLenient;
+ default :
+ a = new RegExp(regexpEscape(unescapeFormat(token.replace('\\', '')), 'i'));
+ return a;
+ }
+ }
+
+ function utcOffsetFromString(string) {
+ string = string || '';
+ var possibleTzMatches = (string.match(parseTokenTimezone) || []),
+ tzChunk = possibleTzMatches[possibleTzMatches.length - 1] || [],
+ parts = (tzChunk + '').match(parseTimezoneChunker) || ['-', 0, 0],
+ minutes = +(parts[1] * 60) + toInt(parts[2]);
+
+ return parts[0] === '+' ? minutes : -minutes;
+ }
+
+ // function to convert string input to date
+ function addTimeToArrayFromToken(token, input, config) {
+ var a, datePartArray = config._a;
+
+ switch (token) {
+ // QUARTER
+ case 'Q':
+ if (input != null) {
+ datePartArray[MONTH] = (toInt(input) - 1) * 3;
+ }
+ break;
+ // MONTH
+ case 'M' : // fall through to MM
+ case 'MM' :
+ if (input != null) {
+ datePartArray[MONTH] = toInt(input) - 1;
+ }
+ break;
+ case 'MMM' : // fall through to MMMM
+ case 'MMMM' :
+ a = config._locale.monthsParse(input, token, config._strict);
+ // if we didn't find a month name, mark the date as invalid.
+ if (a != null) {
+ datePartArray[MONTH] = a;
+ } else {
+ config._pf.invalidMonth = input;
+ }
+ break;
+ // DAY OF MONTH
+ case 'D' : // fall through to DD
+ case 'DD' :
+ if (input != null) {
+ datePartArray[DATE] = toInt(input);
+ }
+ break;
+ case 'Do' :
+ if (input != null) {
+ datePartArray[DATE] = toInt(parseInt(
+ input.match(/\d{1,2}/)[0], 10));
+ }
+ break;
+ // DAY OF YEAR
+ case 'DDD' : // fall through to DDDD
+ case 'DDDD' :
+ if (input != null) {
+ config._dayOfYear = toInt(input);
+ }
+
+ break;
+ // YEAR
+ case 'YY' :
+ datePartArray[YEAR] = moment.parseTwoDigitYear(input);
+ break;
+ case 'YYYY' :
+ case 'YYYYY' :
+ case 'YYYYYY' :
+ datePartArray[YEAR] = toInt(input);
+ break;
+ // AM / PM
+ case 'a' : // fall through to A
+ case 'A' :
+ config._meridiem = input;
+ // config._isPm = config._locale.isPM(input);
+ break;
+ // HOUR
+ case 'h' : // fall through to hh
+ case 'hh' :
+ config._pf.bigHour = true;
+ /* falls through */
+ case 'H' : // fall through to HH
+ case 'HH' :
+ datePartArray[HOUR] = toInt(input);
+ break;
+ // MINUTE
+ case 'm' : // fall through to mm
+ case 'mm' :
+ datePartArray[MINUTE] = toInt(input);
+ break;
+ // SECOND
+ case 's' : // fall through to ss
+ case 'ss' :
+ datePartArray[SECOND] = toInt(input);
+ break;
+ // MILLISECOND
+ case 'S' :
+ case 'SS' :
+ case 'SSS' :
+ case 'SSSS' :
+ datePartArray[MILLISECOND] = toInt(('0.' + input) * 1000);
+ break;
+ // UNIX OFFSET (MILLISECONDS)
+ case 'x':
+ config._d = new Date(toInt(input));
+ break;
+ // UNIX TIMESTAMP WITH MS
+ case 'X':
+ config._d = new Date(parseFloat(input) * 1000);
+ break;
+ // TIMEZONE
+ case 'Z' : // fall through to ZZ
+ case 'ZZ' :
+ config._useUTC = true;
+ config._tzm = utcOffsetFromString(input);
+ break;
+ // WEEKDAY - human
+ case 'dd':
+ case 'ddd':
+ case 'dddd':
+ a = config._locale.weekdaysParse(input);
+ // if we didn't get a weekday name, mark the date as invalid
+ if (a != null) {
+ config._w = config._w || {};
+ config._w['d'] = a;
+ } else {
+ config._pf.invalidWeekday = input;
+ }
+ break;
+ // WEEK, WEEK DAY - numeric
+ case 'w':
+ case 'ww':
+ case 'W':
+ case 'WW':
+ case 'd':
+ case 'e':
+ case 'E':
+ token = token.substr(0, 1);
+ /* falls through */
+ case 'gggg':
+ case 'GGGG':
+ case 'GGGGG':
+ token = token.substr(0, 2);
+ if (input) {
+ config._w = config._w || {};
+ config._w[token] = toInt(input);
+ }
+ break;
+ case 'gg':
+ case 'GG':
+ config._w = config._w || {};
+ config._w[token] = moment.parseTwoDigitYear(input);
+ }
+ }
+
+ function dayOfYearFromWeekInfo(config) {
+ var w, weekYear, week, weekday, dow, doy, temp;
+
+ w = config._w;
+ if (w.GG != null || w.W != null || w.E != null) {
+ dow = 1;
+ doy = 4;
+
+ // TODO: We need to take the current isoWeekYear, but that depends on
+ // how we interpret now (local, utc, fixed offset). So create
+ // a now version of current config (take local/utc/offset flags, and
+ // create now).
+ weekYear = dfl(w.GG, config._a[YEAR], weekOfYear(moment(), 1, 4).year);
+ week = dfl(w.W, 1);
+ weekday = dfl(w.E, 1);
+ } else {
+ dow = config._locale._week.dow;
+ doy = config._locale._week.doy;
+
+ weekYear = dfl(w.gg, config._a[YEAR], weekOfYear(moment(), dow, doy).year);
+ week = dfl(w.w, 1);
+
+ if (w.d != null) {
+ // weekday -- low day numbers are considered next week
+ weekday = w.d;
+ if (weekday < dow) {
+ ++week;
+ }
+ } else if (w.e != null) {
+ // local weekday -- counting starts from begining of week
+ weekday = w.e + dow;
+ } else {
+ // default to begining of week
+ weekday = dow;
+ }
+ }
+ temp = dayOfYearFromWeeks(weekYear, week, weekday, doy, dow);
+
+ config._a[YEAR] = temp.year;
+ config._dayOfYear = temp.dayOfYear;
+ }
+
+ // convert an array to a date.
+ // the array should mirror the parameters below
+ // note: all values past the year are optional and will default to the lowest possible value.
+ // [year, month, day , hour, minute, second, millisecond]
+ function dateFromConfig(config) {
+ var i, date, input = [], currentDate, yearToUse;
+
+ if (config._d) {
+ return;
+ }
+
+ currentDate = currentDateArray(config);
+
+ //compute day of the year from weeks and weekdays
+ if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
+ dayOfYearFromWeekInfo(config);
+ }
+
+ //if the day of the year is set, figure out what it is
+ if (config._dayOfYear) {
+ yearToUse = dfl(config._a[YEAR], currentDate[YEAR]);
+
+ if (config._dayOfYear > daysInYear(yearToUse)) {
+ config._pf._overflowDayOfYear = true;
+ }
+
+ date = makeUTCDate(yearToUse, 0, config._dayOfYear);
+ config._a[MONTH] = date.getUTCMonth();
+ config._a[DATE] = date.getUTCDate();
+ }
+
+ // Default to current date.
+ // * if no year, month, day of month are given, default to today
+ // * if day of month is given, default month and year
+ // * if month is given, default only year
+ // * if year is given, don't default anything
+ for (i = 0; i < 3 && config._a[i] == null; ++i) {
+ config._a[i] = input[i] = currentDate[i];
+ }
+
+ // Zero out whatever was not defaulted, including time
+ for (; i < 7; i++) {
+ config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
+ }
+
+ // Check for 24:00:00.000
+ if (config._a[HOUR] === 24 &&
+ config._a[MINUTE] === 0 &&
+ config._a[SECOND] === 0 &&
+ config._a[MILLISECOND] === 0) {
+ config._nextDay = true;
+ config._a[HOUR] = 0;
+ }
+
+ config._d = (config._useUTC ? makeUTCDate : makeDate).apply(null, input);
+ // Apply timezone offset from input. The actual utcOffset can be changed
+ // with parseZone.
+ if (config._tzm != null) {
+ config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
+ }
+
+ if (config._nextDay) {
+ config._a[HOUR] = 24;
+ }
+ }
+
+ function dateFromObject(config) {
+ var normalizedInput;
+
+ if (config._d) {
+ return;
+ }
+
+ normalizedInput = normalizeObjectUnits(config._i);
+ config._a = [
+ normalizedInput.year,
+ normalizedInput.month,
+ normalizedInput.day || normalizedInput.date,
+ normalizedInput.hour,
+ normalizedInput.minute,
+ normalizedInput.second,
+ normalizedInput.millisecond
+ ];
+
+ dateFromConfig(config);
+ }
+
+ function currentDateArray(config) {
+ var now = new Date();
+ if (config._useUTC) {
+ return [
+ now.getUTCFullYear(),
+ now.getUTCMonth(),
+ now.getUTCDate()
+ ];
+ } else {
+ return [now.getFullYear(), now.getMonth(), now.getDate()];
+ }
+ }
+
+ // date from string and format string
+ function makeDateFromStringAndFormat(config) {
+ if (config._f === moment.ISO_8601) {
+ parseISO(config);
+ return;
+ }
+
+ config._a = [];
+ config._pf.empty = true;
+
+ // This array is used to make a Date, either with `new Date` or `Date.UTC`
+ var string = '' + config._i,
+ i, parsedInput, tokens, token, skipped,
+ stringLength = string.length,
+ totalParsedInputLength = 0;
+
+ tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
+
+ for (i = 0; i < tokens.length; i++) {
+ token = tokens[i];
+ parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
+ if (parsedInput) {
+ skipped = string.substr(0, string.indexOf(parsedInput));
+ if (skipped.length > 0) {
+ config._pf.unusedInput.push(skipped);
+ }
+ string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
+ totalParsedInputLength += parsedInput.length;
+ }
+ // don't parse if it's not a known token
+ if (formatTokenFunctions[token]) {
+ if (parsedInput) {
+ config._pf.empty = false;
+ }
+ else {
+ config._pf.unusedTokens.push(token);
+ }
+ addTimeToArrayFromToken(token, parsedInput, config);
+ }
+ else if (config._strict && !parsedInput) {
+ config._pf.unusedTokens.push(token);
+ }
+ }
+
+ // add remaining unparsed input length to the string
+ config._pf.charsLeftOver = stringLength - totalParsedInputLength;
+ if (string.length > 0) {
+ config._pf.unusedInput.push(string);
+ }
+
+ // clear _12h flag if hour is <= 12
+ if (config._pf.bigHour === true && config._a[HOUR] <= 12) {
+ config._pf.bigHour = undefined;
+ }
+ // handle meridiem
+ config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR],
+ config._meridiem);
+ dateFromConfig(config);
+ checkOverflow(config);
+ }
+
+ function unescapeFormat(s) {
+ return s.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
+ return p1 || p2 || p3 || p4;
+ });
+ }
+
+ // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
+ function regexpEscape(s) {
+ return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
+ }
+
+ // date from string and array of format strings
+ function makeDateFromStringAndArray(config) {
+ var tempConfig,
+ bestMoment,
+
+ scoreToBeat,
+ i,
+ currentScore;
+
+ if (config._f.length === 0) {
+ config._pf.invalidFormat = true;
+ config._d = new Date(NaN);
+ return;
+ }
+
+ for (i = 0; i < config._f.length; i++) {
+ currentScore = 0;
+ tempConfig = copyConfig({}, config);
+ if (config._useUTC != null) {
+ tempConfig._useUTC = config._useUTC;
+ }
+ tempConfig._pf = defaultParsingFlags();
+ tempConfig._f = config._f[i];
+ makeDateFromStringAndFormat(tempConfig);
+
+ if (!isValid(tempConfig)) {
+ continue;
+ }
+
+ // if there is any input that was not parsed add a penalty for that format
+ currentScore += tempConfig._pf.charsLeftOver;
+
+ //or tokens
+ currentScore += tempConfig._pf.unusedTokens.length * 10;
+
+ tempConfig._pf.score = currentScore;
+
+ if (scoreToBeat == null || currentScore < scoreToBeat) {
+ scoreToBeat = currentScore;
+ bestMoment = tempConfig;
+ }
+ }
+
+ extend(config, bestMoment || tempConfig);
+ }
+
+ // date from iso format
+ function parseISO(config) {
+ var i, l,
+ string = config._i,
+ match = isoRegex.exec(string);
+
+ if (match) {
+ config._pf.iso = true;
+ for (i = 0, l = isoDates.length; i < l; i++) {
+ if (isoDates[i][1].exec(string)) {
+ // match[5] should be 'T' or undefined
+ config._f = isoDates[i][0] + (match[6] || ' ');
+ break;
+ }
+ }
+ for (i = 0, l = isoTimes.length; i < l; i++) {
+ if (isoTimes[i][1].exec(string)) {
+ config._f += isoTimes[i][0];
+ break;
+ }
+ }
+ if (string.match(parseTokenTimezone)) {
+ config._f += 'Z';
+ }
+ makeDateFromStringAndFormat(config);
+ } else {
+ config._isValid = false;
+ }
+ }
+
+ // date from iso format or fallback
+ function makeDateFromString(config) {
+ parseISO(config);
+ if (config._isValid === false) {
+ delete config._isValid;
+ moment.createFromInputFallback(config);
+ }
+ }
+
+ function map(arr, fn) {
+ var res = [], i;
+ for (i = 0; i < arr.length; ++i) {
+ res.push(fn(arr[i], i));
+ }
+ return res;
+ }
+
+ function makeDateFromInput(config) {
+ var input = config._i, matched;
+ if (input === undefined) {
+ config._d = new Date();
+ } else if (isDate(input)) {
+ config._d = new Date(+input);
+ } else if ((matched = aspNetJsonRegex.exec(input)) !== null) {
+ config._d = new Date(+matched[1]);
+ } else if (typeof input === 'string') {
+ makeDateFromString(config);
+ } else if (isArray(input)) {
+ config._a = map(input.slice(0), function (obj) {
+ return parseInt(obj, 10);
+ });
+ dateFromConfig(config);
+ } else if (typeof(input) === 'object') {
+ dateFromObject(config);
+ } else if (typeof(input) === 'number') {
+ // from milliseconds
+ config._d = new Date(input);
+ } else {
+ moment.createFromInputFallback(config);
+ }
+ }
+
+ function makeDate(y, m, d, h, M, s, ms) {
+ //can't just apply() to create a date:
+ //http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply
+ var date = new Date(y, m, d, h, M, s, ms);
+
+ //the date constructor doesn't accept years < 1970
+ if (y < 1970) {
+ date.setFullYear(y);
+ }
+ return date;
+ }
+
+ function makeUTCDate(y) {
+ var date = new Date(Date.UTC.apply(null, arguments));
+ if (y < 1970) {
+ date.setUTCFullYear(y);
+ }
+ return date;
+ }
+
+ function parseWeekday(input, locale) {
+ if (typeof input === 'string') {
+ if (!isNaN(input)) {
+ input = parseInt(input, 10);
+ }
+ else {
+ input = locale.weekdaysParse(input);
+ if (typeof input !== 'number') {
+ return null;
+ }
+ }
+ }
+ return input;
+ }
+
+ /************************************
+ Relative Time
+ ************************************/
+
+
+ // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
+ function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
+ return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
+ }
+
+ function relativeTime(posNegDuration, withoutSuffix, locale) {
+ var duration = moment.duration(posNegDuration).abs(),
+ seconds = round(duration.as('s')),
+ minutes = round(duration.as('m')),
+ hours = round(duration.as('h')),
+ days = round(duration.as('d')),
+ months = round(duration.as('M')),
+ years = round(duration.as('y')),
+
+ args = seconds < relativeTimeThresholds.s && ['s', seconds] ||
+ minutes === 1 && ['m'] ||
+ minutes < relativeTimeThresholds.m && ['mm', minutes] ||
+ hours === 1 && ['h'] ||
+ hours < relativeTimeThresholds.h && ['hh', hours] ||
+ days === 1 && ['d'] ||
+ days < relativeTimeThresholds.d && ['dd', days] ||
+ months === 1 && ['M'] ||
+ months < relativeTimeThresholds.M && ['MM', months] ||
+ years === 1 && ['y'] || ['yy', years];
+
+ args[2] = withoutSuffix;
+ args[3] = +posNegDuration > 0;
+ args[4] = locale;
+ return substituteTimeAgo.apply({}, args);
+ }
+
+
+ /************************************
+ Week of Year
+ ************************************/
+
+
+ // firstDayOfWeek 0 = sun, 6 = sat
+ // the day of the week that starts the week
+ // (usually sunday or monday)
+ // firstDayOfWeekOfYear 0 = sun, 6 = sat
+ // the first week is the week that contains the first
+ // of this day of the week
+ // (eg. ISO weeks use thursday (4))
+ function weekOfYear(mom, firstDayOfWeek, firstDayOfWeekOfYear) {
+ var end = firstDayOfWeekOfYear - firstDayOfWeek,
+ daysToDayOfWeek = firstDayOfWeekOfYear - mom.day(),
+ adjustedMoment;
+
+
+ if (daysToDayOfWeek > end) {
+ daysToDayOfWeek -= 7;
+ }
+
+ if (daysToDayOfWeek < end - 7) {
+ daysToDayOfWeek += 7;
+ }
+
+ adjustedMoment = moment(mom).add(daysToDayOfWeek, 'd');
+ return {
+ week: Math.ceil(adjustedMoment.dayOfYear() / 7),
+ year: adjustedMoment.year()
+ };
+ }
+
+ //http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
+ function dayOfYearFromWeeks(year, week, weekday, firstDayOfWeekOfYear, firstDayOfWeek) {
+ var d = makeUTCDate(year, 0, 1).getUTCDay(), daysToAdd, dayOfYear;
+
+ d = d === 0 ? 7 : d;
+ weekday = weekday != null ? weekday : firstDayOfWeek;
+ daysToAdd = firstDayOfWeek - d + (d > firstDayOfWeekOfYear ? 7 : 0) - (d < firstDayOfWeek ? 7 : 0);
+ dayOfYear = 7 * (week - 1) + (weekday - firstDayOfWeek) + daysToAdd + 1;
+
+ return {
+ year: dayOfYear > 0 ? year : year - 1,
+ dayOfYear: dayOfYear > 0 ? dayOfYear : daysInYear(year - 1) + dayOfYear
+ };
+ }
+
+ /************************************
+ Top Level Functions
+ ************************************/
+
+ function makeMoment(config) {
+ var input = config._i,
+ format = config._f,
+ res;
+
+ config._locale = config._locale || moment.localeData(config._l);
+
+ if (input === null || (format === undefined && input === '')) {
+ return moment.invalid({nullInput: true});
+ }
+
+ if (typeof input === 'string') {
+ config._i = input = config._locale.preparse(input);
+ }
+
+ if (moment.isMoment(input)) {
+ return new Moment(input, true);
+ } else if (format) {
+ if (isArray(format)) {
+ makeDateFromStringAndArray(config);
+ } else {
+ makeDateFromStringAndFormat(config);
+ }
+ } else {
+ makeDateFromInput(config);
+ }
+
+ res = new Moment(config);
+ if (res._nextDay) {
+ // Adding is smart enough around DST
+ res.add(1, 'd');
+ res._nextDay = undefined;
+ }
+
+ return res;
+ }
+
+ moment = function (input, format, locale, strict) {
+ var c;
+
+ if (typeof(locale) === 'boolean') {
+ strict = locale;
+ locale = undefined;
+ }
+ // object construction must be done this way.
+ // https://github.com/moment/moment/issues/1423
+ c = {};
+ c._isAMomentObject = true;
+ c._i = input;
+ c._f = format;
+ c._l = locale;
+ c._strict = strict;
+ c._isUTC = false;
+ c._pf = defaultParsingFlags();
+
+ return makeMoment(c);
+ };
+
+ moment.suppressDeprecationWarnings = false;
+
+ moment.createFromInputFallback = deprecate(
+ 'moment construction falls back to js Date. This is ' +
+ 'discouraged and will be removed in upcoming major ' +
+ 'release. Please refer to ' +
+ 'https://github.com/moment/moment/issues/1407 for more info.',
+ function (config) {
+ config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
+ }
+ );
+
+ // Pick a moment m from moments so that m[fn](other) is true for all
+ // other. This relies on the function fn to be transitive.
+ //
+ // moments should either be an array of moment objects or an array, whose
+ // first element is an array of moment objects.
+ function pickBy(fn, moments) {
+ var res, i;
+ if (moments.length === 1 && isArray(moments[0])) {
+ moments = moments[0];
+ }
+ if (!moments.length) {
+ return moment();
+ }
+ res = moments[0];
+ for (i = 1; i < moments.length; ++i) {
+ if (moments[i][fn](res)) {
+ res = moments[i];
+ }
+ }
+ return res;
+ }
+
+ moment.min = function () {
+ var args = [].slice.call(arguments, 0);
+
+ return pickBy('isBefore', args);
+ };
+
+ moment.max = function () {
+ var args = [].slice.call(arguments, 0);
+
+ return pickBy('isAfter', args);
+ };
+
+ // creating with utc
+ moment.utc = function (input, format, locale, strict) {
+ var c;
+
+ if (typeof(locale) === 'boolean') {
+ strict = locale;
+ locale = undefined;
+ }
+ // object construction must be done this way.
+ // https://github.com/moment/moment/issues/1423
+ c = {};
+ c._isAMomentObject = true;
+ c._useUTC = true;
+ c._isUTC = true;
+ c._l = locale;
+ c._i = input;
+ c._f = format;
+ c._strict = strict;
+ c._pf = defaultParsingFlags();
+
+ return makeMoment(c).utc();
+ };
+
+ // creating with unix timestamp (in seconds)
+ moment.unix = function (input) {
+ return moment(input * 1000);
+ };
+
+ // duration
+ moment.duration = function (input, key) {
+ var duration = input,
+ // matching against regexp is expensive, do it on demand
+ match = null,
+ sign,
+ ret,
+ parseIso,
+ diffRes;
+
+ if (moment.isDuration(input)) {
+ duration = {
+ ms: input._milliseconds,
+ d: input._days,
+ M: input._months
+ };
+ } else if (typeof input === 'number') {
+ duration = {};
+ if (key) {
+ duration[key] = input;
+ } else {
+ duration.milliseconds = input;
+ }
+ } else if (!!(match = aspNetTimeSpanJsonRegex.exec(input))) {
+ sign = (match[1] === '-') ? -1 : 1;
+ duration = {
+ y: 0,
+ d: toInt(match[DATE]) * sign,
+ h: toInt(match[HOUR]) * sign,
+ m: toInt(match[MINUTE]) * sign,
+ s: toInt(match[SECOND]) * sign,
+ ms: toInt(match[MILLISECOND]) * sign
+ };
+ } else if (!!(match = isoDurationRegex.exec(input))) {
+ sign = (match[1] === '-') ? -1 : 1;
+ parseIso = function (inp) {
+ // We'd normally use ~~inp for this, but unfortunately it also
+ // converts floats to ints.
+ // inp may be undefined, so careful calling replace on it.
+ var res = inp && parseFloat(inp.replace(',', '.'));
+ // apply sign while we're at it
+ return (isNaN(res) ? 0 : res) * sign;
+ };
+ duration = {
+ y: parseIso(match[2]),
+ M: parseIso(match[3]),
+ d: parseIso(match[4]),
+ h: parseIso(match[5]),
+ m: parseIso(match[6]),
+ s: parseIso(match[7]),
+ w: parseIso(match[8])
+ };
+ } else if (duration == null) {// checks for null or undefined
+ duration = {};
+ } else if (typeof duration === 'object' &&
+ ('from' in duration || 'to' in duration)) {
+ diffRes = momentsDifference(moment(duration.from), moment(duration.to));
+
+ duration = {};
+ duration.ms = diffRes.milliseconds;
+ duration.M = diffRes.months;
+ }
+
+ ret = new Duration(duration);
+
+ if (moment.isDuration(input) && hasOwnProp(input, '_locale')) {
+ ret._locale = input._locale;
+ }
+
+ return ret;
+ };
+
+ // version number
+ moment.version = VERSION;
+
+ // default format
+ moment.defaultFormat = isoFormat;
+
+ // constant that refers to the ISO standard
+ moment.ISO_8601 = function () {};
+
+ // Plugins that add properties should also add the key here (null value),
+ // so we can properly clone ourselves.
+ moment.momentProperties = momentProperties;
+
+ // This function will be called whenever a moment is mutated.
+ // It is intended to keep the offset in sync with the timezone.
+ moment.updateOffset = function () {};
+
+ // This function allows you to set a threshold for relative time strings
+ moment.relativeTimeThreshold = function (threshold, limit) {
+ if (relativeTimeThresholds[threshold] === undefined) {
+ return false;
+ }
+ if (limit === undefined) {
+ return relativeTimeThresholds[threshold];
+ }
+ relativeTimeThresholds[threshold] = limit;
+ return true;
+ };
+
+ moment.lang = deprecate(
+ 'moment.lang is deprecated. Use moment.locale instead.',
+ function (key, value) {
+ return moment.locale(key, value);
+ }
+ );
+
+ // This function will load locale and then set the global locale. If
+ // no arguments are passed in, it will simply return the current global
+ // locale key.
+ moment.locale = function (key, values) {
+ var data;
+ if (key) {
+ if (typeof(values) !== 'undefined') {
+ data = moment.defineLocale(key, values);
+ }
+ else {
+ data = moment.localeData(key);
+ }
+
+ if (data) {
+ moment.duration._locale = moment._locale = data;
+ }
+ }
+
+ return moment._locale._abbr;
+ };
+
+ moment.defineLocale = function (name, values) {
+ if (values !== null) {
+ values.abbr = name;
+ if (!locales[name]) {
+ locales[name] = new Locale();
+ }
+ locales[name].set(values);
+
+ // backwards compat for now: also set the locale
+ moment.locale(name);
+
+ return locales[name];
+ } else {
+ // useful for testing
+ delete locales[name];
+ return null;
+ }
+ };
+
+ moment.langData = deprecate(
+ 'moment.langData is deprecated. Use moment.localeData instead.',
+ function (key) {
+ return moment.localeData(key);
+ }
+ );
+
+ // returns locale data
+ moment.localeData = function (key) {
+ var locale;
+
+ if (key && key._locale && key._locale._abbr) {
+ key = key._locale._abbr;
+ }
+
+ if (!key) {
+ return moment._locale;
+ }
+
+ if (!isArray(key)) {
+ //short-circuit everything else
+ locale = loadLocale(key);
+ if (locale) {
+ return locale;
+ }
+ key = [key];
+ }
+
+ return chooseLocale(key);
+ };
+
+ // compare moment object
+ moment.isMoment = function (obj) {
+ return obj instanceof Moment ||
+ (obj != null && hasOwnProp(obj, '_isAMomentObject'));
+ };
+
+ // for typechecking Duration objects
+ moment.isDuration = function (obj) {
+ return obj instanceof Duration;
+ };
+
+ for (i = lists.length - 1; i >= 0; --i) {
+ makeList(lists[i]);
+ }
+
+ moment.normalizeUnits = function (units) {
+ return normalizeUnits(units);
+ };
+
+ moment.invalid = function (flags) {
+ var m = moment.utc(NaN);
+ if (flags != null) {
+ extend(m._pf, flags);
+ }
+ else {
+ m._pf.userInvalidated = true;
+ }
+
+ return m;
+ };
+
+ moment.parseZone = function () {
+ return moment.apply(null, arguments).parseZone();
+ };
+
+ moment.parseTwoDigitYear = function (input) {
+ return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
+ };
+
+ moment.isDate = isDate;
+
+ /************************************
+ Moment Prototype
+ ************************************/
+
+
+ extend(moment.fn = Moment.prototype, {
+
+ clone : function () {
+ return moment(this);
+ },
+
+ valueOf : function () {
+ return +this._d - ((this._offset || 0) * 60000);
+ },
+
+ unix : function () {
+ return Math.floor(+this / 1000);
+ },
+
+ toString : function () {
+ return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
+ },
+
+ toDate : function () {
+ return this._offset ? new Date(+this) : this._d;
+ },
+
+ toISOString : function () {
+ var m = moment(this).utc();
+ if (0 < m.year() && m.year() <= 9999) {
+ if ('function' === typeof Date.prototype.toISOString) {
+ // native implementation is ~50x faster, use it when we can
+ return this.toDate().toISOString();
+ } else {
+ return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
+ }
+ } else {
+ return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
+ }
+ },
+
+ toArray : function () {
+ var m = this;
+ return [
+ m.year(),
+ m.month(),
+ m.date(),
+ m.hours(),
+ m.minutes(),
+ m.seconds(),
+ m.milliseconds()
+ ];
+ },
+
+ isValid : function () {
+ return isValid(this);
+ },
+
+ isDSTShifted : function () {
+ if (this._a) {
+ return this.isValid() && compareArrays(this._a, (this._isUTC ? moment.utc(this._a) : moment(this._a)).toArray()) > 0;
+ }
+
+ return false;
+ },
+
+ parsingFlags : function () {
+ return extend({}, this._pf);
+ },
+
+ invalidAt: function () {
+ return this._pf.overflow;
+ },
+
+ utc : function (keepLocalTime) {
+ return this.utcOffset(0, keepLocalTime);
+ },
+
+ local : function (keepLocalTime) {
+ if (this._isUTC) {
+ this.utcOffset(0, keepLocalTime);
+ this._isUTC = false;
+
+ if (keepLocalTime) {
+ this.subtract(this._dateUtcOffset(), 'm');
+ }
+ }
+ return this;
+ },
+
+ format : function (inputString) {
+ var output = formatMoment(this, inputString || moment.defaultFormat);
+ return this.localeData().postformat(output);
+ },
+
+ add : createAdder(1, 'add'),
+
+ subtract : createAdder(-1, 'subtract'),
+
+ diff : function (input, units, asFloat) {
+ var that = makeAs(input, this),
+ zoneDiff = (that.utcOffset() - this.utcOffset()) * 6e4,
+ anchor, diff, output, daysAdjust;
+
+ units = normalizeUnits(units);
+
+ if (units === 'year' || units === 'month' || units === 'quarter') {
+ output = monthDiff(this, that);
+ if (units === 'quarter') {
+ output = output / 3;
+ } else if (units === 'year') {
+ output = output / 12;
+ }
+ } else {
+ diff = this - that;
+ output = units === 'second' ? diff / 1e3 : // 1000
+ units === 'minute' ? diff / 6e4 : // 1000 * 60
+ units === 'hour' ? diff / 36e5 : // 1000 * 60 * 60
+ units === 'day' ? (diff - zoneDiff) / 864e5 : // 1000 * 60 * 60 * 24, negate dst
+ units === 'week' ? (diff - zoneDiff) / 6048e5 : // 1000 * 60 * 60 * 24 * 7, negate dst
+ diff;
+ }
+ return asFloat ? output : absRound(output);
+ },
+
+ from : function (time, withoutSuffix) {
+ return moment.duration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix);
+ },
+
+ fromNow : function (withoutSuffix) {
+ return this.from(moment(), withoutSuffix);
+ },
+
+ calendar : function (time) {
+ // We want to compare the start of today, vs this.
+ // Getting start-of-today depends on whether we're locat/utc/offset
+ // or not.
+ var now = time || moment(),
+ sod = makeAs(now, this).startOf('day'),
+ diff = this.diff(sod, 'days', true),
+ format = diff < -6 ? 'sameElse' :
+ diff < -1 ? 'lastWeek' :
+ diff < 0 ? 'lastDay' :
+ diff < 1 ? 'sameDay' :
+ diff < 2 ? 'nextDay' :
+ diff < 7 ? 'nextWeek' : 'sameElse';
+ return this.format(this.localeData().calendar(format, this, moment(now)));
+ },
+
+ isLeapYear : function () {
+ return isLeapYear(this.year());
+ },
+
+ isDST : function () {
+ return (this.utcOffset() > this.clone().month(0).utcOffset() ||
+ this.utcOffset() > this.clone().month(5).utcOffset());
+ },
+
+ day : function (input) {
+ var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
+ if (input != null) {
+ input = parseWeekday(input, this.localeData());
+ return this.add(input - day, 'd');
+ } else {
+ return day;
+ }
+ },
+
+ month : makeAccessor('Month', true),
+
+ startOf : function (units) {
+ units = normalizeUnits(units);
+ // the following switch intentionally omits break keywords
+ // to utilize falling through the cases.
+ switch (units) {
+ case 'year':
+ this.month(0);
+ /* falls through */
+ case 'quarter':
+ case 'month':
+ this.date(1);
+ /* falls through */
+ case 'week':
+ case 'isoWeek':
+ case 'day':
+ this.hours(0);
+ /* falls through */
+ case 'hour':
+ this.minutes(0);
+ /* falls through */
+ case 'minute':
+ this.seconds(0);
+ /* falls through */
+ case 'second':
+ this.milliseconds(0);
+ /* falls through */
+ }
+
+ // weeks are a special case
+ if (units === 'week') {
+ this.weekday(0);
+ } else if (units === 'isoWeek') {
+ this.isoWeekday(1);
+ }
+
+ // quarters are also special
+ if (units === 'quarter') {
+ this.month(Math.floor(this.month() / 3) * 3);
+ }
+
+ return this;
+ },
+
+ endOf: function (units) {
+ units = normalizeUnits(units);
+ if (units === undefined || units === 'millisecond') {
+ return this;
+ }
+ return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
+ },
+
+ isAfter: function (input, units) {
+ var inputMs;
+ units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');
+ if (units === 'millisecond') {
+ input = moment.isMoment(input) ? input : moment(input);
+ return +this > +input;
+ } else {
+ inputMs = moment.isMoment(input) ? +input : +moment(input);
+ return inputMs < +this.clone().startOf(units);
+ }
+ },
+
+ isBefore: function (input, units) {
+ var inputMs;
+ units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');
+ if (units === 'millisecond') {
+ input = moment.isMoment(input) ? input : moment(input);
+ return +this < +input;
+ } else {
+ inputMs = moment.isMoment(input) ? +input : +moment(input);
+ return +this.clone().endOf(units) < inputMs;
+ }
+ },
+
+ isBetween: function (from, to, units) {
+ return this.isAfter(from, units) && this.isBefore(to, units);
+ },
+
+ isSame: function (input, units) {
+ var inputMs;
+ units = normalizeUnits(units || 'millisecond');
+ if (units === 'millisecond') {
+ input = moment.isMoment(input) ? input : moment(input);
+ return +this === +input;
+ } else {
+ inputMs = +moment(input);
+ return +(this.clone().startOf(units)) <= inputMs && inputMs <= +(this.clone().endOf(units));
+ }
+ },
+
+ min: deprecate(
+ 'moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548',
+ function (other) {
+ other = moment.apply(null, arguments);
+ return other < this ? this : other;
+ }
+ ),
+
+ max: deprecate(
+ 'moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548',
+ function (other) {
+ other = moment.apply(null, arguments);
+ return other > this ? this : other;
+ }
+ ),
+
+ zone : deprecate(
+ 'moment().zone is deprecated, use moment().utcOffset instead. ' +
+ 'https://github.com/moment/moment/issues/1779',
+ function (input, keepLocalTime) {
+ if (input != null) {
+ if (typeof input !== 'string') {
+ input = -input;
+ }
+
+ this.utcOffset(input, keepLocalTime);
+
+ return this;
+ } else {
+ return -this.utcOffset();
+ }
+ }
+ ),
+
+ // keepLocalTime = true means only change the timezone, without
+ // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
+ // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
+ // +0200, so we adjust the time as needed, to be valid.
+ //
+ // Keeping the time actually adds/subtracts (one hour)
+ // from the actual represented time. That is why we call updateOffset
+ // a second time. In case it wants us to change the offset again
+ // _changeInProgress == true case, then we have to adjust, because
+ // there is no such time in the given timezone.
+ utcOffset : function (input, keepLocalTime) {
+ var offset = this._offset || 0,
+ localAdjust;
+ if (input != null) {
+ if (typeof input === 'string') {
+ input = utcOffsetFromString(input);
+ }
+ if (Math.abs(input) < 16) {
+ input = input * 60;
+ }
+ if (!this._isUTC && keepLocalTime) {
+ localAdjust = this._dateUtcOffset();
+ }
+ this._offset = input;
+ this._isUTC = true;
+ if (localAdjust != null) {
+ this.add(localAdjust, 'm');
+ }
+ if (offset !== input) {
+ if (!keepLocalTime || this._changeInProgress) {
+ addOrSubtractDurationFromMoment(this,
+ moment.duration(input - offset, 'm'), 1, false);
+ } else if (!this._changeInProgress) {
+ this._changeInProgress = true;
+ moment.updateOffset(this, true);
+ this._changeInProgress = null;
+ }
+ }
+
+ return this;
+ } else {
+ return this._isUTC ? offset : this._dateUtcOffset();
+ }
+ },
+
+ isLocal : function () {
+ return !this._isUTC;
+ },
+
+ isUtcOffset : function () {
+ return this._isUTC;
+ },
+
+ isUtc : function () {
+ return this._isUTC && this._offset === 0;
+ },
+
+ zoneAbbr : function () {
+ return this._isUTC ? 'UTC' : '';
+ },
+
+ zoneName : function () {
+ return this._isUTC ? 'Coordinated Universal Time' : '';
+ },
+
+ parseZone : function () {
+ if (this._tzm) {
+ this.utcOffset(this._tzm);
+ } else if (typeof this._i === 'string') {
+ this.utcOffset(utcOffsetFromString(this._i));
+ }
+ return this;
+ },
+
+ hasAlignedHourOffset : function (input) {
+ if (!input) {
+ input = 0;
+ }
+ else {
+ input = moment(input).utcOffset();
+ }
+
+ return (this.utcOffset() - input) % 60 === 0;
+ },
+
+ daysInMonth : function () {
+ return daysInMonth(this.year(), this.month());
+ },
+
+ dayOfYear : function (input) {
+ var dayOfYear = round((moment(this).startOf('day') - moment(this).startOf('year')) / 864e5) + 1;
+ return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');
+ },
+
+ quarter : function (input) {
+ return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
+ },
+
+ weekYear : function (input) {
+ var year = weekOfYear(this, this.localeData()._week.dow, this.localeData()._week.doy).year;
+ return input == null ? year : this.add((input - year), 'y');
+ },
+
+ isoWeekYear : function (input) {
+ var year = weekOfYear(this, 1, 4).year;
+ return input == null ? year : this.add((input - year), 'y');
+ },
+
+ week : function (input) {
+ var week = this.localeData().week(this);
+ return input == null ? week : this.add((input - week) * 7, 'd');
+ },
+
+ isoWeek : function (input) {
+ var week = weekOfYear(this, 1, 4).week;
+ return input == null ? week : this.add((input - week) * 7, 'd');
+ },
+
+ weekday : function (input) {
+ var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
+ return input == null ? weekday : this.add(input - weekday, 'd');
+ },
+
+ isoWeekday : function (input) {
+ // behaves the same as moment#day except
+ // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
+ // as a setter, sunday should belong to the previous week.
+ return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7);
+ },
+
+ isoWeeksInYear : function () {
+ return weeksInYear(this.year(), 1, 4);
+ },
+
+ weeksInYear : function () {
+ var weekInfo = this.localeData()._week;
+ return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
+ },
+
+ get : function (units) {
+ units = normalizeUnits(units);
+ return this[units]();
+ },
+
+ set : function (units, value) {
+ var unit;
+ if (typeof units === 'object') {
+ for (unit in units) {
+ this.set(unit, units[unit]);
+ }
+ }
+ else {
+ units = normalizeUnits(units);
+ if (typeof this[units] === 'function') {
+ this[units](value);
+ }
+ }
+ return this;
+ },
+
+ // If passed a locale key, it will set the locale for this
+ // instance. Otherwise, it will return the locale configuration
+ // variables for this instance.
+ locale : function (key) {
+ var newLocaleData;
+
+ if (key === undefined) {
+ return this._locale._abbr;
+ } else {
+ newLocaleData = moment.localeData(key);
+ if (newLocaleData != null) {
+ this._locale = newLocaleData;
+ }
+ return this;
+ }
+ },
+
+ lang : deprecate(
+ 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
+ function (key) {
+ if (key === undefined) {
+ return this.localeData();
+ } else {
+ return this.locale(key);
+ }
+ }
+ ),
+
+ localeData : function () {
+ return this._locale;
+ },
+
+ _dateUtcOffset : function () {
+ // On Firefox.24 Date#getTimezoneOffset returns a floating point.
+ // https://github.com/moment/moment/pull/1871
+ return -Math.round(this._d.getTimezoneOffset() / 15) * 15;
+ }
+
+ });
+
+ function rawMonthSetter(mom, value) {
+ var dayOfMonth;
+
+ // TODO: Move this out of here!
+ if (typeof value === 'string') {
+ value = mom.localeData().monthsParse(value);
+ // TODO: Another silent failure?
+ if (typeof value !== 'number') {
+ return mom;
+ }
+ }
+
+ dayOfMonth = Math.min(mom.date(),
+ daysInMonth(mom.year(), value));
+ mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
+ return mom;
+ }
+
+ function rawGetter(mom, unit) {
+ return mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]();
+ }
+
+ function rawSetter(mom, unit, value) {
+ if (unit === 'Month') {
+ return rawMonthSetter(mom, value);
+ } else {
+ return mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
+ }
+ }
+
+ function makeAccessor(unit, keepTime) {
+ return function (value) {
+ if (value != null) {
+ rawSetter(this, unit, value);
+ moment.updateOffset(this, keepTime);
+ return this;
+ } else {
+ return rawGetter(this, unit);
+ }
+ };
+ }
+
+ moment.fn.millisecond = moment.fn.milliseconds = makeAccessor('Milliseconds', false);
+ moment.fn.second = moment.fn.seconds = makeAccessor('Seconds', false);
+ moment.fn.minute = moment.fn.minutes = makeAccessor('Minutes', false);
+ // Setting the hour should keep the time, because the user explicitly
+ // specified which hour he wants. So trying to maintain the same hour (in
+ // a new timezone) makes sense. Adding/subtracting hours does not follow
+ // this rule.
+ moment.fn.hour = moment.fn.hours = makeAccessor('Hours', true);
+ // moment.fn.month is defined separately
+ moment.fn.date = makeAccessor('Date', true);
+ moment.fn.dates = deprecate('dates accessor is deprecated. Use date instead.', makeAccessor('Date', true));
+ moment.fn.year = makeAccessor('FullYear', true);
+ moment.fn.years = deprecate('years accessor is deprecated. Use year instead.', makeAccessor('FullYear', true));
+
+ // add plural methods
+ moment.fn.days = moment.fn.day;
+ moment.fn.months = moment.fn.month;
+ moment.fn.weeks = moment.fn.week;
+ moment.fn.isoWeeks = moment.fn.isoWeek;
+ moment.fn.quarters = moment.fn.quarter;
+
+ // add aliased format methods
+ moment.fn.toJSON = moment.fn.toISOString;
+
+ // alias isUtc for dev-friendliness
+ moment.fn.isUTC = moment.fn.isUtc;
+
+ /************************************
+ Duration Prototype
+ ************************************/
+
+
+ function daysToYears (days) {
+ // 400 years have 146097 days (taking into account leap year rules)
+ return days * 400 / 146097;
+ }
+
+ function yearsToDays (years) {
+ // years * 365 + absRound(years / 4) -
+ // absRound(years / 100) + absRound(years / 400);
+ return years * 146097 / 400;
+ }
+
+ extend(moment.duration.fn = Duration.prototype, {
+
+ _bubble : function () {
+ var milliseconds = this._milliseconds,
+ days = this._days,
+ months = this._months,
+ data = this._data,
+ seconds, minutes, hours, years = 0;
+
+ // The following code bubbles up values, see the tests for
+ // examples of what that means.
+ data.milliseconds = milliseconds % 1000;
+
+ seconds = absRound(milliseconds / 1000);
+ data.seconds = seconds % 60;
+
+ minutes = absRound(seconds / 60);
+ data.minutes = minutes % 60;
+
+ hours = absRound(minutes / 60);
+ data.hours = hours % 24;
+
+ days += absRound(hours / 24);
+
+ // Accurately convert days to years, assume start from year 0.
+ years = absRound(daysToYears(days));
+ days -= absRound(yearsToDays(years));
+
+ // 30 days to a month
+ // TODO (iskren): Use anchor date (like 1st Jan) to compute this.
+ months += absRound(days / 30);
+ days %= 30;
+
+ // 12 months -> 1 year
+ years += absRound(months / 12);
+ months %= 12;
+
+ data.days = days;
+ data.months = months;
+ data.years = years;
+ },
+
+ abs : function () {
+ this._milliseconds = Math.abs(this._milliseconds);
+ this._days = Math.abs(this._days);
+ this._months = Math.abs(this._months);
+
+ this._data.milliseconds = Math.abs(this._data.milliseconds);
+ this._data.seconds = Math.abs(this._data.seconds);
+ this._data.minutes = Math.abs(this._data.minutes);
+ this._data.hours = Math.abs(this._data.hours);
+ this._data.months = Math.abs(this._data.months);
+ this._data.years = Math.abs(this._data.years);
+
+ return this;
+ },
+
+ weeks : function () {
+ return absRound(this.days() / 7);
+ },
+
+ valueOf : function () {
+ return this._milliseconds +
+ this._days * 864e5 +
+ (this._months % 12) * 2592e6 +
+ toInt(this._months / 12) * 31536e6;
+ },
+
+ humanize : function (withSuffix) {
+ var output = relativeTime(this, !withSuffix, this.localeData());
+
+ if (withSuffix) {
+ output = this.localeData().pastFuture(+this, output);
+ }
+
+ return this.localeData().postformat(output);
+ },
+
+ add : function (input, val) {
+ // supports only 2.0-style add(1, 's') or add(moment)
+ var dur = moment.duration(input, val);
+
+ this._milliseconds += dur._milliseconds;
+ this._days += dur._days;
+ this._months += dur._months;
+
+ this._bubble();
+
+ return this;
+ },
+
+ subtract : function (input, val) {
+ var dur = moment.duration(input, val);
+
+ this._milliseconds -= dur._milliseconds;
+ this._days -= dur._days;
+ this._months -= dur._months;
+
+ this._bubble();
+
+ return this;
+ },
+
+ get : function (units) {
+ units = normalizeUnits(units);
+ return this[units.toLowerCase() + 's']();
+ },
+
+ as : function (units) {
+ var days, months;
+ units = normalizeUnits(units);
+
+ if (units === 'month' || units === 'year') {
+ days = this._days + this._milliseconds / 864e5;
+ months = this._months + daysToYears(days) * 12;
+ return units === 'month' ? months : months / 12;
+ } else {
+ // handle milliseconds separately because of floating point math errors (issue #1867)
+ days = this._days + Math.round(yearsToDays(this._months / 12));
+ switch (units) {
+ case 'week': return days / 7 + this._milliseconds / 6048e5;
+ case 'day': return days + this._milliseconds / 864e5;
+ case 'hour': return days * 24 + this._milliseconds / 36e5;
+ case 'minute': return days * 24 * 60 + this._milliseconds / 6e4;
+ case 'second': return days * 24 * 60 * 60 + this._milliseconds / 1000;
+ // Math.floor prevents floating point math errors here
+ case 'millisecond': return Math.floor(days * 24 * 60 * 60 * 1000) + this._milliseconds;
+ default: throw new Error('Unknown unit ' + units);
+ }
+ }
+ },
+
+ lang : moment.fn.lang,
+ locale : moment.fn.locale,
+
+ toIsoString : deprecate(
+ 'toIsoString() is deprecated. Please use toISOString() instead ' +
+ '(notice the capitals)',
+ function () {
+ return this.toISOString();
+ }
+ ),
+
+ toISOString : function () {
+ // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
+ var years = Math.abs(this.years()),
+ months = Math.abs(this.months()),
+ days = Math.abs(this.days()),
+ hours = Math.abs(this.hours()),
+ minutes = Math.abs(this.minutes()),
+ seconds = Math.abs(this.seconds() + this.milliseconds() / 1000);
+
+ if (!this.asSeconds()) {
+ // this is the same as C#'s (Noda) and python (isodate)...
+ // but not other JS (goog.date)
+ return 'P0D';
+ }
+
+ return (this.asSeconds() < 0 ? '-' : '') +
+ 'P' +
+ (years ? years + 'Y' : '') +
+ (months ? months + 'M' : '') +
+ (days ? days + 'D' : '') +
+ ((hours || minutes || seconds) ? 'T' : '') +
+ (hours ? hours + 'H' : '') +
+ (minutes ? minutes + 'M' : '') +
+ (seconds ? seconds + 'S' : '');
+ },
+
+ localeData : function () {
+ return this._locale;
+ },
+
+ toJSON : function () {
+ return this.toISOString();
+ }
+ });
+
+ moment.duration.fn.toString = moment.duration.fn.toISOString;
+
+ function makeDurationGetter(name) {
+ moment.duration.fn[name] = function () {
+ return this._data[name];
+ };
+ }
+
+ for (i in unitMillisecondFactors) {
+ if (hasOwnProp(unitMillisecondFactors, i)) {
+ makeDurationGetter(i.toLowerCase());
+ }
+ }
+
+ moment.duration.fn.asMilliseconds = function () {
+ return this.as('ms');
+ };
+ moment.duration.fn.asSeconds = function () {
+ return this.as('s');
+ };
+ moment.duration.fn.asMinutes = function () {
+ return this.as('m');
+ };
+ moment.duration.fn.asHours = function () {
+ return this.as('h');
+ };
+ moment.duration.fn.asDays = function () {
+ return this.as('d');
+ };
+ moment.duration.fn.asWeeks = function () {
+ return this.as('weeks');
+ };
+ moment.duration.fn.asMonths = function () {
+ return this.as('M');
+ };
+ moment.duration.fn.asYears = function () {
+ return this.as('y');
+ };
+
+ /************************************
+ Default Locale
+ ************************************/
+
+
+ // Set default locale, other locale will inherit from English.
+ moment.locale('en', {
+ ordinalParse: /\d{1,2}(th|st|nd|rd)/,
+ ordinal : function (number) {
+ var b = number % 10,
+ output = (toInt(number % 100 / 10) === 1) ? 'th' :
+ (b === 1) ? 'st' :
+ (b === 2) ? 'nd' :
+ (b === 3) ? 'rd' : 'th';
+ return number + output;
+ }
+ });
+
+ /* EMBED_LOCALES */
+
+ /************************************
+ Exposing Moment
+ ************************************/
+
+ function makeGlobal(shouldDeprecate) {
+ /*global ender:false */
+ if (typeof ender !== 'undefined') {
+ return;
+ }
+ oldGlobalMoment = globalScope.moment;
+ if (shouldDeprecate) {
+ globalScope.moment = deprecate(
+ 'Accessing Moment through the global scope is ' +
+ 'deprecated, and will be removed in an upcoming ' +
+ 'release.',
+ moment);
+ } else {
+ globalScope.moment = moment;
+ }
+ }
+
+ // CommonJS module is defined
+ if (hasModule) {
+ module.exports = moment;
+ } else if (typeof define === 'function' && define.amd) {
+ define(function (require, exports, module) {
+ if (module.config && module.config() && module.config().noGlobal === true) {
+ // release the global variable
+ globalScope.moment = oldGlobalMoment;
+ }
+
+ return moment;
+ });
+ makeGlobal(true);
+ } else {
+ makeGlobal();
+ }
+}).call(this);
\ No newline at end of file
diff --git a/public/js/lib/moment/nextTuesday.js b/public/js/lib/moment/nextTuesday.js
new file mode 100644
index 0000000000..15cd8068a6
--- /dev/null
+++ b/public/js/lib/moment/nextTuesday.js
@@ -0,0 +1,16 @@
+/**
+ * Created by jason on 2/11/15.
+ */
+
+function nextSession () {
+ var next = 'Our next session will be ';
+ var today = moment().day(moment().day());
+ if (today > moment().day(2)) {
+ next += moment().day(9).format('dddd, MMMM Do YYYY') + ' at 9PM EST!';
+ } else {
+ next += moment().day('Tuesday').format('dddd, MMMM Do YYYY') + ' at 9PM EST!';
+ }
+ return next;
+
+
+}
diff --git a/public/js/main.js b/public/js/main.js
index 9b9eea7784..7976c4f6d1 100644
--- a/public/js/main.js
+++ b/public/js/main.js
@@ -66,6 +66,9 @@ $(document).ready(function() {
completedBonfire(didCompleteWith, bonfireSolution, thisBonfireHash);
});
+ $('#completed-courseware').on('click', function() {
+ $('#complete-courseware-dialog').modal('show');
+ });
$('#complete-bonfire-dialog').on('hidden.bs.modal', function() {
editor.focus();
@@ -74,7 +77,7 @@ $(document).ready(function() {
$('#complete-courseware-dialog').on('hidden.bs.modal', function() {
editor.focus();
});
- $('.next-courseware-button').on('click', function() {
+ $('#next-courseware-button').on('click', function() {
if ($('.signup-btn-nav').length < 1) {
$.post(
'/completed-courseware',
@@ -164,7 +167,7 @@ profileValidation.controller('doneWithFirst100HoursFormController', ['$scope',
}
]);
-profileValidation.directive('uniqueUsername', function($http) {
+profileValidation.directive('uniqueUsername',['$http',function($http) {
return {
restrict: 'A',
require: 'ngModel',
@@ -183,9 +186,9 @@ profileValidation.directive('uniqueUsername', function($http) {
});
}
}
-});
+}]);
-profileValidation.directive('existingUsername', function($http) {
+profileValidation.directive('existingUsername', ['$http', function($http) {
return {
restrict: 'A',
require: 'ngModel',
@@ -194,27 +197,26 @@ profileValidation.directive('existingUsername', function($http) {
if (element.val().length > 0) {
ngModel.$setValidity('exists', false);
} else {
+ element.removeClass('ng-dirty');
ngModel.$setPristine();
}
if (element.val()) {
- $http.get("/api/checkExistingUsername/" + element.val()).success(function (data) {
- if (element.val() == scope.existingUsername) {
- ngModel.$setValidity('exists', false);
- } else if (data) {
- ngModel.$setValidity('exists', true);
- }
+ $http
+ .get("/api/checkExistingUsername/" + element.val())
+ .success(function (data) {
+ ngModel.$setValidity('exists', data);
});
}
});
}
}
-});
+}]);
-profileValidation.directive('uniqueEmail', function($http) {
+profileValidation.directive('uniqueEmail', ['$http', function($http) {
return {
restrict: 'A',
require: 'ngModel',
- link: function (scope, element, attrs, ngModel) {
+ link: function getUnique (scope, element, attrs, ngModel) {
element.bind("keyup", function (event) {
ngModel.$setValidity('unique', true);
if (element.val()) {
@@ -229,4 +231,4 @@ profileValidation.directive('uniqueEmail', function($http) {
});
}
}
-});
\ No newline at end of file
+}]);
\ No newline at end of file
diff --git a/seed_data/bonfires.json b/seed_data/bonfires.json
index 7508492dff..9af6ce4be4 100644
--- a/seed_data/bonfires.json
+++ b/seed_data/bonfires.json
@@ -1,38 +1,37 @@
[
{
- "_id" : "ad7123c8c441eddfaeb5bdef",
+ "_id": "ad7123c8c441eddfaeb5bdef",
"name": "Meet Bonfire",
"difficulty": "0",
"description": [
"Click the button below for further instructions.",
"Your goal is to fix the failing test.",
"First, run all the tests by clicking \"Run code\" or by pressing Control + Enter",
- "The failing test is in red. Fix the code so that all tests pass. Then you can move on to the next Bonfire."
+ "The failing test is in red. Fix the code so that all tests pass. Then you can move on to the next Bonfire.",
+ "Make this function return true no matter what."
],
"tests": [
- "expect(meetBonfire(\"test\")).to.be.a(\"boolean\");",
- "expect(meetBonfire(\"test\")).to.be.true;"
+ "expect(meetBonfire()).to.be.a(\"boolean\");",
+ "expect(meetBonfire()).to.be.true;"
],
- "challengeSeed": "function meetBonfire(argument) {\n // Good luck!\n console.log(\"you can read this function's argument in the developer tools\", argument);\n\nreturn false;\n}\n\n",
- "challengeEntryPoint": "meetBonfire(\"You can do this!\");"
+ "challengeSeed": "function meetBonfire(argument) {\n // Good luck!\n console.log(\"you can read this function's argument in the developer tools\", argument);\n\n return false;\n}\n\n\n\nmeetBonfire(\"You can do this!\");"
},
{
- "_id": "a202eed8fc186c8434cb6d61",
- "name": "Reverse a String",
- "difficulty": "1.01",
- "tests": [
- "expect(reverseString('hello')).to.be.a('String');",
- "expect(reverseString('hello')).to.equal('olleh');",
- "expect(reverseString('Howdy')).to.equal('ydwoH');",
- "expect(reverseString('Greetings from Earth')).to.equal('htraE morf sgniteerG');"
- ],
- "description": [
- "Reverse the provided string.",
- "You may need to turn the string into an array before you can reverse it.",
- "Your result must be a string."
- ],
- "challengeEntryPoint": "reverseString('hello');",
- "challengeSeed": "function reverseString(str) {\n return str;\r\n}"
+ "_id": "a202eed8fc186c8434cb6d61",
+ "name": "Reverse a String",
+ "difficulty": "1.01",
+ "tests": [
+ "expect(reverseString('hello')).to.be.a('String');",
+ "expect(reverseString('hello')).to.equal('olleh');",
+ "expect(reverseString('Howdy')).to.equal('ydwoH');",
+ "expect(reverseString('Greetings from Earth')).to.equal('htraE morf sgniteerG');"
+ ],
+ "description": [
+ "Reverse the provided string.",
+ "You may need to turn the string into an array before you can reverse it.",
+ "Your result must be a string."
+ ],
+ "challengeSeed": "function reverseString(str) {\n return str;\r\n}\n\nreverseString('hello');"
},
{
"_id": "a302f7aae1aa3152a5b413bc",
@@ -50,19 +49,17 @@
"Factorials are often represented with the shorthand notation n!",
"For example: 5! = 1 * 2 * 3 * 4 * 5 = 120f"
],
- "challengeSeed": "function factorialize(num) {\n return num;\r\n}",
- "challengeEntryPoint": "factorialize(5);"
+ "challengeSeed": "function factorialize(num) {\n return num;\r\n}\n\nfactorialize(5);"
},
{
- "_id" : "aaa48de84e1ecc7c742e1124",
+ "_id": "aaa48de84e1ecc7c742e1124",
"name": "Check for Palindromes",
"difficulty": "1.03",
"description": [
- "Return 'true' if a given string is a palindrome.",
+ "Return true if the given string is a palindrome. Otherwise, return false.",
"A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing.",
"You'll need to remove punctuation and turn everything lower case in order to check for palindromes.",
- "We'll pass strings with varying formats, such as \"racecar\", \"RaceCar\", and \"race CAR\" among others.",
- "Return true if the string is a palindrome. Otherwise, return false."
+ "We'll pass strings with varying formats, such as \"racecar\", \"RaceCar\", and \"race CAR\" among others."
],
"tests": [
"expect(palindrome(\"eye\")).to.be.a(\"boolean\");",
@@ -73,8 +70,7 @@
"assert.deepEqual(palindrome(\"never odd or even\"), true);",
"assert.deepEqual(palindrome(\"nope\"), false);"
],
- "challengeSeed": "function palindrome(str) {\n // Good luck!\n return true;\n}\n\n",
- "challengeEntryPoint": "palindrome(\"eye\");"
+ "challengeSeed": "function palindrome(str) {\n // Good luck!\n return true;\n}\n\n\n\npalindrome(\"eye\");"
},
{
"_id": "a26cbbe9ad8655a977e1ceb5",
@@ -84,8 +80,7 @@
"Return the length of the longest word in the provided sentence.",
"Your response should be a number."
],
- "challengeEntryPoint": "findLongestWord('The quick brown fox jumped over the lazy dog');",
- "challengeSeed": "function findLongestWord(str) {\n return str.length;\r\n}",
+ "challengeSeed": "function findLongestWord(str) {\n return str.length;\r\n}\n\nfindLongestWord('The quick brown fox jumped over the lazy dog');",
"tests": [
"expect(findLongestWord('The quick brown fox jumped over the lazy dog')).to.be.a('Number');",
"expect(findLongestWord('The quick brown fox jumped over the lazy dog')).to.equal(6);",
@@ -102,8 +97,7 @@
"Return the provided string with the first letter of each word capitalized.",
"For the purpose of this exercise, you should also capitalize connecting words like 'the' and 'of'."
],
- "challengeEntryPoint": "titleCase(\"I'm a little tea pot\");",
- "challengeSeed": "function titleCase(str) {\n return str;\r\n}",
+ "challengeSeed": "function titleCase(str) {\n return str;\r\n}\n\ntitleCase(\"I'm a little tea pot\");",
"tests": [
"expect(titleCase(\"I'm a little tea pot\")).to.be.a('String');",
"expect(titleCase(\"I'm a little tea pot\")).to.equal(\"I'm A Little Tea Pot\");",
@@ -117,20 +111,145 @@
"difficulty": "1.06",
"description": [
"Return an array consisting of the largest numbers in the provided array. The array will contain 4 sub-arrays.",
- "Remember, you an iterate through an array with a simple for loop, and access each member with array syntax arr[i] .",
+ "Remember, you can iterate through an array with a simple for loop, and access each member with array syntax arr[i] .",
"If you are writing your own Chai.js tests, be sure to use a deep equal statement instead of an equal statement when comparing arrays."
],
- "challengeEntryPoint": "largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);",
- "challengeSeed": "function largestOfFour(arr) {\n // You can do this!\r\n return arr;\r\n}",
+ "challengeSeed": "function largestOfFour(arr) {\n // You can do this!\r\n return arr;\r\n}\n\nlargestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);",
"tests": [
"expect(largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]])).to.be.a('array');",
"(largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]])).should.eql([5,27,39,1001]);",
"assert(largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]).should.eql([9,35,97,1000000]));"
]
},
+ {
+ "_id": "acda2fb1324d9b0fa741e6b5",
+ "name": "Confirm the Ending",
+ "difficulty": "1.07",
+ "description": [
+ "Check if a string (first argument) ends with the given target string (second argument)."
+ ],
-
-
+ "challengeSeed": "function end(str, target) {\n // \"Never give up and good luck will find you.\"\r\n // -- Falcor\r\n return str;\r\n}\n\nend('Bastian', 'n');",
+ "tests": [
+ "assert.strictEqual(end('Bastian', 'n'), true, 'should equal true if target equals end of string');",
+ "assert.strictEqual(end('He has to give me a new name', 'name'), true, 'should equal true if target equals end of string');",
+ "assert.strictEqual(end('If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing', 'mountain'), false, 'should equal false if target does not equal end of string');"
+ ]
+ },
+ {
+ "_id": "afcc8d540bea9ea2669306b6",
+ "name": "Repeat a string repeat a string",
+ "difficulty": "1.08",
+ "description": [
+ "Repeat a given string (first argument) n times (second argument). Return an empty string if n is a negative number."
+ ],
+ "challengeSeed": "function repeat(str, num) {\n // repeat after me\r\n return str;\r\n}\n\nrepeat('abc', 3);",
+ "tests": [
+ "assert.strictEqual(repeat('*', 3), '***', 'should repeat a string n times');",
+ "assert.strictEqual(repeat('abc', 3), 'abcabcabc', 'should repeat a string n times');",
+ "assert.strictEqual(repeat('abc', -2), '', 'should return an empty string for negative numbers');"
+ ]
+ },
+ {
+ "_id": "ac6993d51946422351508a41",
+ "name": "Truncate a string",
+ "difficulty": "1.09",
+ "description": [
+ "Truncate a string (first argument) if it is longer than the given maximum string length (second argument). Return the truncated string with a '...' ending.",
+ "Note that the three dots at the end add to the string length."
+ ],
+ "challengeSeed":"function truncate(str, num) {\n // Clear out that junk in your trunk\r\n return str;\r\n}\n\ntruncate('A-tisket a-tasket A green and yellow basket', 11);",
+ "tests": [
+ "expect(truncate('A-tisket a-tasket A green and yellow basket', 11)).to.eqls('A-tisket...');",
+ "assert(truncate('A-tisket a-tasket A green and yellow basket', 'A-tisket a-tasket A green and yellow basket'.length) === 'A-tisket a-tasket A green and yellow basket', 'should not truncate if string is = length');",
+ "assert.strictEqual(truncate('A-tisket a-tasket A green and yellow basket', 'A-tisket a-tasket A green and yellow basket'.length + 2), 'A-tisket a-tasket A green and yellow basket', 'should not truncate if string is < length');"
+ ]
+ },
+ {
+ "_id": "a9bd25c716030ec90084d8a1",
+ "name": "Chunky Monkey",
+ "difficulty": "1.10",
+ "description": [
+ "Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a multidimensional array."
+ ],
+ "challengeSeed": "function chunk(arr, size) {\n // Break it up.\r\n return arr;\r\n}\n\nchunk(['a', 'b', 'c', 'd'], 2);",
+ "tests": [
+ "assert.deepEqual(chunk(['a', 'b', 'c', 'd'], 2), [['a', 'b'], ['c', 'd']], 'should return chunked arrays');",
+ "assert.deepEqual(chunk([0, 1, 2, 3, 4, 5], 3), [[0, 1, 2], [3, 4, 5]], 'should return chunked arrays');",
+ "assert.deepEqual(chunk([0, 1, 2, 3, 4, 5], 4), [[0, 1, 2, 3], [4, 5]], 'should return cthe last chunk as remaining elements');"
+ ]
+ },
+ {
+ "_id": "ab31c21b530c0dafa9e241ee",
+ "name": "Slasher Flick",
+ "difficulty": "1.11",
+ "description": [
+ "Return the remaining elements of an array after chopping off n elements from the head."
+ ],
+ "challengeSeed": "function slasher(arr, howMany) {\n // it doesn't allways pay to be first\r\n return arr;\r\n}\n\nslasher([1, 2, 3], 2);",
+ "tests": [
+ "assert.deepEqual(slasher([1, 2, 3], 2), [3], 'should drop the first two elements');",
+ "assert.deepEqual(slasher([1, 2, 3], 0), [1, 2, 3], 'should return all elements when n < 1');",
+ "assert.deepEqual(slasher([1, 2, 3], 9), [], 'should return an empty array when n >= array.length');"
+ ]
+ },
+ {
+ "_id": "adf08ec01beb4f99fc7a68f2",
+ "name": "Falsey Bouncer",
+ "difficulty": "1.50",
+ "description": [
+ "Remove all falsey values from an array.",
+ "Falsey values in javascript are false, null, 0, \"\", undefined, and NaN."
+ ],
+ "challengeSeed": "function bouncer(arr) {\n // Don't show a false ID to this bouncer.\r\n return arr;\r\n}\n\nbouncer([7, 'ate', '', false, 9]);",
+ "tests": [
+ "assert.deepEqual(bouncer([7, 'ate', '', false, 9]), [7, 'ate', 9], 'should remove falsey values');",
+ "assert.deepEqual(bouncer(['a', 'b', 'c']), ['a', 'b', 'c'], 'should return full array if no falsey elements');",
+ "assert.deepEqual(bouncer([false, null, 0]), [], 'should return empty array if all elements are falsey');"
+ ]
+ },
+ {
+ "_id":"a8e512fbe388ac2f9198f0fa",
+ "name":"Where art thou",
+ "difficulty":"1.55",
+ "description":[
+ "Make a function that looks through a list (first argument) and returns an array of all objects that have equivalent property values (second argument)."
+ ],
+ "challengeSeed":"function where(collection, source) {\n var arr = [];\r\n // What's in a name?\r\n return arr;\r\n}\n\nwhere([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });",
+ "tests":[
+ "assert.deepEqual(where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' }), [{ first: 'Tybalt', last: 'Capulet' }], 'should return an array of objects');",
+ "assert.deepEqual(where([{ 'a': 1 }, { 'a': 1 }, { 'a': 1, 'b': 2 }], { 'a': 1 }), [{ 'a': 1 }, { 'a': 1 }, { 'a': 1, 'b': 2 }], 'should return with multiples');"
+ ]
+ },
+ {
+ "_id":"a39963a4c10bc8b4d4f06d7e",
+ "name":"Seek and Destroy",
+ "difficulty":"1.60",
+ "description":[
+ "Remove all values (last argument(s)) from an array (first argument) and return as a new array."
+ ],
+ "challengeSeed": "function destroyer(arr) {\n // Remove all the values\r\n return arr;\r\n}\n\ndestroyer([1, 2, 3, 1, 2, 3], 2, 3);",
+ "tests": [
+ "assert.deepEqual(destroyer([1, 2, 3, 1, 2, 3], 2, 3), [1, 1], 'should remove correct values from an array');",
+ "assert.deepEqual(destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3), [1, 5, 1], 'should remove correct values from an array');"
+ ]
+ },
+ {
+ "_id": "a24c1a4622e3c05097f71d67",
+ "name": "Where do I belong",
+ "difficulty": "1.61",
+ "description": [
+ "Return the lowest index at which a value (second argument) should be inserted into a sorted array (first argument)."
+ ],
+ "challengeSeed": "function where(arr, num) {\n // Find my place in this sorted array.\r\n return num;\r\n}\n\nwhere([40, 60], 50);",
+ "tests": [
+ "var numbers = [10, 20, 30, 40, 50], num = 35;",
+ "var indexForNum = where(numbers, num);",
+ "assert.equal(indexForNum, 3, '35 should be inserted at index 3');",
+ "var indexFor30 = where(numbers, 30);",
+ "assert.equal(indexFor30, 2, '30 should be inserted at index 2');"
+ ]
+ },
{
"_id": "a3566b1109230028080c9345",
"name": "Sum All Numbers in a Range",
@@ -139,8 +258,7 @@
"We'll pass you an array of two numbers. Return the sum of those two numbers and all numbers between them.",
"The lowest number will not always come first."
],
- "challengeEntryPoint": "sumAll([1, 4]);",
- "challengeSeed": "function sumAll(arr) {\n return(1);\r\n}",
+ "challengeSeed": "function sumAll(arr) {\n return(1);\r\n}\n\nsumAll([1, 4]);",
"tests": [
"expect(sumAll([1, 4])).to.be.a('Number');",
"expect(sumAll([1, 4])).to.equal(10);",
@@ -150,14 +268,13 @@
]
},
{
- "_id": "d5de63ebea8dbee56860f4f2",
+ "_id": "a5de63ebea8dbee56860f4f2",
"name": "Diff Two Arrays",
"difficulty": "2.01",
"description": [
"Compare two arrays and return a new array with any items not found in both of the original arrays."
],
- "challengeEntryPoint": "diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);",
- "challengeSeed": "function diff(arr1, arr2) {\n var newArr = [];\r\n // Same, same; but different.\r\n return newArr;\r\n}",
+ "challengeSeed": "function diff(arr1, arr2) {\n var newArr = [];\r\n // Same, same; but different.\r\n return newArr;\r\n}\n\ndiff([1, 2, 3, 5], [1, 2, 3, 4, 5]);",
"tests": [
"expect(diff([1, 2, 3, 5], [1, 2, 3, 4, 5])).to.be.a('array');",
"assert.deepEqual(diff(['diorite', 'andesite', 'grass', 'dirt', 'pink wool', 'dead shrub'], ['diorite', 'andesite', 'grass', 'dirt', 'dead shrub']), ['pink wool'], 'arrays with only one difference');",
@@ -168,17 +285,79 @@
"assert.deepEqual(diff([], ['snuffleupagus', 'cookie monster', 'elmo']), ['snuffleupagus', 'cookie monster', 'elmo'], 'empty array');"
]
},
+ {
+ "_id": "a77dbc43c33f39daa4429b4f",
+ "name": "Boo who",
+ "difficulty": "2.06",
+ "description": [
+ "Check if a value is classified as a boolean primitive. Return true or false.",
+ "Boolean primitives are true and false."
+ ],
+ "challengeSeed": "function boo(bool) {\n // What is the new fad diet for ghost developers? The Boolean.\r\n return bool;\r\n}\n\nboo(null);",
+ "tests": [
+ "assert.strictEqual(boo(true), true);",
+ "assert.strictEqual(boo(false), true);",
+ "assert.strictEqual(boo([1, 2, 3]), false);",
+ "assert.strictEqual(boo([].slice), false);",
+ "assert.strictEqual(boo({ 'a': 1 }), false);",
+ "assert.strictEqual(boo(1), false);",
+ "assert.strictEqual(boo(NaN), false);",
+ "assert.strictEqual(boo('a'), false);"
+ ]
+ },
+ {
+ "_id": "a105e963526e7de52b219be9",
+ "name": "Sorted Union",
+ "difficulty": "2.07",
+ "description": [
+ "Write a function that takes two or more arrays and returns a new array of unique values in the order of the original provided arrays.",
+ "The unique numbers should be sorted by their original order, but the final array should not be sorted in numerical order.",
+ "Check the assertion tests for examples."
+ ],
+ "challengeSeed": "function unite(arr1, arr2, arr3) {\n return arr1;\r\n}\n\nunite([1, 2, 3], [5, 2, 1, 4], [2, 1]);",
+ "tests": [
+ "assert.deepEqual(unite([1, 3, 2], [5, 2, 1, 4], [2, 1]), [1, 3, 2, 5, 4], 'should return the union of the given arrays');",
+ "assert.deepEqual(unite([1, 3, 2], [1, [5]], [2, [4]]), [1, 3, 2, [5], [4]], 'should not flatten nested arrays');"
+ ]
+ },
+ {
+ "_id": "a6b0bb188d873cb2c8729495",
+ "name": "Convert HTML Entities",
+ "difficulty": "2.07",
+ "description": [
+ "Convert the characters \"&\", \"<\", \">\", '\"', and \"'\", in a string to their corresponding HTML entities."
+ ],
+ "challengeSeed": "function convert(str) {\n // :)\r\n return str;\r\n}\n\nconvert('Dolce & Gabbana');",
+ "tests": [
+ "assert.strictEqual(convert('Dolce & Gabbana'), 'Dolce & Gabbana', 'should escape characters');",
+ "assert.strictEqual(convert('abc'), 'abc', 'should handle strings with nothing to escape');"
+ ]
+ },
+ {
+ "_id": "a103376db3ba46b2d50db289",
+ "name": "Spinal Tap Case",
+ "difficulty": "2.08",
+ "description": [
+ "Convert a string to spinal case. Spinal case is all-lowercase-words-joined-by-dashes."
+ ],
+ "challengeSeed": "function spinalCase(str) {\n // \"It's such a fine line between stupid, and clever.\"\r\n // --David St. Hubbins\r\n return str;\r\n}\n\nspinalCase('This Is Spinal Tap');",
+ "tests": [
+ "assert.strictEqual(spinalCase('This Is Spinal Tap'), 'this-is-spinal-tap', 'should return spinal case from string with spaces');",
+ "assert.strictEqual(spinalCase('thisIsSpinalTap'), 'this-is-spinal-tap', 'should return spinal case from string with camel case');",
+ "assert.strictEqual(spinalCase('The_Andy_Griffith_Show'), 'the-andy-griffith-show', 'should return spinal case from string with snake case');",
+ "assert.strictEqual(spinalCase('Teletubbies say Eh-oh'), 'teletubbies-say-eh-oh', 'should return spinal case from string with spaces and hyphens');"
+ ]
+ },
{
"_id": "a5229172f011153519423690",
"name": "Sum All Odd Fibonacci Numbers",
"difficulty": "2.09",
"description": [
- "Return the sum of all odd fibonacci numbers up to and including the passed number if it is a fibonacci number.",
+ "Return the sum of all odd Fibonacci numbers up to and including the passed number if it is a Fibonacci number.",
"The first few numbers of the Fibonacci sequence are 1, 1, 2, 3, 5 and 8, and each subsequent number is the sum of the previous two numbers.",
- "As an example, passing 4 to the function should return 5 because all the odd fibonacci numbers under 4 are 1, 1, and 3."
+ "As an example, passing 4 to the function should return 5 because all the odd Fibonacci numbers under 4 are 1, 1, and 3."
],
- "challengeEntryPoint": "sumFibs(4);",
- "challengeSeed": "function sumFibs(num) {\n return num;\r\n}",
+ "challengeSeed": "function sumFibs(num) {\n return num;\r\n}\n\nsumFibs(4);",
"tests": [
"expect(sumFibs(1)).to.be.a('number');",
"expect(sumFibs(1000)).to.equal(1785);",
@@ -194,14 +373,13 @@
"difficulty": "2.10",
"description": [
"Sum all the prime numbers up to and including the provided number.",
- "A prime number is defined as having only two divisors, 1 and itself. For example, 2 is a prime number because it's only divisible by 1 and 2. 1 isn't a prime number, because it's only divisible by itself.",
+ "A prime number is defined as having only two divisors, 1 and itself. For example, 2 is a prime number because it's only divisible by 1 and 2. 1 isn't a prime number, because it's only divisible by itself.",
"The provided number may not be a prime."
],
- "challengeEntryPoint": "sumPrimes(10);",
- "challengeSeed": "function sumPrimes(num) {\n return num;\r\n}",
+ "challengeSeed": "function sumPrimes(num) {\n return num;\r\n}\n\nsumPrimes(10);",
"tests": [
"expect(sumPrimes(10)).to.be.a('number');",
- "expect(sumPrimes(10)).to.equal(27);",
+ "expect(sumPrimes(10)).to.equal(17);",
"expect(sumPrimes(977)).to.equal(73156);"
]
},
@@ -213,8 +391,7 @@
"Find the smallest number that evenly divides all numbers in the provided range.",
"The range will be an array of two numbers that will not necessarily be in numerical order."
],
- "challengeEntryPoint": "smallestCommons([1,5]);",
- "challengeSeed": "function smallestCommons(arr) {\n return arr;\r\n}\r\n",
+ "challengeSeed": "function smallestCommons(arr) {\n return arr;\r\n}\r\n\n\nsmallestCommons([1,5]);",
"tests": [
"expect(smallestCommons([1,5])).to.be.a('number');",
"expect(smallestCommons([1,5])).to.equal(60);",
@@ -222,6 +399,77 @@
"(smallestCommons([1,13])).should.equal(360360);"
]
},
+ {
+ "_id": "a6e40f1041b06c996f7b2406",
+ "name": "Finders Keepers",
+ "difficulty": "2.12",
+ "description": [
+ "Create a function that looks through an array (first argument) and returns the first element in the array that passes a truth test (second argument)."
+ ],
+ "challengeSeed": "function find(arr, func) {\n var num = 0;\r\n return num;\r\n}\n\nfind([1, 2, 3, 4], function(num){ return num % 2 === 0; });",
+ "tests": [
+ "assert.strictEqual(find([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; }), 8, 'should return first found value');",
+ "assert.strictEqual(find([1, 3, 5, 9], function(num) { return num % 2 === 0; }), undefined, 'should return undefined if not found');"
+ ]
+ },
+ {
+ "_id": "a5deed1811a43193f9f1c841",
+ "name": "Drop it like it's hot",
+ "difficulty": "2.13",
+ "description": [
+ "Drop the elements of an array (first argument), starting from the front, until the predicate (second argument) returns true."
+ ],
+ "challengeSeed": "function drop(arr, func) {\n // Drop them elements.\r\n return arr;\r\n}\n\ndrop([1, 2, 3], function(n) {return n < 3; });",
+ "tests": [
+ "assert.deepEqual(drop([1, 2, 3, 4], function(n) {return n < 3; }), [3, 4], 'should return remaining array');",
+ "assert.deepEqual(drop([1, 2, 3], function(n) {return n < 0; }), [1, 2, 3], 'should return complete array if predicate met in first element.');",
+ "assert.deepEqual(drop([1, 2, 3, 4], function(n) {return n < 5; }), [], 'should return an empty array if predicate does not return true');"
+ ]
+ },
+ {
+ "_id": "ab306dbdcc907c7ddfc30830",
+ "name": "Steamroller",
+ "difficulty": "2.14",
+ "description": [
+ "Flatten a nested array. You must account for varying levels of nesting."
+ ],
+ "challengeSeed": "function steamroller(arr) {\n // I'm a steamroller, baby\r\n return arr;\r\n}\n\nsteamroller([1, [2], [3, [[4]]]]);",
+ "tests": [
+ "assert.deepEqual(steamroller([[['a']], [['b']]]), ['a', 'b'], 'should flatten nested arrays');",
+ "assert.deepEqual(steamroller([1, [2], [3, [[4]]]]), [1, 2, 3, 4], 'should flatten nested arrays');",
+ "assert.deepEqual(steamroller([1, [], [3, [[4]]]]), [1, 3, 4], 'should work with empty arrays');"
+ ]
+ },
+ {
+ "_id": "a3f503de51cf954ede28891d",
+ "name": "Symmetric Difference",
+ "difficulty": "2.20",
+ "description": [
+ "Create a function that takes two or more arrays and returns an array of the symmetric difference of the provided arrays.",
+ "The mathematical term symmetric difference refers to the elements in two sets that are in either the first or second set, but not in both."
+ ],
+ "challengeSeed": "function sym(arr) {\n return arr;\r\n}\n\nsym([1, 2, 3], [5, 2, 1, 4]);",
+ "tests": [
+ "assert.deepEqual(sym([1, 2, 5], [2, 3, 5], [3, 4, 5]), [1, 4, 5], 'should return the symmetric difference of the given arrays');",
+ "assert.deepEqual(sym([1, 1, 2, 5], [2, 2, 3, 5], [3, 4, 5, 5]), [1, 4, 5], 'should return an array of unique values');",
+ "assert.deepEqual(sym([1, 1]), [1], 'should return an array of unique values');"
+ ]
+ },
+ {
+ "_id": "a10d2431ad0c6a099a4b8b52",
+ "name": "Everything Be True",
+ "difficulty": "2.21",
+ "description": [
+ "Check if the predicate (second argument) returns truthy (defined) for all elements of a collection (first argument).",
+ "For this, check to see if the property defined in the second argument is present on every element of the collection.",
+ "Remember, you can access object properties through either dot notation or [] notation."
+ ],
+ "challengeSeed": "function every(collection, pre) {\n // Does everyone have one of these?\r\n return pre;\r\n}\n\nevery([{'user': 'Tinky-Winky', 'sex': 'male'}, {'user': 'Dipsy', 'sex': 'male'}, {'user': 'Laa-Laa', 'sex': 'female'}, {'user': 'Po', 'sex': 'female'}], 'sex');",
+ "tests": [
+ "assert.strictEqual(every([{'user': 'Tinky-Winky', 'sex': 'male'}, {'user': 'Dipsy', 'sex': 'male'}, {'user': 'Laa-Laa', 'sex': 'female'}, {'user': 'Po', 'sex': 'female'}], 'sex'), true, 'should return true if predicate returns truthy for all elements in the collection');",
+ "assert.strictEqual(every([{'user': 'Tinky-Winky', 'sex': 'male'}, {'user': 'Dipsy', 'sex': 'male'}, {'user': 'Laa-Laa', 'sex': 'female'}, {'user': 'Po', 'sex': 'female'}], {'sex': 'female'}), false, 'should return false if predicate returns falsey for any element in the collection');"
+ ]
+ },
{
"_id": "a2f1d72d9b908d0bd72bb9f6",
"name": "Make a Person",
@@ -229,11 +477,9 @@
"description": [
"Fill in the object constructor with the methods specified in the tests.",
"Those methods are getFirstName(), getLastName(), getFullName(), setFirstName(), setLastName(), and setFullName().",
- "These methods must be the only available means for interacting with the object.",
- "There will be some linting errors on the tests, you may safely ignore them. You should see undefined in the console output."
+ "These methods must be the only available means for interacting with the object."
],
- "challengeEntryPoint": "var bob = new Person('Bob Ross');",
- "challengeSeed": "var Person = function(firstAndLast) {\n return firstAndLast;\r\n};",
+ "challengeSeed": "var Person = function(firstAndLast) {\n return firstAndLast;\r\n};\n\nvar bob = new Person('Bob Ross');\nbob.getFullName();",
"tests": [
"expect(Object.keys(bob).length).to.eql(6);",
"expect(bob instanceof Person).to.be.true;",
@@ -247,18 +493,19 @@
"bob.setLastName('Trees');",
"expect(bob.getLastName()).to.eql('Trees');",
"bob.setFullName('George Carlin');",
- "expect(bob.getFullName()).to.eql('George Carlin');"
+ "expect(bob.getFullName()).to.eql('George Carlin');",
+ "bob.setFullName('Bob Ross');"
]
},
{
- "_id" : "aff0395860f5d3034dc0bfc9",
+ "_id": "aff0395860f5d3034dc0bfc9",
"name": "Validate US Telephone Numbers",
"difficulty": "4.01",
"description": [
"Return true if the passed string is a valid US phone number",
"The user may fill out the form field any way they choose as long as it is a valid US number. The following are all valid formats for US numbers:",
"555-555-5555, (555)555-5555, (555) 555-5555, 555 555 5555, 5555555555, 1 555 555 5555",
- "For this challenge you will be presented with a string such as \"800-692-7753\" or \"8oo-six427676;laskdjf\". Your job is to validate or reject the US phone number based on any combination of the formats provided above. The area code is required. If the country code code is provided, you must confirm that the country code is \"1\". Return true if the string is a valid US phone number; otherwise false."
+ "For this challenge you will be presented with a string such as \"800-692-7753\" or \"8oo-six427676;laskdjf\". Your job is to validate or reject the US phone number based on any combination of the formats provided above. The area code is required. If the country code is provided, you must confirm that the country code is \"1\". Return true if the string is a valid US phone number; otherwise false."
],
"tests": [
"expect(telephoneCheck(\"555-555-5555\")).to.be.a(\"boolean\");",
@@ -284,18 +531,16 @@
"assert.deepEqual(telephoneCheck(\"2(757)6227382\"), false);",
"assert.deepEqual(telephoneCheck(\"2(757)622-7382\"), false);"
],
- "challengeSeed": "function telephoneCheck(str) {\n // Good luck!\n return true;\n}\n\n",
- "challengeEntryPoint": "telephoneCheck(\"555-555-5555\");"
+ "challengeSeed": "function telephoneCheck(str) {\n // Good luck!\n return true;\n}\n\n\n\ntelephoneCheck(\"555-555-5555\");"
},
{
- "_id": "ca2e6f85cab2ab736c9a9b24",
+ "_id": "aa2e6f85cab2ab736c9a9b24",
"name": "Cash Register",
"difficulty": "4.02",
"description": [
"Design a cash register drawer function that accepts purchase price as the first argument, payment as the second argument, and cash-in-drawer (cid) as the third argument. cid is a 2d array listing available currency. Return the string \"Insufficient Funds\" if change due is less than the cash-in-drawer. Return the string \"Closed\" if cash-in-drawer is equal to the change due. Otherwise, return change in coin and bills, sorted in highest to lowest order."
],
- "challengeEntryPoint": "drawer(19.50, 20.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]]);",
- "challengeSeed": "function drawer(price, cash, cid) {\n var change;\r\n // Here is your change, ma'am.\r\n return change;\r\n}\r\n\r\n// Example cash-in-drawer array:\r\n// [['PENNY', 1.01],\r\n// ['NICKEL', 2.05],\r\n// ['DIME', 3.10],\r\n// ['QUARTER', 4.25],\r\n// ['ONE', 90.00],\r\n// ['FIVE', 55.00],\r\n// ['TEN', 20.00],\r\n// ['TWENTY', 60.00],\r\n// ['ONE HUNDRED', 100.00]]",
+ "challengeSeed": "function drawer(price, cash, cid) {\n var change;\r\n // Here is your change, ma'am.\r\n return change;\r\n}\r\n\r\n// Example cash-in-drawer array:\r\n// [['PENNY', 1.01],\r\n// ['NICKEL', 2.05],\r\n// ['DIME', 3.10],\r\n// ['QUARTER', 4.25],\r\n// ['ONE', 90.00],\r\n// ['FIVE', 55.00],\r\n// ['TEN', 20.00],\r\n// ['TWENTY', 60.00],\r\n// ['ONE HUNDRED', 100.00]]\n\ndrawer(19.50, 20.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]]);",
"tests": [
"expect(drawer(19.50, 20.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]])).to.be.a('array');",
"expect(drawer(19.50, 20.00, [['PENNY', 0.01], ['NICKEL', 0], ['DIME', 0], ['QUARTER', 0], ['ONE', 0], ['FIVE', 0], ['TEN', 0], ['TWENTY', 0], ['ONE HUNDRED', 0]])).to.be.a('string');",
@@ -307,14 +552,13 @@
]
},
{
- "_id": "556138aff60341a09ed6c480",
+ "_id": "a56138aff60341a09ed6c480",
"name": "Inventory Update",
"difficulty": "4.03",
"description": [
"Compare and update inventory stored in a 2d array against a second 2d array of a fresh delivery. Update current inventory item quantity, and if an item cannot be found, add the new item and quantity into the inventory array in alphabetical order."
],
- "challengeEntryPoint": "// Example inventory lists\r\nvar curInv = [\r\n [21, 'Bowling Ball'],\r\n [2, 'Dirty Sock'],\r\n [1, 'Hair pin'],\r\n [5, 'Microphone']\r\n];\r\n\r\nvar newInv = [\r\n [2, 'Hair Pin'],\r\n [3, 'Half-Eaten Apple'],\r\n [67, 'Bowling Ball'],\r\n [7, 'Toothpaste']\r\n];\r\n\r\ninventory(curInv, newInv);",
- "challengeSeed": "function inventory(arr1, arr2) {\n // All inventory must be accounted for or you're fired!\r\n return arr1;\r\n}",
+ "challengeSeed": "function inventory(arr1, arr2) {\n // All inventory must be accounted for or you're fired!\r\n return arr1;\r\n}\n\n// Example inventory lists\r\nvar curInv = [\r\n [21, 'Bowling Ball'],\r\n [2, 'Dirty Sock'],\r\n [1, 'Hair pin'],\r\n [5, 'Microphone']\r\n];\r\n\r\nvar newInv = [\r\n [2, 'Hair Pin'],\r\n [3, 'Half-Eaten Apple'],\r\n [67, 'Bowling Ball'],\r\n [7, 'Toothpaste']\r\n];\r\n\r\ninventory(curInv, newInv);",
"tests": [
"expect(inventory([[21, 'Bowling Ball'], [2, 'Dirty Sock'], [1, 'Hair pin'], [5, 'Microphone']], [[2, 'Hair Pin'], [3, 'Half-Eaten Apple'], [67, 'Bowling Ball'], [7, 'Toothpaste']])).to.be.a('array');",
"assert.equal(inventory([[21, 'Bowling Ball'], [2, 'Dirty Sock'], [1, 'Hair pin'], [5, 'Microphone']], [[2, 'Hair Pin'], [3, 'Half-Eaten Apple'], [67, 'Bowling Ball'], [7, 'Toothpaste']]).length, 6);",
@@ -325,4 +569,3 @@
]
}
]
-
diff --git a/seed_data/challenges.json b/seed_data/challenges.json
index 6830fc0442..84cad0c051 100644
--- a/seed_data/challenges.json
+++ b/seed_data/challenges.json
@@ -30,7 +30,7 @@
"Now enter the chat room by going to https://gitter.im/FreeCodeCamp/FreeCodeCamp and clicking the \"sign in with GitHub\" button.",
"Introduce yourself to our chat room by typing: \"hello world!\".",
"Tell your fellow campers how you found Free Code Camp. Also tell us why you want to learn to code.",
- "Keep the chat room open while you work through the other challenges. That way you ask for help If you get stuck on a challenge. You can also socialize when you feel like taking a break.",
+ "Keep the chat room open while you work through the other challenges. That way you ask for help if you get stuck on a challenge. You can also socialize when you feel like taking a break.",
"Now that you've completed this challenge, you can go directly your most-recently visited chat room by clicking the \"Chat\" button in the navigation bar above."
]
},
@@ -67,7 +67,7 @@
"video": "114578441",
"challengeNumber": 4,
"steps": [
- "Next, let's learn about Responsive web design and continue learning about HTML and CSS.",
+ "Next, let's learn about responsive web design and continue learning about HTML and CSS.",
"A responsive website will automatically adapt to changes in your browser's width. This means that you can make one version of a website that will look good on desktop, tablet and phone.",
"Later, we'll use Twitter's Bootstrap CSS framework to build responsive websites.",
"You can check it out here: http://getbootstrap.com/.",
@@ -79,7 +79,8 @@
"time": 60,
"video": "114578438",
"challengeNumber": 5,
- "steps": ["Ready for some more HTML and CSS fundamentals?",
+ "steps": [
+ "Ready for some more HTML and CSS fundamentals?",
"Go to https://dash.generalassemb.ly/projects/eshas-restaurant-1 and complete the third project."]
},
{
@@ -94,7 +95,7 @@
"Right-click an area of the page that doesn't have any HTML elements on it, then choose 'view page source'.",
"Select all the text, then copy it.",
"Go to http://codepen.io/pen/",
- "Paste the HTML you copied from Newsweek.com into the HTML field of Codepen.",
+ "Paste the HTML you copied from Newsweek.com into the HTML field of CodePen.",
"You now have your own customizable version of the Newsweek.com website. See if you can change some of the text and images."
]
},
@@ -103,7 +104,8 @@
"time": 60,
"video": "114578436",
"challengeNumber": 7,
- "steps": ["Now let's learn some more CSS, and a small amount of a JavaScript-based tool called jQuery.",
+ "steps": [
+ "Now let's learn some more CSS, and a small amount of a JavaScript-based tool called jQuery.",
"Go to https://dash.generalassemb.ly/projects/cotbots-1 and complete the fourth project."]
},
{
@@ -155,7 +157,7 @@
"video": "114591801",
"challengeNumber": 12,
"steps": [
- "Finally, let's use jQuery to manipulate the way websites look, by changing the CSS of elements.",
+ "Finally, let's use jQuery to manipulate the way websites look by changing the CSS of elements.",
"Go to http://try.jquery.com/levels/5/challenges/1 and complete the fifth section."
]
},
@@ -166,7 +168,7 @@
"challengeNumber": 13,
"steps": [
"Now that we've built a foundation in jQuery, let's go back to Dash and do its last challenge.",
- "If you aren't familiar with Mad Libs, they basically involve inserting random nouns, adjectives and verbs in to stories. The stories that result are often hilarious.",
+ "If you aren't familiar with Mad Libs, they basically involve inserting random nouns, adjectives and verbs into stories. The stories that result are often hilarious.",
"Go to https://dash.generalassemb.ly/projects/mad-libs-1 and complete the fifth project."
]
},
@@ -204,12 +206,12 @@
"Right-click an area of the page that doesn't have any HTML elements on it, then choose 'view page source'.",
"Select all the text, then copy it.",
"Go to http://codepen.io/pen/",
- "Paste the HTML you copied from GetBootStrap.com into the HTML field of Codepen.",
+ "Paste the HTML you copied from GetBootStrap.com into the HTML field of CodePen.",
"Go to http://bootswatch.com/",
"Decide which theme you want to use.",
- "Click the down arrow next to the download button and choose 'bootstrap.css'",
+ "Click the down arrow next to the download button and choose 'bootstrap.css'.",
"Select all the text, then copy it.",
- "Go back to CodePen and paste the CSS you copied from Bootswatch.com into the CSS field of Codepen.",
+ "Go back to CodePen and paste the CSS you copied from Bootswatch.com into the CSS field of CodePen.",
"Your Bootswatch CSS should now be applied to the HTML from the GetBootStrap page.",
"This page is currently using a two-column layout, with the main content on the left and additional navigation on the right. See if you can make it a one-column layout."
]
@@ -249,7 +251,8 @@
"steps": [
"Now let's tackle week 2 of Stanford's Intro to Computer Science course.",
"This will introduce us to loops, a fundamental feature of every programming language.",
- "Go to https://class.stanford.edu/courses/Engineering/CS101/Summer2014/courseware/z100/a7a70ce6e4724c58862ee6007284face/ and complete Week 2."]
+ "Go to https://class.stanford.edu/courses/Engineering/CS101/Summer2014/courseware/z100/a7a70ce6e4724c58862ee6007284face/ and complete Week 2."
+ ]
},
{
"name": "Learn Computer Hardware",
@@ -270,7 +273,8 @@
"steps": [
"Now that you've learned about computer hardware, it's time to learn about the software that runs on top of it.",
"Particularly important, you will learn about networks and TCP/IP - the protocol that powers the internet.",
- "Go to https://class.stanford.edu/courses/Engineering/CS101/Summer2014/courseware/z187/z144/ and complete Week 4."]
+ "Go to https://class.stanford.edu/courses/Engineering/CS101/Summer2014/courseware/z187/z144/ and complete Week 4."
+ ]
},
{
"name": "Learn Boolean Logic",
@@ -280,7 +284,8 @@
"steps": [
"Now we'll do some more table exercises and learn boolean logic.",
"We'll also learn the difference between digital data and analog data.",
- "Go to https://class.stanford.edu/courses/Engineering/CS101/Summer2014/courseware/z208/z188/ and complete Week 5."]
+ "Go to https://class.stanford.edu/courses/Engineering/CS101/Summer2014/courseware/z208/z188/ and complete Week 5."
+ ]
},
{
"name": "Learn Computer Security",
@@ -291,7 +296,8 @@
"We're almost done with Stanford's Introduction to Computer Science course!",
"We'll learn about one of the most important inventions of the 20th century - spreadsheets.",
"We'll also learn about Computer Security and some of the more common vulnerabilities software systems have.",
- "Go to https://class.stanford.edu/courses/Engineering/CS101/Summer2014/courseware/z229/z213/ and complete Week 6, the final week of the course."]
+ "Go to https://class.stanford.edu/courses/Engineering/CS101/Summer2014/courseware/z229/z213/ and complete Week 6, the final week of the course."
+ ]
},
{
"name": "Build an Adventure Game",
@@ -379,19 +385,19 @@
"video": "114612882",
"challengeNumber": 31,
"steps": [
- "In this final CodeCademy section, we'll learn even more about JavaScript objects.",
+ "In this final Codecademy section, we'll learn even more about JavaScript objects.",
"Go to http://www.codecademy.com/courses/objects-ii/0/1 and complete this section.",
"Be sure to also complete the final section: http://www.codecademy.com/courses/close-the-super-makert/0/1."
]
},
{
- "name": "Get Help The Hacker Way",
+ "name": "Get Help the Hacker Way",
"time": 30,
"video": "111500801",
"challengeNumber": 32,
"steps": [
"Watch the video to learn the RSAP (Read, Search, Ask, Post) methodology for getting help.",
- "Try an intelligent Google query that involves JavaScript and filters for this year (since JavaScript changes)",
+ "Try an intelligent Google query that involves JavaScript and filters for this year (since JavaScript changes).",
"Go to http://stackoverflow.com/ and view the recent questions.",
"Go to http://webchat.freenode.net/ and create an IRC account.",
"Join the #JavaScript chat room and introduce yourself as a Free Code Camp student.",
@@ -412,30 +418,28 @@
]
},
{
- "name": "Pair Program on CoderByte",
+ "name": "Pair Program on Bonfires",
"time": 60,
- "video": "114635308",
+ "video": "119657641",
"challengeNumber": 34,
"steps": [
"OK, we're finally ready to start pair programming!",
"Pair Programming is where two people code together on the same computer. It is an efficient way to collaborate, and widely practiced at software companies. Pair Programming is one of the core concepts of \"Agile\" Software Development, which you will hear more about later.",
"Many people use Skype or Google Hangouts to pair program, but if you talk with professional software engineers, they will tell you that it's not really pair programming unless both people have the ability to use the keyboard and mouse.",
"The most popular tool for pair programming is Screen Hero. You can download Screen Hero for Mac or Windows. Create your new user account from within the app.",
- "If you are using Linux, go to http://www.freecodecamp.com/pair-program-with-team-viewer to learn how to use an alternative (but inferior) tool called Team Viewer.",
"We have a special chat room for people ready to pair program. Go to https://gitter.im/FreeCodeCamp/LetsPair and type \"Hello Pair Programmers!\"",
"If someone is available, they will be your \"pair\" - the person you pair programming with.",
- "Private message your pair and ask for the email address he or she used to register Screen Hero.",
+ "If no one gets back to you in the first few minutes, don't worry. There will be lots of opportunities to pair program in the future.",
+ "If someone does get back to you, private message them and ask for the email address they used to register Screen Hero.",
"Add them as a new contact in Screen Hero, then click the monitor-looking button to attempt to share your screen with them.",
"Once the Screen Hero session starts, your screen's margins will glow orange. You are now sharing your screen.",
- "Your pair will have his or her own cursor, and will be able to type text on his or her and keyboard.",
- "Now it's time to tackle CoderByte.",
- "Create a CoderByte account at http://coderbyte.com/sl/",
- "Now go to http://coderbyte.com/CodingArea/Challenges/#easyChals and start working through Coderbyte's easy algorithm scripting challenges using JavaScript.",
- "When you are finished pair programming, end the session in Screen Hero session.",
+ "Your pair will have their own cursor, and will be able to type text on his or her and keyboard.",
+ "Now it's time to tackle our Bonfires.",
+ "Go to http://freecodecamp.com/bonfires and start working through our Bonfire challenges.",
+ "Once you you finish pair programming, end the session in Screen Hero session.",
"Congratulations! You have completed your first pair programming session.",
- "You should pair program with different campers until you've completed all the Easy, Medium and Hard CoderByte challenges. This is a big time investment, but the JavaScript practice you'll get, along with the scripting and algorithm experience, are well worth it!",
- "You can complete CoderByte problems while you continue to work through Free Code Camp's challenges.",
- "Be sure to pair program on these challenges, and remember to apply the RSAP methodology.",
+ "Try to pair program with different campers until you've completed all the Bonfire challenges. This is a big time investment, but the JavaScript practice you'll get, along with the scripting and algorithm experience, are well worth it!",
+ "You can complete Bonfire challenges while you continue to work through Free Code Camp's challenges. Take your time.",
"Mark this challenge as complete and move on."
]
},
@@ -468,7 +472,7 @@
"video": "114684206",
"challengeNumber": 37,
"steps": [
- "One of the reasons Node.js is so fast is that it is \"evented\" - it processes events in an asynchronous manner.",
+ "One of the reasons Node.js is so fast is that it is \"evented.\" It processes events in an asynchronous manner.",
"As a result, Node.js relies on asynchronous callbacks.",
"We'll learn more about how events and callbacks work in this exciting Code School lesson.",
"Go to http://campus.codeschool.com/courses/real-time-web-with-node-js/level/2/video/1 and complete the section."
@@ -494,7 +498,8 @@
"One of the most exciting features of Node.js is NPM - Node Package Manager",
"With NPM, you quickly install any of thousands of Node.js modules into your app, and it will automatically handle the other modules that each module dependends upon downstream.",
"In this lesson, we'll learn how to include these modules in our Node.js app by requiring them as variables.",
- "Go to http://campus.codeschool.com/courses/real-time-web-with-node-js/level/4/video/1 and complete the section."]
+ "Go to http://campus.codeschool.com/courses/real-time-web-with-node-js/level/4/video/1 and complete the section."
+ ]
},
{
"name": "Start an Express.js Server",
@@ -503,14 +508,17 @@
"challengeNumber": 40,
"steps": [
"We'll complete Code School's Express.js course shortly after completing this course, but this challenge will give you a quick tour of the Express.js framework.",
- "Go to http://campus.codeschool.com/courses/real-time-web-with-node-js/level/5/video/1 and complete the section."]
+ "Go to http://campus.codeschool.com/courses/real-time-web-with-node-js/level/5/video/1 and complete the section."
+ ]
},
{
- "name": "Use Socket.IO",
+ "name": "Use Socket.io",
"time": 45,
"video": "114684530",
"challengeNumber": 41,
- "steps": ["Go to http://campus.codeschool.com/courses/real-time-web-with-node-js/level/6/video/1 and complete the section."]
+ "steps": [
+ "Go to http://campus.codeschool.com/courses/real-time-web-with-node-js/level/6/video/1 and complete the section."
+ ]
},
{
"name": "Use Redis to Persist Data",
@@ -520,7 +528,8 @@
"steps": [
"Redis is a key-value store, which is a type of non-relational database. It's one of the fastest and easiest ways to persist data.",
"Even though we'll ultimately use MongoDB and other technologies to persist data, Redis is quite easy to learn and is still worth learning.",
- "Go to http://campus.codeschool.com/courses/real-time-web-with-node-js/level/7/video/1 and complete the section."]
+ "Go to http://campus.codeschool.com/courses/real-time-web-with-node-js/level/7/video/1 and complete the section."
+ ]
},
{
"name": "Dive Deeper into Express.js",
@@ -529,7 +538,8 @@
"challengeNumber": 43,
"steps": [
"Code School has one of the first comprehensive courses on Express.js. Note that this course requires a Code School subscription, but that you can get a free two-day membership to Code School by going to https://www.codeschool.com/hall_passes/213f3fedb6b9/claim_shared. If you've already used your Code School two-day membership, go to the Free Code Camp main chat room and ask how you can get some extra time to work through this course. Alternatively, you could subscribe to Code School for one month, then take your time in completing these challenges.",
- "Go to http://campus.codeschool.com/courses/building-blocks-of-express-js/level/1/video/1 and complete the section."]
+ "Go to http://campus.codeschool.com/courses/building-blocks-of-express-js/level/1/video/1 and complete the section."
+ ]
},
{
@@ -549,7 +559,7 @@
"video": "114684537",
"challengeNumber": 45,
"steps": [
- "Have you've ever noticed a question mark in your browser's address bar, followed by a series of string? Those are parameters. Parameters are an efficient way to pass information to the server between page loads.",
+ "Have you ever noticed a question mark in your browser's address bar, followed by a series of strings? Those are parameters. Parameters are an efficient way to pass information to the server between page loads.",
"We'll learn about parameters, along with a powerful Express.js feature called Dynamic Routing, in this exciting Code School lesson.",
"Go to http://campus.codeschool.com/courses/building-blocks-of-express-js/level/3/video/1 and complete the section."
]
@@ -594,7 +604,8 @@
"steps": [
"Code School has a short, free Angular.js course. This will give us a quick tour of Angular.js's mechanics and features.",
"In this course, we'll build a virtual shop entirely in Angular.js.",
- "Go to http://campus.codeschool.com/courses/shaping-up-with-angular-js/level/1/section/1/video/1 and complete the section."]
+ "Go to http://campus.codeschool.com/courses/shaping-up-with-angular-js/level/1/section/1/video/1 and complete the section."
+ ]
},
{
"name": "Apply Angular.js Directives",
@@ -615,7 +626,8 @@
"steps": [
"One area where Angular.js really shines is its powerful web forms.",
"Learn how to create reactive Angular.js forms, including real-time form validation.",
- "Go to http://campus.codeschool.com/courses/shaping-up-with-angular-js/level/3/section/1/video/1 and complete the section."]
+ "Go to http://campus.codeschool.com/courses/shaping-up-with-angular-js/level/3/section/1/video/1 and complete the section."
+ ]
},
{
"name": "Customize Angular.js Directives",
@@ -624,7 +636,8 @@
"challengeNumber": 52,
"steps": [
"Now we'll learn how to modify existing Angular.js directives, and even build directives of your own.",
- "Go to http://campus.codeschool.com/courses/shaping-up-with-angular-js/level/4/section/1/video/1 and complete the section."]
+ "Go to http://campus.codeschool.com/courses/shaping-up-with-angular-js/level/4/section/1/video/1 and complete the section."
+ ]
},
{
"name": "Create Angular.js Services",
@@ -634,6 +647,7 @@
"steps": [
"Services are functions that you can use and reuse throughout your Angular.js app to get things done.",
"We'll learn how to use services in this final Code School Angular.js challenge.",
- "Go to http://campus.codeschool.com/courses/shaping-up-with-angular-js/level/5/section/1/video/1 and complete the section."]
+ "Go to http://campus.codeschool.com/courses/shaping-up-with-angular-js/level/5/section/1/video/1 and complete the section."
+ ]
}
]
diff --git a/seed_data/coursewares.json b/seed_data/coursewares.json
index 6d60c808cf..21454b1d0a 100644
--- a/seed_data/coursewares.json
+++ b/seed_data/coursewares.json
@@ -1,4 +1,45 @@
[
+ {
+ "_id" : "bd7123d8c441eddfaeb5bdef",
+ "name": "Learn how Free Code Camp Works",
+ "difficulty": 9.99,
+ "description": [
+ "Watch this 90 second video, or simply read this summary:",
+ "Welcome to Free Code Camp. We're a community of busy people learning to code.",
+ "We built this community because learning to code is hard. But anyone who can stay motivated can learn to code. And the best way to stay motivated is to code with friends.",
+ "To maximize accessibility, all our challenges are self-paced, browser-based, and free.",
+ "All of us start with the same 100 hours of interactive coding challenges. These cover Computer Science and databases. They also cover in-demand JavaScript tools like jQuery, Node.js and MongoDB.",
+ "Once we have a basic understanding of web development, we'll spend another 900 hours putting that theory into practice. We'll build full stack solutions for nonprofits.",
+ "By the end of this process, we'll be good at coding. We'll have a portfolio of apps with happy users to prove it. We'll also have an alumni network of fellow coders and nonprofits ready to serve as references.",
+ "If you make it through Free Code Camp, you will be able to get a coding job. There are far more job openings out there than there are qualified coders to fill them.",
+ "Also, for every pure coding job, there are at least 5 additional jobs that require some coding skills. So even if you decide not to pursue coding as a career, you'll still walk away with a valuable job skill.",
+ "There are 3 keys to succeeding in our community: do the challenges, make friends, and find a routine.",
+ "Now it's time to join our chatroom. Click the \"Go to my next challenge\" button to move on to your next challenge."
+ ],
+ "tests": [
+ ""
+ ],
+ "challengeSeed": [
+ "114486344"
+ ],
+ "challengeType" : 2
+ },
+ {
+ "_id": "bd7123c8c441eddfaeb5bdef",
+ "name": "Meet Booleans",
+ "difficulty": "9.999",
+ "description": [
+ "Return true"
+ ],
+ "tests": [
+ "expect(welcomeToBooleans()).to.be.a(\"boolean\");",
+ "expect(welcomeToBooleans()).to.be.true;"
+ ],
+ "challengeSeed": [
+ "function welcomeToBooleans() {\n // Good luck!\n return false;\n}\n\nwelcomeToBooleans();"
+ ],
+ "challengeType": 1
+ },
{
"_id" : "bd7123c8c441eddfaeb5bdef",
"name": "Start our Challenges",
@@ -6,49 +47,52 @@
"description": [
"Welcome to Free Code Camp's first challenge! Click on the button below for further instructions.",
"Awesome. Now you can read the rest of this challenge's instructions.",
- "You can edit code in text editor we've embedded into this web page.",
+ "You can edit code in the text editor we've embedded into this web page.",
"Do you see the code in the text editor that says <h1>hello</h1>? That's an HTML element.",
- "Most HTML elements have an opening tag and a closing tag. Opening tags look like this: <h1>. Closing tags look like this: </h1>. Note that the only difference between opening and is that closing tags have a slash after their opening angle bracket.",
- "To advance to the next exercise, change the h1 tag's text to say \"hello world\" instead of \"hello\"."
+ "Most HTML elements have an opening tag and a closing tag. Opening tags look like this: <h1>. Closing tags look like this: </h1>. Note that the only difference between opening and closing tags is that closing tags have a slash after their opening angle bracket.",
+ "Once you've completed the challenge, the \"Go to my next challenge\" button will become enabled. Click it - or press control and enter at the same time - to advance to the next challenge.",
+ "To enable the \"Go to my next challenge\" button on this exercise, change the h1 tag's text to say \"Hello World\" instead of \"Hello\"."
],
"tests": [
- "expect($('h1')).to.have.text('hello world');"
+ "expect((/hello(\\s)+world/gi).test($('h1').text())).to.be.true;"
],
"challengeSeed": [
- "
hello
"
+ "
Hello
"
],
"challengeType": 0
},
+
{
"_id" : "bad87fee1348bd9aedf0887a",
"name": "Use the h2 Element",
"difficulty" : "0.01",
"description": [
- "Add an h2 tag that says \"cat photo app\" to create a second HTML element below the \"hello world\" h1 element.",
+ "Add an h2 tag that says \"cat photo app\" to make a second HTML element below the \"hello world\" h1 element.",
"The h2 element you enter will create an h2 element on the website.",
"This element tells the browser how to render the text that it contains.",
- "h2 elements are slightly smaller than h1 elements. There are also an h3, h4, h5 and h6 elements."
+ "h2 elements are slightly smaller than h1 elements. There are also h3, h4, h5 and h6 elements."
],
"tests": [
- "expect($('h1')).to.have.text('hello world');",
- "expect($('h2')).to.have.text('cat photo app');"
+ "expect((/hello(\\s)+world/gi).test($('h1').text())).to.be.true;",
+ "expect((/cat(\\s)+photo(\\s)+app/gi).test($('h2').text())).to.be.true;"
],
"challengeSeed": [
"
hello world
"
],
"challengeType": 0
},
+
{
"_id" : "bad87fee1348bd9aedf08801",
"name": "Use the P Element",
"difficulty" : "0.02",
"description": [
- "Create a p - or paragraph - element below the h2 element, and give it the text \"hello paragraph\".",
- "P elements are the preferred element for normal-sized paragraph text on websites.",
+ "Create a p element below the h2 element, and give it the text \"hello paragraph\".",
+ "p elements are the preferred element for normal-sized paragraph text on websites.",
"You can create a p element like so: <p>I'm a p tag!</p>"
],
"tests": [
- "expect($('p')).to.have.text('hello paragraph');"
+ "expect((/hello(\\s)+paragraph/gi).test($('p').text())).to.be.true;"
],
"challengeSeed": [
"
hello world
",
@@ -56,18 +100,39 @@
],
"challengeType": 0
},
+
+ {
+ "_id" : "bad87fee1348bd9aeaf08801",
+ "name": "Add a Line Break to Visually Separate Elements",
+ "difficulty" : "0.03",
+ "description": [
+ "Add a line break between the <h2> and <p> elements.",
+ "You can create an line break element with <br/>.",
+ "Note that <br/> has no closing tag. It is a self-closing element. See how a forward-slash precedes the closing bracket?"
+ ],
+ "tests": [
+ "expect($('br')).to.exist;"
+ ],
+ "challengeSeed": [
+ "
hello world
",
+ "
hello html
",
+ "
hello paragraph
"
+ ],
+ "challengeType": 0
+ },
+
{
"_id" : "bad87fee1348bd9aedf08802",
"name": "Uncomment HTML",
- "difficulty" : "0.03",
+ "difficulty" : "0.04",
"description": [
- "Uncomment the h1, h2 and p elements.",
+ "Uncomment the h1, h2 and p elements.",
"Commenting is a way that you can leave comments within your code without affecting the code itself.",
"Commenting is also a convenient way to make code inactive without having to delete it entirely.",
"You can start a comment with <!-- and end a comment with -->."
],
"tests": [
- "expect($('h1')).to.have.text('hello world');"
+ "expect((/hello(\\s)+world/gi).test($('h1').text())).to.be.true;"
],
"challengeSeed": [
"",
"",
"",
"
hello world
",
- "
hello html
",
- "
hello paragraph
"
+ "
cat photo app
",
+ "
lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
"
],
"challengeType": 0
},
+
{
"_id" : "bad87fee1348bd9aedf08809",
"name": "Using Important to Override Styles",
- "difficulty" : "0.13",
+ "difficulty" : "0.14",
"description": [
- "",
- ""
+ "Apply both the \"blue-text\" and \"urgently-red\" classes to all h2 elements, but use !important to ensure the element is rendered as being red.",
+ "Sometimes HTML elements will receive conflicting information from CSS classes as to how they should be styled.",
+ "If there's a conflict in the CSS, the browser will use whichever style declaration is closest to the bottom of the CSS document (whichever declaration comes last). Note that in-line style declarations are the final authority in how an HTML element will be rendered.",
+ "There's one way to ensure that an element is rendered with a certain style, regardless of where that declaration is located. That one way is to use !important.",
+ "Look at the example in the editor's style tag to see how you can use !important.",
+ "Now see if you can make sure the h2 element is rendered in the color red without removing the blue-text class, doing an in-line styling, or changing the sequence of CSS class declarations."
],
"tests": [
- "expect($('h1')).to.have.class('text-center');",
- "expect($('h1')).to.have.text('hello world');"
+ "expect($('h2')).to.have.class('urgently-red');",
+ "expect($('h2')).to.have.class('blue-text');",
+ "expect($('h2')).to.have.css('color', '#ff0000');"
],
"challengeSeed": [
- "
hello world
"
+ "",
+ "",
+ "
hello world
",
+ "
cat photo app
",
+ "
lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
"
- ],
- "challengeType": 0
- },
- {
- "_id" : "bad87fee1348bd9aedf08811",
- "name": "Use RGB Codes for Precise Colors",
"difficulty" : "0.15",
"description": [
- "",
- ""
+ "Change the hex code in the \"red-text\" class to hex code for the color red.",
+ "Hexadecimal (hex) code is a popular way of specifying color in CSS.",
+ "Hex code is called \"hex\" because each digit has 16 possible values: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, and f",
+ "The six hex code correspond to red-red-green-green-blue-blue.",
+ "You can change these six values to make more than 16 million colors!",
+ "The higher the value in a field, the more intense its color. For example, #000000 is black, #ffffff is white, and #00ff00 is bright green. You can also get less intense colors by using values lower than f. For example, #00f000 with the second green digit set to 0 is a light green, and #00f900 is a slightly brighter green",
+ "Now figure out how to make the bright green in the \"red-text\" class into a bright red."
],
"tests": [
- "expect($('h1')).to.have.class('text-center');",
- "expect($('h1')).to.have.text('hello world');"
+ "expect($('h2')).to.have.css('color', '#ff0000');",
+ "expect($('h2')).to.have.class('red-text');"
],
"challengeSeed": [
- "
hello world
"
+ "",
+ "",
+ "
hello world
",
+ "
cat photo app
",
+ "
lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
"
],
"challengeType": 0
},
+
+ {
+ "_id" : "bad87fee1348bd9bedf08810",
+ "name": "Use Shortened 3 Digit Hex Codes",
+ "difficulty" : "0.16",
+ "description": [
+ "Change the hex code in the \"red-text\" class to the shortened 3-digit hex code for the color red.",
+ "You can also shorten the 6-digit color hex code to a 3-digit code. For example, #00ff00 becomes #0f0. This is less precise, but equally effective."
+ ],
+ "tests": [
+ "expect($('h2')).to.have.css('color', '#ff0000');",
+ "expect($('h2')).to.have.class('red-text');"
+ ],
+ "challengeSeed": [
+ "",
+ "",
+ "
hello world
",
+ "
cat photo app
",
+ "
lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
"
+ ],
+ "challengeType": 0
+ },
+
+ {
+ "_id" : "bad87fee1348bd9aedf08811",
+ "name": "Use rgb Codes for Precise Colors",
+ "difficulty" : "0.17",
+ "description": [
+ "Change the red-text class's color rgb value to be red.",
+ "Another way to represent color in CSS is with rgb, or red-green-blue notation.",
+ "For each of the three colors, you specify a value between 0 and 256.",
+ "For example, black is rgb(0, 0, 0), white is rgb(255, 255, 255), bright green is rgb(0, 255, 0). You can also get less intense colors by using values lower than 255. For example, light green is rgb(0, 123, 0).",
+ "If you think about it, this is just as precise as using hex code, because 16 times 16 is 256. In practice, most developers use hex code since it's faster to say out loud and to type.",
+ "We'll use 6-digit hex code in all our challenges going forward, but it's good to be aware of this rgb notation."
+ ],
+ "tests": [
+ "expect($('h2')).to.have.css('color', 'rgb(255, 0, 0)');",
+ "expect($('h2')).to.have.class('red-text');"
+ ],
+ "challengeSeed": [
+ "",
+ "",
+ "
hello world
",
+ "
cat photo app
",
+ "
lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
"
+ ],
+ "challengeType": 0
+ },
+
{
"_id" : "bad87fee1348bd9aedf08812",
- "name": "Include images",
- "difficulty" : "0.13",
+ "name": "Add an Image to your Website",
+ "difficulty" : "0.18",
"description": [
- "",
- ""
+ "Use an img element to add the image http://bit.ly/cutegraycat to your website.",
+ "You can add images to your website by using the img element.",
+ "An example of this would be <img src=\"www.your-image-source.com/your-image.jpg\"/>. Note that in most cases, img elements are self-closing.",
+ "Try it with this image: http://bit.ly/cutegraycat."
],
"tests": [
- "expect($('h1')).to.have.class('text-center');",
- "expect($('h1')).to.have.text('hello world');"
+ "expect($('img').attr('src')).to.equal('http://bit.ly/cutegraycat');"
],
"challengeSeed": [
- "
hello world
"
+ "",
+ "",
+ "
hello world
",
+ "
cat photo app
",
+ "
lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
"
],
"challengeType": 0
},
+
{
- "_id" : "bad87fee1348bd9aedf08813",
- "name": "Add a Border Around an Element",
- "difficulty" : "0.14",
+ "_id" : "bad87fee1348bd9acdf08812",
+ "name": "Specify an Image Size",
+ "difficulty" : "0.19",
"description": [
- "",
- ""
+ "Create a class called narrow-image and use it to resize the image so that it's only 200 pixels wide",
+ "Uh-oh, our image is too big to fit on a mobile phone. As a result, our user will need to scroll horizontally to view the image. But we can fix this by specifying an image size.",
+ "CSS has an attribute called width that controls an element's width. Just like with fonts, we'll use pixels(px) to specify the images width.",
+ "Create a class called narrow-image and added it to the image element. Change the width to 200 pixels."
],
"tests": [
- "expect($('h1')).to.have.class('text-center');",
- "expect($('h1')).to.have.text('hello world');"
+ "expect($('img')).to.have.class('narrow-image');",
+ "expect($('img')).to.have.css('width', '200px')"
],
"challengeSeed": [
- "
hello world
"
+ "",
+ "
hello world
",
+ "
cat photo app
",
+ "
lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
",
+ ""
],
"challengeType": 0
},
+
+ {
+ "_id" : "bad87fee1348bd9bedf08813",
+ "name": "Add a Border Around an Element",
+ "difficulty" : "0.20",
+ "description": [
+ "Create a class called \"thick-green-border\" that puts a 5-pixel-wide green border around your cat photo.",
+ "CSS Borders have attributes like style, color and width.",
+ "We've created an example border around your h1 element. See if you can add a 10-pixel-wide green border around your cat photo."
+ ],
+ "tests": [
+ "expect($('img')).to.have.class('thick-green-border');",
+ "expect($('img')).to.have.css('border-color', '#00ff00');",
+ "expect($('img')).to.have.css('border-width', '10px');"
+ ],
+ "challengeSeed": [
+ "",
+ "
hello world
",
+ "
cat photo app
",
+ "
lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
",
+ ""
+ ],
+ "challengeType": 0
+ },
+
{
"_id" : "bad87fee1348bd9aedf08814",
"name": "Add Rounded Corners with a Border Radius",
- "difficulty" : "0.15",
+ "difficulty" : "0.21",
"description": [
- "",
- ""
+ "Give your cat photo a border-radius of 10 pixels.",
+ "Your cat photo currently has sharp corners. We can round out those corners with a CSS attribute called border-radius.",
+ "You can specify a border-radius with pixels. This will affect how rounded the corners are. Add this attribute to your thick-green-border class and set it to 10 pixels."
],
"tests": [
- "expect($('h1')).to.have.class('text-center');",
- "expect($('h1')).to.have.text('hello world');"
+ "expect($('img')).to.have.class('thick-green-border');",
+ "expect($('img')).to.have.css('border-radius', '10px');"
],
"challengeSeed": [
- "
hello world
"
+ "",
+ "
hello world
",
+ "
cat photo app
",
+ "
lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
"
- ],
- "challengeType": 0
- },
- {
- "_id" : "bad87fee1348bd9aedf08821",
- "name": "Add Padding to an Element",
"difficulty" : "0.22",
"description": [
- "",
- ""
+ "Give your cat photo a border-radius of 50%.",
+ "In addition to pixels, you can also specify a border-radius of a percentage."
],
"tests": [
- "expect($('h1')).to.have.class('text-center');",
- "expect($('h1')).to.have.text('hello world');"
+ "expect($('img')).to.have.css('border-radius', '50%');"
],
"challengeSeed": [
- "
hello world
"
+ "",
+ "
cat photo app
",
+ "
lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
",
+ ""
],
"challengeType": 0
},
+
{
- "_id" : "bad87fee1348bd9aedf08822",
- "name": "Add a Margin to an Element",
+ "_id" : "bad87fee1348bd9aedf08816",
+ "name": "Use an Anchor Tag to Link to an External Page",
"difficulty" : "0.23",
"description": [
- "",
- ""
+ "Create an anchor taghyperlink that links to freecodecamp.com",
+ "hyperlinks link your users to other URLs (web addresses).",
+ "All hyperlinks include an href attribute that tells the browser which URL to go to when your user clicks on it.",
+ "hyperlinks are also important for web crawlers (like those used by Google to index the internet), which use links not only in determining which page to crawl next, but also to determine the relative importance of a given website.",
+ "To create a , use an anchor tag, specify an href and enclose the text you want to appear as the link, like this: <a href=\"http://www.google.com\">This is a link to Google</a>"
],
"tests": [
- "expect($('h1')).to.have.class('text-center');",
- "expect($('h1')).to.have.text('hello world');"
+ "expect((/free(\\s+)?code(\\s+)?camp(\\s+)?/gi).test($('a').text())).to.be.true;",
+ "expect($('a').filter(function(index) { return /freecodecamp\\.com/gi.test($('a')[index]); }).length).to.eql(1);"
],
"challengeSeed": [
- "
hello world
"
+ "",
+ "
cat photo app
",
+ "
lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
",
+ "",
+ " ",
+ "This is a link to Google",
+ " "
],
"challengeType": 0
},
+
+ {
+ "_id" : "bad87fee1348bd9aedf08817",
+ "name": "Make Named Anchors using the Hash Symbol",
+ "difficulty" : "0.24",
+ "description": [
+ "Use the hash symbol(#) to turn the link at the bottom of your website into a named anchor.",
+ "Sometimes you'll want to add an anchor element to your website before you know which URL its href will link to.",
+ "This is also handy when you're changing the behavior of your link using jQuery, which we'll learn about later.",
+ "Replace your link to freecodecamp.com's href with a hash symbol to turn it into a named anchor."
+ ],
+ "tests": [
+ "expect((/this link leads nowhere/gi).test($('a').text())).to.be.true;",
+ "expect($('a').filter(function(index) { return /#/gi.test($('a')[index]); }).length).to.eql(1);"
+ ],
+ "challengeSeed": [
+ "",
+ "
cat photo app
",
+ "
lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
",
+ "",
+ " ",
+ "This named anchor leads nowhere",
+ " "
+ ],
+ "challengeType": 0
+ },
+
+ {
+ "_id" : "bad87fee1348bd9aedf08820",
+ "name": "Turn an Image into a Link",
+ "difficulty" : "0.25",
+ "description": [
+ "Wrap the gray cat's image with an anchor tag that leads nowhere.",
+ "You can make elements into links by wrapping them in an anchor tag.",
+ "Check out the example snow-colored cat's photo. When you hover over it with your cursor, you'll see the finger pointer you usually see when you hover over a link. The photo is now a link.",
+ "Wrap your gray cat's photo in an anchor tag",
+ "Use the hash symbol as the anchor tag's href."
+ ],
+ "tests": [
+ "expect($('a').filter(function(index) { return /#/gi.test($('a')[index]); }).length).to.eql(2);"
+ ],
+ "challengeSeed": [
+ "",
+ "
cat photo app
",
+ "",
+ ""
+ ],
+ "challengeType": 0
+ },
+
+ {
+ "_id" : "bad87fee1348bd9aedf08818",
+ "name": "Add Alt Text to an image",
+ "difficulty" : "0.26",
+ "description": [
+ "Add the alt text \"a photo of a cute gray cat\" to our cat photo",
+ "alt text is what browsers will display if they fail to load the image. alt text also helps your blind or visually impaired users understand what your image portrays. Search engines also look at alt text.",
+ "In short, every image on your website should have alt text!",
+ "You can add alt text right in the image tag, like we've done here with the \"cute white cat\" image."
+ ],
+ "tests": [
+ "expect($('img').filter(function(){ return /cat/gi.test(this.alt) }).length).to.eql(2);"
+ ],
+ "challengeSeed": [
+ "",
+ "
cat photo app
",
+ "",
+ ""
+ ],
+ "challengeType": 0
+ },
+
+ {
+ "_id" : "bad88fee1348bd9aedf08825",
+ "name": "Adjusting the Padding of an Element",
+ "difficulty" : "0.27",
+ "description": [
+ "Change the padding of the green box to match that of the red box.",
+ "An element's padding controls the amount of space between an element and its border.",
+ "Here, we can see that the green box and the red box and the green box are nested within the yellow box. Note that the red box has more padding than the green box.",
+ "When you increase the green box's padding, it will increase the distance between the word \"padding\" and the border around the text."
+ ],
+ "tests": [
+ "expect($('.green-box')).to.have.css('padding', '20px')"
+ ],
+ "challengeSeed": [
+ "",
+ "
margin
",
+ "",
+ "
",
+ "
padding
",
+ "
padding
",
+ "
"
+ ],
+ "challengeType": 0
+ },
+
+ {
+ "_id" : "bad87fee1348bd9aedf08822",
+ "name": "Adjust the Margin of an Element",
+ "difficulty" : "0.28",
+ "description": [
+ "Change the margin of the green box to match that of the red box.",
+ "An element's margin controls the amount of space between an element's border and surrounding elements.",
+ "Here, we can see that the green box and the red box and the green box are nested within the yellow box. Note that the red box has more margin than the green box, making it appear smaller.",
+ "When you increase the green box's padding, it will increase the distance between its border and surrounding elements."
+ ],
+ "tests": [
+ "expect($('.green-box')).to.have.css('margin', '20px')"
+ ],
+ "challengeSeed": [
+ "",
+ "
margin
",
+ "",
+ "
",
+ "
padding
",
+ "
padding
",
+ "
"
+ ],
+ "challengeType": 0
+ },
+
{
"_id" : "bad87fee1348bd9aedf08823",
"name": "Add a Negative Margin to an Element",
- "difficulty" : "0.24",
+ "difficulty" : "0.29",
"description": [
- "",
- ""
+ "Change the margin of the green box to a negative value, so it fills the entire horizontal width of the blue box.",
+ "An element's margin controls the amount of space between an element's border and surrounding elements.",
+ "If you set an element's margin to a negative value, the element will grow larger.",
+ "Try to set the margin to a negative value like the one for the red box."
],
"tests": [
- "expect($('h1')).to.have.class('text-center');",
- "expect($('h1')).to.have.text('hello world');"
+ "expect($('.green-box')).to.have.css('margin', '-15px')"
],
"challengeSeed": [
- "
hello world
"
+ "",
+ "",
+ "
",
+ "
padding
",
+ "
padding
",
+ "
"
],
"challengeType": 0
},
+
{
"_id" : "bad87fee1348bd9aedf08824",
- "name": "Add Padding Only to the Top and Bottom of an Element",
- "difficulty" : "0.25",
+ "name": "Add Different Padding to Each Side of an Element TEST",
+ "difficulty" : "0.30",
"description": [
- "",
- ""
+ "Give the green box a padding of 40 pixels on its top and left side, but only 20 pixels on its bottom and right side.",
+ "Sometimes you will want to customize an element so that it has different padding on each of its sides.",
+ "CSS allows you to control the padding of an element on all four sides with padding-top, padding-right, padding-bottom, and padding-left attributes."
],
"tests": [
- "expect($('h1')).to.have.class('text-center');",
- "expect($('h1')).to.have.text('hello world');"
+ "expect($('.green-box')).to.have.css('padding-bottom', '20px')",
+ "expect($('.green-box')).to.have.css('padding-left', '40px')"
],
"challengeSeed": [
- "
hello world
"
+ "",
+ "
margin
",
+ "",
+ "
",
+ "
padding
",
+ "
padding
",
+ "
"
],
"challengeType": 0
},
+
{
- "_id" : "bad87fee1348bd9aedf08825",
- "name": "Add Margin Only to the Left and Right of an Element",
- "difficulty" : "0.26",
+ "_id" : "bad87fee1248bd9aedf08824",
+ "name": "Add Different a Margin to Each Side of an Element TEST",
+ "difficulty" : "0.31",
"description": [
- "",
- ""
+ "Give the green box a margin of 40 pixels on its top and left side, but only 20 pixels on its bottom and right side.",
+ "Sometimes you will want to customize an element so that it has a different margin on each of its sides.",
+ "CSS allows you to control the margin of an element on all four sides with margin-top, margin-right, margin-bottom, and margin-left attributes."
],
"tests": [
- "expect($('h1')).to.have.class('text-center');",
- "expect($('h1')).to.have.text('hello world');"
+ "expect($('.green-box')).to.have.css('margin-bottom', '20px')",
+ "expect($('.green-box')).to.have.css('margin-left', '40px')"
],
"challengeSeed": [
- "
hello world
"
+ "",
+ "
margin
",
+ "",
+ "
",
+ "
padding
",
+ "
padding
",
+ "
"
],
"challengeType": 0
},
+
{
"_id" : "bad87fee1348bd9aedf08826",
- "name": "Use Clockwise Padding Notation",
- "difficulty" : "0.27",
+ "name": "Use Clockwise Notation to Specify an Element's Padding",
+ "difficulty" : "0.32",
"description": [
- "",
- ""
+ "Use Clockwise Notation to give an element padding of 40 pixels on its top and left side, but only 20 pixels on its bottom and right side.",
+ "Instead of specifying an element's padding-top, padding-right, padding-bottom, and padding-left attributes, you can specify them all in one line, like this: padding: 10px 20px 10px 20px;.",
+ "These four values work like a clock: top, right, bottom, left, and will produce the exact same result as using the side-specific padding instructions.",
+ "You can also use this notation for margins!"
],
"tests": [
- "expect($('h1')).to.have.class('text-center');",
- "expect($('h1')).to.have.text('hello world');"
+ "expect($('.green-box')).to.have.css('margin-bottom', '20px')",
+ "expect($('.green-box')).to.have.css('margin-left', '40px')"
],
"challengeSeed": [
- "
hello world
"
+ "",
+ "
margin
",
+ "",
+ "
",
+ "
padding
",
+ "
padding
",
+ "
"
],
"challengeType": 0
},
+
+ {
+ "_id" : "bad87fee1348bd9acde08812",
+ "name": "Use Bootstrap for Responsive Images",
+ "difficulty" : "0.33",
+ "description": [
+ "Add the img-responsive Bootstrap class to the image.",
+ "Specifying a width of 200 pixels on our img element made it fit our phone's screen, but it's not a perfect fit. It would be great if the image could be exactly the width of our phone's screen.",
+ "Fortunately, there's a Responsive CSS Framework called written by Twitter called Bootstrap. You can add Bootstrap to any app just by including it with <link rel='stylesheet' href='//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css'/> at the top of your HTML, but we've gone ahead and included it for you here.",
+ "Bootstrap will figure out how wide your screen is and respond by resizing your HTML elements - hence the name Responsive Design.",
+ "Now all you need to do is add the img-responsive class to your image."
+ ],
+ "tests": [
+ "expect($('img')).to.have.class('img-responsive');"
+ ],
+ "challengeSeed": [
+ "",
+ "
cat photo app
",
+ "",
+ " ",
+ "This is a link to Google",
+ " "
+ ],
+ "challengeType": 0
+ },
+
+ {
+ "_id" : "bad87fee1348bd8acde08812",
+ "name": "Center Text with Bootstrap",
+ "difficulty" : "0.34",
+ "description": [
+ "Add Bootstrap's text-center class to your h2 element.",
+ "Now that we're using Bootstrap, we can center our heading elements (h2) to make them look better. All we need to do is add the class text-center to the h1 and h2 elements.",
+ "Note that you can add several classes to the same element by seperating each of them with a space, like this: <h2 class=\"text-red text-center\">your text</h2>."
+ ],
+ "tests": [
+ "expect($('h2')).to.have.class('text-center');"
+ ],
+ "challengeSeed": [
+ "",
+ "
cat photo app
",
+ "",
+ " "
+ ],
+ "challengeType": 0
+ },
+
+ {
+ "_id" : "bad87fee1348cd8acde08812",
+ "name": "Create a Button",
+ "difficulty" : "0.35",
+ "description": [
+ "Create a button with the text \"Delete\" using the HTML button element.",
+ "HTML has special elements that function like links, but look like buttons. Let's creating a default HTML button."
+ ],
+ "tests": [
+ "expect((/delete/gi).test($('button').text())).to.be.true;"
+ ],
+ "challengeSeed": [
+ "",
+ "
cat photo app
",
+ "",
+ " ",
+ "",
+ " "
+ ],
+ "challengeType": 0
+ },
+
+ {
+ "_id" : "bad87fee1348cd8acdf08812",
+ "name": "Create a Bootstrap Button",
+ "difficulty" : "0.36",
+ "description": [
+ "Apply the Bootstrap's btn class to both of your buttons.",
+ "Bootstrap has its own button styles, which look much better than the plain HTML ones."
+ ],
+ "tests": [
+ "expect($('.btn').length).to.eql(2);"
+ ],
+ "challengeSeed": [
+ "",
+ "
cat photo app
",
+ "",
+ " ",
+ "",
+ " ",
+ ""
+ ],
+ "challengeType": 0
+ },
+
+ {
+ "_id" : "bad87fee1348cd8acef08812",
+ "name": "Create a Block Element Bootstrap Button",
+ "difficulty" : "0.37",
+ "description": [
+ "Add Bootstrap's btn-block class to both of your buttons.",
+ "Normally, your buttons are only as wide as the text they contain. By making them block elements, your button will stretch to fill your page's entire horizontal space.",
+ "Note that these buttons still need the btn class."
+ ],
+ "tests": [
+ "expect($('.btn-block').length).to.eql(2);"
+ ],
+ "challengeSeed": [
+ "",
+ "
cat photo app
",
+ "",
+ " ",
+ "",
+ " ",
+ ""
+ ],
+ "challengeType": 0
+ },
+
+ {
+ "_id" : "bad87fee1348cd8acef08812",
+ "name": "Color a Bootstrap Button with Button Primary",
+ "difficulty" : "0.38",
+ "description": [
+ "Add Bootstrap's btn-block class to both of your buttons.",
+ "Normally, your buttons are only as wide as the text they contain. By making them block elements, your button will stretch to fill your page's entire horizontal space.",
+ "Note that these buttons still need the btn class."
+ ],
+ "tests": [
+ "expect($('.btn-block').length).to.eql(2);"
+ ],
+ "challengeSeed": [
+ "",
+ "
cat photo app
",
+ "",
+ " ",
+ "",
+ " ",
+ ""
+ ],
+ "challengeType": 0
+ },
+
+ {
+ "_id" : "bad87fee1348cd8acef08812",
+ "name": "Color a Bootstrap Button with Button Primary",
+ "difficulty" : "0.39",
+ "description": [
+ "Add Bootstrap's btn-primary class to both of your buttons.",
+ "Bootstrap comes with several pre-defined colors for buttons. The btn-primary class is the main button color you'll use throughout your app.",
+ "Note that these buttons still need the btn and btn-block classes."
+ ],
+ "tests": [
+ "expect($('.btn-primary').length).to.eql(2);"
+ ],
+ "challengeSeed": [
+ "",
+ "
cat photo app
",
+ "",
+ " ",
+ "",
+ " ",
+ ""
+ ],
+ "challengeType": 0
+ },
+
+ {
+ "_id" : "bad87fee1348ce8acef08812",
+ "name": "Warn your Users of a Dangerous Action with the Bootstrap Button Danger Class",
+ "difficulty" : "0.40",
+ "description": [
+ "Change the \"Delete\" button from btn-primary to btn-danger.",
+ "Bootstrap comes with several pre-defined colors for buttons. The btn-danger class is the button color you'll use to notify users that the button performs a destructive action, such as deleting a cat photo.",
+ "Note that this button still needs the btn and btn-block classes."
+ ],
+ "tests": [
+ "expect($('.btn-danger').length).to.eql(1);"
+ ],
+ "challengeSeed": [
+ "",
+ "
cat photo app
",
+ "",
+ " ",
+ "",
+ " ",
+ ""
+ ],
+ "challengeType": 0
+ },
+
+ {
+ "_id" : "bad88fee1348ce8acef08812",
+ "name": "Use the Bootstrap Grid to Put Two Elements Side By Side",
+ "difficulty" : "0.41",
+ "description": [
+ "Put the \"Like\" and \"Delete\" buttons side-by-side by wrapping them in both in a <div class=\"row\"> element and each of them in a <div class=\"row\"> element.",
+ "Bootstrap uses a responsive grid system, which makes it easy to put elements into rows and specify each element's relative width. Most of Bootstrap's classes can be applied to a div element.",
+ "The row class is applied to a div, and the buttons themselves can be nested within it."
+ ],
+ "tests": [
+ "expect($('.row').length).to.eql(2);",
+ "expect($('.col-xs-12').length).to.eql(4);"
+ ],
+ "challengeSeed": [
+ "",
+ "
cat photo app
",
+ "",
+ " ",
+ "
",
+ "
",
+ " ",
+ "
",
+ "
",
+ " ",
+ "
",
+ "
",
+ "",
+ " ",
+ ""
+ ],
+ "challengeType": 0
+ },
+
+ {
+ "_id" : "bad89fee1348ce8acef08812",
+ "name": "Wrap Side By Side Elements in a Bootstrap Row",
+ "difficulty" : "0.42",
+ "description": [
+ "Put the \"Like\" and \"Delete\" buttons side-by-side by wrapping them in both in a <div class=\"row\"> element and each of them in a <div class=\"row\"> element.",
+ "Bootstrap uses a responsive grid system, which makes it easy to put elements into rows and specify each element's relative width. Most of Bootstrap's classes can be applied to a div element.",
+ "The row class is applied to a div, and the buttons themselves can be nested within it."
+ ],
+ "tests": [
+ "expect($('.row').length).to.eql(2);",
+ "expect($('.col-xs-12').length).to.eql(4);"
+ ],
+ "challengeSeed": [
+ "",
+ "
cat photo app
",
+ "",
+ " ",
+ "
",
+ "
",
+ " ",
+ "
",
+ "
",
+ " ",
+ "
",
+ "
",
+ "",
+ " ",
+ ""
+ ],
+ "challengeType": 0
+ },
+
+ {
+ "_id" : "bad87fee1348bd9aedf08813",
+ "name": "Add Alt Text to an Image TEST",
+ "difficulty" : "0.43",
+ "description": [
+ "Add the alt text \"A picture of a gray cat\" to the image.",
+ "Alt text is a useful way to tell people (and web crawlers like Google) what is pictured in a photo. It's extremely important for helping blind or visually impaired people understand the content of your website.",
+ "You can add alt text right in the img element like this: <img src=\"www.your-image-source.com/your-image.jpg\" alt=\"your alt text\"/>."
+ ],
+ "tests": [
+ "expect((/cat/gi).test($('img').attr('alt')).to.be.true;"
+ ],
+ "challengeSeed": [
+ "",
+ "
hello world
",
+ "
cat photo app
",
+ "
lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.