Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>Temperature</title>
- <script type="text/javascript"
- src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
- <script type=text/javascript
- src=http://dl.dropbox.com/u/128855213/SteelSeries/tween-min.js></script>
- <script type=text/javascript
- src=http://dl.dropbox.com/u/128855213/SteelSeries/steelseries-min.js></script>
- </head>
- <script type="text/javascript">
- //Assemble GS Request
- var apiKey = 'c0d6dc0a-ddff-324d-aed4-3ae5d03927c1'; //Change This!!!
- function getLastValue(successFn) {
- var items = [ {
- compId : '90:a2:da:0e:60:a3', // Change This!!! Your component ID.
- streamId : 's4', // Change This!!! The components stream ID
- } ];
- //Use https if your domain is using SSL
- var url = 'http://grovestreams.com/api/feed?&api_key=' + apiKey;
- url += '&itemsById=' + JSON.stringify(items);
- url += '&startDate=0&endDate=0&flatten=true'; //If dates are equal, then only last value information is returned
- $.ajax({
- type : 'GET',
- url : url,
- dataType : 'json',
- cache : false,
- processData : true,
- crossDomain : true,
- async : true,
- success : function(jobj) {
- successFn(jobj.feed.stream[0].lastValue);
- },
- error : function(a) {
- //alert("Error");
- }
- });
- }
- function getLastValueWithDailyMinMax(successFn) {
- var items = [ {
- compId : '90:a2:da:0e:60:a3', // Change This!!! Your component ID.
- streamId : 's4', // Change This!!! The components stream ID
- cycleId : 'gs.days', // Cycle ID. Cycle, in GS, should reference a timezone if your viewers cross zones
- stats : 'MIN,MAX,MINOCCURRENCE,MAXOCCURRENCE' //Dayly Min, Max and the times they occured.
- } ];
- //GS will expand the dates to the start and end datetimes of the day sd falls into for the given cycle ID in the URl
- // But they cannot be equal or no MIN MAX stats will be returned.
- var now = new Date();
- var sd = now.getTime();
- var ed = sd + 1;
- //Use https if your domain is using SSL
- var url = 'http://grovestreams.com/api/feed?&api_key=' + apiKey;
- url += '&itemsById=' + JSON.stringify(items);
- url += '&startDate=' + sd + '&endDate=' + ed + '&flatten=true';
- $.ajax({
- type : 'GET',
- url : url,
- dataType : 'json',
- cache : false,
- processData : true,
- crossDomain : true,
- async : true,
- success : function(jobj) {
- var lastValue = jobj.feed.stream[0].lastValue;
- var dailyMin = jobj.feed.stream[0].statistic[0].data[0];
- var dailyMax = jobj.feed.stream[0].statistic[1].data[0];
- var minTime = new Date(jobj.feed.stream[0].statistic[2].data[0]);
- var maxTime = new Date(jobj.feed.stream[0].statistic[3].data[0]);
- successFn(lastValue, dailyMin, dailyMax, minTime, maxTime);
- },
- error : function(a) {
- //alert("Error");
- }
- });
- }
- function init() {
- // Initialzing gauge
- tempGauge = new steelseries.Radial('gaugeCanvas', {
- gaugeType : steelseries.GaugeType.TYPE6,
- minValue : 0,
- maxValue : 150,
- size : 200,
- frameDesign : steelseries.FrameDesign.BRASS,
- knobStyle : steelseries.KnobStyle.BRASS,
- pointerType : steelseries.PointerType.TYPE6,
- lcdDecimals : 0,
- section : null,
- area : null,
- titleString : 'Outside Temp',
- unitString : '°F',
- threshold : 100,
- lcdVisible : true,
- minMeasuredValueVisible : true,
- maxMeasuredValueVisible : true
- });
- // Start the gauge update
- setInterval(function() {
- getLastValueWithDailyMinMax(function(val, dailyMin, dailyMax, minTime, maxTime) {
- tempGauge.setMinMeasuredValue(dailyMin);
- tempGauge.setValueAnimated(val);
- tempGauge.setMaxMeasuredValue(dailyMax);
- document.getElementById("minTime").innerHTML = 'Today\'s low was at ' + formatAMPM(minTime, 'g:i a');
- document.getElementById("maxTime").innerHTML = 'Today\'s high was at ' + formatAMPM(maxTime, 'g:i a');
- });
- }, 10000);
- }
- function formatAMPM(date) {
- //Avoiding including another large scripting library so added this method
- var hours = date.getHours();
- var minutes = date.getMinutes();
- var ampm = hours >= 12 ? 'pm' : 'am';
- hours = hours % 12;
- hours = hours ? hours : 12; // the hour '0' should be '12'
- minutes = minutes < 10 ? '0' + minutes : minutes;
- var strTime = hours + ':' + minutes + ' ' + ampm;
- return strTime;
- }
- </script>
- <body onload=init()>
- <div>
- <canvas id=gaugeCanvas width=200 height=200>No canvas in your
- browser...sorry...</canvas>
- </div>
- <div
- style="font-size: 13px; font-family: Verdana; padding: 10px 0 0 30px">
- <div id="minTime"></div>
- <div id="maxTime"></div>
- </div>
- </body>
- </html>
Add Comment
Please, Sign In to add comment