2020-01-22 16:40:43 +01:00
|
|
|
console.log("JavaScript is linked");
|
|
|
|
|
2020-01-24 16:12:39 +01:00
|
|
|
|
|
|
|
|
|
|
|
function init() {
|
2020-01-22 16:40:43 +01:00
|
|
|
sayHello();
|
2020-01-22 18:03:46 +01:00
|
|
|
//defTitre1();
|
2020-01-24 16:12:39 +01:00
|
|
|
//defTitre2();
|
|
|
|
//defTitre3();
|
2020-01-22 18:41:36 +01:00
|
|
|
defTitre4();
|
2020-01-22 18:03:46 +01:00
|
|
|
|
2020-01-22 16:40:43 +01:00
|
|
|
}
|
|
|
|
|
2020-01-22 18:41:36 +01:00
|
|
|
function sayHello() {
|
|
|
|
console.log("Hello Everypony !");
|
|
|
|
}
|
|
|
|
|
2020-01-22 17:02:42 +01:00
|
|
|
function defTitre1() {
|
2020-01-24 16:12:39 +01:00
|
|
|
if (document.title = document.getElementById("titre").innerText) {
|
2020-01-22 17:02:42 +01:00
|
|
|
console.log("<title> set : Ok Everypony !");
|
|
|
|
}
|
2020-01-22 16:40:43 +01:00
|
|
|
}
|
|
|
|
|
2020-01-22 17:27:33 +01:00
|
|
|
function defTitre2() {
|
|
|
|
var firstH2 = document.getElementsByTagName("h2");
|
2020-01-24 16:12:39 +01:00
|
|
|
if (firstH2 != null) {
|
|
|
|
document.title = firstH2[0].innerText;
|
2020-01-22 17:27:33 +01:00
|
|
|
console.log("<title> set : Ok Everypony !");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-22 17:39:33 +01:00
|
|
|
function defTitre3() {
|
|
|
|
var lastH2 = document.getElementsByTagName("h2");
|
2020-01-24 16:12:39 +01:00
|
|
|
if (lastH2 != null) {
|
|
|
|
document.title = lastH2[lastH2.length - 1].innerText;
|
2020-01-22 17:39:33 +01:00
|
|
|
console.log("<title> set : Ok Everypony !");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
document.title = "Page par Pauline Célestiale";
|
|
|
|
console.warn("There is no H2 tag on this page Everypony ! /:")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-22 18:03:46 +01:00
|
|
|
function defTitre4() {
|
|
|
|
var choosenH = document.getElementsByClassName("firstOrLast");
|
2020-01-24 16:12:39 +01:00
|
|
|
if (choosenH != null) {
|
|
|
|
if (choosenH.length % 2 == 0) {
|
|
|
|
document.title = choosenH[0].innerText;
|
2020-01-22 18:03:46 +01:00
|
|
|
console.log("<title> set first H : Ok Everypony !");
|
|
|
|
} else {
|
2020-01-24 16:12:39 +01:00
|
|
|
document.title = choosenH[choosenH.length - 1].innerText;
|
2020-01-22 18:03:46 +01:00
|
|
|
console.log("<title> set last H : Ok Everypony !");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
document.title = "Page par Pauline Célestiale";
|
|
|
|
console.warn("There is no H2 tag on this page Everypony ! /:")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-22 18:41:36 +01:00
|
|
|
function invertText() {
|
|
|
|
var buffer;
|
2020-01-22 18:49:53 +01:00
|
|
|
var un = document.getElementById("1");
|
|
|
|
var deux = document.getElementById("2");
|
2020-01-22 18:41:36 +01:00
|
|
|
|
2020-01-22 18:49:53 +01:00
|
|
|
buffer = un.innerText;
|
|
|
|
un.innerText = deux.innerText;
|
|
|
|
deux.innerText = buffer;
|
2020-01-22 18:41:36 +01:00
|
|
|
|
2020-01-24 16:12:39 +01:00
|
|
|
}
|