Commit d2bf4d000867c0bc8efe6b6d416091853c0dc792
1 parent
c7420dbf
partie application web
Showing
7 changed files
with
282 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,59 @@ |
1 | +.introduction { | |
2 | + color: red; | |
3 | + font-size: 40px; | |
4 | + font-family: Verdana; | |
5 | + font-style: italic; | |
6 | + text-decoration: underline; | |
7 | + text-align: center; | |
8 | +} | |
9 | + | |
10 | +body | |
11 | +{ | |
12 | + color: black; /* Le texte de la page sera blanc */ | |
13 | +} | |
14 | + | |
15 | +.onoffswitch { | |
16 | + position: relative; width: 59px; | |
17 | + -webkit-user-select:none; -moz-user-select:none; -ms-user-select: none; | |
18 | +} | |
19 | +.onoffswitch-checkbox { | |
20 | + display: none; | |
21 | +} | |
22 | +.onoffswitch-label { | |
23 | + display: block; overflow: hidden; cursor: pointer; | |
24 | + border: 2px solid #999999; border-radius: 19px; | |
25 | +} | |
26 | +.onoffswitch-inner { | |
27 | + display: block; width: 200%; margin-left: -100%; | |
28 | + transition: margin 0.3s ease-in 0s; | |
29 | +} | |
30 | +.onoffswitch-inner:before, .onoffswitch-inner:after { | |
31 | + display: block; float: left; width: 50%; height: 20px; padding: 0; line-height: 20px; | |
32 | + font-size: 14px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold; | |
33 | + box-sizing: border-box; | |
34 | +} | |
35 | +.onoffswitch-inner:before { | |
36 | + content: "ON"; | |
37 | + padding-left: 10px; | |
38 | + background-color: #000405; color: #FFFFFF; | |
39 | +} | |
40 | +.onoffswitch-inner:after { | |
41 | + content: "OFF"; | |
42 | + padding-right: 10px; | |
43 | + background-color: #EEEEEE; color: #999999; | |
44 | + text-align: right; | |
45 | +} | |
46 | +.onoffswitch-switch { | |
47 | + display: block; width: 16px; margin: 2px; | |
48 | + background: #FFFFFF; | |
49 | + position: absolute; top: 0; bottom: 0; | |
50 | + right: 35px; | |
51 | + border: 2px solid #999999; border-radius: 19px; | |
52 | + transition: all 0.3s ease-in 0s; | |
53 | +} | |
54 | +.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner { | |
55 | + margin-left: 0; | |
56 | +} | |
57 | +.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch { | |
58 | + right: 0px; | |
59 | +} | ... | ... |
... | ... | @@ -0,0 +1,25 @@ |
1 | +<!DOCTYPE html> | |
2 | +<html lang="en"> | |
3 | +<head> | |
4 | + <meta charset="UTF-8"> | |
5 | + <link rel="stylesheet" href="Menu.css" /> | |
6 | + <title>Menu Veilleuse connectée</title> | |
7 | +</head> | |
8 | +<body> | |
9 | +<h1 class = "introduction">Bienvenue sur le menu de votre veilleuse connectée</h1> | |
10 | + | |
11 | +<ul class = "choix"> | |
12 | + <li><h2><a href="intensite.html">Changement de l'intensité</a></h2></li> | |
13 | + <li><h2><a href = "couleur.html">Changement de la couleur</a></h2></li> | |
14 | + <li><h2><a href = "mode.html">Sélection du mode</a></h2></li> | |
15 | +</ul> | |
16 | +<h4 classe = "etat">Etat de la veilleuse</h4> | |
17 | +<div class="onoffswitch"> | |
18 | + <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" checked> | |
19 | + <label class="onoffswitch-label" for="myonoffswitch"> | |
20 | + <span class="onoffswitch-inner"></span> | |
21 | + <span class="onoffswitch-switch"></span> | |
22 | + </label> | |
23 | +</div> | |
24 | +</body> | |
25 | +</html> | ... | ... |
... | ... | @@ -0,0 +1,29 @@ |
1 | +<!DOCTYPE html> | |
2 | +<html lang="en"> | |
3 | +<head> | |
4 | + <meta charset="UTF-8"> | |
5 | + <title>Changement de couleur</title> | |
6 | +</head> | |
7 | +<body> | |
8 | +<h1>Changement de couleur de votre veilleuse connectée</h1> | |
9 | +<h3>Rouge</h3> | |
10 | +<div id = "slider"> | |
11 | +<input type ="range" min ="0" max="255" value ="100" onchange = "rangevalue.value=value"> | |
12 | +<span class = "highlight"></span> | |
13 | +<output id="rangevalue">50</output> | |
14 | +</div> | |
15 | +<h3>Vert</h3> | |
16 | +<div id = "slider1"> | |
17 | + <input type ="range" min ="0" max="255" value ="100" onchange = "rangevalue1.value=value"> | |
18 | + <span class = "highlight"></span> | |
19 | + <output id="rangevalue1">50</output> | |
20 | +</div> | |
21 | +<h3>Bleu</h3> | |
22 | +<div id = "slider2"> | |
23 | + <input type ="range" min ="0" max="255" value ="100" onchange = "rangevalue2.value=value"> | |
24 | + <span class = "highlight"></span> | |
25 | + <output id="rangevalue2">50</output> | |
26 | +</div> | |
27 | +<h4><a href="Menu.html">Retour</a></h4> | |
28 | +</body> | |
29 | +</html> | ... | ... |
... | ... | @@ -0,0 +1,18 @@ |
1 | +<!DOCTYPE html> | |
2 | +<html lang="en"> | |
3 | +<head> | |
4 | + <meta charset="UTF-8"> | |
5 | + <title>Changement d'intensité</title> | |
6 | + | |
7 | +</head> | |
8 | +<body> | |
9 | +<h1>Changement d'intensite de votre veilleuse connectée</h1> | |
10 | +<div id = "slider"> | |
11 | + <input type ="range" min ="0" max="255" value ="100" onchange = "rangevalue.value=value"> | |
12 | + <span class = "highlight"></span> | |
13 | + <output id="rangevalue">50</output> | |
14 | +</div> | |
15 | + | |
16 | +<h3><a href="Menu.html">Retour</a></h3> | |
17 | +</body> | |
18 | +</html> | ... | ... |
... | ... | @@ -0,0 +1,45 @@ |
1 | +.onoffswitch { | |
2 | + position: relative; width: 138px; | |
3 | + -webkit-user-select:none; -moz-user-select:none; -ms-user-select: none; | |
4 | +} | |
5 | +.onoffswitch-checkbox { | |
6 | + display: none; | |
7 | +} | |
8 | +.onoffswitch-label { | |
9 | + display: block; overflow: hidden; cursor: pointer; | |
10 | + border: 2px solid #999999; border-radius: 19px; | |
11 | +} | |
12 | +.onoffswitch-inner { | |
13 | + display: block; width: 200%; margin-left: -100%; | |
14 | + transition: margin 0.3s ease-in 0s; | |
15 | +} | |
16 | +.onoffswitch-inner:before, .onoffswitch-inner:after { | |
17 | + display: block; float: left; width: 50%; height: 34px; padding: 0; line-height: 34px; | |
18 | + font-size: 14px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold; | |
19 | + box-sizing: border-box; | |
20 | +} | |
21 | +.onoffswitch-inner:before { | |
22 | + content: "Automatique"; | |
23 | + padding-left: 10px; | |
24 | + background-color: #30A9C7; color: #FFFFFF; | |
25 | +} | |
26 | +.onoffswitch-inner:after { | |
27 | + content: "Manuel"; | |
28 | + padding-right: 10px; | |
29 | + background-color: #EEEEEE; color: #999999; | |
30 | + text-align: right; | |
31 | +} | |
32 | +.onoffswitch-switch { | |
33 | + display: block; width: 23px; margin: 5.5px; | |
34 | + background: #FFFFFF; | |
35 | + position: absolute; top: 0; bottom: 0; | |
36 | + right: 100px; | |
37 | + border: 2px solid #999999; border-radius: 19px; | |
38 | + transition: all 0.3s ease-in 0s; | |
39 | +} | |
40 | +.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner { | |
41 | + margin-left: 0; | |
42 | +} | |
43 | +.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch { | |
44 | + right: 0px; | |
45 | +} | |
0 | 46 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,20 @@ |
1 | +<!DOCTYPE html> | |
2 | +<html lang="en"> | |
3 | +<head> | |
4 | + <meta charset="UTF-8"> | |
5 | + <link rel="stylesheet" href="mode.css" /> | |
6 | + <title>Changement de mode</title> | |
7 | +</head> | |
8 | +<body> | |
9 | +<h1>Changement de mode de votre veilleuse connectée</h1> | |
10 | +<div class="onoffswitch"> | |
11 | + <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" checked> | |
12 | + <label class="onoffswitch-label" for="myonoffswitch"> | |
13 | + <span class="onoffswitch-inner"></span> | |
14 | + <span class="onoffswitch-switch"></span> | |
15 | + </label> | |
16 | +</div> | |
17 | + | |
18 | +<h3><a href="Menu.html">Retour</a></h3> | |
19 | +</body> | |
20 | +</html> | ... | ... |
... | ... | @@ -0,0 +1,86 @@ |
1 | +#include <stdio.h> | |
2 | +#include <stdlib.h> | |
3 | +#include <string.h> | |
4 | +#include <libwebsockets.h> | |
5 | + | |
6 | +#define MAX_FRAME_SIZE 1024 | |
7 | +#define WAIT_DELAY 50 | |
8 | + | |
9 | +static int callback_http( | |
10 | + struct libwebsocket_context *this, | |
11 | +struct libwebsocket *wsi,enum libwebsocket_callback_reasons reason, | |
12 | +void *user,void *in,size_t len) | |
13 | +{ | |
14 | +return 0; | |
15 | +} | |
16 | + | |
17 | +static int callback_my( | |
18 | + struct libwebsocket_context * this, | |
19 | +struct libwebsocket *wsi,enum libwebsocket_callback_reasons reason, | |
20 | +void *user,void *in,size_t len) | |
21 | +{ | |
22 | +static char *message=NULL; | |
23 | +static int msize=0; | |
24 | +switch(reason){ | |
25 | +case LWS_CALLBACK_ESTABLISHED: | |
26 | + printf("connection established\n"); | |
27 | +message=NULL; | |
28 | +// Declenchement d'un prochain envoi au navigateur | |
29 | +libwebsocket_callback_on_writable(this,wsi); | |
30 | +break; | |
31 | +case LWS_CALLBACK_RECEIVE: | |
32 | +// Ici sont traites les messages envoyes par le navigateur | |
33 | + printf("received data: %s\n",(char *)in); | |
34 | +message=malloc(len+LWS_SEND_BUFFER_PRE_PADDING+LWS_SEND_BUFFER_POST_PADDING); | |
35 | +if(message==NULL){ perror("callback_my.malloc"); exit(EXIT_FAILURE); } | |
36 | +memcpy(message+LWS_SEND_BUFFER_PRE_PADDING,in,len); | |
37 | +// Declenchement d'un prochain envoi au navigateur | |
38 | +msize=len; | |
39 | +libwebsocket_callback_on_writable(this,wsi); | |
40 | +break; | |
41 | +case LWS_CALLBACK_SERVER_WRITEABLE: | |
42 | +// Ici sont envoyes les messages au navigateur | |
43 | +if(message!=NULL){ | |
44 | +char *out=message+LWS_SEND_BUFFER_PRE_PADDING; | |
45 | +libwebsocket_write(wsi,(unsigned char *)out,msize,LWS_WRITE_TEXT); | |
46 | +free(message); | |
47 | +message=NULL; | |
48 | +} | |
49 | +break; | |
50 | +default: | |
51 | +break; | |
52 | +} | |
53 | +return 0; | |
54 | +} | |
55 | + | |
56 | +static struct libwebsocket_protocols protocols[] = { | |
57 | + { | |
58 | + "http-only", // name | |
59 | + callback_http, // callback | |
60 | + 0, // data size | |
61 | + 0 // maximum frame size | |
62 | + }, | |
63 | + {"myprotocol",callback_my,0,MAX_FRAME_SIZE}, | |
64 | + {NULL,NULL,0,0} | |
65 | +}; | |
66 | + | |
67 | +int main(void) { | |
68 | + int port=9000; | |
69 | + struct lws_context_creation_info info; | |
70 | + memset(&info,0,sizeof info); | |
71 | + info.port=port; | |
72 | + info.protocols=protocols; | |
73 | + info.gid=-1; | |
74 | + info.uid=-1; | |
75 | + struct libwebsocket_context *context=libwebsocket_create_context(&info); | |
76 | + if(context==NULL){ | |
77 | + fprintf(stderr, "libwebsocket init failed\n"); | |
78 | + return -1; | |
79 | + } | |
80 | + printf("starting server...\n"); | |
81 | + while(1){ | |
82 | + libwebsocket_service(context,WAIT_DELAY); | |
83 | + } | |
84 | + libwebsocket_context_destroy(context); | |
85 | + return 0; | |
86 | +} | |
0 | 87 | \ No newline at end of file | ... | ... |