Permalink
Switch branches/tags
{{ refName }}
default
Cannot retrieve contributors at this time
7dc701cbe4
Could not load branches
Nothing to show
Could not load tags
Nothing to show
{{ refName }}
default
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
DynamicWebsite/views/menu.handlebars
Go to file- Go to file T
-
Copy path -
Copy permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Menu</title> | |
</head> | |
<body> | |
<header> | |
<h1>Menu</h1> | |
</header> | |
<table> | |
<tr> | |
<th>Item Name</th> | |
<th>Type</th> | |
<th>Price</th> | |
<th>Edit?</th> | |
</tr> | |
{{#each items}} | |
<tr> | |
<td id="itemName" value="{{this.name}}">{{this.name}}</td> | |
<td id="itemType" value="{{this.type}}">{{this.type}}</td> | |
<td id="itemPrice" value="{{this.price}}">{{this.price}}</td> | |
<td><button type="button" name="edit" onclick="window.location='/edit/{{this.ID}}'">Edit</button></td> | |
</tr> | |
{{/each}} | |
</table> | |
<button type="button" name="adding" onclick="window.location='/adding'">Add</button> | |
<br><br><br> | |
<button type="button" name="pdf" onclick="createPDF()">Create PDF</button> | |
<br><br><br> | |
<button type="button" name="mainmenu" onclick="window.location='/mainmenu'">Menu</button> | |
</body> | |
</html> | |
<script src = "./lib/pdf.js" type = "text/javascript"></script> | |
<script> | |
/* create the PDF document */ | |
function createPDF(){ | |
var doc = new pdf(); | |
doc.text(20, 20, 'hello, I am PDF.'); | |
doc.text(20, 30, 'i was created in the browser using javascript.'); | |
doc.text(20, 40, 'i can also be created from node.js'); | |
/* Optional - set properties on the document */ | |
doc.setProperties({ | |
title: 'A sample document created by pdf.js', | |
subject: 'PDFs are kinda cool, i guess', | |
author: 'Marak Squires', | |
keywords: 'pdf.js, javascript, Marak, Marak Squires', | |
creator: 'pdf.js' | |
}); | |
doc.addPage(); | |
doc.setFontSize(22); | |
doc.text(20, 20, 'This is a title'); | |
doc.setFontSize(16); | |
doc.text(20, 30, 'This is some normal sized text underneath.'); | |
var fileName = "testFile"+new Date().getSeconds()+".pdf"; | |
var pdfAsDataURI = doc.output('datauri', {"fileName":fileName}); | |
/* inject the pdf into the browser */ | |
// inject using an iframe | |
// this seems to work in FF but not Chrome? try testing some more on your own >.< | |
//$('#theFrame').attr('src',pdfAsDataURI); | |
// inject using an object tag | |
// doesnt really work but it does something interesting | |
//$('body').append('<object data="'+pdfAsDataURI+'" type="application/pdf"></object>'); | |
// inject changing document.location | |
// doesn't work in FF, kinda works in Chrome. this method is a bit brutal as the user sees a huge URL | |
// document.location = pdfAsDataURI; | |
// create a link | |
// this seems to always work, except clicking the link destroys my FF instantly | |
$('#pdfLink').html('<a href = "'+pdfAsDataURI+'">'+fileName+'</a> <span class = "helper">right click and save file as pdf</span'); | |
} | |
</script> |
-
Copy lines -
Copy permalink - View git blame
- Reference in new issue