Initial Version

This commit is contained in:
2018-04-09 19:18:15 -04:00
commit d23ada9594
18 changed files with 6911 additions and 0 deletions

123
functions/.eslintrc.json Normal file
View File

@@ -0,0 +1,123 @@
{
"parserOptions": {
// Required for certain syntax usages
"ecmaVersion": 6
},
"plugins": [
"promise"
],
"extends": "eslint:recommended",
"rules": {
// Removed rule "disallow the use of console" from recommended eslint rules
"no-console": "off",
// Removed rule "disallow multiple spaces in regular expressions" from recommended eslint rules
"no-regex-spaces": "off",
// Removed rule "disallow the use of debugger" from recommended eslint rules
"no-debugger": "off",
// Removed rule "disallow unused variables" from recommended eslint rules
"no-unused-vars": "off",
// Removed rule "disallow mixed spaces and tabs for indentation" from recommended eslint rules
"no-mixed-spaces-and-tabs": "off",
// Removed rule "disallow the use of undeclared variables unless mentioned in /*global */ comments" from recommended eslint rules
"no-undef": "off",
// Warn against template literal placeholder syntax in regular strings
"no-template-curly-in-string": 1,
// Warn if return statements do not either always or never specify values
"consistent-return": 1,
// Warn if no return statements in callbacks of array methods
"array-callback-return": 1,
// Require the use of === and !==
"eqeqeq": 2,
// Disallow the use of alert, confirm, and prompt
"no-alert": 2,
// Disallow the use of arguments.caller or arguments.callee
"no-caller": 2,
// Disallow null comparisons without type-checking operators
"no-eq-null": 2,
// Disallow the use of eval()
"no-eval": 2,
// Warn against extending native types
"no-extend-native": 1,
// Warn against unnecessary calls to .bind()
"no-extra-bind": 1,
// Warn against unnecessary labels
"no-extra-label": 1,
// Disallow leading or trailing decimal points in numeric literals
"no-floating-decimal": 2,
// Warn against shorthand type conversions
"no-implicit-coercion": 1,
// Warn against function declarations and expressions inside loop statements
"no-loop-func": 1,
// Disallow new operators with the Function object
"no-new-func": 2,
// Warn against new operators with the String, Number, and Boolean objects
"no-new-wrappers": 1,
// Disallow throwing literals as exceptions
"no-throw-literal": 2,
// Require using Error objects as Promise rejection reasons
"prefer-promise-reject-errors": 2,
// Enforce “for” loop update clause moving the counter in the right direction
"for-direction": 2,
// Enforce return statements in getters
"getter-return": 2,
// Disallow await inside of loops
"no-await-in-loop": 2,
// Disallow comparing against -0
"no-compare-neg-zero": 2,
// Warn against catch clause parameters from shadowing variables in the outer scope
"no-catch-shadow": 1,
// Disallow identifiers from shadowing restricted names
"no-shadow-restricted-names": 2,
// Enforce return statements in callbacks of array methods
"callback-return": 2,
// Require error handling in callbacks
"handle-callback-err": 2,
// Warn against string concatenation with __dirname and __filename
"no-path-concat": 1,
// Prefer using arrow functions for callbacks
"prefer-arrow-callback": 1,
// Return inside each then() to create readable and reusable Promise chains.
// Forces developers to return console logs and http calls in promises.
"promise/always-return": 2,
//Enforces the use of catch() on un-returned promises
"promise/catch-or-return": 2,
// Warn against nested then() or catch() statements
"promise/no-nesting": 1
}
}

152
functions/index.js Normal file
View File

@@ -0,0 +1,152 @@
(function (_, Kotlin) {
'use strict';
var Kind_CLASS = Kotlin.Kind.CLASS;
var listOf = Kotlin.kotlin.collections.listOf_i5x0yv$;
function get_cm($receiver) {
return $receiver / 2.54;
}
function get_asPoints($receiver) {
return $receiver * 72;
}
function SlipInfo(eventNbr, event, lane, heat, swimmer, team) {
this.eventNbr = eventNbr;
this.event = event;
this.lane = lane;
this.heat = heat;
this.swimmer = swimmer;
this.team = team;
}
SlipInfo.$metadata$ = {
kind: Kind_CLASS,
simpleName: 'SlipInfo',
interfaces: []
};
SlipInfo.prototype.component1 = function () {
return this.eventNbr;
};
SlipInfo.prototype.component2 = function () {
return this.event;
};
SlipInfo.prototype.component3 = function () {
return this.lane;
};
SlipInfo.prototype.component4 = function () {
return this.heat;
};
SlipInfo.prototype.component5 = function () {
return this.swimmer;
};
SlipInfo.prototype.component6 = function () {
return this.team;
};
SlipInfo.prototype.copy_cdqwiw$ = function (eventNbr, event, lane, heat, swimmer, team) {
return new SlipInfo(eventNbr === void 0 ? this.eventNbr : eventNbr, event === void 0 ? this.event : event, lane === void 0 ? this.lane : lane, heat === void 0 ? this.heat : heat, swimmer === void 0 ? this.swimmer : swimmer, team === void 0 ? this.team : team);
};
SlipInfo.prototype.toString = function () {
return 'SlipInfo(eventNbr=' + Kotlin.toString(this.eventNbr) + (', event=' + Kotlin.toString(this.event)) + (', lane=' + Kotlin.toString(this.lane)) + (', heat=' + Kotlin.toString(this.heat)) + (', swimmer=' + Kotlin.toString(this.swimmer)) + (', team=' + Kotlin.toString(this.team)) + ')';
};
SlipInfo.prototype.hashCode = function () {
var result = 0;
result = result * 31 + Kotlin.hashCode(this.eventNbr) | 0;
result = result * 31 + Kotlin.hashCode(this.event) | 0;
result = result * 31 + Kotlin.hashCode(this.lane) | 0;
result = result * 31 + Kotlin.hashCode(this.heat) | 0;
result = result * 31 + Kotlin.hashCode(this.swimmer) | 0;
result = result * 31 + Kotlin.hashCode(this.team) | 0;
return result;
};
SlipInfo.prototype.equals = function (other) {
return this === other || (other !== null && (typeof other === 'object' && (Object.getPrototypeOf(this) === Object.getPrototypeOf(other) && (Kotlin.equals(this.eventNbr, other.eventNbr) && Kotlin.equals(this.event, other.event) && Kotlin.equals(this.lane, other.lane) && Kotlin.equals(this.heat, other.heat) && Kotlin.equals(this.swimmer, other.swimmer) && Kotlin.equals(this.team, other.team)))));
};
function main$lambda(req, res) {
var doc = new (require('pdfkit'))();
res.setHeader('Content-Type', 'application/pdf');
var slips = listOf([new SlipInfo(1, 'Girls 8&U 100 Yd Medley Relay', 1, 1, 'A', 'Delshire'), new SlipInfo(1, 'Girls 8&U 100 Yd Medley Relay', 1, 3, 'B', 'Delshire'), new SlipInfo(19, 'Boys 15-18 50 Yd Freestyle', 3, 5, 'Jack Hart', 'Delshire'), new SlipInfo(19, 'Boys 15-18 50 Yd Freestyle', 6, 1, 'Joseph Obert', 'Delshire'), new SlipInfo(1, 'Girls 8&U 100 Yd Medley Relay', 1, 1, 'A', 'Delshire'), new SlipInfo(1, 'Girls 8&U 100 Yd Medley Relay', 1, 3, 'B', 'Delshire')]);
doc.pipe(res);
writeSlip(slips.get_za3lpa$(0), doc, 0, 0);
writeSlip(slips.get_za3lpa$(1), doc, 1, 0);
writeSlip(slips.get_za3lpa$(2), doc, 0, 1);
writeSlip(slips.get_za3lpa$(3), doc, 1, 1);
writeSlip(slips.get_za3lpa$(4), doc, 0, 2);
writeSlip(slips.get_za3lpa$(5), doc, 1, 2);
var dashOptions = {};
dashOptions.space = 10;
doc.moveTo(get_asPoints(get_cm(10.25)), get_asPoints(get_cm(1.0))).lineTo(get_asPoints(get_cm(10.25)), get_asPoints(get_cm(27.0))).dash(5, dashOptions).stroke();
doc.moveTo(get_asPoints(get_cm(1.0)), get_asPoints(get_cm(8.5))).lineTo(get_asPoints(get_cm(21.0)), get_asPoints(get_cm(8.5))).dash(5, dashOptions).stroke();
doc.moveTo(get_asPoints(get_cm(1.0)), get_asPoints(get_cm(16.5))).lineTo(get_asPoints(get_cm(21.0)), get_asPoints(get_cm(16.5))).dash(5, dashOptions).stroke();
return doc.end();
}
function main(args) {
var fireFunctions = require('firebase-functions');
fireFunctions.config();
exports.laneslips = fireFunctions.https.onRequest(main$lambda);
}
function writeSlip($receiver, doc, x, y) {
var xOffset = get_asPoints(get_cm(10.0)) * x;
var yOffset = get_asPoints(get_cm(8.0)) * y;
var leftMargin = get_asPoints(get_cm(1.0)) + xOffset;
var opts = {};
opts.width = get_asPoints(get_cm(8.5));
opts.align = 'center';
doc.fontSize(13);
doc.font('Helvetica-Bold');
doc.text('Southern Ohio Swim League', leftMargin, get_asPoints(get_cm(1.5)) + yOffset, opts);
doc.fontSize(11);
doc.font('Times-Roman');
var eventY = get_asPoints(get_cm(2.3)) + yOffset;
doc.text('EVENT #' + $receiver.eventNbr + ' - ' + $receiver.event, leftMargin, eventY);
var lineSeparation = get_asPoints(get_cm(0.6));
var laneY = eventY + lineSeparation;
doc.text('Lane:', leftMargin, laneY);
var colWidth = get_asPoints(get_cm(1.3));
doc.text('1', leftMargin + colWidth * 1, laneY);
doc.text('2', leftMargin + colWidth * 2, laneY);
doc.text('3', leftMargin + colWidth * 3, laneY);
doc.text('4', leftMargin + colWidth * 4, laneY);
doc.text('5', leftMargin + colWidth * 5, laneY);
doc.text('6', leftMargin + colWidth * 6, laneY);
doc.circle(leftMargin + colWidth * $receiver.lane + get_asPoints(get_cm(0.1)), laneY + get_asPoints(get_cm(0.15)), get_asPoints(get_cm(0.3)));
doc.stroke();
var heatY = laneY + lineSeparation;
doc.text('Heat:', leftMargin, heatY);
doc.text('1', leftMargin + colWidth * 1, heatY);
doc.text('2', leftMargin + colWidth * 2, heatY);
doc.text('3', leftMargin + colWidth * 3, heatY);
doc.text('4', leftMargin + colWidth * 4, heatY);
doc.text('5', leftMargin + colWidth * 5, heatY);
doc.text('6', leftMargin + colWidth * 6, heatY);
doc.circle(leftMargin + colWidth * $receiver.heat + get_asPoints(get_cm(0.1)), heatY + get_asPoints(get_cm(0.15)), get_asPoints(get_cm(0.3)));
doc.stroke();
var nameY = heatY + lineSeparation;
doc.text('Name: ' + $receiver.swimmer, leftMargin, nameY);
var teamY = nameY + lineSeparation;
doc.text('Team: ' + $receiver.team, leftMargin, teamY);
var timesY = teamY + lineSeparation * 1.5;
doc.text('Times:', leftMargin, timesY);
doc.moveTo(leftMargin + colWidth, timesY + 14).lineTo(leftMargin + colWidth + get_asPoints(get_cm(2.0)), timesY + 14).stroke();
doc.moveTo(leftMargin + colWidth + get_asPoints(get_cm(2.7)), timesY + 14).lineTo(leftMargin + colWidth + get_asPoints(get_cm(4.7)), timesY + 14).stroke();
doc.moveTo(leftMargin + colWidth + get_asPoints(get_cm(5.4)), timesY + 14).lineTo(leftMargin + colWidth + get_asPoints(get_cm(7.4)), timesY + 14).stroke();
var officialTimesY = timesY + lineSeparation * 1.5;
doc.text('Official Time:', leftMargin, officialTimesY);
doc.moveTo(leftMargin + colWidth * 2, officialTimesY + 14).lineTo(leftMargin + colWidth * 2 + get_asPoints(get_cm(4.0)), officialTimesY + 14).stroke();
var placeY = officialTimesY + lineSeparation * 1.25;
doc.text('Place:', leftMargin, placeY);
doc.text('1', leftMargin + colWidth * 1, placeY);
doc.text('2', leftMargin + colWidth * 2, placeY);
doc.text('3', leftMargin + colWidth * 3, placeY);
doc.text('4', leftMargin + colWidth * 4, placeY);
doc.text('5', leftMargin + colWidth * 5, placeY);
doc.text('6', leftMargin + colWidth * 6, placeY);
}
var package$online = _.online || (_.online = {});
var package$cinphart = package$online.cinphart || (package$online.cinphart = {});
var package$laneslips = package$cinphart.laneslips || (package$cinphart.laneslips = {});
package$laneslips.get_cm_yrwdxr$ = get_cm;
package$laneslips.get_asPoints_yrwdxr$ = get_asPoints;
package$laneslips.SlipInfo = SlipInfo;
package$laneslips.main_kand9s$ = main;
package$laneslips.writeSlip_xwsitz$ = writeSlip;
main([]);
Kotlin.defineModule('index', _);
return _;
}(module.exports, require('kotlin')));

1
functions/index.meta.js Normal file
View File

@@ -0,0 +1 @@
// Kotlin.kotlin_module_metadata(513, "index", "H4sIAAAAAAAAAF2Ty27TQBSGfYs9OUnbwaU0mAIh3CuBjLmIbUtBaRdV5YLEgo3rDI1FPBPsCW32KA8AG9Z9Cp6AR8gL8CKccYYksPH/zZl/5sx/JBvE9r978NsCV/BBxhmQNOPDflJIqA8SzspBNiyBHKPs848C3E9Cog/sHT4Gwr4wLg9PCrD3uYRatQT3WBYZPwVHnQenzxIJXnmW5TkrwJEsyQFSkQ8FR/eTJY6W+OkSP1vi50v8ApxUDMfgss+jZFCCtyvEgCUcakL2sRfpJ2X/lehhKCn0ozx2PhSFRPMhmlTFnyV6vDfmSZ6lb8dD9Cflkcg42tw9MToZMLDSHJw8weTOO55JcJLitITaTlEkY/AKfEFWMHBz0Ruhu35WZJKpoYHdEymY52CO/Q9gUQMcYlATvybFoROL2i0D6w6yQ2vISj2tda1XtF7TekPrLa23W0ZwYQabtB1YYSNq0k5AfMe3Qi9s/iRGsEXvBNDe2nZaZlgL65FL76LR607aavcRvaeObVuhHa3S+/85H+Cei/pQKdo7GzRYtryffDVVeY1eRwfgLfDyzaxw85/CD2J1LiwyIS07ssLabui71FWXohL1HFTQ64bWpq6vKD2o01VV7/6yEdeqBBXSRfXSAv2FYf0vvqaXAxWT4OCr3hVV3SuCea0xp+Z8d2V2jXmwTjcQSUToZlCNoTtVbVpV86mJeLWyTs1YZ4t11lhni3XWWGeMdUac0zdigRHoH+0PWtUuxaEDAAA=");

5529
functions/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

23
functions/package.json Normal file
View File

@@ -0,0 +1,23 @@
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"lint": "eslint .",
"serve": "firebase serve --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"dependencies": {
"firebase-admin": "~5.12.0",
"firebase-functions": "^1.0.1",
"kotlin": "^1.2.31",
"pdfkit": "^0.8.3"
},
"devDependencies": {
"eslint": "^4.12.0",
"eslint-plugin-promise": "^3.6.0"
},
"private": true
}