Skip to content

Commit

Permalink
Merge pull request #21 from faraplay/prefs
Browse files Browse the repository at this point in the history
Format preferences page
  • Loading branch information
OctoNezd authored Jul 2, 2023
2 parents 127115f + 2aadb61 commit 1b303e3
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 4 deletions.
24 changes: 24 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "wp-build",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [],
"label": "npm: wp-build",
"detail": "webpack"
},
{
"type": "npm",
"script": "install",
"group": "none",
"problemMatcher": [],
"label": "npm: install",
"detail": "install dependencies from package"
}
]
}
5 changes: 5 additions & 0 deletions css/customUi.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ form.usertext {
#header {
display: none;
}

div.pref-row {
border-top: 1px solid var(--md-sys-color-outline-variant);
padding-bottom: 10px;
}
1 change: 1 addition & 0 deletions js/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ import "./general.js";
import "./header.js";
import "./sidebars.js";
import "./posts";
import "./preferences.js";
console.log("Content script loaded.");
25 changes: 25 additions & 0 deletions js/preferences.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export function formatPrefTable() {
const table = document.querySelector("table.preftable");
if (!table) {
return;
}
const tableParent = table.parentNode;
const prefDiv = document.createElement("div");
tableParent.appendChild(prefDiv);
tableParent.removeChild(table);
const tbody = table.firstChild;
for (const row of tbody.childNodes) {
const newRow = document.createElement("div");
newRow.setAttribute("class", "pref-row");
prefDiv.appendChild(newRow);

const header = document.createElement("h1");
header.innerText = row.firstChild.innerText;
newRow.appendChild(header);

const prefright = row.lastChild;
newRow.appendChild(prefright);
}
}

formatPrefTable();
8 changes: 5 additions & 3 deletions js/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ function setupSidebars() {
const [toggleSub, subSide] = setupSubredditSidebar();
const [toggleUser, userSide] = setupUserSidebar();
document.addEventListener("toggleUser", toggleUser);
document.addEventListener("toggleSub", toggleSub);
if (toggleSub) {
document.addEventListener("toggleSub", toggleSub);
}
document.addEventListener("swiped-right", function (e) {
// sidebar.classList.remove("active");
if (subSide.classList.contains("active")) {
if (subSide && subSide.classList.contains("active")) {
toggleSub();
return;
}
Expand All @@ -21,7 +23,7 @@ function setupSidebars() {
toggleUser();
return;
}
if (!subSide.classList.contains("active")) {
if (subSide && !subSide.classList.contains("active")) {
toggleSub();
}
});
Expand Down
3 changes: 3 additions & 0 deletions js/subreddit_sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ export default function setupSidebar() {
const sidebar = document.createElement("div");
const sidebarToggle = document.createElement("div");
const actualSidebar = document.querySelector(".side");
if (!actualSidebar) {
return [null, null];
}
sidebarToggle.id = "sidebar-toggle";
sidebar.id = "custom-sidebar";
sidebar.appendChild(sidebarToggle);
Expand Down
1 change: 1 addition & 0 deletions js/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ import "./general.js";
import "./header.js";
import "./sidebars.js";
import "./posts";
import "./preferences.js";

console.log("oldlander user.js loaded");
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@
"webpack-cli": "^5.1.1"
},
"packageManager": "[email protected]"
}
}

0 comments on commit 1b303e3

Please sign in to comment.