-
Notifications
You must be signed in to change notification settings - Fork 0
/
appp.js
135 lines (82 loc) · 2.98 KB
/
appp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
class mvc {
constructor(model,view,controller){
console.log("mvc class");
this.model = model;
this.view = view;
this.controller = controller;
this.model.view = view;
this.model.controller = controller;
this.view.model = model;
this.view.controller = controller;
this.controller.model = model;
this.controller.view = view;
this.model.initialise();
this.view.initialise();
this.controller.initialise();
}
}
class Model {
constructor(){
console.log("model class");
}
chaîne (){
return ["Tf1","France 2","France 3","Canal +","France 5"," M6 "," Arte "," D8 "," W9 "," TMC "];
}
liens(){
return ["programme-tf1-19.html","programme-france-2-6.html","programme-france-3-7.html","programme-canalplus-2.html","programme-france-5-9.html","programme-m6-12.html","programme-arte-337.html","programme-c8-4.html","programme-w9-24.html","programme-tmc-21.html"];
}
algorithme(){
const algorithme = document.getElementsByTagName("button");
for(let i = 0 ; i < algorithme.length ; i++){
algorithme[i].addEventListener("click", () => this.controller.charge());
}
}
initialise(){
console.log("model init");
}
}
class View {
constructor(element){
console.log("view class");
this.affichage = element;
}
initialise(){
console.log("view init");
}
//fonction : créer les boutons [chaînes].
bouton(chaîne){
chaîne.forEach(e => {
let initialisation = document.createElement("button");
initialisation.innerText = e;
initialisation.classList.add("btn");
this.affichage.appendChild(initialisation);
initialisation.addEventListener("mouseup" , () => this.controller.charge());
return initialisation;
})
}
// fonction : renvoie la page avec le programme journalier de la chaîne.
newpage(page){
const algorithme = document.getElementsByTagName("button");
for(let i = 0 ; i < algorithme.length ; i++){
algorithme[i].addEventListener("click", () => window.open("https://www.programme-tv.net/programme/chaine/"+page[i]));
document.location.reload(true);
}
}
}
class Controller {
constructor(){
console.log("controller class ");
}
initialise(){
console.log("controller init");
this.view.bouton(this.model.chaîne());
}
charge(){
this.view.newpage(this.model.liens());
}
}
// partie load().
let modelc = new Model();
let viewc = new View(document.body);
let controllerc = new Controller();
const mvcc = new mvc(modelc,viewc,controllerc);