mirror of https://github.com/MISP/MISP
chg: [eventgraph] Force constant color for the eventgraph's nodes. Fix #4536
parent
1cc5f61473
commit
ffbbb9292d
|
@ -46,7 +46,7 @@ class AppController extends Controller
|
|||
|
||||
public $helpers = array('Utility', 'OrgImg', 'FontAwesome');
|
||||
|
||||
private $__queryVersion = '67';
|
||||
private $__queryVersion = '68';
|
||||
public $pyMispVersion = '2.4.106';
|
||||
public $phpmin = '7.0';
|
||||
public $phprec = '7.2';
|
||||
|
|
|
@ -111,7 +111,7 @@ class EventGraph {
|
|||
|
||||
for (var event_id in that.extended_event_points) {
|
||||
if (that.extended_event_color_mapping[event_id] === undefined) {
|
||||
eventGraph.extended_event_color_mapping[event_id] = getRandomColor(event_id);
|
||||
eventGraph.extended_event_color_mapping[event_id] = stringToRGB(event_id);
|
||||
}
|
||||
var chosen_color = eventGraph.extended_event_color_mapping[event_id];
|
||||
|
||||
|
@ -710,7 +710,7 @@ class EventGraph {
|
|||
group: group,
|
||||
mass: 5,
|
||||
icon: {
|
||||
color: getRandomColor(),
|
||||
color: stringToRGB(label),
|
||||
face: 'FontAwesome',
|
||||
code: that.get_FA_icon(node['meta-category']),
|
||||
}
|
||||
|
@ -1825,15 +1825,6 @@ function getCentroid(coordList) {
|
|||
return {x: cx, y: cy};
|
||||
}
|
||||
|
||||
function getRandomColor() {
|
||||
var letters = '0123456789ABCDEF';
|
||||
var color = '#';
|
||||
for (var i = 0; i < 6; i++) {
|
||||
color += letters[Math.floor(Math.random() * 16)];
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
function generate_background_shortcuts(shortcut_text) {
|
||||
var table = document.createElement('table');
|
||||
for (var shortcut of shortcut_text.split("\n")) {
|
||||
|
|
|
@ -9,6 +9,20 @@ if (!String.prototype.startsWith) {
|
|||
};
|
||||
}
|
||||
|
||||
function stringToRGB(str){
|
||||
var hash = 0;
|
||||
if (str.length == 0) return hash;
|
||||
for (i = 0; i < str.length; i++) {
|
||||
hash = ((hash<<5)-hash) + str.charCodeAt(i);
|
||||
hash = hash & hash; // Convert to 32bit integer
|
||||
}
|
||||
var c = (hash & 0x00FFFFFF)
|
||||
.toString(16)
|
||||
.toUpperCase();
|
||||
|
||||
return "#" + "00000".substring(0, 6 - c.length) + c;
|
||||
}
|
||||
|
||||
function deleteObject(type, action, id, event) {
|
||||
var destination = 'attributes';
|
||||
var alternateDestinations = ['shadow_attributes', 'template_elements', 'taxonomies', 'galaxy_clusters', 'objects', 'object_references'];
|
||||
|
|
Loading…
Reference in New Issue