web-cv/assets/js/script.js

57 lines
1.7 KiB
JavaScript

function opencell(id) {
var x = document.getElementsByClassName("opened");
var url = window.location.toString();
url = url.split("#")[0];
if ( x.length !== 0) {
var w = x[0].getElementsByClassName("data");
w[0].classList.add("hidden");
w[0].classList.remove("display");
var currentid = x[0].id
// x[0].classList.add("closed");
x[0].classList.remove("opened");
if (currentid !== id){
var y = document.getElementById(id);
// y.classList.remove("closed");
y.classList.add("opened");
var z = y.getElementsByClassName("hidden");
z[0].classList.add("display");
z[0].classList.remove("hidden");
url = url.concat("#",id);
window.scrollBy(0, 300);
}
}
else
{
var y = document.getElementById(id);
// y.classList.remove("closed");
y.classList.add("opened");
var z = y.getElementsByClassName("hidden");
z[0].classList.add("display");
z[0].classList.remove("hidden");
url = url.concat("#",id);
window.scrollBy(0, 300);
}
history.pushState({}, null, url);
}
function init() {
if(window.location.hash) {
var anchor = window.location.hash.substring(1);
var x = document.getElementById("jobs");
console.log(x.children[anchor] );
var w = x.children[anchor]
if ( w !== undefined) {
// w.classList.remove("closed");
w.classList.add("opened");
var z = w.getElementsByClassName("hidden");
z[0].classList.add("display");
z[0].classList.remove("hidden");
window.scrollBy(0, 300);
}
}
}