| 1 |
<script type="text/javascript" src="js/eye/datepicker.js"></script> |
|---|
| 2 |
<script type="text/javascript" src="js/eye/eye.js"></script> |
|---|
| 3 |
<script type="text/javascript" src="js/eye/utils.js"></script> |
|---|
| 4 |
<script type="text/javascript"> |
|---|
| 5 |
<!-- |
|---|
| 6 |
var ws_displayinfo = { start : 14*86400, cnt: '100', end: '' }; |
|---|
| 7 |
var wsinfo = {}; |
|---|
| 8 |
function update_current_worksheet(f) { |
|---|
| 9 |
var str = JSON.stringify(wsinfo); |
|---|
| 10 |
$.post("json/worksheet/store", |
|---|
| 11 |
{'json':str}, |
|---|
| 12 |
function(d) { |
|---|
| 13 |
wsinfo.id = d.id; |
|---|
| 14 |
if(d.error) $("#ws-tool-error").html(d.error).fadeIn('fast'); |
|---|
| 15 |
else $("#ws-tool-error").fadeOut('fast'); |
|---|
| 16 |
if(wsinfo.id && wsinfo.title && wsinfo.saved != true && |
|---|
| 17 |
$(".rememberWorksheet:visible").length == 0) { |
|---|
| 18 |
$(".rememberWorksheet").html('"Remember" this worksheet.').fadeIn('slow'); |
|---|
| 19 |
$(".rememberWorksheet").click(function() { |
|---|
| 20 |
wsinfo.saved = true; |
|---|
| 21 |
update_current_worksheet(function(r) { |
|---|
| 22 |
if(r.error) wsinfo.saved = false; |
|---|
| 23 |
else $(".rememberWorksheet").html('Remebered').fadeOut('slow'); |
|---|
| 24 |
}); |
|---|
| 25 |
}); |
|---|
| 26 |
} |
|---|
| 27 |
if(f) f(d); |
|---|
| 28 |
}, 'json'); |
|---|
| 29 |
} |
|---|
| 30 |
|
|---|
| 31 |
function process_worksheet_json(r) { |
|---|
| 32 |
wsinfo.id = r.sheetid; |
|---|
| 33 |
wsinfo.title = r.title; |
|---|
| 34 |
var ul = $("ul#worksheet-graphs"); |
|---|
| 35 |
$("h2#worksheetTitle").html(r.title); |
|---|
| 36 |
ul.empty(); |
|---|
| 37 |
for(var i = 0; i < r.graphs.length; i++) { |
|---|
| 38 |
var g = {}; |
|---|
| 39 |
g.graphid = r.graphs[i]; |
|---|
| 40 |
g.start = ws_displayinfo.start; |
|---|
| 41 |
g.end = ws_displayinfo.end; |
|---|
| 42 |
g.cnt = ws_displayinfo.cnt; |
|---|
| 43 |
var o = $('<div></div>').ReconGraph(g); |
|---|
| 44 |
ul.append($('<li/>').append(o)); |
|---|
| 45 |
o.ReconGraphRefresh(); |
|---|
| 46 |
} |
|---|
| 47 |
ul.sortable("refresh"); |
|---|
| 48 |
} |
|---|
| 49 |
function add_graph_to_worksheet(graphid) { |
|---|
| 50 |
var g = { start: ws_displayinfo.start, |
|---|
| 51 |
end: ws_displayinfo.end, |
|---|
| 52 |
cnt: ws_displayinfo.cnt, |
|---|
| 53 |
graphid: graphid }; |
|---|
| 54 |
var o = $('<div></div>').ReconGraph( g ); |
|---|
| 55 |
var ul = $("ul#worksheet-graphs"); |
|---|
| 56 |
ul.append($('<li/>').append(o)); |
|---|
| 57 |
o.ReconGraphRefresh(); |
|---|
| 58 |
ul.sortable("refresh"); |
|---|
| 59 |
if(!wsinfo.graphs) wsinfo.graphs = new Array(); |
|---|
| 60 |
alert('pushing ' + graphid); |
|---|
| 61 |
wsinfo.graphs.push(graphid); |
|---|
| 62 |
update_current_worksheet(); |
|---|
| 63 |
} |
|---|
| 64 |
function refresh_worksheet() { |
|---|
| 65 |
var g = { start: ws_displayinfo.start, |
|---|
| 66 |
end: ws_displayinfo.end, |
|---|
| 67 |
cnt: ws_displayinfo.cnt }; |
|---|
| 68 |
$("ul#worksheet-graphs > li > div").ReconGraphRefresh(g); |
|---|
| 69 |
} |
|---|
| 70 |
function load_worksheet(id) { |
|---|
| 71 |
$.getJSON("json/worksheet/info/" + id, process_worksheet_json); |
|---|
| 72 |
} |
|---|
| 73 |
--> |
|---|
| 74 |
</script> |
|---|
| 75 |
<span class="rememberWorksheet"></span> |
|---|
| 76 |
<span class="blankWorksheet">New Blank</span> |
|---|
| 77 |
<h2 id="worksheetTitle">Worksheet Title</h2> |
|---|
| 78 |
<p/> |
|---|
| 79 |
<!-- date range box --> |
|---|
| 80 |
<script type="text/javascript"> |
|---|
| 81 |
$(document).ready(function(){ |
|---|
| 82 |
var time_windows = { '2d' : 86400*2, |
|---|
| 83 |
'1w' : 86400*7, |
|---|
| 84 |
'2w' : 86400*14, |
|---|
| 85 |
'4w' : 86400*28, |
|---|
| 86 |
'1y' : 86400*365, |
|---|
| 87 |
}; |
|---|
| 88 |
var state = false; |
|---|
| 89 |
$("h2#worksheetTitle").editable(function(value, settings) { |
|---|
| 90 |
wsinfo.title = value; |
|---|
| 91 |
update_current_worksheet(); |
|---|
| 92 |
return(value); |
|---|
| 93 |
}, { }); |
|---|
| 94 |
$("#ws_datetool .btn-slide").click(function(){ |
|---|
| 95 |
$("#ws_widgetCalendar").stop().animate({ |
|---|
| 96 |
height: state ? 0 : |
|---|
| 97 |
$('#ws_widgetCalendar div.datepicker').get(0).offsetHeight |
|---|
| 98 |
}, 500); |
|---|
| 99 |
state = !state; |
|---|
| 100 |
$(this).toggleClass("active"); |
|---|
| 101 |
return false; |
|---|
| 102 |
}); |
|---|
| 103 |
$("#ws_datetool .datechoice").click(function(){ |
|---|
| 104 |
$("#ws_datetool .range a.btn-slide").html("YYYY/MM/DD - YYYY/MM/DD"); |
|---|
| 105 |
$("#ws_widgetCalendar").slideUp("slow"); |
|---|
| 106 |
$(".datechoice").removeClass("selected"); |
|---|
| 107 |
ws_displayinfo.start = time_windows[$(this).html()]; |
|---|
| 108 |
ws_displayinfo.end = ''; |
|---|
| 109 |
$(this).addClass("selected"); |
|---|
| 110 |
refresh_worksheet(); |
|---|
| 111 |
return false; |
|---|
| 112 |
}); |
|---|
| 113 |
$('#ws_widgetCalendar').DatePicker({ |
|---|
| 114 |
flat: true, |
|---|
| 115 |
format: 'Y/m/d', |
|---|
| 116 |
date: [new Date(), new Date()], |
|---|
| 117 |
calendars: 3, |
|---|
| 118 |
mode: 'range', |
|---|
| 119 |
starts: 1, |
|---|
| 120 |
onChange: function(formated) { |
|---|
| 121 |
var dates; |
|---|
| 122 |
dates = formated[0].split('/'); |
|---|
| 123 |
var start = new Date(dates[0], dates[1]-1, dates[2], 0, 0, 0); |
|---|
| 124 |
dates = formated[1].split('/'); |
|---|
| 125 |
var end = new Date((new Date(dates[0], dates[1]-1, dates[2], 0, 0, 0)).getTime() + 86400000); |
|---|
| 126 |
ws_displayinfo.start = start.toUTCString(); |
|---|
| 127 |
ws_displayinfo.end = end.toUTCString(); |
|---|
| 128 |
refresh_worksheet(); |
|---|
| 129 |
$(".datechoice").removeClass("selected"); |
|---|
| 130 |
$('#ws_datetool .range a.btn-slide').get(0).innerHTML = formated.join(' - '); |
|---|
| 131 |
} |
|---|
| 132 |
}); |
|---|
| 133 |
$("#ws-tool-error").click(function(){ |
|---|
| 134 |
$("#ws-tool-error").fadeOut("slow"); |
|---|
| 135 |
}); |
|---|
| 136 |
var ul = $("ul#worksheet-graphs"); |
|---|
| 137 |
ul.sortable({ handle: '.graphTitle', |
|---|
| 138 |
scroll: true, |
|---|
| 139 |
stop: |
|---|
| 140 |
function (e,ui) { |
|---|
| 141 |
wsinfo.graphs = new Array(); |
|---|
| 142 |
ui.item.parent().find("> li > div").each( |
|---|
| 143 |
function(i) { wsinfo.graphs.push($(this).attr("id")); } |
|---|
| 144 |
); |
|---|
| 145 |
update_current_worksheet(); |
|---|
| 146 |
} |
|---|
| 147 |
}); |
|---|
| 148 |
}); |
|---|
| 149 |
</script> |
|---|
| 150 |
|
|---|
| 151 |
<div id="ws_datetool"> |
|---|
| 152 |
<div class="zoom"> |
|---|
| 153 |
<dl> |
|---|
| 154 |
<dt>Zoom:</dt> |
|---|
| 155 |
<dd><a href="#" class="first datechoice">2d</a></dd> |
|---|
| 156 |
<dd><a href="#" class="datechoice">1w</a></dd> |
|---|
| 157 |
<dd><a href="#" class="selected datechoice">2w</a></dd> |
|---|
| 158 |
<dd><a href="#" class="datechoice">4w</a></dd> |
|---|
| 159 |
<dd><a href="#" class="datechoice">1y</a></dd> |
|---|
| 160 |
</dl> |
|---|
| 161 |
</div> |
|---|
| 162 |
<div class="range"> |
|---|
| 163 |
<dl> |
|---|
| 164 |
<dt>Date Range:</dt> |
|---|
| 165 |
<dd><a href="" class="btn-slide">YYYY/MM/DD - YYYY/MM/DD</a></dd> |
|---|
| 166 |
</dl> |
|---|
| 167 |
</div> |
|---|
| 168 |
<br style="clear:both; margin-bottom:0.5em;"/> |
|---|
| 169 |
<div id="ws_widgetCalendar" class="widgetCalendar"></div> |
|---|
| 170 |
</div> |
|---|
| 171 |
|
|---|
| 172 |
<div> |
|---|
| 173 |
<ul id="worksheet-graphs" /> |
|---|
| 174 |
<br style="clear:left" /> |
|---|
| 175 |
</div> |
|---|
| 176 |
<div style="display:none"> |
|---|
| 177 |
<div id="maingraph-template"> |
|---|
| 178 |
<h3 class="graphTitle">graph title</h3> |
|---|
| 179 |
<div class="plot-area" style="width:380px;height:180px"></div> |
|---|
| 180 |
<div class="plot-legend">legend</div> |
|---|
| 181 |
</div> |
|---|
| 182 |
</div> |
|---|
| 183 |
|
|---|
| 184 |
<div class="error"><p class="error" id="ws-tool-error"></p></div> |
|---|
| 185 |
|
|---|
| 186 |
<div id="ws_payload"> |
|---|
| 187 |
</div> |
|---|