Difference between revisions of "Template:NYMU-Taipei/newtemplate1"

Line 477: Line 477:
 
<script type="text/javascript">
 
<script type="text/javascript">
 
$(document).ready(function(){
 
$(document).ready(function(){
var dots = [];
+
var dots = [];
 
var contents = document.getElementsByClassName("subtitle");
 
var contents = document.getElementsByClassName("subtitle");
console.log(contents);
 
console.log(Array.isArray(contents));
 
console.log(contents.length);
 
console.log(typeof contents);
 
console.log(contents[0]);
 
 
for (var i = 0; i <= contents.length - 1; i++) {
 
for (var i = 0; i <= contents.length - 1; i++) {
console.log("one");
+
dots.push('<div class="sidebar-item"><span class="sidebar-stuff sidebar-switch dot"></span><div class="sidebar-content sidebar-stuff"><a href=#'+(i+1)+">"+contents[i].innerHTML+'</a></div></div>');
dots.push('<div class="sidebar-item"><span class="sidebar-stuff sidebar-switch dot"></span><div class="sidebar-content sidebar-stuff"><a href=#'+(i+1)+">"+contents[i].innerHTML+'</a></div></div>');
+
 
}
 
}
console.log('two');
 
 
$("#dot-side-bar").html(dots.join().replace(/,/g,''));
 
$("#dot-side-bar").html(dots.join().replace(/,/g,''));
 
});
 
});
 +
  
  
Line 507: Line 501:
 
         if(window.pageYOffset <=borders[i+1]) {
 
         if(window.pageYOffset <=borders[i+1]) {
 
         sidebar[i].style.display = "inline-block";
 
         sidebar[i].style.display = "inline-block";
 +
        }
 +
        else{
 +
        sidebar[i].style.display = "none";
 
         }
 
         }
 
         }
 
         }
 
         else{
 
         else{
 
         sidebar[i].style.display = "none";
 
         sidebar[i].style.display = "none";
        console.log(sidebar[i]);
 
 
         }
 
         }
      $(".sidebar-item").mouseenter(function(){
 
      console.log(this.lastChild);
 
        this.lastChild.style.display = "inline-block";
 
});
 
$(".sidebar-item").mouseleave(function(){
 
      console.log(this.lastChild);
 
        this.lastChild.style.display = "none";
 
});
 
 
         }
 
         }
 
     });
 
     });
 +
 +
    $(".sidebar-item").mouseenter(function(){
 +
        this.lastChild.style.display = "inline-block";
 +
});
 +
$(".sidebar-item").mouseleave(function(){
 +
  this.lastChild.style.display = "none";
 +
});
 
});
 
});
 +
  
 
</script>
 
</script>

Revision as of 04:58, 12 July 2018