From f9b254415ef06f6d5fc43b07033d910f43b72681 Mon Sep 17 00:00:00 2001 From: Evgeny Blokhin Date: Thu, 22 Dec 2022 01:12:06 +0100 Subject: [PATCH] Fix ptable vis, add static properties ptable, fix search input login saving --- src_js/events.js | 12 ++++++++++-- src_js/main_logic.js | 4 ++-- src_js/markup.js | 2 +- src_js/ptable.js | 26 ++++++++++++++++++++++++-- src_js/wmsettings.js | 1 + webassets/ermac.css | 5 +++-- 6 files changed, 41 insertions(+), 9 deletions(-) diff --git a/src_js/events.js b/src_js/events.js index f94cf82..9581b67 100755 --- a/src_js/events.js +++ b/src_js/events.js @@ -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'); @@ -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)); diff --git a/src_js/main_logic.js b/src_js/main_logic.js index ef3c0bb..2e714bc 100755 --- a/src_js/main_logic.js +++ b/src_js/main_logic.js @@ -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){ diff --git a/src_js/markup.js b/src_js/markup.js index 4c4d448..6dd6d7e 100755 --- a/src_js/markup.js +++ b/src_js/markup.js @@ -29,7 +29,7 @@ function register_html(){
- +
μx° diff --git a/src_js/ptable.js b/src_js/ptable.js index addf9a0..aced8fb 100644 --- a/src_js/ptable.js +++ b/src_js/ptable.js @@ -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(){ @@ -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; @@ -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 = ''; @@ -142,9 +149,11 @@ 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 = ''; @@ -152,6 +161,7 @@ function refresh_ptable_results(elA, elB, elC){ } 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('-'); @@ -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 = ''; @@ -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) : '') + 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){ @@ -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 = ''; } } diff --git a/src_js/wmsettings.js b/src_js/wmsettings.js index 680e276..6955836 100755 --- a/src_js/wmsettings.js +++ b/src_js/wmsettings.js @@ -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/?'; diff --git a/webassets/ermac.css b/webassets/ermac.css index c962a0d..e27daac 100755 --- a/webassets/ermac.css +++ b/webassets/ermac.css @@ -425,12 +425,13 @@ div.sops_col{letter-spacing:1px;} #ptable_holder{display:none;position:absolute;z-index:1;width:1050px;height:auto;top:280px;left:50%;margin-left:-525px;background:#fff;user-select:none;} #ptable_holder.resulted{top:80px;} -#ptable_results_area{width:99%;margin:0 auto;} +#ptable_results{width:99%;margin:0 auto;} #ptable_previews{float:left;width:50%;text-align:left;padding-top:20px;background:#fff;} #ptable_previews > div.subphases_trigger{width:50%;margin:30px auto;font-size:0.95em;} #ptable_previews > div.subphases_trigger > span{font-size:26px;} -#ptable_previews.ptable_dtype_2 > div.gallery_item:hover, div.gallery_item.active{background:#cf9;} +#ptable_previews.ptable_dtype_2 > div.gallery_item:hover, div.gallery_item.active, #ptable_previews.ptable_dtype_3 > div.gallery_item:hover, div.gallery_item.active{background:#cf9;} #ptable_vis{float:right;width:50%;text-align:right;padding-top:20px;background:#fff;} +#ptable_vis.fixed{position:fixed;width:525px;top:30px;left:50%;} #ptable_vis > iframe{border:1px solid #bbb;margin-top:16px;} #ptable_area{width:100%;position:relative;}