2019-06-20 09:21:37 +00:00
|
|
|
"use strict";
|
|
|
|
|
2019-04-05 12:59:31 +00:00
|
|
|
function pageload() {
|
2019-06-20 09:21:37 +00:00
|
|
|
window.addEventListener("scroll", function(e){
|
|
|
|
var distanceY = window.pageYOffset || document.documentElement.scrollTop;
|
|
|
|
var shrinkOn = 94;
|
|
|
|
var home = document.getElementById("home");
|
|
|
|
var links = document.getElementById("jumplinks");
|
|
|
|
var search = document.getElementById("search");
|
|
|
|
var body = document.getElementById("body");
|
2019-04-05 12:59:31 +00:00
|
|
|
if (distanceY > shrinkOn) {
|
|
|
|
if (home.className != "navhide") {
|
2019-06-20 09:21:37 +00:00
|
|
|
body.className = "navhide";
|
|
|
|
home.className = "navhide";
|
|
|
|
links.className = "navhide";
|
|
|
|
search.className = "navhide";
|
2019-04-05 12:59:31 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (home.className == "navhide") {
|
2019-06-20 09:21:37 +00:00
|
|
|
body.className = "";
|
|
|
|
home.className = "";
|
|
|
|
links.className = "";
|
|
|
|
search.className = "";
|
2019-04-05 12:59:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2019-04-05 15:49:05 +00:00
|
|
|
|
|
|
|
/* Setting this class makes the advanced search options visible */
|
2019-06-20 09:21:37 +00:00
|
|
|
var advancedSearch = document.getElementById("advancedsearch");
|
|
|
|
advancedSearch.className = "advancedsearch";
|
2019-04-05 15:49:05 +00:00
|
|
|
|
2019-06-20 09:21:37 +00:00
|
|
|
var simpleSearch = document.getElementById("simplesearch");
|
|
|
|
simpleSearch.addEventListener("submit", advancedsearch);
|
2019-04-05 15:49:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function advancedsearch(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
|
2019-06-20 09:21:37 +00:00
|
|
|
var form = document.createElement("form");
|
2019-04-05 15:49:05 +00:00
|
|
|
form.setAttribute("method", "get");
|
|
|
|
|
2019-06-20 09:21:37 +00:00
|
|
|
var newq = document.createElement("input");
|
2019-04-05 15:49:05 +00:00
|
|
|
newq.setAttribute("type", "hidden");
|
|
|
|
form.appendChild(newq);
|
|
|
|
|
2019-06-20 09:21:37 +00:00
|
|
|
var q = document.getElementById("searchq");
|
|
|
|
var whats = document.getElementsByName("what");
|
|
|
|
var what = "website";
|
2019-04-05 15:49:05 +00:00
|
|
|
for (var i = 0; i < whats.length; i++) {
|
|
|
|
if (whats[i].checked) {
|
|
|
|
what = whats[i].value;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-13 12:10:17 +00:00
|
|
|
form.setAttribute("action", "https://google.com/search");
|
|
|
|
newq.setAttribute("name", "q");
|
|
|
|
|
2019-04-05 15:49:05 +00:00
|
|
|
if (what == "website") {
|
|
|
|
newq.value = "site:libvirt.org " + q.value;
|
|
|
|
} else if (what == "wiki") {
|
2023-03-13 12:10:17 +00:00
|
|
|
newq.value = "site:wiki.libvirt.org " + q.value;
|
2019-04-05 15:49:05 +00:00
|
|
|
} else if (what == "devs") {
|
|
|
|
newq.value = "site:redhat.com/archives/libvir-list " + q.value;
|
|
|
|
} else if (what == "users") {
|
|
|
|
newq.value = "site:redhat.com/archives/libvirt-users " + q.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
document.body.appendChild(form);
|
|
|
|
form.submit();
|
|
|
|
|
|
|
|
return false;
|
2019-04-05 12:59:31 +00:00
|
|
|
}
|
2019-06-19 13:50:40 +00:00
|
|
|
|
|
|
|
function fetchRSS() {
|
|
|
|
if (document.location.protocol == "file:")
|
|
|
|
return;
|
|
|
|
|
|
|
|
var planet = document.getElementById("planet");
|
|
|
|
if (planet === null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
var req = new XMLHttpRequest();
|
|
|
|
req.open("GET", "https://planet.virt-tools.org/atom.xml");
|
|
|
|
req.setRequestHeader("Accept", "application/atom+xml, text/xml");
|
|
|
|
req.onerror = function(e) {
|
|
|
|
if (this.statusText != "")
|
|
|
|
console.error(this);
|
|
|
|
};
|
|
|
|
req.onload = function(e) {
|
|
|
|
if (this.readyState !== 4)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (this.status != 200) {
|
|
|
|
console.error(this.statusText);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.responseXML === null) {
|
|
|
|
console.error("Atom response is not an XML");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var dl = document.createElement("dl");
|
|
|
|
var dateOpts = { day: "numeric", month: "short", year: "numeric"};
|
|
|
|
|
|
|
|
var entries = this.responseXML.querySelectorAll("feed > entry:not(:nth-of-type(1n+5))");
|
|
|
|
|
|
|
|
entries.forEach(function(e) {
|
|
|
|
var name = e.querySelector("author > name").textContent;
|
|
|
|
var title = e.querySelector("title").textContent;
|
|
|
|
var updated = e.querySelector("updated").textContent;
|
2019-06-20 15:00:17 +00:00
|
|
|
var link = e.querySelector("link").attributes.href.textContent;
|
2019-06-19 13:50:40 +00:00
|
|
|
|
|
|
|
var a = document.createElement("a");
|
2019-06-20 15:00:17 +00:00
|
|
|
a.href = link;
|
2019-06-19 13:50:40 +00:00
|
|
|
a.innerText = title;
|
|
|
|
|
|
|
|
var dt = document.createElement("dt");
|
|
|
|
dt.appendChild(a);
|
|
|
|
dl.appendChild(dt);
|
|
|
|
|
|
|
|
var date = new Date(updated);
|
|
|
|
date = date.toLocaleDateString("default", dateOpts);
|
|
|
|
|
|
|
|
var dd = document.createElement("dd");
|
|
|
|
dd.innerText = ` by ${name} on ${date}`;
|
|
|
|
|
|
|
|
dl.appendChild(dd);
|
|
|
|
});
|
|
|
|
|
|
|
|
planet.appendChild(dl);
|
|
|
|
};
|
|
|
|
req.send();
|
|
|
|
}
|