Skip to content

Commit

Permalink
v1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
graycat27 committed Feb 6, 2022
1 parent 5d2952d commit 45a0a17
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
3 changes: 2 additions & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ <h1>Footnote js</h1>
<foot-note-list></foot-note-list>
</div>
<div>
see also <a href="otherUsage.html">the other one</a> to check how this library works in some cases.
See also <a href="otherUsage.html">the other one</a> to check how this library works in some cases.<br>
*NOTE: from v1.1, hover on the span wrapped word will show tool-chip
</div>
</body>
</html>
16 changes: 10 additions & 6 deletions docs/js/footnote.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://yui-kitamura.eng.pro
*
* footnote-js
* version 1.0 released on 2022.02.05.
* version 1.1 released on 2022.02.06.
* This provide footnote for your HTML document.
*
* usage
Expand Down Expand Up @@ -65,7 +65,9 @@ let footnoteJs = (function () {
// foot-note の直前に対象を挿入する
targetEle = document.createElement('span');
if(forAtr == null){
targetEle.id = (fn.prefixFootNoteTargetId + fn.cntNotForLinked);
let targetId = (fn.prefixFootNoteTargetId + fn.cntNotForLinked);
element.setAttribute('for', targetId)
targetEle.id = targetId;
fn.cntNotForLinked += 1;
}else{
targetEle.id = forAtr;
Expand All @@ -80,8 +82,6 @@ let footnoteJs = (function () {
fn.cntFootNote += 1;
targetEle.appendChild(numLinkEle);

// append title attribute
targetEle.setAttribute('title', element.textContent);
},
footNoteListTagFunc: function(element){
element.style.display = 'block';
Expand All @@ -91,9 +91,13 @@ let footnoteJs = (function () {
// create footnote list
const footnoteList = document.querySelectorAll('foot-note');
footnoteList.forEach(function(noteEle){
const footnoteRefId = noteEle.getAttribute('for');
// original title attribute
document.getElementById(footnoteRefId).setAttribute('title', noteEle.textContent);

// generate list content
let footNoteEle = document.createElement('div');
const footnoteNum = noteEle.getAttribute('foot-note-num');
const footnoteRefId = noteEle.getAttribute('for');
footNoteEle.id = fn.prefixFootNoteId + footnoteNum;
footNoteEle.innerHTML = ('<a href="#'+ footnoteRefId +'">['+ footnoteNum +']</a>. '+ noteEle.innerHTML);
element.appendChild(footNoteEle);
Expand All @@ -116,10 +120,10 @@ let footnoteJs = (function () {
fn: fn
};
}());
footnoteJs.fn.init();
footnoteJs.fn.registerCustomTagFootNote();

window.addEventListener('DOMContentLoaded', function(){
footnoteJs.fn.init();
footnoteJs.fn.rescueMissedFootNote();
});

2 changes: 1 addition & 1 deletion src/js/footnote.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://yui-kitamura.eng.pro
*
* footnote-js
* version 1.0 released on 2022.02.05.
* version 1.1 released on 2022.02.06.
* This provide footnote for your HTML document.
*
* usage
Expand Down

0 comments on commit 45a0a17

Please sign in to comment.