Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dark background option to config.js, allowed to switch background #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ setParams({
Show the edge arrows when the edge is directed
this setting can't be changed from the User Interface
*/
darkBackground:true,
/*
Switch background to dark
*/
language: false,
/*
Set to an ISO language code to switch the interface to that language.
Expand Down
41 changes: 38 additions & 3 deletions js/gexfjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,12 @@ function traceMap() {
}
}
if (_fs > GexfJS.params.textDisplayThreshold) {
GexfJS.ctxGraphe.fillStyle = ( ( i != GexfJS.params.activeNode ) && _tagsMisEnValeur.length && ( ( !_d.isTag ) || ( _centralNode != -1 ) ) ? "rgba(60,60,60,0.7)" : "rgb(0,0,0)" );
if (typeof GexfJS.params.darkBackground != "undefined" && GexfJS.params.darkBackground) {
GexfJS.ctxGraphe.fillStyle = ( ( i != GexfJS.params.activeNode ) && _tagsMisEnValeur.length && ( ( !_d.isTag ) || ( _centralNode != -1 ) ) ? "rgba(210,210,210,0.7)" : "rgb(215,215,215)" );
} else {
GexfJS.ctxGraphe.fillStyle = ( ( i != GexfJS.params.activeNode ) && _tagsMisEnValeur.length && ( ( !_d.isTag ) || ( _centralNode != -1 ) ) ? "rgba(60,60,60,0.7)" : "rgb(0,0,0)" );
}
// GexfJS.ctxGraphe.fillStyle = ( ( i != GexfJS.params.activeNode ) && _tagsMisEnValeur.length && ( ( !_d.isTag ) || ( _centralNode != -1 ) ) ? "rgba(60,60,60,0.7)" : "rgb(0,0,0)" );
GexfJS.ctxGraphe.font = Math.floor( _fs )+"px Arial";
GexfJS.ctxGraphe.textAlign = "center";
GexfJS.ctxGraphe.textBaseline = "middle";
Expand All @@ -971,12 +976,22 @@ function traceMap() {
GexfJS.ctxGraphe.font = "bold " + Math.floor( _fs )+"px Arial";
GexfJS.ctxGraphe.textAlign = "center";
GexfJS.ctxGraphe.textBaseline = "middle";
GexfJS.ctxGraphe.fillStyle = "rgba(255,255,250,0.8)";
if (typeof GexfJS.params.darkBackground != "undefined" && GexfJS.params.darkBackground) {
GexfJS.ctxGraphe.fillStyle = "rgb(0,0,0)";
} else {
GexfJS.ctxGraphe.fillStyle = "rgba(255,255,250,0.8)";
}
// GexfJS.ctxGraphe.fillStyle = "rgba(255,255,250,0.8)";
GexfJS.ctxGraphe.fillText(_dnc.label, _dnc.coords.real.x - 2, _dnc.coords.real.y);
GexfJS.ctxGraphe.fillText(_dnc.label, _dnc.coords.real.x + 2, _dnc.coords.real.y);
GexfJS.ctxGraphe.fillText(_dnc.label, _dnc.coords.real.x, _dnc.coords.real.y - 2);
GexfJS.ctxGraphe.fillText(_dnc.label, _dnc.coords.real.x, _dnc.coords.real.y + 2);
GexfJS.ctxGraphe.fillStyle = "rgb(0,0,0)";
if (typeof GexfJS.params.darkBackground != "undefined" && GexfJS.params.darkBackground) {
GexfJS.ctxGraphe.fillStyle = "rgba(255,255,250,0.8)";
} else {
GexfJS.ctxGraphe.fillStyle = "rgb(0,0,0)";
}
// GexfJS.ctxGraphe.fillStyle = "rgb(0,0,0)";
GexfJS.ctxGraphe.fillText(_dnc.label, _dnc.coords.real.x, _dnc.coords.real.y);
}

Expand Down Expand Up @@ -1045,6 +1060,26 @@ function setParams(paramlist) {
}

$(document).ready(function() {
// setup background css
var gradient_style_dark = [
"background-color:#070813",
"background-image:-webkit-radial-gradient(#263458, #070813)",
"background-image:-moz-radial-gradient(#ffffff, #d8d8e0)",
"color:white"
].join(';');

var gradient_style_light = [
"background-color: #f0f0f8",
"background-image: -webkit-radial-gradient(#ffffff, #d8d8e0)",
"background-image: -moz-radial-gradient(#ffffff, #d8d8e0)",
"color:black"
].join(';');

if (typeof GexfJS.params.darkBackground != "undefined" && GexfJS.params.darkBackground) {
$(".gradient").attr('style',gradient_style_dark);
} else {
$(".gradient").attr('style',gradient_style_light);
}

var lang = (
typeof GexfJS.params.language != "undefined" && GexfJS.params.language
Expand Down