This commit is contained in:
9
output/OutputItem.js
Normal file
9
output/OutputItem.js
Normal file
@@ -0,0 +1,9 @@
|
||||
module.exports = class OutputItem {
|
||||
constructor (name, parts, set) {
|
||||
this.name = name + ' prime'
|
||||
this.parts = parts
|
||||
this.set = set
|
||||
|
||||
this.difference = set - parts
|
||||
}
|
||||
}
|
||||
39
output/index.js
Normal file
39
output/index.js
Normal file
@@ -0,0 +1,39 @@
|
||||
const fs = require('fs')
|
||||
const Handlebars = require('handlebars')
|
||||
const OutputItem = require('./OutputItem')
|
||||
|
||||
class Output {
|
||||
constructor () {
|
||||
this.items = []
|
||||
this.timestamp = null
|
||||
}
|
||||
|
||||
addItem (...p) {
|
||||
this.items.push(new OutputItem(...p))
|
||||
}
|
||||
|
||||
async compileTemplate () {
|
||||
const templateFile = await fs.readFileSync('./output/template.hbs', 'utf8')
|
||||
const template = Handlebars.compile(templateFile)
|
||||
return template(this)
|
||||
}
|
||||
|
||||
async writeToFile (content) {
|
||||
const filename = 'index.html'
|
||||
|
||||
try {
|
||||
await fs.unlinkSync(filename)
|
||||
} catch {
|
||||
console.log('File probably doesnt exist')
|
||||
}
|
||||
fs.writeFileSync(filename, content, 'utf-8')
|
||||
}
|
||||
|
||||
async submit () {
|
||||
this.timestamp = new Date()
|
||||
const content = await this.compileTemplate()
|
||||
await this.writeToFile(content)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new Output()
|
||||
41
output/template.hbs
Normal file
41
output/template.hbs
Normal file
@@ -0,0 +1,41 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Warframe Market Gaps</title>
|
||||
|
||||
<style>
|
||||
* {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
ul li b {
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.timestamp {
|
||||
font-size: small;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Warframe Market Gaps</h1>
|
||||
|
||||
<ul>
|
||||
{{#each items}}
|
||||
<li>
|
||||
<b>{{this.name}}</b>
|
||||
Parts price: {{this.parts}}
|
||||
Set price: {{this.set}}
|
||||
Difference: {{this.difference}}
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
|
||||
<div class="timestamp">
|
||||
Generated at {{timestamp}}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user