summaryrefslogtreecommitdiffstats
path: root/module/web/static/js/views/headerView.js
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2012-08-19 11:36:29 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2012-08-19 11:36:29 +0200
commitac58037d5dbc9d2ad8dc05cf609f90176aebb2b0 (patch)
treede731981b9cf32a25403e0b03fa1a2d7c1158a55 /module/web/static/js/views/headerView.js
parentcompleted renaming (diff)
downloadpyload-ac58037d5dbc9d2ad8dc05cf609f90176aebb2b0.tar.xz
boilerplate for js code
Diffstat (limited to 'module/web/static/js/views/headerView.js')
-rw-r--r--module/web/static/js/views/headerView.js76
1 files changed, 76 insertions, 0 deletions
diff --git a/module/web/static/js/views/headerView.js b/module/web/static/js/views/headerView.js
new file mode 100644
index 000000000..26f2ea706
--- /dev/null
+++ b/module/web/static/js/views/headerView.js
@@ -0,0 +1,76 @@
+define(['jquery', 'backbone', 'flot'], function($, Backbone){
+ // Renders the header with all information
+ return Backbone.View.extend({
+
+ el: 'header',
+
+ events: {
+
+ },
+
+ initialize: function() {
+ this.$el.find("#globalprogress").progressbar({ value:37 });
+
+ var totalPoints = 100;
+ var data = [];
+
+ function getRandomData() {
+ if (data.length > 0)
+ data = data.slice(1);
+
+ // do a random walk
+ while (data.length < totalPoints) {
+ var prev = data.length > 0 ? data[data.length - 1] : 50;
+ var y = prev + Math.random() * 10 - 5;
+ if (y < 0)
+ y = 0;
+ if (y > 100)
+ y = 100;
+ data.push(y);
+ }
+
+ // zip the generated y values with the x values
+ var res = [];
+ for (var i = 0; i < data.length; ++i)
+ res.push([i, data[i]])
+ return res;
+ }
+
+ var updateInterval = 1500;
+
+ var speedgraph = $.plot(this.$el.find("#speedgraph"), [getRandomData()], {
+ series:{
+ lines:{ show:true, lineWidth:2 },
+ shadowSize:0,
+ color:"#fee247"
+ },
+ xaxis:{ ticks:[], mode:"time" },
+ yaxis:{ ticks:[], min:0, autoscaleMargin:0.1 },
+ grid:{
+ show:true,
+// borderColor: "#757575",
+ borderColor:"white",
+ borderWidth:1,
+ labelMargin:0,
+ axisMargin:0,
+ minBorderMargin:0
+ }
+ });
+
+ function update() {
+ speedgraph.setData([ getRandomData() ]);
+ // since the axes don't change, we don't need to call plot.setupGrid()
+ speedgraph.draw();
+
+ setTimeout(update, updateInterval);
+ }
+
+ update();
+
+ },
+
+
+ render: function() {
+ }
+ });
+}); \ No newline at end of file