-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathc1a3cb70.html
90 lines (81 loc) · 3.12 KB
/
c1a3cb70.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width" />
<title>EasyCloud</title>
<link href="//api.easylink.io/static/ionic/css/ionic.min.css" rel="stylesheet">
</head>
<body>
<ul class="list">
<label class="item item-input">
<input type="text" placeholder="Device ID" id="device_id" ng-model="device_id" disabled>
</label>
<div class="list">
<!--div class="item range range-positive">
<i class="icon ion-ios7-lightbulb"></i>
<input type="range" class="custom" id="brightness" name="brightness" min="0" max="100" value="0">
<i class="icon ion-ios7-lightbulb-outline"></i>
</div-->
<div class="item range range-calm">
<i class="icon ion-ios7-moon"></i>
<input type="range" id="white" name="white" min="0" max="100" value="50">
<i class="icon ion-ios7-moon-outline"></i>
</div>
<div class="item range range-energized">
<i class="icon ion-ios7-sunny"></i>
<input type="range" id="yellow" name="yellow" min="0" max="360" value="128">
<i class="icon ion-ios7-sunny-outline"></i>
</div>
</div>
</ul>
<div class="row row-center">
<div class="col col-center">
</div>
<script src="zepto.min.js"></script>
<script src="detect.js"></script>
<script src="print_r.js"></script>
<script>
function getParameterByName(name) {
var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
}
var access_token = getParameterByName('access_token');
var device_id = getParameterByName('device_id');
$('#device_id').val(device_id);
var lastcolor = '';
setInterval(function() {
var white = parseInt($('#white').val());
var yellow = parseInt($('#yellow').val());
//var brightness = parseInt($('#brightness').val());
//var color = JSON.stringify({"cmd":"on", "white": white, "yellow": yellow, "brightness": brightness });
//var color = [1,yellow,white,brightness].join(',');
var color = [1,yellow,white].join(',');
if ( lastcolor != color ) {
lastcolor = color;
$.ajax({
type: 'GET',
dataType: 'jsonp',
url: 'http://api.easylink.io/device/in.js',
data: {'access_token':access_token, 'device_id':device_id, 'msg': color}
});
}
}, 1000);
if (!!$.os.ios)
$('input[type="range"]').on('touchstart MSPointerDown pointerdown touchmove MSPointerMove pointermove', function(e){
if ( !this.hasOwnProperty('touchValue') ) {
$this = $(this);
var offset = $this.offset();
var width = $this.width();
var length = $this.attr('max') - $this.attr('min');
var countE = $('#count');
this.touchValue = function(touch) {
return ((touch.pageX - offset.left) / width) * length;
}
}
this.value = this.touchValue(e.touches[0]);
e.stopPropagation();
});
</script>
</body>
</html>