Skip to content

Commit

Permalink
Support individual bid listing and polish
Browse files Browse the repository at this point in the history
  • Loading branch information
blokhin committed Mar 21, 2024
1 parent 5bb8a2f commit 6bf6ea4
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 20 deletions.
8 changes: 4 additions & 4 deletions src_js/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function register_events(){
var urlstr = $.param(query);
if (window.location.hash == '#inquiry/' + urlstr){
// hash-hack FIXME?
if (urlstr.slice(-1) == '=') urlstr = urlstr.substr(0, urlstr.length-1);
if (urlstr.slice(-1) == '=') urlstr = urlstr.substr(0, urlstr.length - 1);
else urlstr += '=';
}
window.location.hash = '#inquiry/' + urlstr;
Expand Down Expand Up @@ -218,7 +218,7 @@ function register_events(){
open_context(parent_row, true);
});

$('#databrowser').on('click', 'a.launch_ph', function(e){
$('#databrowser').on('click', 'a.launch_id', function(e){
wmgui.cancel_event(e);
var phid_link = $(this).attr('href');
if (window.location.hash == phid_link){
Expand Down Expand Up @@ -1108,7 +1108,7 @@ function register_events(){
var urlstr = $.param(orepr);
if (window.location.hash == '#inquiry/' + urlstr){
// hash-hack FIXME?
if (urlstr.slice(-1) == '=') urlstr = urlstr.substr(0, urlstr.length-1);
if (urlstr.slice(-1) == '=') urlstr = urlstr.substr(0, urlstr.length - 1);
else urlstr += '=';
}
window.location.hash = '#inquiry/' + urlstr;
Expand All @@ -1128,7 +1128,7 @@ function register_events(){
var urlstr = $.param(orepr);
if (window.location.hash == '#inquiry/' + urlstr){
// hash-hack FIXME?
if (urlstr.slice(-1) == '=') urlstr = urlstr.substr(0, urlstr.length-1);
if (urlstr.slice(-1) == '=') urlstr = urlstr.substr(0, urlstr.length - 1);
else urlstr += '=';
}
window.location.hash = '#inquiry/' + urlstr;
Expand Down
73 changes: 61 additions & 12 deletions src_js/main_logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ function request_search(search, caption, without_history){
if (wmgui.search_type == 2){
$db.addClass('tablesorter').tablesorter({ sortMultiSortKey: 'ctrlKey', headers: {
0: {sorter: 'doi'},
6: {sorter: 'digit'}
5: {sorter: false}
}, selectorHeaders: '#dataheader_articles > thead > tr > th', selectorHeaderParent: 'dataheader_articles' });
$('#header_articles').show();

Expand Down Expand Up @@ -305,11 +305,11 @@ function request_search(search, caption, without_history){
// switchers
if (wmgui.visavis_terminating) stop_visavis();

if (wmgui.search_type || search.phid || search.entry || search.interlinkage || search.doi || search.numeric){
if (wmgui.search_type || search.phid || search.bid || search.entry || search.interlinkage || search.doi || search.numeric){

if (search.phid || search.entry){
if (search.phid || search.bid || search.entry){
switch_control_mode(9, 11, 'a', 'c');
show_dunit_info(search.phid, search.entry);
show_dunit_info(search.phid, search.bid, search.entry);

} else if (search.interlinkage){
switch_control_mode(9, 11, 'a', 'c');
Expand Down Expand Up @@ -534,13 +534,13 @@ function build_cells(json, header, footer){
$.each(json, function(k, row){
row[0] = parseInt(row[0]);
if (row[0] == 999999) row[4] = wmgui.mockyear; // special *ref_id*, only handled in GUI
result_html += '<tr id="e__B' + row[0] + '" class="tcell" data-type="B"><td class=c55>[<a class="resolve_ref' + ((wmgui.bid_history.indexOf(row[0]) > -1) ? ' visited' : '') + '" href="' + wmgui.refs_endpoint + '?ref_id=' + row[0] + '&sid=' + wmgui.sid + '&ed=' + wmgui.edition + '" rel="' + row[0] + '" target="_blank" rel="noopener noreferrer">' + row[0] + '</a>]</td><td class=a1>' + row[1] + '</td><td class=a2 title="' + row[2] + '">' + row[2] + '</td><td class=a5>' + row[5] + '</td><td class=cj>' + row[3] + '</td><td class=c4>' + row[4] + '</td></tr>';
result_html += '<tr id="e__B' + row[0] + '" class="tcell" data-type="B"><td class=c55>[<a class="resolve_ref' + ((wmgui.bid_history.indexOf(row[0]) > -1) ? ' visited' : '') + '" href="' + wmgui.refs_endpoint + '?ref_id=' + row[0] + '&sid=' + wmgui.sid + '&ed=' + wmgui.edition + '" rel="' + row[0] + '" target="_blank" rel="noopener noreferrer">' + row[0] + '</a>]</td><td class=a1>' + row[1] + '</td><td class=a2 title="' + row[2] + '">' + row[2] + '</td><td class=a5>' + row[5] + '</td><td class=c4>' + row[4] + '</td><td class=a6><a class="launch_id" href="#article/' + row[0] + '">Show</a></td></tr>';
});
} else if (wmgui.search_type == 1){
if (json[0].length != 5){ wmgui.notify('Rendering error, please try to <a href=javascript:location.reload()>reload</a>'); return ''; }

$.each(json, function(k, row){
result_html += '<tr id="e__Z' + row[0] + '" class="tcell" data-type="Z"><td class=p1>' + row[1] + '</td><td class=p2>' + row[2] + '</td><td class=p3>' + row[3] + '</td><td class=p4>' + row[4] + '</td><td class=p5><a class="launch_ph" href="#phase_id/' + row[0] + '">Show entries</a></td></tr>';
result_html += '<tr id="e__Z' + row[0] + '" class="tcell" data-type="Z"><td class=p1>' + row[1] + '</td><td class=p2>' + row[2] + '</td><td class=p3>' + row[3] + '</td><td class=p4>' + row[4] + '</td><td class=p5><a class="launch_id" href="#phase_id/' + row[0] + '">Show entries</a></td></tr>';
});
} else {
if (json[0].length != 8){ wmgui.notify('Rendering error, please try to <a href=javascript:location.reload()>reload</a>'); return ''; }
Expand Down Expand Up @@ -576,7 +576,7 @@ function build_thumbs(json){
if (row[0] == 999999) row[4] = wmgui.mockyear; // special *ref_id*, only handled in GUI
if (full_display) title_html = (row[1].length > 60 ? row[1].substr(0, 60) + '&hellip;' : row[1]) + ', <span>' + (row[2].length > 80 ? row[2].substr(0, 80) + '&hellip;' : row[2]) + '</span>';
else title_html = '<br /><br />&#x1f4d6;'; // book icon
result_html += '<div class="gallery_item" id="e__B' + row[0] + '" data-type="B"><div class="gallery_img"><div class="articled">' + title_html + '</div></div><div class="gallery_label"><i>' + row[5] + '</i><br />[<a class="resolve_ref' + ((wmgui.bid_history.indexOf(row[0]) > -1) ? ' visited' : '') + '" href="' + wmgui.refs_endpoint + '?ref_id=' + row[0] + '&sid=' + wmgui.sid + '&ed=' + wmgui.edition + '" rel="' + row[0] + '" target="_blank" rel="noopener noreferrer">' + row[3] + '&rsquo;' + row[4].toString().substr(2, 2) + '</a>]</div></div>';
result_html += '<div class="gallery_item" id="e__B' + row[0] + '" data-type="B"><div class="gallery_img"><div class="articled">' + title_html + '</div></div><div class="gallery_label"><a class="launch_id" href="#article/' + row[0] + '">Show entries</a><br />[<a class="resolve_ref' + ((wmgui.bid_history.indexOf(row[0]) > -1) ? ' visited' : '') + '" href="' + wmgui.refs_endpoint + '?ref_id=' + row[0] + '&sid=' + wmgui.sid + '&ed=' + wmgui.edition + '" rel="' + row[0] + '" target="_blank" rel="noopener noreferrer">' + row[3] + '&rsquo;' + row[4].toString().substr(2, 2) + '</a>]</div></div>';
});
} else if (wmgui.search_type == 1){
if (json[0].length != 5){ wmgui.notify('Rendering error, please try to <a href=javascript:location.reload()>reload</a>'); return ''; }
Expand All @@ -585,7 +585,7 @@ function build_thumbs(json){
return a[1] > b[1] ? 1 : a[1] < b[1] ? -1 : 0;
});
$.each(json, function(k, row){
result_html += '<div class="gallery_item" id="e__Z' + row[0] + '" data-type="Z"><div class="gallery_img" rel="' + row[0] + '"><div class="phased">' + row[1] + '<br /><br />space group ' + row[2] + '</div></div><div class="gallery_label"><a class="launch_ph" href="#phase_id/' + row[0] + '">Show ' + row[3] + (row[3] == 1 ? ' entry' : ' entries') + '</a><br />Publications: ' + row[4] + '</div></div>';
result_html += '<div class="gallery_item" id="e__Z' + row[0] + '" data-type="Z"><div class="gallery_img" rel="' + row[0] + '"><div class="phased">' + row[1] + '<br /><br />space group ' + row[2] + '</div></div><div class="gallery_label"><a class="launch_id" href="#phase_id/' + row[0] + '">Show ' + row[3] + (row[3] == 1 ? ' entry' : ' entries') + '</a><br />Publications: ' + row[4] + '</div></div>';
});
} else {
if (json[0].length != 8){ wmgui.notify('Rendering error, please try to <a href=javascript:location.reload()>reload</a>'); return ''; }
Expand Down Expand Up @@ -1489,10 +1489,20 @@ function render_all_polyhedra(){
$('#all_polyhedra_content').html(aetypes_html);
}

function show_dunit_info(phid, entry){
$('#ind_title').html( phid ? 'Phase ' + phid : 'Entry ' + entry );
$('#ind_link').attr('href', 'https://mpds.io/' + (phid ? 'phase_id' : 'entry') + '/' + (phid || entry));
$('#ind_link').html('www.mpds.io/' + (phid ? 'phase_id' : 'entry') + '/' + (phid || entry));
function show_dunit_info(phid, bid, entry){
if (phid){
$('#ind_title').html('Phase ' + phid);
$('#ind_link').attr('href', 'https://mpds.io/phase_id/' + phid).html('www.mpds.io/phase_id/' + phid);

} else if (bid){
$('#ind_title').html('Publication B' + bid);
$('#ind_link').attr('href', 'https://mpds.io/article/' + bid).html('www.mpds.io/article/' + bid);

} else if (entry){
$('#ind_title').html('Entry ' + entry);
$('#ind_link').attr('href', 'https://mpds.io/entry/' + entry).html('www.mpds.io/entry/' + entry);
}

$('#refine_col, #ctx_col').hide();
$('#phase_info, #ind_col > span').empty();

Expand All @@ -1516,6 +1526,45 @@ function show_dunit_info(phid, entry){
if (textStatus != 'abort')
wmgui.notify('Sorry, a network error occured. Please, try again');
});

} else if (bid){
$('#ind_col > span').html('<strong>&#x1f4d6;</strong>'); // book icon
$('#phase_info').html('<h4>Ref. ' + bid + '</h4><p>Please make sure you are<br /><a target="_blank" href="#modal/menu">logged in</a> to see all the details.</p>');

wmgui.active_ajax = $.ajax({
type: 'GET',
url: wmgui.refs_endpoint + '?noredir=1&fmt=bib&ref_id=' + bid + '&sid=' + wmgui.sid

}).done(function(data){
var citation = wmgui.parse_bib(data),
citation_html = '',
main_author = '',
links_html = '';

if (citation[0].length){
citation[0].split(',').forEach(function(item, index){
var author_name = item.trim().split('.')[0];
author_name = author_name.substr(0, author_name.length - 2).replace("'", "");
if (index === 0) main_author = author_name;
links_html += '<a href="#inquiry/authors=' + author_name + '" style="color:#777;border-bottom-color:#777;">' + author_name + '</a> or ';
});
links_html = links_html.substr(0, links_html.length - 4); // " or "
if (citation[0].indexOf(',') !== -1) main_author += ' et al.';
citation_html += '<a href="' + wmgui.refs_endpoint + '?fmt=bib&ref_id=' + bid + '&sid=' + wmgui.sid + '">' + main_author + ', ' + citation[1] + '. <i>' + citation[2] + '</i> <b>(' + citation[3] + ')</b></a>';
}

if (bid == 999999){
$('#phase_info').html('<h4>In-house data</h4><p>These data were generated automatically on the MPDS platform based on the original peer-reviewed Pauling File data. Please cite as ' + citation_html + '.</p>');

} else {
var n_entries = wmgui.thumbed_display ? $('div.gallery_item').length : $('tr.tcell').length;
$('#phase_info').html('<h4>Ref. ' + bid + '</h4><p>We have ' + (n_entries == 1 ? 'one entry' : n_entries + ' entries') + ' from this reference ' + citation_html + '.</p><p>In addition, search all data co-authored by ' + links_html + '.</p>');
}

}).fail(function(xhr, textStatus, errorThrown){});

} else {
$('#ind_col > span').html('<strong>&#x1f52c;</strong>'); // microscope icon
}

$('#ind_col').show();
Expand Down
4 changes: 2 additions & 2 deletions src_js/markup.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ function register_html(){
<th class="a1">Authors</th>
<th class="a2">Title</th>
<th class="a5">J. name</th>
<th class="cj">J. code</th>
<th class="c4">Year</th>
<th class="a6"></th>
</tr></thead>
</table>
</div>
Expand Down Expand Up @@ -488,7 +488,7 @@ function register_html(){
<a id="sim_trigger" href="#" class="wmbutton sim_col_ctx" rel="nofollow">Show more</a>
<div id="pd_legend" class="sim_col_ctx">
<div class="col_title">Area colors</div>
<div class="col_title">Color legend</div>
<ul>
<li>liquid or gas <span style="color:#fff;background:#9cf;padding:2px;">blue or violet</span></li>
<li>1-phase <span style="color:#fff;background:#d1cde6;padding:2px;">violet</span></li>
Expand Down
4 changes: 2 additions & 2 deletions src_js/ptable.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ function build_thumbs_ph(json){ // FIXME duplicates another function *build_thum
json.forEach(function(row){
result_html += '<div class="gallery_item">';
result_html += ' <div class="gallery_img" rel="' + row[0] + '" style="background-image:url(https://mpds.io/phid_thumbs/' + row[0] + '.png);"><span><p>' + row[1] + '<br />space group ' + row[2] + '</p></span></div>';
result_html += ' <div class="gallery_label"><a class="launch_ph" href="#phase_id/' + row[0] + '">Show ' + row[3] + (row[3] == 1 ? ' entry' : ' entries') + '</a><br />Publications: ' + row[4] + '</div>';
result_html += ' <div class="gallery_label"><a class="launch_id" href="#phase_id/' + row[0] + '">Show ' + row[3] + (row[3] == 1 ? ' entry' : ' entries') + '</a><br />Publications: ' + row[4] + '</div>';
result_html += '</div>';
});
return result_html;
Expand All @@ -402,7 +402,7 @@ function build_thumbs_pd(json){ // FIXME duplicates another function *build_thum

result_html += '<div class="gallery_item' + (row[4] ? ' opened' : '') + '">';
result_html += ' <div class="gallery_img" rel="' + row[0] + '" data-path="entry">' + content + '</div>';
result_html += ' <div class="gallery_label"><a class="launch_ph" href="#entry/' + row[0] + '">' + row[0] + '</a>' + '<br />[' + row[5] + '&rsquo;' + row[6].toString().substr(2, 2) + ']' + '</div>';
result_html += ' <div class="gallery_label"><a class="launch_id" href="#entry/' + row[0] + '">' + row[0] + '</a>' + '<br />[' + row[5] + '&rsquo;' + row[6].toString().substr(2, 2) + ']' + '</div>';
result_html += '</div>';
});
return result_html;
Expand Down
12 changes: 12 additions & 0 deletions src_js/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,18 @@ function url__phase(arg){
} else return wmgui.notify('Sorry, wrong phase given');
}

/**
* The individual B-entry display /#article/integer
*/
function url__article(arg){
wmgui.search_type = 0;
show_interpretation();
var bentry = parseInt(arg);
wmgui.search = {'bid': bentry};
wmgui.search.search_type = wmgui.search_type;
request_search({'bid': bentry}, 'B' + bentry, true);
}

/**
* The display of menu with all the physical props
*/
Expand Down
20 changes: 20 additions & 0 deletions src_js/wmcore.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,3 +408,23 @@ wmgui.get_interpretation = function(search, facet_names, num_database){

return interpret_html;
}

/**
* Parse MPDS BIBTEX
*/

wmgui.parse_bib = function(string){
try {
var title = string.split('title={')[1].split('},')[0].trim(),
authors = string.split('author={')[1].split('},')[0].trim(),
journal = string.split('journal={')[1].split('},')[0].trim(),
pubyear = string.split('year={')[1].split('},')[0].trim();
} catch (error){
console.error('Misformatted BIB, terminating...');
var title = '',
authors = '',
journal = '',
pubyear = '';
}
return [authors, title, journal, pubyear];
}

0 comments on commit 6bf6ea4

Please sign in to comment.