-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalart_vue_body.js
62 lines (61 loc) · 1.64 KB
/
alart_vue_body.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
/**
* Make Vue body for movie alart vue and return it.
* @pamam {string} el_str name of el.
* @pamam {string} serial_id_str serial_id.
*/
function alart_vue_body(el_str, serial_id_str){
return {
el: el_str,
data: {
message: '2016年9月7日、水警報受信',
},
methods: {
release: function(){
// 表示を消す
$(el_str).removeClass("hidden");
// alart_vue.message = data.water;
this.message = "";
// alart.ini を消す
$.ajax({
type: "POST",
url: "postalart.php",
data: {
serial_id: serial_id_str,
name: "water",
status: "off"
},
dataType: "json",
})
.then(
function(data, dataType){
},
function(XMLHttpRequest, textStatus, errorThrown){
console.log('Error : ' + errorThrown);
});
},
check_alart: function(){
setInterval(function(){
$.ajax({
type: "POST",
url: "alart.php",
data: {serial_id: serial_id_str},
dataType: "json",
})
.then(
function(data, dataType){
if (data.water != ""){
$(el_str).removeClass("hidden");
alart_vue.message = data.water;
} else {
$(el_str).addClass("hidden");
alart_vue.message = "";
}
},
function(XMLHttpRequest, textStatus, errorThrown){
console.log('Error : ' + errorThrown);
})
}, 1000 );
},
}
};
}