Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Tocbot with functionality from Bootstrap and remove jQuery #487

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion sipa/static/css/tocbot.css

This file was deleted.

15 changes: 0 additions & 15 deletions sipa/static/css/usersuite_index.css

This file was deleted.

40 changes: 26 additions & 14 deletions sipa/static/js/contact-hints.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
var hints = [];
$.getJSON("/sipa/static/js/hints.json", function (raw_hints) {
hints = raw_hints.map(function (hint) {
let hints = [];

fetch("static/js/hints.json").then(response => response.json()).then((raw_hints) => {
hints = raw_hints.map((hint) => {
return {
not_in_dorm: hint.not_in_dorm,
patterns: hint.patterns.map(function (pattern) {
patterns: hint.patterns.map((pattern) => {
return new RegExp(pattern, "i");
}),
hint: hint.hint
};
});
});
$("#message").on("input", function () {
var applicable = hints.filter(function (hint) {
var contains = hint.patterns.some(function (pattern) {
return pattern.test($("#message").val())


const e_message = document.getElementById("message");
const e_dormitory = document.getElementById("dormitory");
const e_hints = document.getElementById("hints")

e_message.addEventListener("input", (event) => {
const applicable = hints.filter((hint) => {
const contains = hint.patterns.some((pattern) => {
return pattern.test(e_message.value)
});
var not_blacklisted = hint.not_in_dorm.every(function (dorm) {
return dorm !== $("#dormitory").val();
const not_blacklisted = hint.not_in_dorm.every((dorm) => {
return dorm !== e_dormitory.value;
});
return contains & not_blacklisted;
});
$("#hints").empty();
applicable.forEach(function (hint) {
var hint_text = hint.hint[get_language()];
$("#hints").append("<div class='alert alert-warning'>" + hint_text + "</div>");

while (e_hints.lastChild) {
e_hints.removeChild(e_hints.lastChild);
}
applicable.forEach((hint) => {
e_hints.insertAdjacentHTML("beforeend",
"<div class='alert alert-warning'>" + hint.hint[get_language()] +
"</div>"
);
FestplattenSchnitzel marked this conversation as resolved.
Show resolved Hide resolved
});
});
Loading
Loading