- Thi
- Automatically reload page if js file changes
- Add MathJax to website
- Heading hover anchor links
- Back to top button
- Hide / Show box
- Click to enlarge photo
- Prevent default event
- Search + result + navigation
- Scrolling headings in TOC
- Fetch starred repository (JSON to
ol
)
Thi
Ref: π Site: update briefs π Note: magnific popup π Note: jekyll inner links π Note: secret recipes
Automatically reload page if js file changes
- Install nodejs.
- Install live-server using nodejs:
npm install -g live-server
. cd
to the project folder.- run
live-server
(accept all networks notification) - Browse: http://127.0.0.1:8080
- Enjoy!
::: warning It may not reload the browser (it only detects the changes)! :::
Add MathJax to website
π Check the codes.
Anchor links hidden by fixed navigation
If you use table of content for posts in which links starting with #
link to headings. After jumping, headings are usually hidden by the fixed navigation. Adding below script before </body>
tag can solve the problem (change value 100
to change where the page jump).link
π Check the codes. Update 10/26/21: This method is not good. It works only if we click on an <a>
tag which starts with #
in the href
. In the case of which inside <a>
containing an <svg>
, for example, it wonβt work!
Heading hover anchor links
Back to top button
Click and go back to the top of the page using javascript with smooth effect.
π Check the codes.
Hide / Show box
Auto hide / show the next div
of the currently clicked div
.
π Check the codes.
Advantage: We donβt need the id of content div, this method requires that div.hs__content
comes right after div.hs__title
, otherwise it wonβt work!
Click to enlarge photo
If some photos on your page are too small and you wanna add a function in that users can click on the photo to enlarge it. This technique requires Bootstrap 4.
π Check the codes.
Prevent default event
Stop arrow key acts as usual,
window.addEventListener("keydown", function(e) {
// space and arrow keys
if([32, 37, 38, 39, 40].indexOf(e.keyCode) > -1) {
e.preventDefault();
}
}, false);
If div_1
inside div_2
, prevent actions in div_2
when performs on div_1
(check this example), use e.stopPropagation()
.
Search + result + navigation
- Auto close the result if losing focus.
- Cycling the result items with arrow up/down keys.
- Auto focus to the
a
tag of the title.
π Check the codes.
Scrolling headings in TOC
Follow the position of viewport, auto highlight heading in toc w.r.t the current heading on page
π Check the codes.
Fetch starred repository (JSON to ol
)
Automatically fetch a list of Github starred repositories using Github API and display it under <ol>
html tag.link
π Check the codes.
The following wiki, pages and posts are tagged with
Title | Type | Excerpt |
---|---|---|
learningjavascript canvas tag | post | Friday, getting started with the book by coding for user input canvas, amazing! |
ES6 tools techniques and paradigm | post | Fri, Oct 15, 21, a practical and thorough coverage of important language concepts. |
Javascript 101 | post | Tue, Oct 19, 21, quick reference for fundamental things in javascript |
Javascript tips at par with this jekyll | post | Tue, Oct 26, 21, reload page, lose focus, add MathJax to website, hover anchor links, default event, search result navigation, starred repo json |
Javascript dome pattern | post | Thu, Oct 28, 21, Javascipt Patterns μ± μ 8μ₯ 'DOM κ³Ό λΈλΌμ°μ ν¨ν΄' μ μμ½ |
D3 square.github.io data binding | post | Thu, Nov 11, 21, data binding |
D3.js square.github.io tutorial | post | Thu, Nov 11, 21, data binding |
μλ°μ€ν¬λ¦½νΈλ μ κ·Έ λͺ¨μμΌκΉ? | page | λκΈλΌμ€ ν¬λ½ν¬λκ° μλ €μ£Όλ |
javascript for impatient | page | Exploit the power of modern javascript and avoid the pitfalls |
리ν©ν λ§ 2ν | page | μ½λ ꡬ쑰λ₯Ό 체κ³μ μΌλ‘ κ°μ νμ¬ ν¨μ¨μ μΈ λ¦¬ν©ν°λ§ ꡬννκΈ° |
μλ°μ€ν¬λ¦½νΈ μ½λ©μ κΈ°μ | page | λλνκ² μ½λ©νλ λ² |
jsimpatient learning path | post | javascript revisited |