Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let mysql = require("mysql");
- let con = mysql.createConnection({
- host: "localhost",
- user: "root",
- password: ""
- });
- let set = mysql.createConnection({
- host: "localhost",
- user: "root",
- password: ""
- });
- let temp;
- let temp2;
- con.connect(function(err) {
- if (err) throw err;
- console.log("MySQL: Connected to localhost!");
- let sql = "USE Abschlussprojekt;"
- con.query(sql, function (err, result) {
- if (err) throw err;
- console.log(result);
- });
- });
- set.connect(function(err) {
- if (err) throw err;
- console.log("MySQL: Connected to localhost!");
- let sql2 = "USE Abschlussprojekt;"
- set.query(sql2, function (err, result) {
- if (err) throw err;
- console.log(result);
- });
- });
- async function dat2(Befehl) {
- set.query(Befehl, async function (err, result2) {
- if (err) throw err;
- await Sleep(10);
- //console.log(result);
- temp2 = result2;
- });
- return temp2;
- }
- async function dat(Befehl) {
- con.query(Befehl, async function (err, result) {
- if (err) throw err;
- await Sleep(10);
- //console.log(result);
- temp = result;
- });
- return temp;
- }
- let hs;
- async function loadhighscore()
- {
- return await dat('SELECT * FROM highscore;');
- }
- async function loadSettings()
- {
- console.log("Reading from table settings...");
- return await dat2('SELECT * FROM settings;');
- }
- let ohno = await loadSettings(); //new Variable
- //await Sleep(100);
- console.log("ohno=");
- console.log(ohno);
- while (ohno == undefined) { //Did the varibale load right?
- delete ohno;
- let ohno = await loadSettings();
- if (ohno != undefined) {
- console.warn("Ohno has the right type"); //Isn't undefined anymore, can continue and break out of loop
- console.log(ohno);
- haha = ohno; //Had to use a new one because ohno always undeclares itself
- break;
- }
- console.warn("ohno = undefined");
- console.log(ohno);
- await Sleep(1000);
- }
- await Sleep(100);
- while (haha == []) { //Is the variable empty?
- console.warn("haha is empty");
- delete haha;
- let haha = await loadSettings();
- await Sleep(1000);
- }
- console.log(haha);
- await Sleep(100);
- if (haha[0].DarkMode == "true") {
- DarkMode = true;
- }
- else if (haha[0].DarkMode == "false") {
- DarkMode = false;
- }
- else {
- DarkMode = false;
- Fehler(2);
- }
- console.log('DarkModeColour: ' + haha[0].Farbe);
- if (DunklerModusFarbe.indexOf("#") > -1) { // Ist # schon enthalten?
- DunklerModusFarbe = haha[0].Farbe;
- }
- else {
- DunklerModusFarbe = "#"+haha[0].Farbe;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement