mirror of
https://gitlab.com/octtspacc/OcttKB
synced 2025-06-06 00:29:12 +02:00
OcttKB Cross-Repo Sync (HTML to Raw)
This commit is contained in:
37
Wiki-OcttKB/tiddlers/System/Macros/Breadcrumbs/_Main.tid
Normal file
37
Wiki-OcttKB/tiddlers/System/Macros/Breadcrumbs/_Main.tid
Normal file
@@ -0,0 +1,37 @@
|
||||
created: 20230129125013039
|
||||
creator: Octt
|
||||
modified: 20230301212518124
|
||||
modifier: Octt
|
||||
tags:
|
||||
title: $:/Macros/Breadcrumbs/Main
|
||||
|
||||
\define cp() javascript:(navigator.clipboard.writeText("$(currentTiddler)$"))
|
||||
|
||||
\define MakeViewBreadcrumbs()
|
||||
\whitespace trim
|
||||
<span class="View-Breadcrumbs">
|
||||
<$set name="Caller" value=<<currentTiddler>>>
|
||||
<$list filter="[<currentTiddler>split[/]limit[-1]]" counter="Index">
|
||||
<span class="Path-Elem" data-path-elem=<<currentTiddler>>>
|
||||
<$link to={{{[<Caller>split[/]limit<Index>join[/]]}}}>
|
||||
<<currentTiddler>>
|
||||
</$link>
|
||||
</span>
|
||||
<span class="Inline-Sep">
|
||||
<span>/</span>
|
||||
</span>
|
||||
</$list>
|
||||
</$set>
|
||||
<$set name="Tiddler" value={{{[<currentTiddler>split[/]last[]]}}}>
|
||||
<span class="Path-Elem" data-path-elem=<<Tiddler>>>
|
||||
<details>
|
||||
<summary>
|
||||
<$text text=<<Tiddler>>/>
|
||||
</summary>
|
||||
<$macrocall $name="tiddlertree" tag=<<currentTiddler>>/>
|
||||
</details>
|
||||
</span>
|
||||
</$set>
|
||||
<a href=<<cp>> class="Path-Copy" title="Copy path to Clipboard">▪️</a>
|
||||
</span>
|
||||
\end
|
@@ -0,0 +1,40 @@
|
||||
/*\
|
||||
Hide i18n namespace labels dynamically from the Breadcrumbs line
|
||||
(by wrapping them in CSS-selectable elements)
|
||||
\*/
|
||||
(function(){
|
||||
"use strict";
|
||||
exports.name = "i18nBreadcrumbsNamespaceLabelStrip";
|
||||
exports.params = [];
|
||||
|
||||
exports.run = function() {
|
||||
try {
|
||||
var Languages = $tw.wiki.getTiddler('$:/i18n').fields.Languages.toLowerCase().split(' ');
|
||||
var Path = this.getVariable('currentTiddler');
|
||||
var Select = `.tc-story-river > div[data-tiddler-title="${Path}"] > .View-Breadcrumbs > .Path-Elem`;
|
||||
var List = document.querySelectorAll(Select + ':last-of-type');
|
||||
for (var i=0; i < List.length; i++) {
|
||||
// At end of tiddler path (e.g: Tests/Misc/Test:en)
|
||||
var Name = List[i].innerHTML.trim();
|
||||
var Code = Name.toLowerCase().split(':').slice(-1)[0];
|
||||
if (Languages.includes(Code)) {
|
||||
List[i].innerHTML = `${Name.split(':').slice(0, -1)}<span class="Inline-Hidden">:${Code}</span>`;
|
||||
} else {
|
||||
// At start of tiddler path (e.g: Testing:en/Misc/Test); handle $:/ prefix if present
|
||||
var Index = Path.startsWith('$:/') ? 2 : 1;
|
||||
var Code = Path.toLowerCase().split(':')[Index];
|
||||
if (Code) {
|
||||
Code = Code.split('/')[0];
|
||||
if (Languages.includes(Code)) {
|
||||
var List = document.querySelectorAll(`${Select}:nth-child(${Index})`);
|
||||
for (var i=0; i < List.length; i++) {
|
||||
// TODO // List[i].innerHTML = `<span class="Inline-Hidden">:${Code}</span>/${Path.split(':')[Index].split('/').slice(1).join('/')}`;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
} catch(e) {
|
||||
$OcttKB.ErrAtLine(e);
|
||||
};
|
||||
}})();
|
@@ -0,0 +1,8 @@
|
||||
created: 20230125222831006
|
||||
creator: Octt
|
||||
modified: 20230202185802952
|
||||
modifier: Octt
|
||||
module-type: macro
|
||||
tags:
|
||||
title: $:/Macros/Breadcrumbs/i18nNamespaceLabelStrip.js
|
||||
type: application/javascript
|
Reference in New Issue
Block a user