Advertisement
Guest User

Untitled

a guest
Mar 4th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. let mysql = require("mysql");
  2. let con = mysql.createConnection({
  3. host: "localhost",
  4. user: "root",
  5. password: ""
  6. });
  7. let set = mysql.createConnection({
  8. host: "localhost",
  9. user: "root",
  10. password: ""
  11. });
  12. let temp;
  13. let temp2;
  14. con.connect(function(err) {
  15. if (err) throw err;
  16. console.log("MySQL: Connected to localhost!");
  17. let sql = "USE Abschlussprojekt;"
  18. con.query(sql, function (err, result) {
  19. if (err) throw err;
  20. console.log(result);
  21. });
  22. });
  23. set.connect(function(err) {
  24. if (err) throw err;
  25. console.log("MySQL: Connected to localhost!");
  26. let sql2 = "USE Abschlussprojekt;"
  27. set.query(sql2, function (err, result) {
  28. if (err) throw err;
  29. console.log(result);
  30. });
  31. });
  32. async function dat2(Befehl) {
  33. set.query(Befehl, async function (err, result2) {
  34. if (err) throw err;
  35. await Sleep(10);
  36. //console.log(result);
  37. temp2 = result2;
  38. });
  39. return temp2;
  40. }
  41. async function dat(Befehl) {
  42. con.query(Befehl, async function (err, result) {
  43. if (err) throw err;
  44. await Sleep(10);
  45. //console.log(result);
  46. temp = result;
  47. });
  48. return temp;
  49. }
  50. let hs;
  51. async function loadhighscore()
  52. {
  53. return await dat('SELECT * FROM highscore;');
  54. }
  55. async function loadSettings()
  56. {
  57. console.log("Reading from table settings...");
  58. return await dat2('SELECT * FROM settings;');
  59. }
  60.  
  61. let ohno = await loadSettings(); //new Variable
  62. //await Sleep(100);
  63. console.log("ohno=");
  64. console.log(ohno);
  65.  
  66. while (ohno == undefined) { //Did the varibale load right?
  67. delete ohno;
  68. let ohno = await loadSettings();
  69. if (ohno != undefined) {
  70. console.warn("Ohno has the right type"); //Isn't undefined anymore, can continue and break out of loop
  71. console.log(ohno);
  72. haha = ohno; //Had to use a new one because ohno always undeclares itself
  73. break;
  74. }
  75. console.warn("ohno = undefined");
  76. console.log(ohno);
  77. await Sleep(1000);
  78. }
  79. await Sleep(100);
  80. while (haha == []) { //Is the variable empty?
  81. console.warn("haha is empty");
  82. delete haha;
  83. let haha = await loadSettings();
  84. await Sleep(1000);
  85. }
  86. console.log(haha);
  87. await Sleep(100);
  88. if (haha[0].DarkMode == "true") {
  89. DarkMode = true;
  90. }
  91. else if (haha[0].DarkMode == "false") {
  92. DarkMode = false;
  93. }
  94. else {
  95. DarkMode = false;
  96. Fehler(2);
  97. }
  98.  
  99.  
  100. console.log('DarkModeColour: ' + haha[0].Farbe);
  101. if (DunklerModusFarbe.indexOf("#") > -1) { // Ist # schon enthalten?
  102. DunklerModusFarbe = haha[0].Farbe;
  103. }
  104. else {
  105. DunklerModusFarbe = "#"+haha[0].Farbe;
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement