aboutsummaryrefslogtreecommitdiff
path: root/p/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'p/scripts')
-rw-r--r--p/scripts/main.js10
-rw-r--r--p/scripts/repartition.js72
-rw-r--r--p/scripts/stats.js56
3 files changed, 133 insertions, 5 deletions
diff --git a/p/scripts/main.js b/p/scripts/main.js
index 31b07721a..f07cdafd7 100644
--- a/p/scripts/main.js
+++ b/p/scripts/main.js
@@ -1245,10 +1245,10 @@ function init_configuration_alert() {
});
}
-function parseJavaScriptCookie() {
- var vars = decodeURIComponent(document.cookie.replace(/(?:(?:^|.*;\s*)FreshRSS-vars\s*\=\s*([^;]*).*$)|^.*$/, "$1"));
- document.cookie = 'FreshRSS-vars=; expires=Thu, 01 Jan 1970 00:00:00 GMT';
- var json = JSON.parse(vars);
+function parseJsonVars() {
+ var jsonVars = document.getElementById('jsonVars'),
+ json = JSON.parse(jsonVars.innerHTML);
+ jsonVars.outerHTML = '';
window.context = json.context;
window.shortcuts = json.shortcuts;
window.url = json.url;
@@ -1264,7 +1264,7 @@ function init_all() {
window.setTimeout(init_all, 50);
return;
}
- parseJavaScriptCookie();
+ parseJsonVars();
init_notifications();
init_confirm_action();
$stream = $('#stream');
diff --git a/p/scripts/repartition.js b/p/scripts/repartition.js
new file mode 100644
index 000000000..a391de2f2
--- /dev/null
+++ b/p/scripts/repartition.js
@@ -0,0 +1,72 @@
+"use strict";
+function initStats() {
+ if (!window.Flotr) {
+ if (window.console) {
+ console.log('FreshRSS waiting for Flotr…');
+ }
+ window.setTimeout(initStats, 50);
+ return;
+ }
+ var jsonRepartition = document.getElementById('jsonRepartition'),
+ stats = JSON.parse(jsonRepartition.innerHTML);
+ jsonRepartition.outerHTML = '';
+ // Entry per hour
+ Flotr.draw(document.getElementById('statsEntryPerHour'),
+ [{
+ data: stats.repartitionHour,
+ bars: {horizontal: false, show: true}
+ }],
+ {
+ grid: {verticalLines: false},
+ xaxis: {noTicks: 23,
+ tickFormatter: function(x) {
+ var x = parseInt(x);
+ return x + 1;
+ },
+ min: -0.9,
+ max: 23.9,
+ tickDecimals: 0},
+ yaxis: {min: 0},
+ mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return numberFormat(obj.y);}}
+ });
+ // Entry per day of week
+ Flotr.draw(document.getElementById('statsEntryPerDayOfWeek'),
+ [{
+ data: stats.repartitionDayOfWeek,
+ bars: {horizontal: false, show: true}
+ }],
+ {
+ grid: {verticalLines: false},
+ xaxis: {noTicks: 6,
+ tickFormatter: function(x) {
+ var x = parseInt(x);
+ return stats.days[x];
+ },
+ min: -0.9,
+ max: 6.9,
+ tickDecimals: 0},
+ yaxis: {min: 0},
+ mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return numberFormat(obj.y);}}
+ });
+ // Entry per month
+ Flotr.draw(document.getElementById('statsEntryPerMonth'),
+ [{
+ data: stats.repartitionMonth,
+ bars: {horizontal: false, show: true}
+ }],
+ {
+ grid: {verticalLines: false},
+ xaxis: {noTicks: 12,
+ tickFormatter: function(x) {
+ var x = parseInt(x);
+ return stats.months[(x - 1)];
+ },
+ min: 0.1,
+ max: 12.9,
+ tickDecimals: 0},
+ yaxis: {min: 0},
+ mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return numberFormat(obj.y);}}
+ });
+
+}
+initStats();
diff --git a/p/scripts/stats.js b/p/scripts/stats.js
new file mode 100644
index 000000000..2e8ab6e27
--- /dev/null
+++ b/p/scripts/stats.js
@@ -0,0 +1,56 @@
+"use strict";
+function initStats() {
+ if (!window.Flotr) {
+ if (window.console) {
+ console.log('FreshRSS waiting for Flotr…');
+ }
+ window.setTimeout(initStats, 50);
+ return;
+ }
+ var jsonStats = document.getElementById('jsonStats'),
+ stats = JSON.parse(jsonStats.innerHTML);
+ jsonStats.outerHTML = '';
+ // Entry per day
+ var avg = [];
+ for (var i = -31; i <= 0; i++) {
+ avg.push([i, stats.average]);
+ }
+ Flotr.draw(document.getElementById('statsEntryPerDay'),
+ [{
+ data: stats.dataCount,
+ bars: {horizontal: false, show: true}
+ },{
+ data: avg,
+ lines: {show: true},
+ label: stats.average,
+ }],
+ {
+ grid: {verticalLines: false},
+ xaxis: {noTicks: 6, showLabels: false, tickDecimals: 0, min: -30.75, max: -0.25},
+ yaxis: {min: 0},
+ mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return numberFormat(obj.y);}}
+ });
+ // Feed per category
+ Flotr.draw(document.getElementById('statsFeedPerCategory'),
+ stats.feedByCategory,
+ {
+ grid: {verticalLines: false, horizontalLines: false},
+ pie: {explode: 10, show: true, labelFormatter: function(){return '';}},
+ xaxis: {showLabels: false},
+ yaxis: {showLabels: false},
+ mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return obj.series.label + ' - '+ numberFormat(obj.y) + ' ('+ (obj.fraction * 100).toFixed(1) + '%)';}},
+ legend: {container: document.getElementById('statsFeedPerCategoryLegend'), noColumns: 3}
+ });
+ // Entry per category
+ Flotr.draw(document.getElementById('statsEntryPerCategory'),
+ stats.entryByCategory,
+ {
+ grid: {verticalLines: false, horizontalLines: false},
+ pie: {explode: 10, show: true, labelFormatter: function(){return '';}},
+ xaxis: {showLabels: false},
+ yaxis: {showLabels: false},
+ mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return obj.series.label + ' - '+ numberFormat(obj.y) + ' ('+ (obj.fraction * 100).toFixed(1) + '%)';}},
+ legend: {container: document.getElementById('statsEntryPerCategoryLegend'), noColumns: 3}
+ });
+}
+initStats();