const page = (function () { return { init: function () { loadAllCSS(); initTitle(); initBody(); initHeader(); initControl(); initResult(); initFooter(); addActions(); page.generateTooltips($('body')); }, update: function (scrollToTop) { $('.tooltipstered').tooltipster('hide'); selectors.updateSelectors(); references.updateReferences(); stats.updateStats(); tags.updateTagClouds(); clustering.updateClusters(); entryLayout.updateEntryList(); setTimeout( function() { // workaround: delayed loading waiting for the grid layout to be computed (to determine the correct width of the svg) timeline.updateTimeline(); }, 500); if (scrollToTop) { $('#result_body').scrollTop(0); } }, updateShowAll: function () { bib.nVisibleEntries = 999999999; page.update(false); }, updateShowMore: function () { bib.nVisibleEntries += 20; page.update(false); }, updateShowPart: function () { bib.nVisibleEntries = 20; page.update(true); }, updateTags: function () { tags.updateTagClouds(); }, updateTimeline: function () { timeline.updateTimeline(); }, updateTimelineLayout: function () { timeline.updateTimeline(true); }, notify: function (message, type) { const notificationDiv = $(`
${message}
`).appendTo($('#notifications')); notificationDiv.fadeIn('fast').delay(5000).fadeOut('fast'); }, generateTooltips: function (div) { div.find('.tooltip').tooltipster({ theme: 'tooltipster-survis' }); } }; function initBody() { var container = ($('
', { id: 'page-container' })).appendTo($('body')); $('
', { id: 'header' }).appendTo(container); $('
', { id: 'control' }).appendTo(container); $('
', { id: 'result' }).appendTo(container); $('
', { id: 'footer' }).appendTo(container); $('
', { id: 'notifications'}).appendTo($('body')); } function loadAllCSS() { var cssList = [ "codemirror/codemirror.css", "tooltipster/tooltipster.css", "tooltipster/tooltipster-survis.css", "style.css", "selector.css", "sparkline.css", "timeline.css", "entries.css" ]; $.each(cssList, function (i, css) { loadCSS(stylesDir + css); }); if (customStyle) { loadCSS(customStyle); } function loadCSS(href) { $('head').append($('', { rel: 'stylesheet', type: 'text/css', href: href })); } } function initTitle() { document.title = title; } function initHeader() { var headerDiv = $('#header'); var titleDiv = $('
', { id: 'title' }); if (!electron) { titleDiv.append($('

', { text: title })); if (paper) { var paperDiv = $('
' + paper.html + '
'); if (paper.id) { var showPaperButton = $('
', { class: 'button', text: 'select' }); showPaperButton.click(function (event) { selectors.toggleSelector('search', paper.id, event); if (showPaperButton.text() == 'select') { showPaperButton.text('deselect'); } else { showPaperButton.text('select'); } }); paperDiv.append(showPaperButton) } titleDiv.append(paperDiv); } } else { headerDiv.addClass('electron'); } titleDiv.append($(``)); headerDiv.append(titleDiv); $('').appendTo(headerDiv); headerDiv.append($('
Selectors
clear
')); } function initControl() { var controlDiv = $('#control'); var timelineContainerDiv = $('
', { id: 'timeline-container' }).appendTo(controlDiv); var timelineHeading = $('

/Timeline

').appendTo(timelineContainerDiv); timelineHeading.click(function () { uiUtil.toggleControl(timelineHeading); page.updateTimeline(); }); $('
', { id: 'timeline', class: 'toggle-container' }).appendTo(timelineContainerDiv); $('
', { id: 'tag_clouds' }).appendTo(controlDiv); var clustersDiv = $('
', { id: 'clusters', class: 'tag_cloud' }).appendTo(controlDiv); var clusterHeading = $('

/Clusters

').appendTo(clustersDiv); clusterHeading.click(function () { uiUtil.toggleControl(clusterHeading); page.updateTimeline(); }); $('
', { id: 'clusterings', class: 'toggle-container' }).appendTo(clustersDiv); var clusteringControls = $('
', { id: 'clustering_controls', class: 'toggle-container' }).appendTo(clustersDiv); $('', { class: 'label', text: 'new clustering:' }).appendTo(clusteringControls); var nClusterDiv = $('
', { class: 'n_clusters', text: 'number of clusters' }).appendTo(clusteringControls); var nClusterSpan = $('', { text: Math.max(1, clustering.nClusters) }); var buttonDec = $('
', { class: 'button dec small', text: '-' }).appendTo(nClusterDiv); buttonDec.click(function (event) { if (clustering.nClusters > 1) { clustering.nClusters--; nClusterSpan.text(clustering.nClusters); } }); if (clustering.nClusters < 1) { clustering.nClusters = 1 } nClusterSpan.appendTo(nClusterDiv); var buttonInc = $('
', { class: 'button inc small', text: '+' }).appendTo(nClusterDiv); buttonInc.click(function (event) { clustering.nClusters++; nClusterSpan.text(clustering.nClusters); }); var checkboxDiv = $('
', { class: 'clustering_criteria' }).appendTo(clusteringControls); $('', { id: 'keywords_checkbox', type: 'checkbox', checked: '' }).appendTo(checkboxDiv); $('', { text: 'keywords' }).appendTo(checkboxDiv); $('', { id: 'author_checkbox', type: 'checkbox' }).appendTo(checkboxDiv); $('', { text: 'authors' }).appendTo(checkboxDiv); var createClusteringButton = $('
', { id: 'create_clustering', class: 'button tooltip', title: 'create a new clustering to automatically group publications', text: 'create clustering' }).appendTo(clusteringControls); createClusteringButton.click(function () { clustering.createClustering(); page.update(); }); } function initResult() { var resultHeaderDiv = $('
', { id: 'result_header' }).appendTo('#result'); $('
', { id: 'stats' }).appendTo(resultHeaderDiv); $('
', { id: 'sorting_description', text: 'sorted by selector agreement and publication key' }).appendTo(resultHeaderDiv); $('
', { id: 'result_body', class: 'ui-layout-content' }).appendTo('#result'); } function initFooter() { var footer = $('#footer'); var menuDiv = ($('