Skip to content

Commit 597b5a7

Browse files
authored
Merge pull request #10 from morrolinuxyt/publish_proxmox
refactor docker/proxmox/common scripts and fix umami tags
2 parents 219f329 + 9ebf4dc commit 597b5a7

File tree

7 files changed

+123
-258
lines changed

7 files changed

+123
-258
lines changed

docker.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@
355355
<script src="js/jquery.fitvids.js"></script>
356356

357357
<!-- Custom JavaScript -->
358+
<script src="js/common.js"></script>
358359
<script src="js/docker_script.js"></script>
359360
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.min.js"></script>
360361

index.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@
153153
</section>
154154

155155

156-
<section style="margin-top: -9rem;">
156+
<section id="corsi" style="margin-top: -9rem;">
157157
<div class="container text-center">
158-
<h2 id="corsi" class="my-5">SCEGLI IL TUO CORSO LINUX</h2>
158+
<h2 class="my-5">SCEGLI IL TUO CORSO LINUX</h2>
159159
<p class="mb-1 text-justify">
160160
Qualunque sia il tuo livello di partenza e il tuo obiettivo, in questa pagina troverai il corso che fa per te. <br>
161161
Ciascuna delle seguenti schede è relativa ad un corso di <b><a data-umami-event="link_intro_LPI" class="js-scroll-trigger" href="#lpi">certificazione LPI</a></b>.
@@ -911,6 +911,7 @@
911911
<script src="js/jquery.fitvids.js"></script>
912912

913913
<!-- Custom JavaScript -->
914+
<script src="js/common.js"></script>
914915
<script src="js/script.js"></script>
915916
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.min.js"></script>
916917

js/common.js

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
(function($) {
2+
"use strict"; // Start of use strict
3+
4+
// Smooth scrolling using jQuery easing
5+
$('a.js-scroll-trigger[href*="#"]:not([href="#"])').click(function() {
6+
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
7+
var target = $(this.hash);
8+
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
9+
if (target.length) {
10+
$('html, body').animate({
11+
scrollTop: (target.offset().top - 56)
12+
}, 1000, "easeInOutExpo");
13+
return false;
14+
}
15+
}
16+
});
17+
18+
// Closes responsive menu when a scroll trigger link is clicked
19+
$('.js-scroll-trigger').click(function() {
20+
$('.navbar-collapse').collapse('hide');
21+
});
22+
23+
// Activate scrollspy to add active class to navbar items on scroll
24+
$('body').scrollspy({
25+
target: '#mainNav',
26+
offset: 56
27+
});
28+
29+
})(jQuery); // End of use strict
30+
31+
function isInViewport(el, partially) {
32+
33+
if (typeof(partially) === 'undefined') {
34+
var partially = 0;
35+
}
36+
37+
if (typeof jQuery === "function" && el instanceof jQuery) {
38+
el = el[0];
39+
}
40+
41+
var rect = el.getBoundingClientRect();
42+
var windowHeight = (window.innerHeight || document.documentElement.clientHeight);
43+
var windowWidth = (window.innerWidth || document.documentElement.clientWidth);
44+
45+
partialCoeff = 1;
46+
47+
if (partially == 1) {
48+
var vertInView = (rect.top <= windowHeight) && ((rect.top + rect.height) >= 0);
49+
var horInView = (rect.left <= windowWidth) && ((rect.left + rect.width) >= 0);
50+
return (vertInView && horInView);
51+
} else if (partially > 1)
52+
partialCoeff = partially;
53+
54+
return ((rect.left >= 0) && (rect.top >= 0) &&
55+
((rect.left + rect.width) <= windowWidth) &&
56+
((rect.top + rect.height/partialCoeff) <= windowHeight));
57+
}
58+
59+
60+
function increment(){
61+
$('.counting').each(function() {
62+
var $this = $(this),
63+
countTo = $this.attr('data-count');
64+
65+
$({ countNum: $this.text()}).animate({
66+
countNum: countTo
67+
},
68+
{
69+
duration: 1000,
70+
easing:'linear',
71+
step: function() {
72+
$this.text(Math.floor(this.countNum));
73+
},
74+
complete: function() {
75+
$this.text(this.countNum);
76+
}
77+
});
78+
});
79+
}

js/docker_script.js

Lines changed: 2 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -1,185 +1,18 @@
1-
(function($) {
2-
"use strict"; // Start of use strict
3-
4-
// Smooth scrolling using jQuery easing
5-
$('a.js-scroll-trigger[href*="#"]:not([href="#"])').click(function() {
6-
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
7-
var target = $(this.hash);
8-
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
9-
if (target.length) {
10-
$('html, body').animate({
11-
scrollTop: (target.offset().top - 56)
12-
}, 1000, "easeInOutExpo");
13-
return false;
14-
}
15-
}
16-
});
17-
18-
// Closes responsive menu when a scroll trigger link is clicked
19-
$('.js-scroll-trigger').click(function() {
20-
$('.navbar-collapse').collapse('hide');
21-
});
22-
23-
// Activate scrollspy to add active class to navbar items on scroll
24-
$('body').scrollspy({
25-
target: '#mainNav',
26-
offset: 56
27-
});
28-
29-
})(jQuery); // End of use strict
30-
31-
function isInViewport(el, partially) {
32-
33-
if (typeof(partially) === 'undefined') {
34-
var partially = 0;
35-
}
36-
37-
if (typeof jQuery === "function" && el instanceof jQuery) {
38-
el = el[0];
39-
}
40-
41-
var rect = el.getBoundingClientRect();
42-
var windowHeight = (window.innerHeight || document.documentElement.clientHeight);
43-
var windowWidth = (window.innerWidth || document.documentElement.clientWidth);
44-
45-
partialCoeff = 1;
46-
47-
if (partially == 1) {
48-
var vertInView = (rect.top <= windowHeight) && ((rect.top + rect.height) >= 0);
49-
var horInView = (rect.left <= windowWidth) && ((rect.left + rect.width) >= 0);
50-
return (vertInView && horInView);
51-
} else if (partially > 1)
52-
partialCoeff = partially;
53-
54-
return ((rect.left >= 0) && (rect.top >= 0) &&
55-
((rect.left + rect.width) <= windowWidth) &&
56-
((rect.top + rect.height/partialCoeff) <= windowHeight));
57-
}
58-
59-
60-
function increment(){
61-
$('.counting').each(function() {
62-
var $this = $(this),
63-
countTo = $this.attr('data-count');
64-
65-
$({ countNum: $this.text()}).animate({
66-
countNum: countTo
67-
},
68-
{
69-
duration: 1000,
70-
easing:'linear',
71-
step: function() {
72-
$this.text(Math.floor(this.countNum));
73-
},
74-
complete: function() {
75-
$this.text(this.countNum);
76-
}
77-
});
78-
});
79-
}
80-
81-
82-
function drawChart(){
83-
// create and animate charts only when they become visible
84-
// loop over all html-defined doughnut charts
85-
var charts = document.getElementsByClassName("doughnut");
86-
for (var i = 0; i < charts.length; i++) {
87-
var canva = document.createElement("canvas");
88-
var desc = charts[i].getAttribute("desc");
89-
var inputColor = charts[i].getAttribute("color");
90-
var inputValue = charts[i].getAttribute("value");
91-
charts[i].appendChild(canva);
92-
93-
// set data
94-
data = {
95-
datasets:
96-
[{
97-
data: [inputValue, 100-inputValue],
98-
backgroundColor: [inputColor,"#FFFFFF00"],
99-
}],
100-
}
101-
102-
// create chart
103-
var promisedDeliveryChart = new Chart(canva, {
104-
type: 'doughnut',
105-
data: data,
106-
options: {
107-
elements: {arc: {borderWidth: 0}},
108-
cutoutPercentage: 80,
109-
tooltips: {enabled: false},
110-
hover: {mode: null},
111-
responsive: true,
112-
legend: {display: false}
113-
}
114-
});
115-
116-
// override chart with percentage value
117-
Chart.plugins.register({
118-
id: desc,
119-
beforeDraw: function(chart) {
120-
var width = chart.chart.width,
121-
height = chart.chart.height,
122-
ctx = chart.chart.ctx;
123-
ctx.restore();
124-
var fontSize = (height / 114).toFixed(2);
125-
ctx.font = fontSize + "em sans-serif";
126-
ctx.textBaseline = "middle";
127-
var text = chart.data.datasets[0]["data"][0] + "%",
128-
textX = Math.round((width - ctx.measureText(text).width) / 2),
129-
textY = height / 2;
130-
ctx.fillText(text, textX, textY);
131-
ctx.save();
132-
}
133-
});
134-
135-
// append the chart to the DOM
136-
var description = document.createElement("p");
137-
var spacer = document.createElement("br");
138-
var h5 = document.createElement("h5");
139-
description.appendChild(spacer);
140-
description.appendChild(h5);
141-
h5.innerHTML = desc;
142-
charts[i].appendChild(description);
143-
}
144-
}
145-
1461
var recensioniVisible = false;
147-
var testimonianzeVisible = false;
148-
var percorsoVisible = false;
149-
var comparaVisible = false;
150-
var LFStatsChartsVisible = false;
1512
var countersVisible = false;
1523

1534
function track_scroll(){
1545
if(isInViewport($('#recensioni'), 1)){
1556
if(recensioniVisible) return;
1567
recensioniVisible = true;
157-
umami.track('scroll_recensioni');
8+
umami.track('scroll_docker_recensioni');
1589
return;
15910
}
16011
if(isInViewport($('#counters'), 1)){
16112
if(countersVisible) return;
16213
countersVisible = true;
16314
increment();
164-
umami.track('scroll_counters');
165-
return;
166-
}
167-
if(isInViewport($('#testimonianze'), 1)){
168-
if(testimonianzeVisible) return;
169-
testimonianzeVisible = true;
170-
umami.track('scroll_testimonianze');
171-
return;
172-
}
173-
if(isInViewport($('#percorso'), 1)){
174-
if(percorsoVisible) return;
175-
percorsoVisible = true;
176-
umami.track('scroll_percorso');
177-
return;
178-
}
179-
if(isInViewport($('#compara'), 1)){
180-
if(comparaVisible) return;
181-
comparaVisible = true;
182-
umami.track('scroll_compara');
15+
umami.track('scroll_docker_counters');
18316
return;
18417
}
18518
}

js/proxmox_script.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
var recensioniVisible = false;
2+
var countersVisible = false;
3+
4+
function track_scroll(){
5+
if(isInViewport($('#recensioni'), 1)){
6+
if(recensioniVisible) return;
7+
recensioniVisible = true;
8+
umami.track('scroll_proxmox_recensioni');
9+
return;
10+
}
11+
if(isInViewport($('#counters'), 1)){
12+
if(countersVisible) return;
13+
countersVisible = true;
14+
increment();
15+
umami.track('scroll_proxmox_counters');
16+
return;
17+
}
18+
}
19+
20+
21+
$('.yt_video').fitVids();
22+
23+
24+
$(window).scroll(function(){
25+
track_scroll();
26+
});
27+
28+
$(document).ready(function(){
29+
track_scroll();
30+
// increment();
31+
drawChart();
32+
});

0 commit comments

Comments
 (0)