Move "legacy" or otherwise deprecated styles into sub-folder

This commit is contained in:
MrOtherGuy 2023-01-01 18:40:37 +02:00
parent a46d28bcab
commit 7953cb9d8e
18 changed files with 65 additions and 55 deletions

View file

@ -53,8 +53,6 @@ pre:empty{ display: none }
max-width: 30%;
cursor: pointer;
white-space:nowrap;
overflow: hidden;
text-overflow: ellipsis;
display: flex;
}
.target > a{
@ -66,6 +64,10 @@ pre:empty{ display: none }
background-size: contain;
flex-shrink: 0;
}
.target > span{
overflow: hidden;
pointer-events: none;
}
.target:hover{ background-color: rgb(80,80,90) }
.target.selected{ background-color: rgb(80,80,120) }
.target > a:hover{ filter: drop-shadow(0 0 3px fuchsia) }

View file

@ -1,23 +1,34 @@
'use strict';
let DB = null;
function initDB(obj){
DB = obj.content;
Object.defineProperty(DB,"query",{value:function (q,list){
const DB = new (function(){
this.content = null;
this.query = (q,list) => {
let nlist = [];
for(let key of list || this.keys){
if(this[key].includes(q)){
if(this.content[key].includes(q)){
nlist.push(key)
}
}
return nlist
};
this.init = (obj) => {
this.content = obj
}
this._keys = null;
Object.defineProperty(this,"keys",{ get:() => {
if(this.content && !this._keys){
this._keys = Object.keys(this.content).sort();
}
return this._keys
}});
Object.defineProperty(DB,"keys",{value:(Object.keys(DB).sort())});
Object.defineProperty(DB,"getTagsForFile",{value:function(name){return this[name]}});
return true
this.getTagsForFile = (name) => {
return this.content[name];
}
})();
function initDB(obj){
window.DB = DB;
DB.init(obj.content);
}
function fetchWithType(url){
@ -106,7 +117,7 @@ function getSecondaryCategories(list){
function showMatchingTargets(fileNames,setSelected = false){
let bonus = 0;
for(let c of Array.from(document.querySelectorAll(".target"))){
if(fileNames.includes(getText(c))){
if(fileNames.includes(c.dataset.filename)){
c.classList.remove("hidden");
setSelected && selectedTarget.add(c)
}else{
@ -129,7 +140,7 @@ function onCategoryClicked(categoryNode,isSecondary = false){
let fileNames = currentCategory.getFileNames(categoryNode,isSecondary);
if(!isSecondary){
if(fileNames.length > 9){
if(fileNames.length > 9 && categoryNode.textContent != "legacy"){
let matchingSecondaries = getSecondaryCategories(fileNames);
for(let child of Array.from(secondaryCategoriesNode.children)){
matchingSecondaries.includes(child.textContent) ? child.classList.remove("hidden") : child.classList.add("hidden")
@ -148,7 +159,7 @@ function onCategoryClicked(categoryNode,isSecondary = false){
async function onTargetClicked(target,append = false){
const text = typeof target === "string"
? target
: getText(target);
: target.dataset.filename;
fetchWithType(`chrome/${text}`)
.then(obj => {
@ -185,7 +196,7 @@ function onFilenameClicked(box,ctrlKey){
if(ctrlKey){
selectedTarget.deselect(box);
let previewbox = document.getElementById("previewBox");
let preview = previewbox.getNamedSection(`chrome/${box.getAttribute("title")}.css`);
let preview = previewbox.getNamedSection(`chrome/${box.dataset.filename}`);
if(preview){
preview.remove();
}
@ -256,18 +267,19 @@ function createCategories(){
const TAR_PARENT = document.getElementById("targets");
TAR_PARENT.addEventListener("click",onSomeClicked,{passive:true});
const createNode = function(name,type){
const createNode = function(name,type,isDeprecated){
let node = document.createElement("div");
node.classList.add(type);
if(type === "target"){
let link = node.appendChild(document.createElement("a"));
node.classList.add("hidden");
link.href = `https://github.com/MrOtherGuy/firefox-csshacks/tree/master/chrome/${name}`;
link.href = `https://github.com/MrOtherGuy/firefox-csshacks/tree/master/chrome/${isDeprecated?"deprecated/":""}${name}`;
link.title = "See on Github";
link.target = "_blank";
const content = name.substring(0,name.lastIndexOf("."));
node.append(content);
node.appendChild(document.createElement("span")).textContent = content;
node.dataset.filename = `${content}.css`;
node.setAttribute("title",content);
}else{
node.textContent = name.name;
@ -276,17 +288,13 @@ function createCategories(){
return node;
}
const createCategory = name => createNode(name,"category");
const createTarget = name => createNode(name,"target");
const CAT_NAMES = (function(){
let list = [];
for(let key of Object.keys(DB)){
TAR_PARENT.appendChild(createNode(key,"target"));
let things = DB[key];
for(let key of DB.keys){
let things = DB.content[key];
TAR_PARENT.appendChild(createNode(key,"target",things.includes("legacy")));
for(let t of things){
list.push(t)
}

View file

@ -9,7 +9,7 @@
"autohide_tabstoolbar.css":["autohide","tabs","toolbars"],
"autohide_toolbox.css":["autohide","toolbars","fullscreen"],
"blank_page_background.css":["dark-mode"],
"bookmarksbar_on_new_tabs_only.css":["legacy"],
"deprecated/bookmarksbar_on_new_tabs_only.css":["legacy"],
"bookmarks_toolbar_on_newtabs_only.css":["bookmarks","toolbars","autohide","hiding"],
"button_effect_icon_glow.css":["buttons","effect"],
"button_effect_scale_onclick.css":["buttons","effect"],
@ -42,8 +42,8 @@
"fake_statusbar_w_menubar.css":["hack","status","toolbars","menubar"],
"fake_tab_tooltip.css":["tab","hack","popup"],
"floating_findbar_on_top.css":["findbar"],
"full_width_urlbar_popup.css":["legacy"],
"google_style_urlbar_popup.css":["legacy"],
"deprecated/full_width_urlbar_popup.css":["legacy"],
"deprecated/google_style_urlbar_popup.css":["legacy"],
"grid_overflow_menu.css":["popup","menu"],
"hide_statuspanel_when_fullscreen.css":["status","fullscreen","hiding"],
"hide_tabs_scrollbuttons.css":["tabs","hiding","buttons","minimal"],
@ -78,10 +78,10 @@
"multi-row_main_toolbar.css":["urlbar","toolbars","multi-row","hack"],
"multi-row_oneliner_combo_patch.css":["multi-row","patch","one-line","minimal"],
"multi-row_tabs.css":["tabs","multi-row","toolbars"],
"multi-row_tabs_Fx66+.css":["legacy"],
"deprecated/multi-row_tabs_Fx66+.css":["legacy"],
"multi-row_tabs_below_content.css":["multi-row","tabs","toolbars"],
"multi-row_tabs_below_content_legacy.css":["legacy"],
"multi-row_tabs_legacy.css":["legacy"],
"deprecated/multi-row_tabs_below_content_legacy.css":["legacy"],
"deprecated/multi-row_tabs_legacy.css":["legacy"],
"multi-row_tabs_separate_pinned_row_patch.css":["tabs","multi-row","patch"],
"multi-row_tabs_window_control_patch.css":["patch","multi-row","window-control"],
"navbar_below_content.css":["nav-bar","toolbars"],
@ -130,17 +130,17 @@
"tabs_on_bottom_menubar_on_top_patch.css":["tabs","menubar","toolbars","classic","patch"],
"textual_context_navigation.css":["navigation","popup","menu"],
"textual_searchbar_one-offs.css":["popup","menu"],
"theme_additional_windows.css":["legacy"],
"theme_aware_modal_prompts.css":["effect","dark-mode","colors","popup","legacy"],
"theme_color_variables.css":["legacy"],
"theme_popups_and_menus.css":["legacy"],
"theme_sidebar.css":["legacy"],
"theme_toolbars.css":["legacy"],
"toggle_bookmarksbar_with_alt.css":["legacy"],
"deprecated/theme_additional_windows.css":["legacy"],
"deprecated/theme_aware_modal_prompts.css":["legacy"],
"deprecated/theme_color_variables.css":["legacy"],
"deprecated/theme_popups_and_menus.css":["legacy"],
"deprecated/theme_sidebar.css":["legacy"],
"deprecated/theme_toolbars.css":["legacy"],
"deprecated/toggle_bookmarksbar_with_alt.css":["legacy"],
"toggle_tabs_toolbar_with_alt.css":["hack","tabs","menubar"],
"toolbarbuttons_icon+label.css":["buttons","icon"],
"toolbars_below_content.css":["tabs","toolbars"],
"urlbar_and_popup_equal_width.css":["legacy"],
"deprecated/urlbar_and_popup_equal_width.css":["legacy"],
"urlbar_centered_text.css":["urlbar"],
"urlbar_connection_type_background_colors.css":["urlbar","colors","status"],
"urlbar_connection_type_text_colors.css":["urlbar","colors","status"],