Skip to content

Commit b10b9d0

Browse files
authored
2.0.111 + Merge pull request #254 from Morikko/search-folders-add-path
Add path for folders results when searching + additional features for 2.0.111
2 parents b6a9198 + 8e42b8a commit b10b9d0

File tree

3 files changed

+73
-17
lines changed

3 files changed

+73
-17
lines changed

sidebar/panel.css

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
:root{
1+
:root {
22
--bg-color: white;
33
--txt-color: #222426;
44
}
@@ -200,11 +200,10 @@ p {
200200
}
201201

202202
#trace {
203-
width: 200px;
203+
width: calc(100% - 9px);
204204
resize: none;
205205
font-size: x-small;
206206
white-space: pre;
207-
overflow: visible;
208207
flex: none;
209208
margin-left: 4px;
210209
}
@@ -228,6 +227,11 @@ table {
228227
border-spacing: 0;
229228
}
230229

230+
#resultstable {
231+
width: 100%;
232+
table-layout: fixed;
233+
}
234+
231235
tbody {
232236
min-width: 100%;
233237
}
@@ -323,6 +327,10 @@ tbody {
323327
border-bottom: solid 2px transparent;
324328
margin-top: -2px;
325329
margin-bottom: -2px;
330+
width: 100%;
331+
padding-right: 4px;
332+
display: flex;
333+
flex-direction: row;
326334
}
327335

328336
.bkmkitem_s {
@@ -369,6 +377,7 @@ tbody {
369377
}
370378

371379
.rtwistieac {
380+
flex: none;
372381
display: inline-block;
373382
height: 16px;
374383
width: 16px;
@@ -395,6 +404,7 @@ tbody {
395404
}
396405

397406
.ffavicon {
407+
flex: none;
398408
display: inline-block;
399409
height: 16px;
400410
width: 16px;
@@ -422,6 +432,17 @@ tbody {
422432
white-space: pre;
423433
}
424434

435+
.rfavpath {
436+
flex-grow: 1;
437+
text-align: end;
438+
font-style: italic;
439+
font-size: 90%;
440+
padding-left: 10px;
441+
opacity: 0.6;
442+
overflow-x: hidden;
443+
text-overflow: ellipsis;
444+
}
445+
425446
.mymenu {
426447
position: fixed;
427448
z-index: 9999;

sidebar/panel.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<div id="searchresult" class="rscrollok" hidden=true>
1919
<img src="/icons/waiting.gif" height="20px" id="waitingsearch">
2020
<!--
21-
<table><tbody>
21+
<table id="resultstable"><tbody>
2222
<tr data-id=".." data-type="bookmark" data-rslt="true"><td class="brow" tabindex="0" draggable="false">
2323
<div class="rbkmkitem_b" href=".." draggable="false">
2424
<img src="/icons/nofavicon.png" class="favicon" draggable="false">

sidebar/panel.js

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@ tmpElem1 = document.createElement("span"); // Assuming it is an HTMLSpanElement
252252
tmpElem1.classList.add("favtext");
253253
tmpElem1.draggable = false; // False by default for <span>
254254
RFolderTempl.appendChild(tmpElem1);
255+
tmpElem1 = document.createElement("span"); // Assuming it is an HTMLSpanElement
256+
tmpElem1.classList.add("rfavpath");
257+
tmpElem1.draggable = false; // False by default for <span>
258+
RFolderTempl.appendChild(tmpElem1);
255259
/*
256260
******* Prepare special Folder structure for node cloning
257261
*/
@@ -288,6 +292,10 @@ tmpElem1 = document.createElement("span"); // Assuming it is an HTMLSpanElement
288292
tmpElem1.classList.add("favtext");
289293
tmpElem1.draggable = false; // False by default for <span>
290294
RSFolderTempl.appendChild(tmpElem1);
295+
tmpElem1 = document.createElement("span"); // Assuming it is an HTMLSpanElement
296+
tmpElem1.classList.add("rfavpath");
297+
tmpElem1.draggable = false; // False by default for <span>
298+
RSFolderTempl.appendChild(tmpElem1);
291299
/*
292300
******* Prepare Separator structure for node cloning
293301
*/
@@ -553,13 +561,15 @@ function appendResult (BN) {
553561
// - a <div> (class "rtwistiexx") if a folder
554562
// - an <div>, or <img> if special folder, (class "favicon")
555563
// - and a <span> with text (class "favtext")
564+
// - for folder results, additionally, a <span> with path to the folder (class "rfavpath")
556565
if (type == "folder") { // Folder
557566
// Mark that row as folder
558567
row.dataset.type = "folder";
559568

560569
// Create elements
561570
let div2;
562571
let span;
572+
let pathspan;
563573
if (BN.fetchedUri) { // Special bookmark folder with special favicon
564574
div2 = RSFolderTempl.cloneNode(true);
565575
let img = div2.firstElementChild.nextElementSibling;
@@ -573,16 +583,20 @@ function appendResult (BN) {
573583
if (BN.inBSP2Trash) { // Set to italics
574584
span.style.fontStyle = "italic";
575585
}
576-
577586
let title = BN.title;
587+
span.textContent = title;
588+
// span.draggable = false;
589+
590+
pathspan = span.nextElementSibling;
591+
let p = pathspan.textContent = BN_path(BN.parentId);
592+
// pathspan.draggable = false;
593+
578594
if (showPath_option) {
579-
div2.title = BN_path(BN.parentId);
595+
div2.title = p;
580596
}
581597
else {
582598
div2.title = title;
583599
}
584-
span.textContent = title;
585-
// span.draggable = false;
586600
cell.appendChild(div2);
587601
}
588602
else { // "bookmark"
@@ -603,7 +617,7 @@ function appendResult (BN) {
603617
anchor = RNFBookmarkTempl.cloneNode(true);
604618
span = anchor.firstElementChild.nextElementSibling;
605619
}
606-
else { // clone normal one, and fill image
620+
else { // Clone normal one, and fill image
607621
anchor = RBookmarkTempl.cloneNode(true);
608622
let img = anchor.firstElementChild;
609623
img.src = uri;
@@ -921,6 +935,7 @@ function displayResults (a_BTN) {
921935
// Create search results table
922936
// resultsFragment = document.createDocumentFragment();
923937
resultsTable = document.createElement("table");
938+
resultsTable.id = "resultstable";
924939
SearchResult.appendChild(resultsTable); // Display the search results table + reflow
925940
// resultsFragment.appendChild(resultsTable);
926941

@@ -967,7 +982,7 @@ let searchlistTimeoutId;
967982
function closeSearchList () {
968983
searchlistTimeoutId == undefined;
969984
SearchTextInput.blur(); // This closes the search list
970-
SearchTextInput.focus(); // Givz back focus to be able to type again
985+
SearchTextInput.focus(); // Give back focus to be able to type again
971986
let l = SearchTextInput.value.length; // Focus is selecting all text in the input => de-select to type at end ...
972987
SearchTextInput.setSelectionRange(l, l);
973988
}
@@ -5366,19 +5381,39 @@ console.log("tabs length: "+len);
53665381
|| types.includes(type = "text/x-moz-url") // Dragging the location bar URL address
53675382
) {
53685383
let url = dt.getData(type);
5369-
let title = dt.getData("text/x-moz-url-desc");
5370-
if (title.length == 0) {
5371-
title = dt.getData("text/x-moz-url");
5384+
// Try the URL description type
5385+
let title = dt.getData("text/x-moz-url-desc").trim();
5386+
let splitIndex = title.indexOf("\n"); // Remove any "\n" and following part if there is in title
5387+
if (splitIndex > 0) {
5388+
title = title.slice(0, splitIndex);
53725389
}
53735390

5374-
let splitIndex = url.indexOf("\n"); // Remove any "\n" and following part if there is in URL
5391+
// Get URL
5392+
splitIndex = url.indexOf("\n"); // Remove any "\n" and following part if there is in URL
53755393
if (splitIndex > 0) {
53765394
url = url.slice(0, splitIndex);
53775395
}
5378-
if (title.length == 0) { // If title is empty, use the URL as title
5396+
if (url.startsWith("https://www.google.com/url?")) { // Handle Google search result drag = simplify it
5397+
splitIndex = url.indexOf("&url="); // Remove any "&url=" and parts before
5398+
if (splitIndex > 0) {
5399+
url = url.slice(splitIndex+5);
5400+
splitIndex = url.indexOf("&"); // Remove any following "&" and parts after, to keep only the real URL
5401+
if (splitIndex > 0) {
5402+
url = url.slice(0, splitIndex);
5403+
}
5404+
// Decode the URL
5405+
url = decodeURIComponent(url);
5406+
}
5407+
}
5408+
5409+
// Adjust title if empty
5410+
if (title.length == 0) { // If title is empty, try the URL content (e.g. location bar drag & drop)
5411+
title = dt.getData("text/x-moz-url");
5412+
}
5413+
if (title.length == 0) { // If title is still empty, use the URL as title
53795414
title = url;
53805415
}
5381-
else { // If there is an "\n", keep the part after
5416+
else { // If there is an "\n", keep the part after (can only be for "text/x-moz-url", e.g. location bar drag & drop)
53825417
splitIndex = title.indexOf("\n");
53835418
title = title.slice(splitIndex+1);
53845419
}
@@ -7130,7 +7165,7 @@ if (traceEnabled_option) {
71307165
}
71317166
// If a show path option changed, update any open search result
71327167
if ((showPath_option_old != showPath_option)
7133-
|| (showPath_option && (reversePath_option_old != reversePath_option))
7168+
|| (reversePath_option_old != reversePath_option)
71347169
) {
71357170
// Trigger an update as results can change, if there is a search active
71367171
triggerUpdate();

0 commit comments

Comments
 (0)