82 lines
2.6 KiB
JavaScript
82 lines
2.6 KiB
JavaScript
var api_baseurl = "https://api.itbyhf.xyz/v2/Profilpage";
|
|
|
|
if (page == "start") {
|
|
//Introduction Text
|
|
$.get(api_baseurl + "/txt_introduction", function (data) {
|
|
document.getElementById("pp-text-intro").innerHTML = data["txt"];
|
|
});
|
|
|
|
|
|
//Skills
|
|
$.get(api_baseurl + "/skills", function (data) {
|
|
let wr = document.getElementById("skill-box");
|
|
$.each(data, function () {
|
|
let el = document.createElement("span");
|
|
let logo = document.createElement("img");
|
|
let txt = document.createElement("span");
|
|
logo.setAttribute("src", this["img"]);
|
|
el.appendChild(logo);
|
|
txt.innerHTML = this["span"];
|
|
el.setAttribute("class", "col-xs-6 col-sm-3 skill_item");
|
|
el.appendChild(txt);
|
|
wr.appendChild(el);
|
|
});
|
|
});
|
|
|
|
//Pages
|
|
$.get(api_baseurl+"/pages/recommended",function(data){
|
|
let wr = document.getElementById("recentposts-wr");
|
|
let post,title,summary;
|
|
$.each(data,function(){
|
|
post = document.createElement("div");
|
|
post.setAttribute("class","col-xs-6 col-sm-3 recommended_post");
|
|
|
|
title=document.createElement("span");
|
|
title.innerHTML="<a href='"+this["url"]+"'><h3>"+this["title"]+"</h3></a>";
|
|
|
|
summary = document.createElement("p");
|
|
summary.innerHTML=this["summary"];
|
|
|
|
post.appendChild(title);
|
|
post.appendChild(summary);
|
|
wr.appendChild(post);
|
|
});
|
|
});
|
|
|
|
|
|
}
|
|
$( "#contactSubmit" ).click(function() {
|
|
document.getElementById('contactSubmit').style.backgroundColor = "gray";
|
|
document.getElementById('contactSubmit').disabled = true;
|
|
|
|
document.getElementById('contactStatus').innerHTML = "Nachricht wird gesendet....";
|
|
|
|
|
|
let url = "https://api.itbyhf.xyz/v2/Profilpage/contact/submit";
|
|
let xhr = new XMLHttpRequest();
|
|
xhr.open("POST", url);
|
|
|
|
xhr.setRequestHeader("Content-Type", "application/json");
|
|
|
|
xhr.onreadystatechange = function () {
|
|
if (xhr.readyState === 4) {
|
|
if(xhr.status==200){
|
|
document.getElementById('contactStatus').innerHTML = " Nachricht erfolgreich gesendet!";
|
|
}else {
|
|
document.getElementById('contactStatus').innerHTML = "Fehler beim senden der Nachricht!";
|
|
console.log(xhr.statusText)
|
|
}
|
|
}
|
|
};
|
|
|
|
const ct = {
|
|
formSenderMail: $('#contactEmail').val(),
|
|
formTitle: $('#contactTitle').val(),
|
|
formContent: $('#contactText').val()
|
|
}
|
|
|
|
let data =JSON.stringify(ct);
|
|
console.log(data);
|
|
|
|
xhr.send(data);
|
|
}); |