This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -2,4 +2,4 @@ node_modules
|
||||
.DS_Store
|
||||
.vscode
|
||||
.env
|
||||
public/index.html
|
||||
public/*.html
|
||||
|
||||
@@ -3,3 +3,5 @@
|
||||
Список Прайм предметов: https://warframe.fandom.com/wiki/Prime
|
||||
|
||||
Маркет: https://warframe.market
|
||||
|
||||
Документация API маркета: https://warframe.market/api_docs
|
||||
|
||||
@@ -3,7 +3,7 @@ module.exports = {
|
||||
name: 'warframe-market-bot',
|
||||
script: './src/index.js',
|
||||
watch: true,
|
||||
ignore_watch: ['node_modules', 'index.html'],
|
||||
ignore_watch: ['node_modules', 'public/*'],
|
||||
restart_delay: 600000
|
||||
}]
|
||||
}
|
||||
|
||||
BIN
public/assets/languages/de.png
Normal file
BIN
public/assets/languages/de.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.9 KiB |
BIN
public/assets/languages/en.png
Normal file
BIN
public/assets/languages/en.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
BIN
public/assets/languages/fr.png
Normal file
BIN
public/assets/languages/fr.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.9 KiB |
BIN
public/assets/languages/ru.png
Normal file
BIN
public/assets/languages/ru.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.6 KiB |
BIN
public/assets/languages/ua.png
Normal file
BIN
public/assets/languages/ua.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.0 KiB |
@@ -94,6 +94,24 @@ a {
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.languages {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.languages > a {
|
||||
position: relative;
|
||||
display: block;
|
||||
margin: 10px;
|
||||
padding: 10px;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.languages img {
|
||||
max-height: 100%;
|
||||
}
|
||||
|
||||
.controls {
|
||||
margin: 32px auto;
|
||||
display: flex;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = class OutputItem {
|
||||
module.exports = class ListingSet {
|
||||
constructor (name, parts, set) {
|
||||
this.name = name + ' prime'
|
||||
this.parts = parts
|
||||
22
src/output/i18n.json
Normal file
22
src/output/i18n.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"en": {
|
||||
"title": "Market Gaps",
|
||||
"description": "Find a profitable difference between the price of the set and the price of the sum of it's parts.",
|
||||
"filter_by_difference": "Filter by difference:",
|
||||
"name": "Name",
|
||||
"parts_price": "Parts price",
|
||||
"set_price": "Set price",
|
||||
"difference": "Difference",
|
||||
"generated_at": "Generated at"
|
||||
},
|
||||
"ru": {
|
||||
"title": "Market Gaps",
|
||||
"description": "Находите выгоду между покупкой сета по отдельности и продажей его в собранном виде.",
|
||||
"filter_by_difference": "Фильтровать по разнице:",
|
||||
"name": "Название",
|
||||
"parts_price": "Стоимость частей",
|
||||
"set_price": "Стоимость сета",
|
||||
"difference": "Разница",
|
||||
"generated_at": "Сгенерировано в"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
const fs = require('fs')
|
||||
const Handlebars = require('handlebars')
|
||||
const OutputItem = require('./OutputItem')
|
||||
const ListingSet = require('./ListingSet')
|
||||
const i18n = require('./i18n.json')
|
||||
|
||||
class Output {
|
||||
constructor () {
|
||||
@@ -9,18 +10,15 @@ class Output {
|
||||
}
|
||||
|
||||
addItem (...p) {
|
||||
this.items.push(new OutputItem(...p))
|
||||
this.items.push(new ListingSet(...p))
|
||||
}
|
||||
|
||||
async compileTemplate () {
|
||||
async _compileTemplate () {
|
||||
const templateFile = await fs.readFileSync('./src/output/template.hbs', 'utf8')
|
||||
const template = Handlebars.compile(templateFile)
|
||||
return template(this)
|
||||
return Handlebars.compile(templateFile)
|
||||
}
|
||||
|
||||
async writeToFile (content) {
|
||||
const filename = './public/index.html'
|
||||
|
||||
async _writeToFile (filename, content) {
|
||||
try {
|
||||
await fs.unlinkSync(filename)
|
||||
} catch {
|
||||
@@ -31,8 +29,16 @@ class Output {
|
||||
|
||||
async submit () {
|
||||
this.timestamp = new Date()
|
||||
const content = await this.compileTemplate()
|
||||
await this.writeToFile(content)
|
||||
const template = await this._compileTemplate()
|
||||
|
||||
Object.keys(i18n).forEach(locale => {
|
||||
const filename = locale === 'en' ? 'index' : locale
|
||||
this._writeToFile(`./public/${filename}.html`, template({
|
||||
...this,
|
||||
t: i18n[locale],
|
||||
languages: Object.keys(i18n).filter(language => language !== locale)
|
||||
}))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,16 +28,24 @@
|
||||
<div class="main">
|
||||
<img class="logo" src="./assets/warframe_logo.png">
|
||||
<div class="text">
|
||||
<h1>Market Gaps</h1>
|
||||
<p>Find a profitable difference between the price of the set and the price of the sum of it's parts.</p>
|
||||
<h1>{{t.title}}</h1>
|
||||
<p>{{t.description}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<img id="gunner2" src="./assets/gunner2.png">
|
||||
|
||||
<div class="languages">
|
||||
{{#each languages}}
|
||||
<a href="/{{this}}">
|
||||
<img src="./assets/languages/{{this}}.png">
|
||||
</a>
|
||||
{{/each}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="main-column">
|
||||
<div class="controls">
|
||||
<label for="min-difference">Filter by difference:</label>
|
||||
<label for="min-difference">{{t.filter_by_difference}}</label>
|
||||
<input type="range" min="1" max="60" value="1" id="min-difference">
|
||||
<span id="filter-value">1</span>
|
||||
</div>
|
||||
@@ -45,10 +53,10 @@
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Parts price</th>
|
||||
<th>Set price</th>
|
||||
<th>Difference</th>
|
||||
<th>{{t.name}}</th>
|
||||
<th>{{t.parts_price}}</th>
|
||||
<th>{{t.set_price}}</th>
|
||||
<th>{{t.difference}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="items">
|
||||
@@ -69,7 +77,7 @@
|
||||
</div>
|
||||
|
||||
<div class="timestamp">
|
||||
Generated at {{timestamp}}
|
||||
{{t.generated_at}} {{timestamp}}
|
||||
</div>
|
||||
|
||||
<script src="index.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user