Skip to content

Commit

Permalink
Added an option to hide/show all tags
Browse files Browse the repository at this point in the history
  • Loading branch information
frianasoa committed Dec 19, 2023
1 parent 63296a9 commit 3122ef9
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 49 deletions.
7 changes: 3 additions & 4 deletions content/notes/menus.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ Menus = {
else if(key=="translate-google-en")
{
var mode = "api-key";

if(!annotationkey)
{
alert("Annotation not found!");
Expand Down Expand Up @@ -396,9 +397,7 @@ Menus = {
{
var annotation = Zotero.Items.get(annotationid);
var target = "cell";
data = {
"Direct quote": annotation["annotationText"],
}
data = Table.celldata(td);

if(key.includes("-row"))
{
Expand Down Expand Up @@ -451,7 +450,7 @@ Menus = {
{
html="-"+r;
}
Dialog.open(html, function(){
TabbedDialog.open(html, div, function(){
});
});
}
Expand Down
77 changes: 41 additions & 36 deletions content/notes/table.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@

Table = {
celldata(td)
{
let d = {};
td.querySelectorAll(".user-note").forEach(div=>{
if(Object.keys(d).includes("Reader notes") && div.innerText!="")
{
d["Reader notes"]+=div.innerText.trim("\n")+"\n";
}
else if(div.innerText!="")
{
d["Reader notes"]=div.innerText.trim("\n")+"\n";
}
});

if(Object.keys(d).includes("Reader notes"))
{
d["Reader notes"] = d["Reader notes"].trim("\n")
}

td.querySelectorAll(".annotation-body").forEach(div=>{
var annotationcontent = div.querySelector(".direct-quote").innerText;
var author = div.querySelector(".direct-quote").parentNode.dataset.author;
var date = div.querySelector(".direct-quote").parentNode.dataset.date;
var annotationcomments = Table.splitusernotes(div.querySelector(".annotation-comment").innerHTML);
s = annotationcomments;
s["Direct quote"] = annotationcontent;
s["Author"] = author;
s["Date"] = date;
if(Object.keys(d).includes("Selections"))
{
d["Selections"].push(s);
}
else {
d["Selections"] = [s];
}
});

return d;
},

rowdata(tr){
var data = {
info: {},
Expand All @@ -9,44 +49,9 @@ Table = {
let key = e.dataset.column;
data["info"][key] = e.innerText;
});

tr.querySelectorAll("td").forEach(node=>{
let d = this.celldata(node);
let tag = node.dataset.column;
let d = {};
node.querySelectorAll(".user-note").forEach(div=>{
if(Object.keys(d).includes("Reader notes") && div.innerText!="")
{
d["Reader notes"]+=div.innerText.trim("\n")+"\n";
}
else if(div.innerText!="")
{
d["Reader notes"]=div.innerText.trim("\n")+"\n";
}
});

if(Object.keys(d).includes("Reader notes"))
{
d["Reader notes"] = d["Reader notes"].trim("\n")
}

node.querySelectorAll(".annotation-body").forEach(div=>{
var annotationcontent = div.querySelector(".direct-quote").innerText;
var author = div.querySelector(".direct-quote").parentNode.dataset.author;
var date = div.querySelector(".direct-quote").parentNode.dataset.date;
var annotationcomments = Table.splitusernotes(div.querySelector(".annotation-comment").innerHTML);
s = annotationcomments;
s["Direct quote"] = annotationcontent;
s["Author"] = author;
s["Date"] = date;
if(Object.keys(d).includes("Selections"))
{
d["Selections"].push(s);
}
else {
d["Selections"] = [s];
}
});

if(Object.keys(d).length>0)
{
d["Part"] = tag;
Expand Down
2 changes: 1 addition & 1 deletion content/settings/manage-tags.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<th>Type</th>
<th>Status</th>
<th>Header size</th>
<th></th>
<th><button onclick="Zotero_Preferences.ZNTable.hideall(event);"><i class="fa-solid fa-hurricane red-icon"></i> Hide all</button><button onclick="Zotero_Preferences.ZNTable.showall(event);"><i class="fa solid fa-hurricane"></i> Show all</button></th>
</tr>
</thead>
<tbody id="table-manage-tags-body">
Expand Down
55 changes: 55 additions & 0 deletions content/settings/zntable.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,61 @@ Zotero_Preferences.ZNTable = {
Zotero_Preferences.ZeNotes.saveandreload();
},

hideall(e)
{
if(!confirm("Caution! This will hide all your tags and your previous settings will be lost.\nDo you want to procede?"))
{
return;
}

var table = e.target.closest("table");
table.querySelectorAll("tr").forEach(tr=>{
var visibles = tr.querySelectorAll("span.status-visible");
var visibility = tr.querySelector("span.tag-status:first-child");
if(visibles.length>0)
{
visibility.innerHTML = "hidden";
visibility.className = "tag-status status-hidden";
for(v of visibles)
{
v.classList.add("status-hidden");
v.classList.remove("status-visible");
}
var eye = tr.querySelector(".fa-eye")
eye.className = "fa-solid fa-eye-slash red-icon";
}
});
Zotero_Preferences.ZeNotes.saveandreload();

},

showall(e)
{
if(!confirm("Caution! This will show all your tags and your previous settings will be lost.\nDo you want to procede?"))
{
return;
}
var table = e.target.closest("table");
table.querySelectorAll("tr").forEach(tr=>{
var hiddens = tr.querySelectorAll("span.status-hidden");
var visibility = tr.querySelector("span.tag-status:first-child");
if(hiddens.length>0)
{
visibility.innerHTML = "visible";
visibility.className = "tag-status status-visible";
for(h of hiddens)
{
h.classList.add("status-visible");
h.classList.remove("status-hidden");
}
var eye = tr.querySelector(".fa-eye-slash")
eye.className = "fa-solid fa-eye";
}
});
Zotero_Preferences.ZeNotes.saveandreload();

},

togglevisibility(e)
{
var tr = e.target.closest("tr");
Expand Down
2 changes: 1 addition & 1 deletion install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Description about="urn:mozilla:install-manifest">
<em:id>[email protected]</em:id>
<em:name>ZeNotes</em:name>
<em:version>0.6.5</em:version>
<em:version>0.6.6</em:version>
<em:multiprocessCompatible>true</em:multiprocessCompatible>
<em:updateURL>https://raw.githubusercontent.com/frianasoa/zenotes/main/zenote-update.json</em:updateURL>
<em:homepageURL>https://github.com/frianasoa/zenotes</em:homepageURL>
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Ze Notes",
"version": "0.6.5",
"version": "0.6.6",
"description": "Advanced notes manager",
"homepage_url": "https://github.com/frianasoa/zenotes",
"author": "Fanantenana Rianasoa Andriariniaina",
Expand Down
6 changes: 3 additions & 3 deletions zenote-update.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"[email protected]": {
"updates": [
{
"version": "0.6.5",
"update_link": "https://github.com/frianasoa/Ze-Notes/releases/download/v0.6.5/zenotes-v0.6.5.xpi",
"update_hash": "sha256:16a72706ada3e65f6125324804f97ef9042a5819598c08947ccc078735a535f1",
"version": "0.6.6",
"update_link": "https://github.com/frianasoa/Ze-Notes/releases/download/v0.6.6/zenotes-v0.6.6.xpi",
"update_hash": "sha256:c9bc7bb01d8b6daf534635de158392d1b6ca39a80f95e6ccc617aed3dae30787",
"applications": {
"gecko": {
"strict_min_version": "60.0"
Expand Down
6 changes: 3 additions & 3 deletions zenote-update.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<rdf:Seq>
<rdf:li>
<rdf:Description>
<ns1:version>0.6.5</ns1:version>
<ns1:version>0.6.6</ns1:version>
<ns1:targetApplication>
<rdf:Description>
<ns1:id>[email protected]</ns1:id>
<ns1:minVersion>5.0.0</ns1:minVersion>
<ns1:maxVersion>6.*</ns1:maxVersion>
<ns1:updateLink>https://github.com/frianasoa/Ze-Notes/releases/download/v0.6.5/zenotes-v0.6.5.xpi</ns1:updateLink>
<ns1:updateLink>https://github.com/frianasoa/Ze-Notes/releases/download/v0.6.6/zenotes-v0.6.6.xpi</ns1:updateLink>
</rdf:Description>
</ns1:targetApplication>

Expand All @@ -20,7 +20,7 @@
<ns1:id>[email protected]</ns1:id>
<ns1:minVersion>4.999</ns1:minVersion>
<ns1:maxVersion>6.*</ns1:maxVersion>
<ns1:updateLink>https://github.com/frianasoa/Ze-Notes/releases/download/v0.6.5/zenotes-v0.6.5.xpi</ns1:updateLink>
<ns1:updateLink>https://github.com/frianasoa/Ze-Notes/releases/download/v0.6.6/zenotes-v0.6.6.xpi</ns1:updateLink>
</rdf:Description>
</ns1:targetApplication>

Expand Down

0 comments on commit 3122ef9

Please sign in to comment.