Commit ae6c93e4 authored by Elger Jonker's avatar Elger Jonker

improved ticker, with configurable slogan


Former-commit-id: 33f39c82
parent b4e355cb
......@@ -536,7 +536,7 @@ path {
}
#ticker {
z-index: 1000;
z-index: 1002;
width: 100%;
height: 200px;
position: fixed;
......
......@@ -974,7 +974,8 @@ function views() {
data: {
tickertext: "",
visible: false,
data: Array
changes: Array(),
slogan: ""
},
methods: {
colorize: function (value, rank) {
......@@ -1013,32 +1014,35 @@ function views() {
return;
self = this;
$.getJSON('/data/ticker/' + this.country + '/' + this.category + '/0/0', function (data) {
j = 0;
fetch('/data/ticker/' + this.country + '/' + this.category + '/0/0').then(response => response.json()).then(data => {
self.data = data;
this.changes = data.changes;
this.slogan = data.slogan;
for (j=0;j<data.length;j++){
self.tickertext += " &nbsp; " + data[j]['organization'] + " ";
for (let j=0; j<this.changes.length; j++){
change = this.changes[j];
this.tickertext += " &nbsp; " + change['organization'] + " ";
self.tickertext += "<a style='color: " + self.colorize(data[j]['high_now'], 'high') +"'>" + data[j]['high_now'] + "</a>";
self.tickertext += self.arrow(data[j]['high_changes'], 'high');
self.tickertext += " | ";
this.tickertext += "<a style='color: " + this.colorize(change['high_now'], 'high') +"'>" + change['high_now'] + "</a>";
this.tickertext += this.arrow(change['high_changes'], 'high');
this.tickertext += " | ";
self.tickertext += "<a style='color: " + self.colorize(data[j]['medium_now'], 'medium') +"'>" + data[j]['medium_now'] + "</a>";
self.tickertext += self.arrow(data[j]['medium_changes'], 'medium');
self.tickertext += " | ";
this.tickertext += "<a style='color: " + this.colorize(change['medium_now'], 'medium') +"'>" + change['medium_now'] + "</a>";
this.tickertext += this.arrow(change['medium_changes'], 'medium');
this.tickertext += " | ";
self.tickertext += "<a style='color: " + self.colorize(data[j]['low_now'], 'low') +"'>" + data[j]['low_now'] + "</a>";
self.tickertext += self.arrow(data[j]['low_changes'], 'low');
self.tickertext += " ";
this.tickertext += "<a style='color: " + this.colorize(change['low_now'], 'low') +"'>" + change['low_now'] + "</a>";
this.tickertext += this.arrow(change['low_changes'], 'low');
this.tickertext += " ";
if (j % 10 === 0) {
self.tickertext += " - <b> failmap.org, monitor governments </b> - "
this.tickertext += " - <b> " + this.slogan + " </b> - "
}
}
});
}).catch((fail) => {console.log('An error occurred: ' + fail)});
}, 42)
}
});
......
......@@ -1278,7 +1278,9 @@ def ticker(request, country: str = "NL", organization_type: str = "municipality"
changes.append(change)
return JsonResponse(changes, encoder=JSEncoder, json_dumps_params={'indent': 2}, safe=False)
data = {'changes': changes, 'slogan': config.TICKER_SLOGAN}
return JsonResponse(data, encoder=JSEncoder, json_dumps_params={'indent': 2}, safe=False)
def map_default(request, days_back: int = 0, displayed_issue: str = None):
......
......@@ -696,6 +696,7 @@ CONSTANCE_CONFIG = {
'SHOW_COMPLY_OR_EXPLAIN_DISCUSS': (False, 'Shows a link to the comply or explain discussion forum. The url of this'
'forum can be edited below.', bool),
'SHOW_TICKER': (False, 'Shows stock-ticker with updates in the past month.', bool),
'TICKER_SLOGAN': ('failmap.org - monitor everything', 'Text to show between every 10 changes.', str),
'SHOW_SCAN_SCHEDULE': (False, 'Shows list of upcoming scans, so everyone knows what scan is due next.', bool),
'SHOW_SERVICES': (True, 'Show table with how many services are scanned. Requires SHOW_STATS_NUMBERS.', bool),
......@@ -775,7 +776,6 @@ CONSTANCE_CONFIG_FIELDSETS = OrderedDict([
('Website', ('SHOW_INTRO', 'SHOW_GOOD_BAD', 'SHOW_EXTENSIVE_STATISTICS', 'SHOW_DATASETS', 'SHOW_STATS_GRAPHS',
'SHOW_STATS_IMPROVEMENTS', 'SHOW_STATS_NUMBERS', 'SHOW_SERVICES', 'SHOW_STATS_CHANGES',
'SHOW_TICKER',
'SHOW_DNS_DNSSEC', 'SHOW_HTTP_TLS_QUALYS', 'SHOW_HTTP_MISSING_TLS',
'SHOW_HTTP_HEADERS_HSTS', 'SHOW_HTTP_HEADERS_XFO', 'SHOW_HTTP_HEADERS_X_XSS',
'SHOW_HTTP_HEADERS_X_CONTENT', 'SHOW_FTP', 'SHOW_SCAN_SCHEDULE', 'SHOW_DONATION'
......@@ -802,6 +802,8 @@ CONSTANCE_CONFIG_FIELDSETS = OrderedDict([
('Game', ('GOOGLE_MAPS_API_KEY',)),
('Ticker', ('SHOW_TICKER', 'TICKER_SLOGAN')),
('Chat (using gitter)', ('GITTER_CHAT_ENABLE', 'GITTER_CHAT_CHANNEL'))
])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment