-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from RUGSoftEng/develop
Develop
- Loading branch information
Showing
64 changed files
with
17,031 additions
and
347 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
node_modules | ||
node_modules/ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ var passport = require('passport'); | |
var LocalStrategy = require('passport-local').Strategy; | ||
var mongo = require('mongodb'); | ||
var mongoose = require('mongoose'); | ||
var forceHttps = require('express-force-https'); | ||
|
||
mongoose.connect('mongodb://root:[email protected]:27017,med-shard-00-01-mgwxu.mongodb.net:27017,med-shard-00-02-mgwxu.mongodb.net:27017/loginapp?ssl=true&replicaSet=med-shard-0&authSource=admin'); | ||
//mongoose.connect('mongodb://localhost/loginapp'); | ||
|
@@ -19,6 +20,8 @@ var routes = require('./routes/index'); | |
var users = require('./routes/users'); | ||
var create = require('./routes/create'); | ||
var save = require('./routes/save'); | ||
var profile = require('./routes/profile'); | ||
|
||
|
||
// Init App | ||
var app = express(); | ||
|
@@ -29,7 +32,7 @@ app.engine('handlebars', exphbs({defaultLayout:'layout'})); | |
app.set('view engine', 'handlebars'); | ||
|
||
// BodyParser Middleware | ||
app.use(bodyParser.json()); | ||
app.use(bodyParser.json({limit: '1mb'})); | ||
app.use(bodyParser.urlencoded({ extended: false })); | ||
app.use(cookieParser()); | ||
|
||
|
@@ -43,6 +46,9 @@ app.use(session({ | |
resave: true | ||
})); | ||
|
||
// Force HTTPS when not running on localhost | ||
app.use(forceHttps); | ||
|
||
// Passport init | ||
app.use(passport.initialize()); | ||
app.use(passport.session()); | ||
|
@@ -83,6 +89,7 @@ app.use('/', routes); | |
app.use('/users', users); | ||
app.use('/create', create); | ||
app.use('/save', save); | ||
app.use('/profile', profile); | ||
|
||
|
||
// Set Port | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>JSDoc: Source: card.js</title> | ||
|
||
<script src="scripts/prettify/prettify.js"> </script> | ||
<script src="scripts/prettify/lang-css.js"> </script> | ||
<!--[if lt IE 9]> | ||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> | ||
<![endif]--> | ||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> | ||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> | ||
</head> | ||
|
||
<body> | ||
|
||
<div id="main"> | ||
|
||
<h1 class="page-title">Source: card.js</h1> | ||
|
||
|
||
|
||
|
||
|
||
|
||
<section> | ||
<article> | ||
<pre class="prettyprint source linenums"><code>define(['medid/creator', 'jspdf', 'medid/res'], function(Creator, jsPDF) { | ||
|
||
/** | ||
* The card module implements card creation functionality upon the creator.js module. | ||
* Its main functionality lies in the createPDF method, which generates the Medical ID card PDF. | ||
* | ||
* @exports MIDcard | ||
* @requires creator | ||
* @requires jquery | ||
* @requires jsPDF | ||
*/ | ||
var MIDcard = {}; | ||
|
||
/** | ||
* Helper method to draw a card shape of a credit card size on a given document. | ||
* @param {jsPDF} doc - Document to draw the card upon | ||
* @param {number} x - Horizontal location of the card in the document in millimeters. | ||
* @param {number} y - Horizontal location of the card in the document in millimeters. | ||
* @param {number} barSize - Height of the red bar that is automatically added to the card. | ||
*/ | ||
MIDcard.drawCard = function (doc, x, y, barSize) { | ||
doc.setFillColor(200,0,0) | ||
doc.setDrawColor(0,0,0) | ||
doc.roundedRect(x,y,85.6,53.98,3,3,'F') | ||
doc.setFillColor(255,255,255) | ||
doc.setDrawColor(255,255,255) | ||
doc.roundedRect(x, y + barSize,85.6,38.98,3,3,'F') | ||
doc.rect(x, y + barSize,85.6,10,'F') | ||
doc.setDrawColor(0,0,0) | ||
doc.roundedRect(x,y,85.6,53.98,3,3,'S') | ||
} | ||
|
||
/** | ||
* Method to generate the Medical ID card PDF. | ||
* Uses the fields() method of the creator module as input data. | ||
* @return {jsPDF} The document object of the generated card. | ||
*/ | ||
MIDcard.createPDF = function () { | ||
|
||
var fields = Creator.fields(); | ||
var doc = new jsPDF(); | ||
|
||
doc.setFont('helvetica'); | ||
|
||
// Front side | ||
MIDcard.drawCard(doc, 10, 10, 15); | ||
|
||
//Labels | ||
doc.setFontSize(9); | ||
|
||
var image; | ||
var leftCounter = 0, rightCounter = 0; | ||
var leftStartPos = [12,55], rightStartPos = [38,30]; | ||
var lineHeight = 5, leftLabelWidth = 19, rightLabelWidth = 21; | ||
for (i = 0; i < fields.length; i++) { | ||
if (fields[i].label == "Image") { | ||
image = fields[i].field; | ||
} else { | ||
fields[i].label = fields[i].label.substring(0, 13); | ||
fields[i].field = fields[i].field.substring(0, 19); | ||
if (fields[i].label == 'Donor' || fields[i].label == 'Blood type') { | ||
// We place the short fields 'donor' and 'blood type' in the corner | ||
if (leftCounter < 2) { // Max capacity | ||
doc.setFontStyle("bold"); | ||
doc.text(leftStartPos[0], leftStartPos[1] + lineHeight * leftCounter, fields[i].label + ": "); | ||
doc.setFontStyle("normal"); | ||
doc.text(leftStartPos[0] + leftLabelWidth, leftStartPos[1] + lineHeight * leftCounter, fields[i].field); | ||
} | ||
leftCounter++; | ||
} | ||
else { | ||
// Place remaining lines on the main part of the card | ||
if (rightCounter < 7) { // Max capacity | ||
doc.setFontStyle("bold"); | ||
doc.text(rightStartPos[0], rightStartPos[1] + lineHeight * rightCounter, fields[i].label + ": "); | ||
doc.setFontStyle("normal"); | ||
doc.text(rightStartPos[0] + rightLabelWidth, rightStartPos[1] + lineHeight * rightCounter, fields[i].field); | ||
} | ||
rightCounter++; | ||
} | ||
} | ||
} | ||
|
||
if (image) { | ||
doc.addImage(image , 13, 28, Creator.imageWidth/4.5, Creator.imageHeight/4.5); | ||
} else { | ||
doc.addImage(Resources.placeholder , 11, 26, 23, 23); | ||
} | ||
|
||
// Back side | ||
MIDcard.drawCard(doc, 100, 10, 15); | ||
doc.setFontStyle('normal'); | ||
doc.text(110, 40, "This is an example card."); | ||
doc.text(110, 44, "The functional version of this card is reserved"); | ||
doc.text(110, 48, "for registered users."); | ||
|
||
// Header bars | ||
doc.addImage(Resources.redLogo,'JPEG', 12,12,12,12); | ||
doc.setTextColor(255,255,255); | ||
doc.setFontSize(16); | ||
doc.text(25, 19.5, "MEDICAL INFORMATION"); | ||
doc.setFontSize(14); | ||
doc.text(104, 19, "SCAN FOR MORE INFORMATION"); | ||
|
||
return doc; | ||
} | ||
|
||
Creator.getMethod(function (callback) { | ||
callback(MIDcard.createPDF().output('datauristring')); //getDataUrl(callback); | ||
}); | ||
Creator.downloadMethod(function (name) { | ||
MIDcard.createPDF().save(name); | ||
}); | ||
Creator.saveEndpoint = '/save/card'; | ||
Creator.init(); | ||
|
||
return MIDcard; | ||
|
||
}); | ||
</code></pre> | ||
</article> | ||
</section> | ||
|
||
|
||
|
||
|
||
</div> | ||
|
||
<nav> | ||
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-creator.html">creator</a></li><li><a href="module-MIDcard.html">MIDcard</a></li><li><a href="module-MIDdocument.html">MIDdocument</a></li><li><a href="module-util.html">util</a></li></ul> | ||
</nav> | ||
|
||
<br class="clear"> | ||
|
||
<footer> | ||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Wed Apr 05 2017 16:49:56 GMT+0200 (CEST) | ||
</footer> | ||
|
||
<script> prettyPrint(); </script> | ||
<script src="scripts/linenumber.js"> </script> | ||
</body> | ||
</html> |
Oops, something went wrong.