cv-online/js/main.js

288 lines
7.5 KiB
JavaScript
Raw Permalink Normal View History

2018-05-15 23:18:54 +00:00
function checkSectionWidth(){
var mainsection = $('#section-main');
if(mainsection.width()-46 < 800)//article border added width = 46px
$('body').attr({'data-width': 'small'});
// mainsection.addClass('fullwidth');
else
$('body').attr({'data-width': 'large'});
// mainsection.removeClass('fullwidth');
}
$(window).resize(checkSectionWidth);
$(document).ready(checkSectionWidth);
$(document).ready(() => {
let path = document.location.pathname;
setPage(path);
2018-05-15 23:46:53 +00:00
$("nav > a").each((i, elmt) => {
const href = $(elmt).attr("href");
if(href[0] === "/"){
$(elmt).bind("click", () => {
// window.location.pathname = href;
history.pushState(null, null, href);
setPage(href);
return false;
})
}
})
2018-05-15 23:18:54 +00:00
})
function setPage(path){
const markedOpt = {
pedantic: false,
gfm: true,
tables: true,
breaks: false,
smartLists: true,
smartypants: false,
xhtml: false,
sanitize: false,
};
2018-05-15 23:46:53 +00:00
if(path === "/" || path === "" || path === "/index.html"){
path = "/home";
}
const existingPages = [ "/home", "/skills", "/projects", "/experiences", "/hobbies"];
if(existingPages.findIndex(a => a === path) >= 0){
window.scrollTo(0, 0);
$("#article-container").empty();
2018-10-26 23:53:18 +00:00
$("#left > a").each((i, elmt) => {
let hrefPath = elmt.attributes["href"].value;
if(hrefPath === "/" || path === "" || path === "/index.html")
hrefPath = "/home";
$(elmt).toggleClass("active", hrefPath === path);
});
$.ajax("/pages"+path+".md")
.done((res) => {
2018-10-26 23:53:18 +00:00
$("#article-container").html(res);
const len = $("#article-container > article").length;
let cnt = 0;
$("#article-container > article").each((i, elmt) => {
2019-09-18 07:35:22 +00:00
marked($(elmt).html(), markedOpt, (err, res) => {
$(elmt).html(res);
cnt++;
if(cnt === len){
if(path == "/skills"){
2019-09-18 07:35:22 +00:00
skillsPageSetup();
}
2019-09-18 07:35:22 +00:00
setTimeout(() => {
if(window.location.hash != ""){
target = $(window.location.hash);
if(target.length > 0){
target = target[0];
$('html,body').animate({
scrollTop: (target.offsetTop)
}, 400);
}
}
}, 500);// I'm lazy to search a way to wait for the view engine to be updated, 500ms should be fine
2018-05-15 23:18:54 +00:00
}
2019-09-18 07:35:22 +00:00
});
});
})
.fail((err) => {
$("#article-container").html(`<article><h1>Error ${err.status}'</h1><p>${err.statusText}<br/>${err.responseText}</p>`);
console.error(err);
2018-05-15 23:18:54 +00:00
});
}
else{
$("#article-container").html(`<article><h1>Error 404</h1><p>Page <code>${path}</code> does not exist</p>`);
}
2018-05-15 23:18:54 +00:00
}
function smoothScrollSetup(){
2018-05-16 00:02:46 +00:00
$("a[href*='#']:not([href='#'])").click(function()
2018-05-15 23:18:54 +00:00
{
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname)
{
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length)
{
$('html,body').animate(
{
scrollTop: (target.offset().top)
2018-05-15 23:18:54 +00:00
}, 400);
return true;
2018-05-15 23:18:54 +00:00
}
}
});
}
function skillsPageSetup(){
smoothScrollSetup();
const graphoptions = {
segmentStrokeWidth : 5,
animation : false,
labelFontFamily : "Arial",
labelFontStyle : "normal",
labelFontSize : 20,
labelFontColor : "#666",
graphTitle : "",
graphTitleFontFamily : "'Croissant One', cursive",
graphTitleFontSize : 20,
graphTitleFontStyle : "bold",
graphTitleFontColor : "#3A4145",
legend : true,
legendFontFamily : "'Noto Serif',serif",
legendFontSize : 15,
legendFontStyle : "normal",
legendFontColor : "#666",
legendBlockSize : 20,
legendBorders : false,
annotateDisplay : true,
pointLabelFontFamily : "'Noto Serif',serif"
}
{
let ctx = document.getElementById("whatilove_").getContext("2d");
let data = [
{ value: 5, color: "#ff706a", title: "Low-level programming" },
{ value: 5, color: "#efc26c", title: "Higher-level programming" },
2018-05-15 23:18:54 +00:00
{ value: 5, color: "#76ef6c", title: "Linux Environment" },
2019-03-11 14:20:44 +00:00
{ value: 3, color: "#dd8ae5", title: "Backend dev" },
{ value: 1, color: "#6cd6ef", title: "Frontend dev" }
2018-05-15 23:18:54 +00:00
];
graphoptions["graphTitle"] = "What I love";
new Chart(ctx).Pie(data, graphoptions);
}
{
let ctx = document.getElementById("howilearnt").getContext("2d");
let data = [
{ value: 3, color: "#ff706a", title: "With courses" },
{ value: 6, color: "#6cef7c", title: "By myself" },
{ value: 2, color: "#6cb3ef", title: "During conferences" }
];
graphoptions["graphTitle"] = "How I learnt it";
new Chart(ctx).Pie(data, graphoptions);
}
{
let ctx = document.getElementById("theory").getContext("2d");
let data = {
2019-03-11 14:20:44 +00:00
labels : ["Toolchains", "Code generation", "Algorithmic", "Architecture design", "Quality assurance", "CI / Automation", "Reverse-engineering"],
2018-05-15 23:18:54 +00:00
datasets : [{
fillColor : "rgba(83, 142, 193, 0.5)",
strokeColor : "#6091ff",
pointColor : "#1a76e2",
pointStrokeColor : "#fff",
2019-03-11 14:20:44 +00:00
data : [80, 80, 80, 90, 70, 80, 60]
2018-05-15 23:18:54 +00:00
},{
strokeColor : "rgba(0,0,0,0)",
pointColor : "rgba(0,0,0,0)",
2019-03-11 14:20:44 +00:00
data : [0, 100]
2018-05-15 23:18:54 +00:00
}]
};
graphoptions["graphTitle"] = "Theory";
new Chart(ctx).Radar(data, graphoptions);
}
{
var ctx = document.getElementById("proglanguages").getContext("2d");
var data = {
2019-03-11 14:20:44 +00:00
labels : ["C, C++17, D", "Go", "Rust", "Bash", "SQL", "ASM", "HTML5, CSS3, JS, PHP"],
2018-05-15 23:18:54 +00:00
datasets : [{
fillColor : "rgba(83, 142, 193, 0.5)",
strokeColor : "rgb(96, 145, 255)",
pointColor : "rgb(26, 118, 226)",
pointStrokeColor : "#fff",
2019-03-11 14:20:44 +00:00
data : [100, 60, 70, 90, 80, 40, 70]
2018-05-15 23:18:54 +00:00
},{
strokeColor : "rgba(0,0,0,0)",
pointColor : "rgba(0,0,0,0)",
data : [0, 100]
}]
};
graphoptions["graphTitle"] = "Programming languages";
new Chart(ctx).Radar(data,graphoptions);
}
{
var ctx = document.getElementById("linux").getContext("2d");
var data = {
2019-03-11 14:20:44 +00:00
labels : ["Ubuntu/Debian", "Archlinux", "Linux From Scratch", "Server admin", "Graphical stack", "Kernel"],
2018-05-15 23:18:54 +00:00
datasets : [{
fillColor : "rgba(83, 142, 193, 0.5)",
strokeColor : "rgb(96, 145, 255)",
pointColor : "rgb(26, 118, 226)",
pointStrokeColor : "#fff",
2019-03-11 14:20:44 +00:00
data : [90, 100, 60, 90, 80, 60]
2018-05-15 23:18:54 +00:00
},{
strokeColor : "rgba(0,0,0,0)",
pointColor : "rgba(0,0,0,0)",
data : [0, 100]
}]
};
graphoptions["graphTitle"] = "Linux";
new Chart(ctx).Radar(data,graphoptions)
}
{
var ctx = document.getElementById("network").getContext("2d");
var data = {
labels : ["Cisco CCNA1 (Basis)", "Cisco CCNA2 (Routing)", "Cisco CCNA3", "Cisco CCNA4 (VLAN)", "PFSense (Unix distro for routers)", "Linux network daemons"],
2018-05-15 23:18:54 +00:00
datasets : [{
fillColor : "rgba(83, 142, 193, 0.5)",
strokeColor : "rgb(96, 145, 255)",
pointColor : "rgb(26, 118, 226)",
pointStrokeColor : "#fff",
data : [100, 90, 50, 40, 70, 80]
2018-05-15 23:18:54 +00:00
},{
strokeColor : "rgba(0,0,0,0)",
pointColor : "rgba(0,0,0,0)",
data : [0, 100]
}]
};
graphoptions["graphTitle"] = "Networking";
new Chart(ctx).Radar(data,graphoptions);
}
{
var ctx = document.getElementById("tools").getContext("2d");
var data = {
2019-09-18 07:35:22 +00:00
labels : ["Git", "Gitlab / Github / Gitea", "GitlabCI / TravisCI / CircleCI"],
datasets : [{
fillColor : "rgba(83, 142, 193, 0.5)",
strokeColor : "rgb(96, 145, 255)",
pointColor : "rgb(26, 118, 226)",
pointStrokeColor : "#fff",
data : [100, 90, 80]
},{
strokeColor : "rgba(0,0,0,0)",
pointColor : "rgba(0,0,0,0)",
data : [0, 100]
}]
2018-05-15 23:18:54 +00:00
};
2019-09-18 07:35:22 +00:00
graphoptions["graphTitle"] = "Tools";
new Chart(ctx).Radar(data,graphoptions);
2018-05-15 23:18:54 +00:00
}
2019-03-11 14:20:44 +00:00
}