concen 0.1 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. data/LICENSE +20 -0
  2. data/lib/concen/version.rb +1 -1
  3. data/public/concen/images/button-grid.png +0 -0
  4. data/public/concen/images/button-next-disabled.png +0 -0
  5. data/public/concen/images/button-next.png +0 -0
  6. data/public/concen/images/button-prev-disabled.png +0 -0
  7. data/public/concen/images/button-prev.png +0 -0
  8. data/public/concen/images/fileuploader-loading.gif +0 -0
  9. data/public/concen/images/glyph-small-check-alt.png +0 -0
  10. data/public/concen/images/glyph-small-check.png +0 -0
  11. data/public/concen/images/glyph-small-delete.png +0 -0
  12. data/public/concen/images/glyph-small-handle.png +0 -0
  13. data/public/concen/images/grid.png +0 -0
  14. data/public/concen/images/icon-handle.png +0 -0
  15. data/public/concen/images/magnifying-glass.png +0 -0
  16. data/public/concen/images/original/button-grid.png +0 -0
  17. data/public/concen/images/original/button-next-disabled.png +0 -0
  18. data/public/concen/images/original/button-next.png +0 -0
  19. data/public/concen/images/original/button-prev-disabled.png +0 -0
  20. data/public/concen/images/original/button-prev.png +0 -0
  21. data/public/concen/images/original/glyph-small-check-alt.png +0 -0
  22. data/public/concen/images/original/glyph-small-check.png +0 -0
  23. data/public/concen/images/original/glyph-small-delete.png +0 -0
  24. data/public/concen/images/original/glyph-small-handle.png +0 -0
  25. data/public/concen/images/original/magnifying-glass.png +0 -0
  26. data/public/concen/images/original/record-visit.gif +0 -0
  27. data/public/concen/images/original/search-field.png +0 -0
  28. data/public/concen/images/record-visit.gif +0 -0
  29. data/public/concen/images/search-field.png +0 -0
  30. data/public/concen/javascripts/ace/ace-uncompressed.js +17635 -0
  31. data/public/concen/javascripts/ace/ace.js +1 -0
  32. data/public/concen/javascripts/ace/cockpit-uncompressed.js +2504 -0
  33. data/public/concen/javascripts/ace/cockpit.js +1 -0
  34. data/public/concen/javascripts/ace/keybinding-emacs.js +1 -0
  35. data/public/concen/javascripts/ace/keybinding-vim.js +1 -0
  36. data/public/concen/javascripts/ace/mode-c_cpp.js +1 -0
  37. data/public/concen/javascripts/ace/mode-clojure.js +1 -0
  38. data/public/concen/javascripts/ace/mode-coffee.js +1 -0
  39. data/public/concen/javascripts/ace/mode-csharp.js +1 -0
  40. data/public/concen/javascripts/ace/mode-css.js +1 -0
  41. data/public/concen/javascripts/ace/mode-groovy.js +1 -0
  42. data/public/concen/javascripts/ace/mode-html.js +1 -0
  43. data/public/concen/javascripts/ace/mode-java.js +1 -0
  44. data/public/concen/javascripts/ace/mode-javascript.js +1 -0
  45. data/public/concen/javascripts/ace/mode-json.js +1 -0
  46. data/public/concen/javascripts/ace/mode-ocaml.js +1 -0
  47. data/public/concen/javascripts/ace/mode-perl.js +1 -0
  48. data/public/concen/javascripts/ace/mode-php.js +1 -0
  49. data/public/concen/javascripts/ace/mode-python.js +1 -0
  50. data/public/concen/javascripts/ace/mode-ruby.js +1 -0
  51. data/public/concen/javascripts/ace/mode-scad.js +1 -0
  52. data/public/concen/javascripts/ace/mode-scala.js +1 -0
  53. data/public/concen/javascripts/ace/mode-scss.js +1 -0
  54. data/public/concen/javascripts/ace/mode-svg.js +1 -0
  55. data/public/concen/javascripts/ace/mode-textile.js +1 -0
  56. data/public/concen/javascripts/ace/mode-xml.js +1 -0
  57. data/public/concen/javascripts/ace/theme-clouds.js +1 -0
  58. data/public/concen/javascripts/ace/theme-clouds_midnight.js +1 -0
  59. data/public/concen/javascripts/ace/theme-cobalt.js +1 -0
  60. data/public/concen/javascripts/ace/theme-crimson_editor.js +1 -0
  61. data/public/concen/javascripts/ace/theme-dawn.js +1 -0
  62. data/public/concen/javascripts/ace/theme-eclipse.js +1 -0
  63. data/public/concen/javascripts/ace/theme-idle_fingers.js +1 -0
  64. data/public/concen/javascripts/ace/theme-kr_theme.js +1 -0
  65. data/public/concen/javascripts/ace/theme-merbivore.js +1 -0
  66. data/public/concen/javascripts/ace/theme-merbivore_soft.js +1 -0
  67. data/public/concen/javascripts/ace/theme-mono_industrial.js +1 -0
  68. data/public/concen/javascripts/ace/theme-monokai.js +1 -0
  69. data/public/concen/javascripts/ace/theme-pastel_on_dark.js +1 -0
  70. data/public/concen/javascripts/ace/theme-solarized_dark.js +1 -0
  71. data/public/concen/javascripts/ace/theme-solarized_light.js +1 -0
  72. data/public/concen/javascripts/ace/theme-textmate.js +1 -0
  73. data/public/concen/javascripts/ace/theme-twilight.js +1 -0
  74. data/public/concen/javascripts/ace/theme-vibrant_ink.js +1 -0
  75. data/public/concen/javascripts/ace/worker-coffee.js +1 -0
  76. data/public/concen/javascripts/ace/worker-css.js +1 -0
  77. data/public/concen/javascripts/ace/worker-javascript.js +1 -0
  78. data/public/concen/javascripts/blank.gif +0 -0
  79. data/public/concen/javascripts/controlcenter.js +173 -0
  80. data/public/concen/javascripts/excanvas.js +1427 -0
  81. data/public/concen/javascripts/fileuploader.js +1251 -0
  82. data/public/concen/javascripts/jquery-ui/jquery.ui.autocomplete.js +612 -0
  83. data/public/concen/javascripts/jquery-ui/jquery.ui.core.js +312 -0
  84. data/public/concen/javascripts/jquery-ui/jquery.ui.draggable.js +823 -0
  85. data/public/concen/javascripts/jquery-ui/jquery.ui.droppable.js +296 -0
  86. data/public/concen/javascripts/jquery-ui/jquery.ui.mouse.js +160 -0
  87. data/public/concen/javascripts/jquery-ui/jquery.ui.position.js +252 -0
  88. data/public/concen/javascripts/jquery-ui/jquery.ui.resizable.js +842 -0
  89. data/public/concen/javascripts/jquery-ui/jquery.ui.sortable.js +1077 -0
  90. data/public/concen/javascripts/jquery-ui/jquery.ui.widget.js +262 -0
  91. data/public/concen/javascripts/jquery.browser.min.js +1 -0
  92. data/public/concen/javascripts/jquery.easing.1.3.js +205 -0
  93. data/public/concen/javascripts/jquery.equal-heights.js +30 -0
  94. data/public/concen/javascripts/jquery.flot.js +2599 -0
  95. data/public/concen/javascripts/jquery.flot.resize.js +60 -0
  96. data/public/concen/javascripts/jquery.flot.stack.js +184 -0
  97. data/public/concen/javascripts/jquery.js +8981 -0
  98. data/public/concen/javascripts/jquery.min.js +18 -0
  99. data/public/concen/javascripts/jquery.placeholder.js +101 -0
  100. data/public/concen/javascripts/jquery.ui.nestedSortable.js +356 -0
  101. data/public/concen/javascripts/jquery_ujs.js +316 -0
  102. data/public/concen/javascripts/modernizr.js +1116 -0
  103. data/public/concen/javascripts/page.js +153 -0
  104. data/public/concen/javascripts/performance.js +110 -0
  105. data/public/concen/javascripts/pxToEm.js +56 -0
  106. data/public/concen/javascripts/status.js +15 -0
  107. data/public/concen/javascripts/traffic.js +113 -0
  108. data/public/concen/javascripts/user.js +14 -0
  109. data/public/concen/stylesheets/application.css +1342 -0
  110. data/public/concen/stylesheets/fileuploader.css +31 -0
  111. data/public/concen/stylesheets/ie.css +124 -0
  112. data/public/concen/stylesheets/jquery.ui.base.css +11 -0
  113. data/public/concen/stylesheets/jquery.ui.core.css +41 -0
  114. data/public/concen/stylesheets/jquery.ui.resizable.css +20 -0
  115. data/public/concen/stylesheets/main.css +1225 -0
  116. data/public/concen/stylesheets/non_ios.css +28 -0
  117. data/public/concen/stylesheets/print.css +84 -0
  118. metadata +141 -25
@@ -0,0 +1,153 @@
1
+ $(document).ready(function() {
2
+ $("#file-manager a.new-file").live("click", function(event) {
3
+ var filename = prompt("Filename", "");
4
+ if (filename) {
5
+ $.post($(this).attr("href"), {filename: filename}, function(data, textStatus, xhr) {
6
+ if (data.success) {
7
+ $("#file-manager div.files").replaceWith(data.content);
8
+ };
9
+ });
10
+ };
11
+ event.preventDefault();
12
+ });
13
+
14
+ // Delete files.
15
+ $("#file-manager a.delete").live("click", function(event) {
16
+ if (confirm("Are you sure?") == true) {
17
+ targetURL = $(this).attr("href");
18
+ parentLi = $(this).parents("li").eq(0);
19
+ $.ajax({
20
+ url: targetURL,
21
+ type: "DELETE",
22
+ dataType: "json",
23
+ success: function(data, textStatus, xhr) {
24
+ if (data.success) {
25
+ console.log(parentLi);
26
+ parentLi.remove();
27
+ };
28
+ }
29
+ });
30
+ };
31
+ event.preventDefault();
32
+ });
33
+
34
+ // Insert file path to text editor by drag and drop.
35
+ $("#file-manager a.filename").draggable({
36
+ revert: "invalid",
37
+ helper: "clone"
38
+ });
39
+ $( "#text-editor" ).droppable({
40
+ accept: ".filename",
41
+ drop: function(event, ui) {
42
+ window.editor.insert(ui.draggable.data("path"));
43
+ }
44
+ });
45
+
46
+ // Setup text editor (ace.js).
47
+ setupTextEditor = function() {
48
+ if ($("#text-editor").length > 0) {
49
+ window.editor = ace.edit("text-editor");
50
+ window.editor.setHighlightActiveLine(false);
51
+ window.editor.setShowPrintMargin(false);
52
+ window.editor.getSession().setValue($("textarea.text-editor-content").eq(0).val());
53
+ window.editor.getSession().setTabSize(2);
54
+ window.editor.getSession().setUseSoftTabs(true);
55
+ window.editor.getSession().setUseWrapMode(true);
56
+ window.editor.renderer.setShowGutter(false);
57
+
58
+ $("form.with-text-editor").submit(function() {
59
+ var editorContent = window.editor.getSession().getValue();
60
+ $("textarea.text-editor-content").eq(0).val(editorContent);
61
+ });
62
+ };
63
+ };
64
+
65
+ setupTextEditor();
66
+
67
+ // Text editor is resizable.
68
+ resizableTextEditor = $("form.with-text-editor .border").eq(0)
69
+ resizableTextEditor.resizable({
70
+ minHeight: resizableTextEditor.height(),
71
+ minWidth: resizableTextEditor.width(),
72
+ maxWidth: resizableTextEditor.width(),
73
+ stop: function(event, ui) {
74
+ $("#text-editor").css("height", $("#text-editor").parent().height());
75
+ window.editor.resize();
76
+ }
77
+ });
78
+
79
+ // Setup file uploader. Support multiple files upload and drag and drop.
80
+ if ($("#file-uploader").length > 0) {
81
+ var uploader = new qq.FileUploader({
82
+ element: $("#file-uploader")[0],
83
+ action: $("#file-uploader").data("upload-path"),
84
+ params: {},
85
+ sizeLimit: 0, // max size
86
+ minSizeLimit: 0, // min size
87
+ debug: false,
88
+ csrf: true,
89
+ template: '<div class="qq-uploader">' +
90
+ '<div class="qq-upload-drop-area"><span>Drop files here to upload</span></div>' +
91
+ '<div class="qq-upload-button">Upload Files</div>' +
92
+ '<ul class="qq-upload-list"></ul>' +
93
+ '</div>',
94
+ onComplete: function(id, fileName, responseJSON){
95
+ if (responseJSON.success) {
96
+ $("#file-manager ul.qq-upload-list li.qq-upload-success").remove();
97
+ $("#file-manager div.files").replaceWith(responseJSON.content);
98
+ };
99
+ },
100
+ showMessage: function(message){ alert(message); }
101
+ });
102
+ };
103
+
104
+ $("ul.pages").nestedSortable({
105
+ disableNesting: "no-nest",
106
+ forcePlaceholderSize: true,
107
+ helper: "clone",
108
+ handle: "span.handle",
109
+ items: "li",
110
+ maxLevels: 3,
111
+ opacity: .6,
112
+ placeholder: "placeholder",
113
+ revert: 250,
114
+ tabSize: 25,
115
+ tolerance: "pointer",
116
+ toleranceElement: "> p",
117
+ listType: "ul",
118
+ update: function(event, ui) {
119
+ data = $("ul.pages").nestedSortable("serialize", {"attribute": "data-id"});
120
+ console.log(data);
121
+ if ($("ul.pages > li").length > 1) {
122
+ $("ul.pages").nestedSortable("cancel")
123
+ } else {
124
+ $.ajax({
125
+ url: "/pages/sort",
126
+ type: "PUT",
127
+ dataType: "json",
128
+ data: data,
129
+ success: function(data, textStatus, xhr) {
130
+ if (!data.success) {
131
+ $("ul.pages").nestedSortable("cancel");
132
+ };
133
+ // $(this).sortable("cancel");
134
+ }
135
+ });
136
+ };
137
+ },
138
+ });
139
+
140
+ $("ul.pages a.title").live("click", function(event) {
141
+ if ($(this).hasClass("active")) {
142
+ $(this).removeClass("active");
143
+ $(this).parent().find("a.link-button").addClass("hidden");
144
+ window.location = $(this).attr("href");
145
+ } else {
146
+ $("ul.pages a.title").removeClass("active");
147
+ $("ul.pages a.link-button").addClass("hidden");
148
+ $(this).addClass("active");
149
+ $(this).parent().find("a.link-button").removeClass("hidden");
150
+ };
151
+ event.preventDefault();
152
+ });
153
+ });
@@ -0,0 +1,110 @@
1
+ $(function() {
2
+ function plotWithOptions(data) {
3
+ window.plot = $.plot($("#recent-responses"), [{label: "Total Runtime", data: data.total_runtime}, {label: "View Runtime", data: data.view_runtime},{label: "MongoDB Runtime", data: data.mongo_runtime}], {
4
+ xaxis: {
5
+ mode: "time",
6
+ timeformat: "%h:%M %P",
7
+ color: "#141F52",
8
+ tickColor: "#DADCE7",
9
+ tickSize: [5, "minute"]
10
+ },
11
+ yaxis: {
12
+ tickDecimals: 0,
13
+ color: "#141F52",
14
+ tickColor: "#DADCE7"
15
+ },
16
+ grid: {
17
+ hoverable: true,
18
+ clickable: true,
19
+ borderWidth: 1,
20
+ borderColor: "#141F52",
21
+ color: "#fe3145",
22
+ markings: [ { xaxis: { from: 0, to: 2 }, yaxis: { from: 10, to: 10 }, color: "#bb0000" } ]
23
+ },
24
+ legend: {show: true, position: "nw", labelBoxBorderColor: false},
25
+ series: {
26
+ lines: {show: true, fill: false, steps: false, lineWidth: 2, fillColor: {colors: [{opacity: 0.1}, {opacity: 0.1}]}},
27
+ stack: null,
28
+ shadowSize: 0
29
+ },
30
+ colors: ["#F3535C", "#E7C400", "#19c84f"]
31
+ });
32
+ };
33
+
34
+ // plotWithOptions({});
35
+
36
+ function showTooltip(x, y, contents) {
37
+ $("<div id='tooltip'>" + contents + "</div>").css( {
38
+ position: "absolute",
39
+ display: "none",
40
+ top: y + 5,
41
+ left: x + 5,
42
+ padding: "4px 8px",
43
+ "background-color": "#19c84f",
44
+ opacity: 0.80,
45
+ color: "white",
46
+ "font-size": "12px",
47
+ "font-weight": "bold"
48
+ }).appendTo("body").fadeIn(200);
49
+ };
50
+
51
+ var previousPoint = null;
52
+ $("#recent-responses").bind("plothover", function (event, pos, item) {
53
+ $("#x").text(pos.x.toFixed(2));
54
+ $("#y").text(pos.y.toFixed(2));
55
+
56
+ if (item) {
57
+ if (previousPoint != item.dataIndex) {
58
+ previousPoint = item.dataIndex;
59
+
60
+ $("#tooltip").remove();
61
+ var x = item.datapoint[0].toFixed(2),
62
+ y = item.datapoint[1].toFixed(2);
63
+
64
+ showTooltip(item.pageX, item.pageY, "Total Runtime: " + parseInt(y));
65
+ }
66
+ }
67
+ else {
68
+ $("#tooltip").remove();
69
+ previousPoint = null;
70
+ }
71
+ });
72
+
73
+ $("#recent-responses").resize(function() {});
74
+
75
+ $(window).resize(function() {
76
+ updatePanelTextWidth();
77
+ });
78
+
79
+ function updatePanelTextWidth() {
80
+ $("div.panel ul li p.right").each(function(index) {
81
+ $(this).parents("li").eq(0).find("p:not(.right)").width($(this).parents("li").eq(0).width() - $(this).innerWidth());
82
+ $(this).parents("li").eq(0).find("a").width($(this).parents("li").eq(0).width() - $(this).innerWidth());
83
+ });
84
+ }
85
+
86
+ function update() {
87
+ $.getJSON("/performance/responses", {"hour": 1}, function(json, textStatus) {
88
+ plotWithOptions(json);
89
+ // window.plot.setData([json.total_runtime, json.view_runtime, json.mongo_runtime]);
90
+ // window.plot.setupGrid();
91
+ // window.plot.draw();
92
+ // console.log(window.plot.getOptions())
93
+ });
94
+ $.get("/performance/runtimes", {"type": "total"}, function(data, textStatus, xhr) {
95
+ $("div.panel.total-runtime").find("ul").replaceWith(data);
96
+ updatePanelTextWidth();
97
+ });
98
+ $.get("/performance/runtimes", {"type": "view"}, function(data, textStatus, xhr) {
99
+ $("div.panel.view-runtime").find("ul").replaceWith(data);
100
+ updatePanelTextWidth();
101
+ });
102
+ $.get("/performance/runtimes", {"type": "mongo"}, function(data, textStatus, xhr) {
103
+ $("div.panel.mongodb-runtime").find("ul").replaceWith(data);
104
+ updatePanelTextWidth();
105
+ });
106
+ setTimeout(update, 5000);
107
+ };
108
+
109
+ update();
110
+ });
@@ -0,0 +1,56 @@
1
+ /*--------------------------------------------------------------------
2
+ * javascript method: "pxToEm"
3
+ * by:
4
+ Scott Jehl (scott@filamentgroup.com)
5
+ Maggie Wachs (maggie@filamentgroup.com)
6
+ http://www.filamentgroup.com
7
+ *
8
+ * Copyright (c) 2008 Filament Group
9
+ * Dual licensed under the MIT (filamentgroup.com/examples/mit-license.txt) and GPL (filamentgroup.com/examples/gpl-license.txt) licenses.
10
+ *
11
+ * Description: Extends the native Number and String objects with pxToEm method. pxToEm converts a pixel value to ems depending on inherited font size.
12
+ * Article: http://www.filamentgroup.com/lab/retaining_scalable_interfaces_with_pixel_to_em_conversion/
13
+ * Demo: http://www.filamentgroup.com/examples/pxToEm/
14
+ *
15
+ * Options:
16
+ scope: string or jQuery selector for font-size scoping
17
+ reverse: Boolean, true reverses the conversion to em-px
18
+ * Dependencies: jQuery library
19
+ * Usage Example: myPixelValue.pxToEm(); or myPixelValue.pxToEm({'scope':'#navigation', reverse: true});
20
+ *
21
+ * Version: 2.0, 08.01.2008
22
+ * Changelog:
23
+ * 08.02.2007 initial Version 1.0
24
+ * 08.01.2008 - fixed font-size calculation for IE
25
+ --------------------------------------------------------------------*/
26
+
27
+ Number.prototype.pxToEm = String.prototype.pxToEm = function(settings){
28
+ //set defaults
29
+ settings = jQuery.extend({
30
+ scope: 'body',
31
+ reverse: false
32
+ }, settings);
33
+
34
+ var pxVal = (this == '') ? 0 : parseFloat(this);
35
+ var scopeVal;
36
+ var getWindowWidth = function(){
37
+ var de = document.documentElement;
38
+ return self.innerWidth || (de && de.clientWidth) || document.body.clientWidth;
39
+ };
40
+
41
+ /* When a percentage-based font-size is set on the body, IE returns that percent of the window width as the font-size.
42
+ For example, if the body font-size is 62.5% and the window width is 1000px, IE will return 625px as the font-size.
43
+ When this happens, we calculate the correct body font-size (%) and multiply it by 16 (the standard browser font size)
44
+ to get an accurate em value. */
45
+
46
+ if (settings.scope == 'body' && $.browser.msie && (parseFloat($('body').css('font-size')) / getWindowWidth()).toFixed(1) > 0.0) {
47
+ var calcFontSize = function(){
48
+ return (parseFloat($('body').css('font-size'))/getWindowWidth()).toFixed(3) * 16;
49
+ };
50
+ scopeVal = calcFontSize();
51
+ }
52
+ else { scopeVal = parseFloat(jQuery(settings.scope).css("font-size")); };
53
+
54
+ var result = (settings.reverse == true) ? (pxVal * scopeVal).toFixed(2) + 'px' : (pxVal / scopeVal).toFixed(2) + 'em';
55
+ return result;
56
+ };
@@ -0,0 +1,15 @@
1
+ $(function() {
2
+ function update() {
3
+ $.getJSON("/status/counts", function(json, textStatus) {
4
+ $("div.panel.pages").find("p.big-number").html(json.pages);
5
+ $("div.panel.users").find("p.big-number").html(json.users);
6
+ });
7
+
8
+ $.get("/status/server", function(data, textStatus, xhr) {
9
+ $("div.panel.server").find("ul").replaceWith(data);
10
+ });
11
+
12
+ setTimeout(update, 5000);
13
+ };
14
+ update();
15
+ });
@@ -0,0 +1,113 @@
1
+ $(function() {
2
+ function plotWithOptions() {
3
+ window.plot = $.plot($("#recent-visits"), [{label: "Visits", data: []}], {
4
+ xaxis: {
5
+ mode: "time",
6
+ timeformat: "%h %P",
7
+ color: "#141F52",
8
+ tickColor: "#DADCE7",
9
+ minTickSize: [1, "hour"],
10
+ tickSize: [1, "hour"]
11
+ },
12
+ yaxis: {
13
+ tickDecimals: 0,
14
+ color: "#141F52",
15
+ tickColor: "#DADCE7"
16
+ },
17
+ grid: {
18
+ hoverable: true,
19
+ clickable: true,
20
+ borderWidth: 1,
21
+ borderColor: "#141F52",
22
+ color: "#fe3145",
23
+ markings: [ { xaxis: { from: 0, to: 2 }, yaxis: { from: 10, to: 10 }, color: "#bb0000" } ]
24
+ },
25
+ legend: {show: false, position: "ne"},
26
+ series: {
27
+ lines: {show: true, fill: true, steps: false, lineWidth: 2, fillColor: {colors: [{opacity: 0.1}, {opacity: 0.1}]}},
28
+ stack: true,
29
+ shadowSize: 0
30
+ },
31
+ colors: ["#19c84f"]
32
+ });
33
+ };
34
+
35
+ plotWithOptions();
36
+
37
+ function showTooltip(x, y, contents) {
38
+ $("<div id='tooltip'>" + contents + "</div>").css( {
39
+ position: "absolute",
40
+ display: "none",
41
+ top: y + 5,
42
+ left: x + 5,
43
+ padding: "4px 8px",
44
+ "background-color": "#19c84f",
45
+ opacity: 0.80,
46
+ color: "white",
47
+ "font-size": "12px",
48
+ "font-weight": "bold"
49
+ }).appendTo("body").fadeIn(200);
50
+ };
51
+
52
+ var previousPoint = null;
53
+ $("#recent-visits").bind("plothover", function (event, pos, item) {
54
+ $("#x").text(pos.x.toFixed(2));
55
+ $("#y").text(pos.y.toFixed(2));
56
+
57
+ if (item) {
58
+ if (previousPoint != item.dataIndex) {
59
+ previousPoint = item.dataIndex;
60
+
61
+ $("#tooltip").remove();
62
+ var x = item.datapoint[0].toFixed(2),
63
+ y = item.datapoint[1].toFixed(2);
64
+
65
+ showTooltip(item.pageX, item.pageY, "Visits: " + parseInt(y));
66
+ }
67
+ }
68
+ else {
69
+ $("#tooltip").remove();
70
+ previousPoint = null;
71
+ }
72
+ });
73
+
74
+ $("#recent-visits").resize(function() {});
75
+
76
+ $(window).resize(function() {
77
+ updatePanelTextWidth();
78
+ });
79
+
80
+ function updatePanelTextWidth() {
81
+ $("div.panel ul li p.right").each(function(index) {
82
+ $(this).parents("li").eq(0).find("p:not(.right)").width($(this).parents("li").eq(0).width() - $(this).innerWidth());
83
+ $(this).parents("li").eq(0).find("a").width($(this).parents("li").eq(0).width() - $(this).innerWidth());
84
+ });
85
+ }
86
+
87
+ function update() {
88
+ $.getJSON("/traffic/visits_counts", {"hour": 24}, function(json, textStatus) {
89
+ window.plot.setData([json]);
90
+ window.plot.setupGrid();
91
+ window.plot.draw();
92
+ });
93
+ $.getJSON("/traffic/visits_counts", {"hour": 1}, function(json, textStatus) {
94
+ if (json.length > 0) {
95
+ $("div.panel.visits-1-hour").find("p.big-number").html(json[0][1]);
96
+ } else {
97
+ $("div.panel.visits-1-hour").find("p.big-number").html("0");
98
+ };
99
+ });
100
+ $.get("/traffic/pages", function(data, textStatus, xhr) {
101
+ $("div.panel.pages").find("ul").replaceWith(data);
102
+ updatePanelTextWidth();
103
+ });
104
+ $.get("/traffic/referrals", function(data, textStatus, xhr) {
105
+ $("div.panel.referrals").find("ul").replaceWith(data);
106
+ updatePanelTextWidth();
107
+ });
108
+
109
+ setTimeout(update, 5000);
110
+ };
111
+
112
+ update();
113
+ });