edit after keyup 'e' or ctrl+click on triad link..
This commit is contained in:
parent
2859538315
commit
992897b9cb
4 changed files with 35 additions and 4 deletions
|
@ -54,13 +54,41 @@ window.addEventListener("scroll", function (e) {
|
|||
}
|
||||
});
|
||||
|
||||
function editPage(repoJsId) {
|
||||
let relPath = "../".repeat(relPathDepth - 1);
|
||||
var el = document.createElement('script');
|
||||
el.onload = ()=> {
|
||||
console.log("loading...")
|
||||
console.log(repo)
|
||||
}
|
||||
el.src = `${relPath}js/repo/${repoJsId}.js`
|
||||
document.body.appendChild(el)
|
||||
document.location.href = `${relPath}svedit/index.html#${repoJsId}`
|
||||
ev}
|
||||
|
||||
window.addEventListener("keyup", (e)=> {
|
||||
if (e.key == "e") {
|
||||
editPage(sandpointsPageId)
|
||||
}
|
||||
})
|
||||
|
||||
window.addEventListener("DOMContentLoaded", (e) => {
|
||||
document.querySelectorAll('.triadlink').forEach((i) => {
|
||||
console.log(i)
|
||||
i.addEventListener("click", (ev) => {
|
||||
if (ev.ctrlKey) {
|
||||
ev.preventDefault()
|
||||
editPage(ev.target.getAttribute("repoid"))
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
let preview = document.querySelector("#preview");
|
||||
if (
|
||||
location.pathname.split("/").includes("_preview") ||
|
||||
location.hash.startsWith("#/_edit")
|
||||
) {
|
||||
preview.style.display = "flex";
|
||||
evpreview.style.display = "flex";
|
||||
}
|
||||
|
||||
let par = document.querySelector(
|
||||
|
|
|
@ -29,9 +29,9 @@
|
|||
{{- $session := $.Page.Site.GetPage (printf "/%s" (replace .Destination ":" "/")) -}}
|
||||
{{ .Page.Scratch.Add "links" (slice $session) }}
|
||||
{{- if not $text_link -}}
|
||||
<a printhref="#ph-{{- $session.File.UniqueID -}}" href="{{- $session.RelPermalink -}}{{- if eq hugo.Environment "offline" -}}index.html{{- end -}}"{{- with $session.Title}} title="{{- $session.Title -}}"{{- end -}}><span class="sup">{{- index (split .Destination ":") 0 -}}⁄</span>{{- $session.Title -}}</a>
|
||||
<a class="triadlink" repoid="{{- $session.File.UniqueID -}}" printhref="#ph-{{- $session.File.UniqueID -}}" href="{{- $session.RelPermalink -}}{{- if eq hugo.Environment "offline" -}}index.html{{- end -}}"{{- with $session.Title}} title="{{- $session.Title -}}"{{- end -}}><span class="sup">{{- index (split .Destination ":") 0 -}}⁄</span>{{- $session.Title -}}</a>
|
||||
{{- else -}}
|
||||
<a printhref="#ph-{{- $session.File.UniqueID -}}" href="{{- $session.RelPermalink -}}{{- if eq hugo.Environment "offline" -}}index.html{{- end -}}"{{- with .Title}} title="{{- . -}}"{{- end -}}><span class="sup">{{- index (split .Destination ":") 0 -}}⁄</span>{{- $text_link -}}</a>
|
||||
<a class="triadlink" repoid="{{- $session.File.UniqueID -}}" printhref="#ph-{{- $session.File.UniqueID -}}" href="{{- $session.RelPermalink -}}{{- if eq hugo.Environment "offline" -}}index.html{{- end -}}"{{- with .Title}} title="{{- . -}}"{{- end -}}><span class="sup">{{- index (split .Destination ":") 0 -}}⁄</span>{{- $text_link -}}</a>
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
<a href="{{- .Destination -}}/{{- if eq hugo.Environment "offline" -}}index.html{{- end -}}">{{- $text_link -}}⦚<span>{{- .Destination -}} not found</span></a>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<script type="text/javascript">var relPathDepth = {{- .RelPermalink | strings.Count "/" -}};</script>
|
||||
<script type="text/javascript">var relPathDepth = {{- .RelPermalink | strings.Count "/" -}};var sandpointsPageId = "{{- with .File -}}{{- .UniqueID -}}{{- end -}}";</script>
|
||||
{{ $sjsopts := dict "targetPath" "js/sandpoints.js" "minify" "true"}}
|
||||
{{ $sjs := resources.Get "js/sandpoints.js" | js.Build $sjsopts }}
|
||||
<script defer src='{{ $sjs.RelPermalink }}' type="application/javascript"></script>
|
||||
|
|
|
@ -93,3 +93,6 @@
|
|||
{{ with .Page.Params.abstract }}<div class="abstract"><span class="supt">abstract⁄</span>{{ . | $.Page.RenderString | htmlUnescape | safeHTML }}</div>{{ end }}
|
||||
|
||||
{{- $vld := false -}}{{- range $k, $v := .Page.Params.keywords -}}{{- if eq $k 0 -}}{{- $vld = true -}}<div class="keywords"><span class="sup">keywords⁄</span>{{- $v -}}{{- else -}}, {{- $v -}}{{- end -}}{{- end -}}{{- with $vld -}}</div>{{- end -}}
|
||||
|
||||
{{ $var := printf "repo={\"frontmatter\": %s, \"content\": %s, \"path\": \"%s\", \"relpermalink\": \"%s\"}" (jsonify .Params) (jsonify .RawContent) .File.Path .RelPermalink| resources.FromString (printf "js/repo/%s.js" .File.UniqueID) }}
|
||||
{{ $dummy := $var.Permalink }}
|
||||
|
|
Loading…
Add table
Reference in a new issue