diff --git a/config/config.cfg.default b/config/config.cfg.default index a20434b..004327b 100644 --- a/config/config.cfg.default +++ b/config/config.cfg.default @@ -21,6 +21,7 @@ clusteringDistance = 10 [CONTRIB] max_number_of_last_contributor = 10 +min_between_reload = 5 #How much harder it gets to rank up (exponential multiplier) [1.5 -> +inf] rankMultiplier = 2 categories_in_datatable = ["internal_reference", "targeting_data", "antivirus_detection", "payload_delivery", "artifacts_dropped", "payload_installation", "persistence_mechanism", "network_activity", "payload_type", "attribution", "external_analysis", "financial_fraud", "support_Tool", "social_network", "person", "other" ] diff --git a/server.py b/server.py index cc666d8..999edfb 100755 --- a/server.py +++ b/server.py @@ -157,7 +157,8 @@ def contrib(): currOrg=currOrg, rankMultiplier=contributor_helper.rankMultiplier, categ_list=json.dumps(categ_list), - categ_list_str=categ_list_str + categ_list_str=categ_list_str, + min_between_reload=cfg.getint('CONTRIB', 'min_between_reload') ) ''' INDEX ''' diff --git a/static/js/contrib.js b/static/js/contrib.js index eed73b4..f5966f6 100644 --- a/static/js/contrib.js +++ b/static/js/contrib.js @@ -2,6 +2,9 @@ var allOrg = []; var datatableTop; var datatableFame; +var refresh_speed = min_between_reload*60; +var will_reload = $("#reloadCheckbox").is(':checked'); +var sec_before_reload = refresh_speed; /* CONFIG */ var maxRank = 16; @@ -246,8 +249,6 @@ function addLastContributor(datatable, data, update) { } } - - function updateProgressHeader(org) { // get Org rank $.getJSON( url_getOrgRank+'?org='+org, function( data ) { @@ -289,7 +290,36 @@ function showOnlyOrg() { datatableCateg.search( $('#orgText').text() ).draw(); } +function timeToString(time) { + var min = Math.floor(time / 60); + min = (min < 10) ? ("0" + min) : min; + var sec = time - 60*min; + sec = (sec < 10) ? ("0" + sec) : sec; + return min + ":" + sec +} + +function updateTimer() { + if ($("#reloadCheckbox").is(':checked')) { + sec_before_reload--; + if (sec_before_reload < 1) { + source_lastContrib.close(); + location.reload(); + } else { + $('#labelRemainingTime').text(timeToString(sec_before_reload)); + setTimeout(function(){ updateTimer(); }, 1000); + } + } else { + sec_before_reload = refresh_speed; + } +} + +$(':checkbox').change(function() { + if ($("#reloadCheckbox").is(':checked')) { setTimeout(function(){ updateTimer(); }, 1000); } +}); + $(document).ready(function() { + $('#labelRemainingTime').text(timeToString(sec_before_reload)); + updateTimer(); $('#orgName').typeahead(typeaheadOption); $('#btnCurrRank').popover(popOverOption); datatableTop = $('#topContribTable').DataTable(optionDatatable_top); @@ -335,5 +365,6 @@ $(document).ready(function() { addLastContributor(datatableLast, json, true); datatableLast.draw(); updateProgressHeader(json.org) + sec_before_reload = refresh_speed; //reset timer at each contribution }; }); diff --git a/templates/contrib.html b/templates/contrib.html index a885910..c1f8dee 100644 --- a/templates/contrib.html +++ b/templates/contrib.html @@ -57,6 +57,14 @@
  • MISP Geolocalisation
  • MISP Contributors
  • +
    +
    + + +
    +
    Organisation name: @@ -242,6 +250,7 @@ /* DATA FROM CONF */ var currOrg = "{{ currOrg }}"; + var min_between_reload = {{ min_between_reload }}; var rankMultiplier = {{ rankMultiplier }}; var categ_list = JSON.parse('{{ categ_list|safe }}');