Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Camil Staps
clean-doc
Commits
606012d9
Verified
Commit
606012d9
authored
Oct 06, 2018
by
Camil Staps
🚀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Keep sidebar information in sessionStorage (
#4
)
parent
2c85b1f5
Pipeline
#14660
failed with stage
in 54 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
4 deletions
+37
-4
data/cleandoc-default/js/cleandoc.js
data/cleandoc-default/js/cleandoc.js
+36
-2
src/Clean/Doc/ModuleCollection/HTML.icl
src/Clean/Doc/ModuleCollection/HTML.icl
+1
-2
No files found.
data/cleandoc-default/js/cleandoc.js
View file @
606012d9
...
...
@@ -80,7 +80,7 @@ function highlightCallback(span, cls, str) {
/* Open collapsable of hashtag in url */
window
.
onhashchange
=
function
()
{
if
(
window
.
location
.
hash
.
substring
(
0
,
1
)
==
'
#
'
)
{
let
id
=
window
.
location
.
hash
.
substring
(
1
);
let
id
=
decodeURIComponent
(
window
.
location
.
hash
.
substring
(
1
)
)
;
let
elem
=
document
.
getElementById
(
id
);
if
(
elem
.
classList
.
contains
(
'
collapsable
'
))
{
elem
.
collapsableOpen
();
...
...
@@ -103,7 +103,7 @@ function highlightCallback(span, cls, str) {
});
}
/*
s
earch field */
/*
S
earch field */
let
searchfield
=
document
.
getElementById
(
'
search-field
'
);
let
searchresults
=
document
.
getElementById
(
'
search-results
'
).
querySelector
(
'
ul
'
);
let
searchcloogle
=
document
.
getElementById
(
'
search-cloogle
'
);
...
...
@@ -111,6 +111,8 @@ function highlightCallback(span, cls, str) {
searchresults
.
innerHTML
=
''
;
searchcloogle
.
innerHTML
=
''
;
sessionStorage
.
searchValue
=
this
.
value
;
if
(
this
.
value
==
''
)
return
;
...
...
@@ -135,4 +137,36 @@ function highlightCallback(span, cls, str) {
searchresults
.
appendChild
(
li
);
}
};
let
savedScrollDivs
=
[
'
toc
'
,
'
search
'
];
for
(
let
i
in
savedScrollDivs
)
{
let
elem
=
document
.
getElementById
(
savedScrollDivs
[
i
]);
elem
.
onscroll
=
function
()
{
sessionStorage
[
'
scrollTop-
'
+
savedScrollDivs
[
i
]]
=
this
.
scrollTop
;
sessionStorage
[
'
scrollLeft-
'
+
savedScrollDivs
[
i
]]
=
this
.
scrollLeft
;
};
}
let
restoreSessionSettings
=
function
()
{
if
(
typeof
sessionStorage
.
searchValue
!=
'
undefined
'
)
{
searchfield
.
value
=
sessionStorage
.
searchValue
;
searchfield
.
oninput
();
}
for
(
let
i
in
savedScrollDivs
)
{
let
elem
=
document
.
getElementById
(
savedScrollDivs
[
i
]);
if
(
typeof
sessionStorage
[
'
scrollTop-
'
+
savedScrollDivs
[
i
]]
!=
'
undefined
'
)
elem
.
scrollTop
=
sessionStorage
[
'
scrollTop-
'
+
savedScrollDivs
[
i
]];
if
(
typeof
sessionStorage
[
'
scrollLeft-
'
+
savedScrollDivs
[
i
]]
!=
'
undefined
'
)
elem
.
scrollLeft
=
sessionStorage
[
'
scrollLeft-
'
+
savedScrollDivs
[
i
]];
}
};
/* Lunr index; afterwards restore session */
fetch
(
make_relative_url
(
'
data/lunr-index.json
'
))
.
then
(
function
(
response
)
{
return
response
.
json
();
})
.
then
(
function
(
json
)
{
build_lunr
(
json
);
restoreSessionSettings
();
});
})();
src/Clean/Doc/ModuleCollection/HTML.icl
View file @
606012d9
...
...
@@ -29,7 +29,7 @@ import Clean.Doc.ModuleCollection.Index => qualified :: IndexItem{name}
generateHTML
::
!
ModuleCollection
->
WebSite
generateHTML
mcoll
=
[(
"
js
/lunr-index.js"
,
"build_lunr("
+++
(
toString
$
toJSON
$
indexModuleCollection
mcoll
)
+++
");"
)
]
++
[(
"
data
/lunr-index.js
on
"
,
toString
$
toJSON
$
indexModuleCollection
mcoll
)]
++
map
(\(
fp
,
html
)
->
(
fp
,
finalizeHTML
fp
html
))
[
(
"index.html"
,
Text
""
)
:
map
moduleFile
mcoll
...
...
@@ -47,7 +47,6 @@ where
,
ScriptTag
[
DeferAttr
"defer"
,
SrcAttr
(
relativePath
"modules/clean-doc-markup/clean-doc-markup.js"
)]
[]
,
ScriptTag
[
DeferAttr
"defer"
,
SrcAttr
(
relativePath
"js/cleandoc.js"
)]
[]
,
ScriptTag
[
DeferAttr
"defer"
,
SrcAttr
(
relativePath
"modules/lunr.js/lunr.js"
)]
[]
,
ScriptTag
[
DeferAttr
"defer"
,
SrcAttr
(
relativePath
"js/lunr-index.js"
)]
[]
]
,
BodyTag
[]
[
DivTag
[
IdAttr
"container"
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment