Skip to content

Commit

Permalink
2.3.0: minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
acaldero committed Jun 22, 2023
1 parent c62a65d commit 4696c25
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 67 deletions.
2 changes: 1 addition & 1 deletion examples/hardware/ep/images/processor.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
100 changes: 74 additions & 26 deletions wepsim_web/wepsim_uielto_cpusvg.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
var w = o.getAttribute('stroke-width');
if (w == null) return;

var wb = o.getAttribute('backup-stroke-width');
var wb = o.getAttribute('backup-stroke-width');
if (wb == null) {
wb = parseFloat(w);
o.setAttribute('backup-stroke-width', wb);
Expand All @@ -111,28 +111,51 @@
}
}


/*
* Drawing part
*/

var DRAW_stop = false ;

var cfg_color_background = 'white' ;
var cfg_color_data_active = '#0066FF' ;
var cfg_color_data_inactive = '#000000' ;
var cfg_color_name_active = '#FF0000' ;
var cfg_color_data_inactive = '#000000' ;
var cfg_color_name_inactive = '#000000' ;
var cfg_size_active = 3.0 ;
var cfg_size_inactive = 1.0 ;

function wepsim_svg_start_drawing ( )
function wepsim_svg_update_drawing ( )
{
DRAW_stop = false ;

// 1) from configuration
cfg_color_data_active = get_cfg('color_data_active') ;
cfg_color_data_inactive = get_cfg('color_data_inactive') ;
cfg_color_name_active = get_cfg('color_name_active') ;
cfg_color_data_inactive = get_cfg('color_data_inactive') ;
cfg_color_name_inactive = get_cfg('color_name_inactive') ;
cfg_size_active = get_cfg('size_active') ;
cfg_size_inactive = get_cfg('size_inactive') ;

// 2) modify because dark-mode
var is_black_mode = get_cfg("ws_skin_dark_mode") ;

if (false == is_black_mode) {
cfg_color_background = 'white' ;
cfg_color_data_inactive = '#000000' ;
cfg_color_name_inactive = '#000000' ;
}
else {
cfg_color_background = 'black' ;
cfg_color_data_inactive = '#FFFFFF' ;
cfg_color_name_inactive = '#FFFFFF' ;
}
}

function wepsim_svg_start_drawing ( )
{
DRAW_stop = false ;

wepsim_svg_update_drawing() ;
}

function wepsim_svg_stop_drawing ( )
Expand Down Expand Up @@ -315,24 +338,8 @@
o.style.visibility = value ;
}

function wepsim_svg_darkmode ( darkmode, svg_id )
function wepsim_svg_apply_darkmode ( svg_id )
{
var back_new = '' ;
var fore_new = '' ;

if (false == darkmode) {
back_new = 'white' ;
fore_new = 'black' ;
cfg_color_data_inactive = '#000000' ;
cfg_color_name_inactive = '#000000' ;
}
else {
back_new = 'black' ;
fore_new = 'white' ;
cfg_color_data_inactive = '#FFFFFF' ;
cfg_color_name_inactive = '#FFFFFF' ;
}

var svg_p = document.getElementById(svg_id);
if (null == svg_p) return ;

Expand All @@ -342,14 +349,55 @@
var svg2 = svg.querySelector('svg') ;
if (null == svg2) return ;

svg2.setAttribute('style', 'background-color:' + back_new);
svg2.setAttribute('style', 'background-color:' + cfg_color_background);
var elements = svg.querySelectorAll("path")
for (var i = 0; i < elements.length; i++) {
elements[i].style.fill = fore_new ;
elements[i].style.fill = cfg_color_data_inactive ;
}

var elements = svg.querySelectorAll("text")
for (var i = 0; i < elements.length; i++) {
elements[i].style.fill = fore_new ;
elements[i].style.fill = cfg_color_data_inactive ;
}
}

function wepsim_svg_refresh ( id_arr )
{
var o = null ;

// set darkmode
wepsim_svg_update_drawing() ;

// refresh svg (just in case)
for (var i in id_arr)
{
o = document.getElementById(id_arr[i]) ;
if (o === null) continue ;

wepsim_svg_apply_darkmode(id_arr[i]) ;
}
}

function wepsim_svg_reload ( id_arr )
{
var o = null ;
var a = null ;

// set darkmode
wepsim_svg_update_drawing() ;

// reload svg (just in case)
for (var i in id_arr)
{
o = document.getElementById(id_arr[i]) ;
if (o === null) continue ;

o.onload = function(obj) {
wepsim_svg_apply_darkmode(obj.currentTarget.id) ;
} ;

a = o.getAttribute('data') ;
o.setAttribute('data', a) ;
}
}

4 changes: 2 additions & 2 deletions wepsim_web/wepsim_uielto_l3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@
// html holder
o1 += "<div class='container text-end'>" +
"" +
'<label class="my-0" for="popover-l3dcfg" style="min-width:95%">' +
'<span class="my-0" for="popover-l3dcfg" style="min-width:95%">' +
'<span data-langkey="quick config">quick config</span>: ' +
"<a data-bs-toggle='collapse' href='#collapse-l3dcfg' aria-expanded='false' " +
" tabindex='0' class='m-auto' role='button' id='popover-l3dcfg'>" +
"<strong><strong class='fas fa-wrench text-secondary'></strong></strong></a>" +
"</label>" +
"</span>" +
"" +
"<table id='collapse-l3dcfg' " +
" class='table table-hover table-sm table-bordered m-0 collapse'>" +
Expand Down
4 changes: 2 additions & 2 deletions wepsim_web/wepsim_uielto_ldm.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@
// html holder
o1 += "<div class='container text-end'>" +
"" +
'<label class="my-0" for="popover-ledmcfg" style="min-width:95%">' +
'<span class="my-0" for="popover-ledmcfg" style="min-width:95%">' +
'<span data-langkey="quick config">quick config</span>: ' +
"<a data-bs-toggle='collapse' href='#collapse-ledmcfg' aria-expanded='false' " +
" tabindex='0' class='m-auto' role='button' id='popover-ledmcfg'>" +
"<strong><strong class='fas fa-wrench text-secondary'></strong></strong></a>" +
"</label>" +
"</span>" +
"" +
"<table id='collapse-ledmcfg' " +
" class='table table-hover table-sm table-bordered m-0 collapse'>" +
Expand Down
4 changes: 2 additions & 2 deletions wepsim_web/wepsim_uielto_mem.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@
{
// html holder
var o1 = "<div class='container text-end multi-collapse-3 collapse show'>" +
'<label class="my-0" for="popover-mem" style="min-width:95%">' +
'<span class="my-0" for="popover-mem" style="min-width:95%">' +
'<span data-langkey="quick config">quick config</span>: ' +
"<a data-bs-toggle='popover-mem' id='popover-mem' " +
" tabindex='0' class='m-auto border-0'>" +
"<strong><strong class='fas fa-wrench text-secondary'></strong></strong>" +
"</a></label>" +
"</a></span>" +
"</div>" +
"<div id='memory_MP' style='height:58vh; width:inherit;'></div>" ;

Expand Down
4 changes: 2 additions & 2 deletions wepsim_web/wepsim_uielto_registers.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
{
// html holder
var o1 = "<div class='container text-end multi-collapse-3 collapse show'>" +
'<label class="my-0" for="popover-rfcfg" style="min-width:95%">' +
'<span class="my-0" for="popover-rfcfg" style="min-width:95%">' +
'<span data-langkey="quick config">quick config</span>: ' +
"<a data-bs-toggle='popover-rfcfg' id='popover-rfcfg' " +
" tabindex='0' class='m-auto'>" +
"<strong><strong class='fas fa-wrench text-secondary'></strong></strong>" +
"</a></label>" +
"</a></span>" +
"</div>" +
'<div id="' + this.tf_div + '" ' +
' style="width:inherit; overflow-y:auto;"' +
Expand Down
4 changes: 2 additions & 2 deletions wepsim_web/wepsim_uipacker_cpu_cu.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@

// row with quick config:
o1 += "<div class='container text-end col-12 px-3 pt-1 multi-collapse-3 collapse show'>" +
"<label class='my-0' for='popover-cpuview' style='min-width:95%'>" +
"<span class='my-0' for='popover-cpuview' style='min-width:95%'>" +
"<span data-langkey='quick config'>quick config</span>: " +
"<a id='popover-cpuview' tabindex='0' " +
" class='show multi-collapse-3 btn my-1 col-auto border-0' " +
" data-bs-toggle='popover-cpuview'>" +
"<strong><strong class='fas fa-wrench text-secondary'></strong></strong></a>" +
"</label>" +
"</span>" +
"</div>" ;

// row with pill-buttons:
Expand Down
8 changes: 1 addition & 7 deletions wepsim_web/wepsim_web_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,7 @@
if (simhw_active() !== null)
{
// reload svg (just in case)
for (var i in id_arr)
{
o = document.getElementById(id_arr[i]) ;
if (o === null) continue ;
a = o.getAttribute('data') ;
o.setAttribute('data', a) ;
}
wepsim_svg_reload(id_arr) ;

// start drawing again
wepsim_svg_start_drawing() ;
Expand Down
34 changes: 14 additions & 20 deletions wepsim_web/wepsim_web_simulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,13 @@
$(classes).addClass('d-none') ;
}

function wepsim_restore_darkmode_aux ( adm )
function wepsim_appy_darkmode ( adm )
{
var o = null ;
var id_arr = [ "svg_p", "svg_cu" ] ;

// skipped elements
o = document.querySelectorAll('.no-dark-mode') ;
for (var i=0; i<o.length; i++)
{
if (adm === false)
o[i].removeAttribute('data-bs-theme', 'nodark') ;
else o[i].setAttribute('data-bs-theme', 'nodark') ;
}

// updating svg
wepsim_svg_darkmode(adm, "svg_p") ;
wepsim_svg_darkmode(adm, "svg_cu") ;
// refresh svg
wepsim_svg_refresh(id_arr) ;

// updating editors
if (adm)
Expand All @@ -147,8 +138,6 @@
return true ;
}

var observer_darkmode = null ;

function wepsim_restore_darkmode ( adm )
{
var o = null ;
Expand All @@ -159,23 +148,28 @@
else document.documentElement.setAttribute('data-bs-theme', 'dark') ;

// set visual updates for dark/light mode
wepsim_restore_darkmode_aux(adm) ;
wepsim_appy_darkmode(adm) ;

/*
// event onChange (TODO: move to some *_init function)
return true ;
}

var observer_darkmode = null ;

function wepsim_keepsync_darkmode ( )
{
// event handler for onChange (only once)
if (observer_darkmode == null)
{
observer = new MutationObserver(function ( mutations ) {
var is_black_mode = get_cfg("ws_skin_dark_mode") ;
wepsim_restore_darkmode_aux(is_black_mode) ;
wepsim_appy_darkmode(is_black_mode) ;
}) ;

observer.observe(document.documentElement, {
attributes: true,
attributeFilter: [ "data-bs-theme" ]
});
}
*/

return true ;
}
Expand Down
Loading

0 comments on commit 4696c25

Please sign in to comment.