var tonicExpress = require("@runkit/runkit/express-endpoint/1.0.0")
// Just provide the exports object to the tonicExpress helper
var app = tonicExpress(module.exports)
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({ extended: false }));
app.get("/", (req, res) => res.send("Hey!"))
app.get("/angielski", (req, res) => {
let litery = [
"PUFDRPSINRI",
"OTIARSKIOME",
"GICESKATEIY",
"EAWHISTLEEL",
"PCTEZYEFPBE",
"ROLLERBLADE",
"SOKASYOYIIA",
"IKSWIMAENDL",
"DHAGNSRITCS",
"TMSCGRDHNNC"
];
let szukaneAktywnosci = [
"climbtrees",
"skateboard",
"tricks",
"driveacar",
"fly",
"rideabicycle",
"ski",
"speak",
"swim",
"telljokes",
"cook",
"iceskate",
"paint",
"playchess",
"playthepiano",
"readmusic",
"rollerblade",
"sing",
"snowboard",
"whistle"
];
tabSlowaPoz = new Array(litery.length);
tabSlowaPion = new Array(litery[0].length);
for (let i = 0; i < litery.length; i++) {
tabSlowaPoz[i] = new String(litery[i].toLowerCase());
}
for (let i = 0; i < tabSlowaPoz[0].length; i++) {
tabSlowaPion[i] = new String("");
for (let j = 0; j < tabSlowaPoz.length; j++) {
tabSlowaPion[i] += tabSlowaPoz[j][i];
}
}
var formData = {};
tabSlowaPoz.forEach((element, index) => {
for (const aktywnosc of szukaneAktywnosci) {
let poz;
if ((poz = element.indexOf(aktywnosc)) >= 0) {
formData[index + 1] = ("wiersz: " + (index + 1) + ", poz: " + (poz + 1) + " - " + aktywnosc);
}
}
});
tabSlowaPion.forEach((element, index) => {
for (const aktywnosc of szukaneAktywnosci) {
let poz;
if ((poz = element.indexOf(aktywnosc)) >= 0) {
formData[index + 1] = ("kolumna: " + (index + 1) + ", poz: " + (poz + 1) + " - " + aktywnosc);
}
}
});
//res.send(`Hello ${req.params.name}!`)
res.send((Object.keys(formData).map( k => `${k}: ${formData[k]}` )).join("\n"));
})
app.post("/echo-form", (req, res) => {
var formData = Object.keys(req.body).map( k => `${k}: ${req.body[k]}` )
res.type("text/plain")
res.send(formData.join("\n"))
})