I have this coding in my index.html:
<!-- Href Hyperlinks -->
<a href="index.html">Trade Bot</a>
<a href="raffles.html">Monthly Raffles</a>
<a href="socials.html">Socials</a>
<a href="donate.html">Donate</a>
<a href="faq.html">FAQ</a>
I have made separate html files (raffles.html, socials.html,donate.html,faq.html) which are all located in the same directory. Im not too sure if my app.js or index.js is correct but when i click the hyperlinks it redirects me to http://gorillaskins.com/donate.html and displays:
Cannot GET /donate.html
app.js:
$(function() {
var app = new Vue({
el: '#app',
data: {
priceList: {},
rates: {
user: {},
bot: {}
},
disableReload: true,
disableTrade: true,
// bot
floats: {},
selectedBot: 'All bots',
botInventories: {},
botInventory: [],
botInventorySelected: [],
botInventorySelectedValue: 0,
// user
userInventory: [],
userInventorySelected: [],
userInventorySelectedValue: 0,
// auth
user: false,
// site
site: {
header: '',
steamGroup: '#',
copyrights: ''
},
// trade
offerStatus: {},
invalidTradelink: false
},
methods: {
setInventorySort: function(who, value) {
if(who == 'bot') {
this.botInventory = this.sortInventory(this.botInventory, value);
} else {
this.userInventory = this.sortInventory(this.userInventory, value);
}
},
sortInventory: function(inventory, desc) {
return inventory.sort(function(a, b) {
if(desc) {
return b.price - a.price;
} else {
return a.price - b.price;
}
});
},
addItem: function(who, id, assetid, price) {
if(typeof price === 'undefined') {
price = assetid;
assetid = id;
}
if(who == 'bot') {
if(this.selectedBot !== id) {
this.activeBot(id);
}
var botInventorySelected = this.botInventorySelected;
botInventorySelected.push(assetid);
this.botInventorySelected = botInventorySelected;
this.botInventorySelectedValue += parseFloat(price);
} else {
var userInventorySelected = this.userInventorySelected;
userInventorySelected.push(assetid);
this.userInventorySelected = userInventorySelected;
this.userInventorySelectedValue += parseFloat(price);
}
this.checkTradeable();
},
removeItem: function(who, id, assetid, price) {
if(typeof price === 'undefined') {
price = assetid;
assetid = id;
}
if(who == 'bot') {
this.botInventorySelected.splice($.inArray(assetid, this.botInventorySelected),1);
this.botInventorySelectedValue -= price;
} else {
this.userInventorySelected.splice($.inArray(assetid, this.userInventorySelected),1);
this.userInventorySelectedValue -= price;
if(this.userInventorySelectedValue <= 0) {
this.userInventorySelectedValue = 0;
}
}
this.checkTradeable();
},
checkTradeable: function() {
var user = parseFloat(this.userInventorySelectedValue.toFixed(2));
var bot = parseFloat(this.botInventorySelectedValue.toFixed(2));
if(user != 0 && user >= bot) {
this.disableTrade = false;
} else {
this.disableTrade = true;
}
},
activeBot: function(id) {
if(this.selectedBot !== id) {
if(id == 'All Bots') {
var botInventory = [];
for(var i in this.botInventories) {
var bot = this.botInventories[i];
for(var y in bot.items) {
var item = bot.items[y];
item.bot = i;
if(app.priceList[item.data.market_hash_name] <= app.rates.trash) {
item.price = (app.priceList[item.data.market_hash_name] * app.rates.bot['trash']).toFixed(2);
} else {
item.price = (app.priceList[item.data.market_hash_name] * app.rates.bot[item.item_type.name]).toFixed(2);
}
botInventory.push(item);
}
}
this.botInventory = sortInventory(botInventory, true);
} else {
this.botInventory = this.sortInventory(this.botInventories[id].items, true);
}
this.botInventorySelected = [];
this.botInventorySelectedValue = 0;
this.selectedBot = id;
}
},
searchInventory: function(who, value) {
var inventory = [];
var search = [];
if(who == 'bot') {
search = this.botInventory;
} else {
search = this.userInventory;
}
for(var i in search) {
var item = search[i];
if(item.data.market_hash_name.toLowerCase().indexOf(value.toLowerCase()) === -1) {
item.hidden = 1;
} else {
item.hidden = 0;
}
inventory.push(item);
}
if(who == 'bot') {
this.botInventory = sortInventory(inventory, true);
} else {
this.userInventory = sortInventory(inventory, true);
}
},
updateTradelink: function() {
var link = this.user.tradelink;
if(typeof link !== 'undefined') {
link = link.trim();
if(
link.indexOf('steamcommunity.com/tradeoffer/new/') === -1 ||
link.indexOf('?partner=') === -1 ||
link.indexOf('&token=') === -1
) {
this.invalidTradelink = true;
} else {
ga('send', 'updateTradelink', {
eventCategory: 'Trade',
eventAction: 'click',
eventLabel: this.user.tradelink
});
this.invalidTradelink = false;
localStorage.setItem(this.user.id, this.user.tradelink);
$('#tradelink').modal('hide');
}
} else {
this.invalidTradelink = true;
}
},
reloadInventories: function() {
this.disableReload = true;
this.botInventory = [];
this.botInventorySelected = [];
this.botInventorySelectedValue = 0;
this.userInventory = [];
this.userInventorySelected = [];
this.userInventorySelectedValue = 0;
socket.emit('get bots inv');
if(this.user && typeof this.user.steamID64 !== 'undefined') {
socket.emit('get user inv', this.user.steamID64);
}
ga('send', 'reloadInventories', {
eventCategory: 'Trade',
eventAction: 'click',
eventLabel: this.user.steamID64 || false
});
},
sendOffer: function() {
if( ! localStorage[this.user.id]) {
$('#tradelink').modal('show');
} else {
ga('send', 'sendOffer', {
eventCategory: 'Trade',
eventAction: 'click',
eventLabel: this.user.id
});
this.offerStatus = {};
this.checkTradeable();
if( ! this.disableTrade) {
this.disableTrade = true;
$('#tradeoffer').modal('show');
socket.emit('get offer', {
user: this.userInventorySelected,
bot: this.botInventorySelected,
bot_id: this.selectedBot,
steamID64: this.user.id,
tradelink: localStorage[this.user.id]
});
}
}
}
}
});
var socket = io();
socket.emit('get pricelist');
socket.emit('get rates');
socket.on('site', function(data) {
app.site = data;
window.document.title = data.header + ' | Web-based CS:GO Trading Bot';
});
socket.on('offer status', function(data) {
app.offerStatus = data;
if(data.status === 3 || data.status === false) {
app.disableTrade = false;
}
if(data.status === 3) {
app.botInventorySelected = [];
app.botInventorySelectedValue = 0;
app.userInventorySelected = [];
app.userInventorySelectedValue = 0;
}
});
socket.on('user', function(user) {
user.steamID64 = user.id;
app.user = user;
if(app.user.steamID64) {
socket.emit('get user inv', app.user.steamID64);
}
if(localStorage[app.user.id]) {
app.user.tradelink = localStorage[app.user.id];
}
if(typeof app.user.tradelink === 'undefined' && app.user) {
$('#tradelink').modal('show');
}
});
socket.on('user inv', function(data) {
app.disableReload = false;
if( ! data.error) {
var userInventory = [];
for(var i in data.items) {
var item = data.items[i];
if(app.priceList[item.data.market_hash_name] <= app.rates.trash) {
item.price = (app.priceList[item.data.market_hash_name] * app.rates.user['trash']).toFixed(2);
} else {
item.price = (app.priceList[item.data.market_hash_name] * app.rates.user[item.item_type.name]).toFixed(2);
}
userInventory.push(item);
}
if( ! userInventory.length) {
userInventory = { error: { error: 'No tradeable items found.' } };
} else {
userInventory = sortInventory(userInventory, true);
}
app.userInventory = userInventory;
} else {
app.userInventory = data;
}
});
socket.on('bots floats', function(floats) {
app.floats = floats;
})
socket.on('bots inv', function(items) {
app.disableReload = false;
// Order items object by key name
const ordered = {};
Object.keys(items).sort().forEach((key) => {
ordered[key] = items[key];
});
// Assign ordered object to botInventories
app.botInventories = Object.assign({}, ordered);
var botInventory = [];
var error = false;
for(var i in items) {
var bot = items[i];
if(bot.error) {
error = bot.error;
}
for(var y in bot.items) {
var item = bot.items[y];
item.bot = i;
if(app.priceList[item.data.market_hash_name] <= app.rates.trash) {
item.price = (app.priceList[item.data.market_hash_name] * app.rates.bot['trash']).toFixed(2);
} else {
item.price = (app.priceList[item.data.market_hash_name] * app.rates.bot[item.item_type.name]).toFixed(2);
}
botInventory.push(item);
}
}
if( ! botInventory.length) {
if( ! error) {
error = { error: { error: 'No tradeable items found. Make sure all bots have items and are not set to private.' } };
}
botInventory = { error: error };
} else {
botInventory = sortInventory(botInventory, true);
}
app.botInventory = botInventory;
});
socket.on('pricelist', function(prices) {
app.priceList = Object.assign({}, app.priceList, prices);
socket.emit('get bots inv');
});
socket.on('rates', function(rates) {
app.rates = Object.assign({}, app.rates, rates);
});
function sortInventory(inventory, desc) {
return inventory.sort(function(a, b) {
return (desc) ? b.price - a.price : a.price - b.price;
});
}
});
index.js:
'use strict'
// Modules
const express = require('express')
const app = express()
const server = require('http').Server(app)
const io = require('socket.io')(server)
const passport = require('passport')
const session = require('express-session')
const sharedsession = require('express-socket.io-session')
const SteamStrategy = require('passport-steam').Strategy
// Site stuff
const TradeBot = require('./lib/index')
const Trade = new TradeBot({ io })
const config = require('./config')
// Web server
server.listen(config.websitePort)
console.log('[!] Website server is online.')
console.log('[!] Socket server is online.')
// Passport
passport.serializeUser((user, done) => {
done(null, user)
})
passport.deserializeUser((obj, done) => {
done(null, obj)
})
passport.use(new SteamStrategy({
returnURL: `${config.website}/auth/steam/return`,
realm: `${config.website}/`,
apiKey: config.steamApiKey,
},
(identifier, profile, done) => {
process.nextTick(() => {
const user = profile
user.identifier = identifier
return done(null, user)
})
}))
const sessionMiddleware = session({
secret: 'csg0tradebot',
name: 'csg0trade',
resave: true,
saveUninitialized: true,
})
app.use(sessionMiddleware)
app.use(passport.initialize())
app.use(passport.session())
app.use('/static', express.static('./static'))
// Routes
app.get('/', (req, res) => {
res.sendFile(`${__dirname}/index.html`)
})
// Auth Routes
app.get('/auth/steam', passport.authenticate('steam'))
app.get('/auth/steam/return', passport.authenticate('steam', { failureRedirect: '/auth/steam' }), (req, res) => {
// Successful authentication, redirect home.
res.redirect('/')
})
app.get('/logout', (req, res) => {
req.logout()
res.redirect('/')
})
// Sockets
io.use(sharedsession(sessionMiddleware))
io.on('connection', (socket) => {
let userObject = false
if (
typeof socket.handshake.session.passport !== 'undefined' &&
typeof socket.handshake.session.passport.user !== 'undefined' &&
typeof socket.handshake.session.passport.user.id !== 'undefined'
) {
userObject = socket.handshake.session.passport.user
}
socket.emit('site', config.site)
socket.emit('user', userObject)
socket.on('get user inv', (steamID64) => {
Trade.getInventory(steamID64, config.appID, config.contextID, (err, data) => {
socket.emit('user inv', { error: err, items: data })
})
})
socket.on('get bot inv', (id) => {
Trade.getInventory(config.bots[id].steamID64, config.appID, config.contextID, (err, data) => {
socket.emit('bot inv', { error: err, items: data })
})
})
socket.on('get bots inv', () => {
const params = []
Object.keys(config.bots).forEach((index) => {
const bot = config.bots[index]
params.push({
id: index,
steamID64: bot.steamID64,
appID: config.appID,
contextID: config.contextID,
})
})
Trade.getInventories(params, (data) => {
socket.emit('bots inv', data)
socket.emit('bots floats', Trade.getFloatValues())
})
})
socket.on('get pricelist', () => {
socket.emit('pricelist', Trade.getPriceList())
})
socket.on('get rates', () => {
socket.emit('rates', {
ignore: Trade.getIgnorePrice(),
trash: Trade.getTrashPrice(),
user: Trade.getUserRates(),
bot: Trade.getBotRates(),
})
})
socket.on('get offer', (data) => {
socket.emit('offer status', {
error: null,
status: 4,
})
const link = data.tradelink
const offerData = data
if (
link.indexOf('steamcommunity.com/tradeoffer/new/') === -1 ||
link.indexOf('?partner=') === -1 ||
link.indexOf('&token=') === -1
) {
socket.emit('offer status', {
error: 'Invalid trade link!',
status: false,
})
} else {
Trade.validateOffer(offerData, (err, success) => {
socket.emit('offer status', {
error: err,
status: (success) ? 1 : false,
})
if (!err && success) {
if (typeof config.bots[offerData.bot_id] === 'undefined') {
offerData.bot_id = Object.keys(config.bots)[0]
}
const Bot = Trade.getBot(offerData.bot_id)
const offer = Bot.manager.createOffer(offerData.tradelink)
offer.addTheirItems(offerData.user.map(assetid => ({
assetid,
appid: config.appID,
contextid: config.contextID,
amount: 1,
})))
if (offerData.bot.length) {
offer.addMyItems(offerData.bot.map(assetid => ({
assetid,
appid: config.appID,
contextid: config.contextID,
amount: 1,
})))
}
offer.setMessage(config.tradeMessage)
offer.getUserDetails((detailsError, me, them) => {
if (detailsError) {
socket.emit('offer status', {
error: detailsError,
status: false,
})
} else if (me.escrowDays + them.escrowDays > 0) {
socket.emit('offer status', {
error: 'You must have 2FA enabled, we do not accept trades that go into Escrow.',
status: false,
})
} else {
offer.send((errSend, status) => {
if (errSend) {
socket.emit('offer status', {
error: errSend,
status: false,
})
} else {
console.log('[!!!!!] Sent a trade: ', data)
if (status === 'pending') {
socket.emit('offer status', {
error: null,
status: 2,
})
Trade.botConfirmation(data.bot_id, offer.id, (errConfirm) => {
if (!errConfirm) {
socket.emit('offer status', {
error: null,
status: 3,
offer: offer.id,
})
} else {
socket.emit('offer status', {
error: errConfirm,
status: false,
})
}
})
} else {
socket.emit('offer status', {
error: null,
status: 3,
offer: offer.id,
})
}
}
})
}
})
}
})
}
})
})