diff --git a/board/boards.js b/board/boards.js index 8ff5561..eb32d92 100644 --- a/board/boards.js +++ b/board/boards.js @@ -1,4 +1,4 @@ -boards = ["tech","gen","films","test"] +boards = ["tech","gen","films","test","maths"] if (typeof module !== 'undefined' && module.exports) { module.exports = boards; diff --git a/board/displayComments.js b/board/displayComments.js index 95566de..95843cf 100644 --- a/board/displayComments.js +++ b/board/displayComments.js @@ -7,9 +7,15 @@ function secondsIntoDay(time) { let second = time.getUTCSeconds(); return ((hour * 3600) + (minute * 60) + second) } +let pfps = [["deadvey","/images/pfp6.png"]] let divText = document.getElementById("comments").innerHTML; newPageHTML=""; -for (let comment = 0; comment < comments.length; comment++) { +for (let comment = 0; comment < comments.length; comment++) { + for (let i = 0; i < pfps.length; i++) { + if (pfps[i][0] == comments[comment][0]) { + comments[comment][0] = ` ` + comments[comment][0] + } + } if (typeof comments[comment][2] == 'undefined') { newPageHTML+=`${comments[comment][0]}: ${comments[comment][1]}
` } @@ -18,7 +24,7 @@ for (let comment = 0; comment < comments.length; comment++) { let second = Math.round((secondsIntoDay(time) / (86400/65536))).toString(16); let day = daysIntoYear(time).toString(16); let year = time.getUTCFullYear().toString(16); - newPageHTML+=`[${second} ${day}/${year}] ${comments[comment][0]}: ${comments[comment][1]}
` + newPageHTML+=`[${second} ${day}/${year}] ${comments[comment][0]}: ${comments[comment][1]}
` } }; document.getElementById("comments").innerHTML = newPageHTML diff --git a/board/index.html b/board/index.html index 6b24e02..a8dd58c 100644 --- a/board/index.html +++ b/board/index.html @@ -2,7 +2,8 @@
/tech/
/gen/
- /films/ + /films/
+
/maths/
diff --git a/board/maths/comments-database.js b/board/maths/comments-database.js new file mode 100644 index 0000000..39d5981 --- /dev/null +++ b/board/maths/comments-database.js @@ -0,0 +1,4 @@ +let comments = [["ADMIN","welcome to the maths board"],["deadvey","Welcome to MATHS","2024-11-18T22:20:49.857Z"],["deadvey","you will have fun!","2024-11-18T22:22:44.301Z"]] + if (typeof module !== "undefined" && module.exports) { + module.exports = comments; + } \ No newline at end of file diff --git a/board/maths/index.html b/board/maths/index.html new file mode 100644 index 0000000..7470aef --- /dev/null +++ b/board/maths/index.html @@ -0,0 +1 @@ +

diff --git a/board/template.js b/board/template.js deleted file mode 100755 index 5cbcaf3..0000000 --- a/board/template.js +++ /dev/null @@ -1,17 +0,0 @@ -let div = document.getElementById('main'); -divText = "" -console.log(boards) -for (let i = 0; i < boards.length; i++) { - divText += `/${boards[i]}/
` -} - -console.log(divText); - -let newPageHTML = `${pageTop}${divText}${pageBottom}` - -document.body.innerHTML = newPageHTML - -function goToLink(link) { - window.location.href = link -} - diff --git a/index.css b/index.css index 39b3157..e768673 100755 --- a/index.css +++ b/index.css @@ -56,10 +56,10 @@ ul { margin: auto; } - +/* img { border: 2px solid #7c6f64; -} +}*/ img:not(.feedicon) { max-width: 100% @@ -241,7 +241,7 @@ body { width: 400px; } -.rotate, img { +.rotate { display: flex; position: relative; animation: spin 5s linear infinite; diff --git a/maths/forms.js b/maths/forms.js new file mode 100644 index 0000000..6233edd --- /dev/null +++ b/maths/forms.js @@ -0,0 +1,28 @@ +let selected_topic = document.getElementById("topic-selection") +let subtopic_selection_div = document.getElementById("subtopic-selection-div") +let subtopic_selection_div_text = subtopic_selection_div.innerHTML + +let subtopics = [ + ["any"], + ["any","basic_algebra","combine_like_terms","complex_quadratic","compound_interest","distance_two_points","expanding","factoring","intersection_of_two_lines","invert_matrix","linear_equations","line_equation_from_2_points","log","matrix_multiplication","midpoint_of_two_points","multiply_complex_numbers","quadratic_equation","simple_interest","system_of_equations","vector_cross","vector_dot","orthogonal_projection"], + ["any","absolute_difference","addition","compare_fractions","cube_root","divide_fractions","division","exponentiation","factorial","fraction_multiplication","fraction_to_decimal","greatest_common_division","is_composite","is_prime","multiplication","percentage","percentage_difference","percentage_error","power_of_powers","square","square_root","simplify_square_root","subtraction"], + ["any","definite_integral","power_rule_differentiation","power_rule_integration","stationary_points","trig_differentiation"], + ["any","bcd_to_decimal","binary_2s_complement","binary_complement_1s","binary_to_decimal","binary_to_hex","decimal_to_bcd","decimal_to_binary","decimal_to_hexadeci","decimal_to_octal","fibonacci_series","modulo_division","nth_fibonacci_number"], + ["any","angle_btw_vectors","angle_regular_polygon","arc_length"], + ["any","arithmatic_progression_sum","arithmatic_progression_term","base_conversion"], + ["any","combinations","conditional_probability"]] + +function onChange() { + let value = selected_topic.value; + let text = selected_topic.options[selected_topic.selectedIndex].text; + value = Number(value) + console.log(value); + let selection_text = "" + subtopic_selection_div.innerHTML = selection_text; +} +selected_topic.onchange = onChange; +onChange(); diff --git a/maths/index.html b/maths/index.html new file mode 100644 index 0000000..83e0dad --- /dev/null +++ b/maths/index.html @@ -0,0 +1,29 @@ + + +
+

Maths practice!

+
+
+

Choose a topic:

+ +
+
+

Choose a subtopic:

+
+
+
+ +
+
+Questions cuertesy of Lukew3s Mathgenerator + + diff --git a/maths/questions.html b/maths/questions.html new file mode 100644 index 0000000..45b983b --- /dev/null +++ b/maths/questions.html @@ -0,0 +1 @@ +hi diff --git a/music/data.js b/music/data.js index b21f981..4a10c66 100644 --- a/music/data.js +++ b/music/data.js @@ -1 +1 @@ -artist = ' Queen'; name = ' Bicycle Race - Remastered 2011' +artist = ' Eurythmics'; name = ' Greetings From A Dead Man' diff --git a/music/index.html b/music/index.html index 810cb08..e5e0845 100644 --- a/music/index.html +++ b/music/index.html @@ -1,10 +1,10 @@
-Name: Bicycle Race - Remastered 2011
-Artist: Queen
+Name: Greetings From A Dead Man
+Artist: Eurythmics
- + diff --git a/node/app.js b/node/app.js index 1996267..1199fee 100644 --- a/node/app.js +++ b/node/app.js @@ -7,6 +7,7 @@ const fs = require("fs") const validator = require('validator'); const rootPath = "/var/www/html/" const { exec } = require("child_process"); +const { execSync } = require("child_process"); const escapeHtml = (unsafe) => { return unsafe @@ -54,6 +55,54 @@ app.post("/music/prev",(req,res) => { }, 1000); }); +app.post("/maths/submit-topics", (req,res) => { + console.log("Quesion page") + console.log(req.body.topic) + console.log(req.body.subtopic) + let topic = Number(req.body.topic) + let subtopic = validator.escape(req.body.subtopic) + let script = ""; + try { + script = execSync(`./maths.sh ${topic} ${subtopic}`, { encoding: 'utf-8' }); // 'utf-8' to get the output as a string + } catch (error) { + console.error('Error executing command:', error); + } + output = script.split(/\r?\n/); + let topic_str = output[0] + let subtopic_str = output[1] + let problem = output[2] + let solution = output[3] + console.log("Topic: ", topic_str) + console.log("Subtopic: ", subtopic_str) + console.log("Problem: ", problem) + console.log("Solution: ", solution) + + res.send(`${topic_str}
+ ${subtopic_str}
+ ${problem} +
+ + + + +
`) +}); + +app.post("/maths/answer", (req,res) => { + console.log("Answer page") + console.log(req.body.topic) + console.log(req.body.subtopic) + let topic = Number(req.body.topic) + let subtopic = validator.escape(req.body.subtopic) + res.send(`${req.body.solution} +
+ + + +
+ `) +}); + app.post("/board/submit-comment", (req,res) => { res.redirect(302, req.get("referer")); let comments = require(`${rootPath}/board/${req.body.pageID}/comments-database.js`) diff --git a/node/makeboards.js b/node/makeboards.js index cd212d5..2c540c2 100644 --- a/node/makeboards.js +++ b/node/makeboards.js @@ -15,7 +15,7 @@ for (let board = 0; board < boards.length; board++) { } else { console.log(`Directory /${boards[board]}/ doesn't exist... Creating`) fs.mkdirSync(boardPath); - fs.appendFile(`${serverPath}/board/${boards[board]}/index.html`,`

`, function (err) { + fs.appendFile(`${serverPath}/board/${boards[board]}/index.html`,`

`, function (err) { if (err) throw err; console.log('Created page'); }); diff --git a/node/maths.py b/node/maths.py new file mode 100755 index 0000000..a61ebe9 --- /dev/null +++ b/node/maths.py @@ -0,0 +1,48 @@ +import sys +import random +import mathgenerator as mg +#print(mg.genList) +#print(sys.argv) + +goodArray = [[],[],[],[],[],[],[]]; + +for x in mg.genList: + if x[4] == "algebra": + goodArray[0].append(x) + elif x[4] == "basic_math": + goodArray[1].append(x) + elif x[4] == "calculus": + goodArray[2].append(x) + elif x[4] == "computer_science": + goodArray[3].append(x) + elif x[4] == "geometry": + goodArray[4].append(x) + elif x[4] == "misc": + goodArray[5].append(x) + elif x[4] == "statistics": + goodArray[6].append(x) + +topics = ["any","algebra","basic_math","calculus","computer_science","geometry","misc","statistics"] + +rand_num = random.randint(0,len(mg.getGenList())-1) + +if sys.argv[2] == "any": + if sys.argv[1] != "0": + while (mg.genList[rand_num][4] != topics[int(sys.argv[1])]): + rand_num = random.randint(0,len(mg.getGenList())-1) + problem, solution = mg.genById(rand_num) + topic = mg.genList[rand_num][4] + subtopic = mg.genList[rand_num][3] + +else: + for i in range(len(mg.genList)): + if mg.genList[i][3] == sys.argv[2]: + problem, solution = mg.genById(i) + topic = mg.genList[i][4] + subtopic = mg.genList[i][3] + + +print(topic) +print(subtopic) +print(problem) +print(solution) diff --git a/node/maths.sh b/node/maths.sh new file mode 100755 index 0000000..84a2355 --- /dev/null +++ b/node/maths.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -e +source $HOME/venv/bin/activate +python3 maths.py $1 $2 +deactivate + diff --git a/node/run.py b/node/run.py new file mode 100644 index 0000000..c6718a9 --- /dev/null +++ b/node/run.py @@ -0,0 +1,11 @@ +import subprocess + +# Path to a Python interpreter that runs any Python script +# under the virtualenv /path/to/virtualenv/ +python_bin = "/home/max/venv/bin/activate" + +# Path to the script that must run under the virtualenv +script_file = "/home/max/maths/maths.py" + +subprocess.Popen([python_bin, script_file]) + diff --git a/node/template.js b/node/template.js index 19710a7..bae5c3d 100644 --- a/node/template.js +++ b/node/template.js @@ -1,6 +1,6 @@ const fs = require("fs"); const serverPath = require("./serverPath.js") -const pages = ["/index.html", "/blog/index.html", "/blog/reviews/index.html", "/project/index.html", "/board/index.html", "/board/tech/index.html", "/board/gen/index.html", "/board/films/index.html"]; +const pages = ["/index.html", "/blog/index.html", "/blog/reviews/index.html", "/project/index.html", "/board/index.html", "/board/tech/index.html", "/board/gen/index.html", "/board/films/index.html", "/board/maths/index.html","/maths/index.html"]; const { header, footer} = require(serverPath+"/html.js") const { exec } = require('child_process');