Skip to content

Commit

Permalink
Fix ptable vis, add static properties ptable, fix search input login …
Browse files Browse the repository at this point in the history
…saving
  • Loading branch information
blokhin committed Dec 22, 2022
1 parent a14cde6 commit f9b2544
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 9 deletions.
12 changes: 10 additions & 2 deletions src_js/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,13 @@ function register_events(){
$('#databrowser, #ptable_results').on('click', 'div.gallery_img', function(){
var that = $(this);
if (that.attr('rel')){
if (wmgui.view_mode === 1 && wmgui.ptable.dtypes == 2){
if (wmgui.view_mode === 1 && wmgui.ptable.dtypes > 1){
var phid = that.attr('rel');
document.querySelector('#ptable_vis > iframe').contentWindow.location.hash = '#' + wmgui.phase_endpoint + '?phid=' + phid + '&struct=1';

wmgui.ptable.dtypes == 2 ?
document.querySelector('#ptable_vis > iframe').contentWindow.location.hash = '#' + wmgui.phase_endpoint + '?phid=' + phid + '&struct=1' :
document.querySelector('#ptable_vis > iframe').contentWindow.location.replace(get_visavis_url({phid: phid}, 'graph', window.innerHeight - 50));

$('div.gallery_item.active').removeClass('active');
that.parent().addClass('active');

Expand Down Expand Up @@ -644,9 +648,13 @@ function register_events(){
document.getElementById('ptable_dtypes_box').classList.remove('resulted');
document.getElementById('legend').style.display = 'none';

(wmgui.ptable.vis_fixed && scroll_pos > 550) ? document.getElementById('ptable_vis').classList.add('fixed') :
document.getElementById('ptable_vis').classList.remove('fixed');

} else {
document.getElementById('ptable_dtypes_box').classList.add('resulted');
document.getElementById('legend').style.display = 'block';
document.getElementById('ptable_vis').classList.remove('fixed');
}
}
}, 300));
Expand Down
4 changes: 2 additions & 2 deletions src_js/main_logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -1082,11 +1082,11 @@ function stop_visavis(){

function get_visavis_url(request, type, height){
if (wmgui.visavis_curtype == 'pie' && !type)
return wmgui.static_host + '/visavis/#' + wmgui.rfn_endpoint + '?q=' + escape(JSON.stringify(request));
return wmgui.v_vis_addr + '#' + wmgui.rfn_endpoint + '?q=' + escape(JSON.stringify(request));

var height_str = height ? ('&visavis_height=' + height) : '';

return wmgui.static_host + '/visavis/?241022#' + wmgui.vis_endpoint + '/' + (type || wmgui.visavis_curtype) + '?q=' + escape(JSON.stringify(request)) + height_str;
return wmgui.v_vis_addr + '#' + wmgui.vis_endpoint + '/' + (type || wmgui.visavis_curtype) + '?q=' + escape(JSON.stringify(request)) + height_str;
}

function describe_perms(perms){
Expand Down
2 changes: 1 addition & 1 deletion src_js/markup.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function register_html(){
<div id="search_area">
<div id="search_holder">
<select id="search_field" autocomplete="false" multiple autofocus></select>
<select id="search_field" autocomplete="off" autofocus></select>
</div>
<a href="#hierarchy" id="hierarchy_trigger" class="wmbutton" title="Show list of properties">&mu;<span><sub>x</sub><sup>&deg;</sup></span></a>
<a href="#" id="advsearch_init_trigger" class="wmbutton" title="Show search options">&#9776;</a>
Expand Down
26 changes: 24 additions & 2 deletions src_js/ptable.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ wmgui.ptable.visible = false; // needed to debounce
wmgui.ptable.activated = false; // should it "jump" on top by input
wmgui.ptable.dtypes = 1; // 0, 1, 2, or 3, see #ptable_dtypes
wmgui.ptable.subphases_button = '';
wmgui.ptable.vis_fixed = false;
wmgui.ptable.elements = ['X'].concat(wmutils.periodic_elements_cased);

wmgui.ptable.show = function(){
Expand Down Expand Up @@ -121,6 +122,7 @@ function refresh_ptable_results(elA, elB, elC){

if (query_ph){
wmgui.ptable.query = query_ph;
wmgui.ptable.vis_fixed = false;

let iframe_addr,
iframe_height = 900;
Expand All @@ -129,6 +131,11 @@ function refresh_ptable_results(elA, elB, elC){

if (wmgui.ptable.dtypes == 2){
iframe_addr = wmgui.v_player_addr_tpl;
wmgui.ptable.vis_fixed = true;

} else if (wmgui.ptable.dtypes == 3){
iframe_addr = wmgui.v_vis_addr;
wmgui.ptable.vis_fixed = true;

} else
document.getElementById('ptable_vis').innerHTML = '';
Expand All @@ -142,16 +149,19 @@ function refresh_ptable_results(elA, elB, elC){

} else if (wmgui.ptable.dtypes == 2){
iframe_addr = wmgui.v_player_addr_tpl;
wmgui.ptable.vis_fixed = true;

} else if (wmgui.ptable.dtypes == 3){
iframe_addr = get_visavis_url({elements: els.join('-'), classes: wmutils.arity_keys[els.length]}, 'graph', iframe_height);
iframe_addr = wmgui.v_vis_addr;
wmgui.ptable.vis_fixed = true;

} else
document.getElementById('ptable_vis').innerHTML = '';

} else {
wmgui.ptable.subphases_set(1);
iframe_height = window.innerHeight - 200;
wmgui.ptable.vis_fixed = true;

if (wmgui.ptable.dtypes == 1){
iframe_addr = wmgui.v_pd_3d_addr + els.join('-');
Expand All @@ -160,7 +170,7 @@ function refresh_ptable_results(elA, elB, elC){
iframe_addr = wmgui.v_player_addr_tpl;

} else if (wmgui.ptable.dtypes == 3){
iframe_addr = get_visavis_url({elements: els.join('-')}, 'graph', iframe_height);
iframe_addr = wmgui.v_vis_addr;

} else
document.getElementById('ptable_vis').innerHTML = '';
Expand Down Expand Up @@ -203,6 +213,8 @@ function render_left(data){
parent.classList.add('ptable_dtype_' + wmgui.ptable.dtypes);
parent.innerHTML = header + (data.out.length ? build_thumbs_ph(data.out) : '<img src="' + wmgui.static_host + '/question.svg" width=100 />') + wmgui.ptable.subphases_button;

if (data.out.length < 10) wmgui.ptable.vis_fixed = false; // prevent screen jumping

if (wmgui.ptable.dtypes == 2){
const els = document.querySelectorAll('#ptable_results div.gallery_img');
if (els.length){
Expand All @@ -212,6 +224,16 @@ function render_left(data){
document.querySelector('#ptable_vis > iframe').contentWindow.location.hash = '#' + wmgui.phase_endpoint + '?phid=' + phid + '&struct=1';

} else document.getElementById('ptable_vis').innerHTML = '';

} else if (wmgui.ptable.dtypes == 3){
const els = document.querySelectorAll('#ptable_results div.gallery_img');
if (els.length){
const rnd_i = Math.floor(Math.random() * els.length);
els[rnd_i].parentNode.classList.add('active');
const phid = els[rnd_i].getAttribute('rel');
document.querySelector('#ptable_vis > iframe').contentWindow.location.replace(get_visavis_url({phid: phid}, 'graph', window.innerHeight - 50));

} else document.getElementById('ptable_vis').innerHTML = '';
}
}

Expand Down
1 change: 1 addition & 0 deletions src_js/wmsettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ wmgui.v_player_addr = wmgui.v_player_addr_tpl + '#' + wmgui.api
wmgui.v_pd_addr = wmgui.static_host + '/pd_stub.html#' + wmgui.api_host + '/download/c?fmt=png&q=';
wmgui.v_pd_addr_anon = wmgui.static_host + '/visavis/?241022#' + wmgui.api_host + '/download/c?fmt=json&q=';
wmgui.v_sd_addr = wmgui.static_host + '/visavis/?241022#' + wmgui.api_host + '/download/p?fmt=json&q=';
wmgui.v_vis_addr = wmgui.static_host + '/visavis/?nobanner&241022';
wmgui.v_ab_vis_addr = wmgui.static_host + '/labs/view-phonons/#' + wmgui.api_host + '/download/p?fmt=json&q=';
wmgui.v_pd_3d_addr = wmgui.static_host + '/labs/pd3d/?';

Expand Down
5 changes: 3 additions & 2 deletions webassets/ermac.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f9b2544

Please sign in to comment.