提交 d922e82b 编写于 作者: M Martin Kletzander

docs: Some JavaScript clean-up

Don't use the global namespace, unify quotes and semicolons at the end of lines
and "use strict".
Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
Reviewed-by: NAndrea Bolognani <abologna@redhat.com>
上级 2674d00e
"use strict";
function pageload() { function pageload() {
window.addEventListener('scroll', function(e){ window.addEventListener("scroll", function(e){
var distanceY = window.pageYOffset || document.documentElement.scrollTop var distanceY = window.pageYOffset || document.documentElement.scrollTop;
var shrinkOn = 94 var shrinkOn = 94;
home = document.getElementById("home"); var home = document.getElementById("home");
links = document.getElementById("jumplinks"); var links = document.getElementById("jumplinks");
search = document.getElementById("search"); var search = document.getElementById("search");
body = document.getElementById("body"); var body = document.getElementById("body");
if (distanceY > shrinkOn) { if (distanceY > shrinkOn) {
if (home.className != "navhide") { if (home.className != "navhide") {
body.className = "navhide" body.className = "navhide";
home.className = "navhide" home.className = "navhide";
links.className = "navhide" links.className = "navhide";
search.className = "navhide" search.className = "navhide";
} }
} else { } else {
if (home.className == "navhide") { if (home.className == "navhide") {
body.className = "" body.className = "";
home.className = "" home.className = "";
links.className = "" links.className = "";
search.className = "" search.className = "";
} }
} }
}); });
/* Setting this class makes the advanced search options visible */ /* Setting this class makes the advanced search options visible */
advancedSearch = document.getElementById("advancedsearch") var advancedSearch = document.getElementById("advancedsearch");
advancedSearch.className = "advancedsearch" advancedSearch.className = "advancedsearch";
simpleSearch = document.getElementById("simplesearch") var simpleSearch = document.getElementById("simplesearch");
simpleSearch.addEventListener("submit", advancedsearch) simpleSearch.addEventListener("submit", advancedsearch);
} }
function advancedsearch(e) { function advancedsearch(e) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
form = document.createElement("form"); var form = document.createElement("form");
form.setAttribute("method", "get"); form.setAttribute("method", "get");
newq = document.createElement("input"); var newq = document.createElement("input");
newq.setAttribute("type", "hidden"); newq.setAttribute("type", "hidden");
form.appendChild(newq); form.appendChild(newq);
q = document.getElementById("searchq"); var q = document.getElementById("searchq");
whats = document.getElementsByName("what"); var whats = document.getElementsByName("what");
what = "website"; var what = "website";
for (var i = 0; i < whats.length; i++) { for (var i = 0; i < whats.length; i++) {
if (whats[i].checked) { if (whats[i].checked) {
what = whats[i].value; what = whats[i].value;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册