Skip to content

Commit

Permalink
Add anchors for each release
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerry committed Jul 22, 2019
1 parent 052ad74 commit 4d40a8e
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 24 deletions.
6 changes: 3 additions & 3 deletions docs/_static/mygene_doc.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
.release-info pre {overflow-x:auto;font-size:12px;padding-bottom:15px;}
.release-link {margin-left:10px;}
.release-version {font-weight:bold;}
.release-date {font-style: italic; font:monospace; margin-bottom:0px}
.release-date {font-style: italic; font:monospace; margin-bottom:4px; font-weight: 500}
#mygene-releases h2 {margin-bottom:5px;}
.release-pane {padding-left:7px;/*border-left:1px solid grey;*/}
.release-pane {margin-bottom: 6px}
.release-collapse {margin-left:10px;}
.release-expand {margin-right:10px;}
.release-control-line {margin-bottom: 5px;}
.release-control-line {margin-bottom: 5px;}
82 changes: 61 additions & 21 deletions docs/_static/mygene_doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ function numberWithCommas(x) {
var Releases = {};
var DATA_FORMAT_VERSION = "1.0";

jQuery(document).ready(function() {
if( jQuery(' .indexed-field-table ').length ) {
jQuery(document).ready(function () {
if (jQuery(' .indexed-field-table ').length) {
jQuery.ajax({
url: "//mygene.info/v3/metadata/fields",
dataType: "JSONP",
jsonpCallback: "callback",
type: "GET",
success: function(data) {
jQuery.each(data, function(field, d) {
success: function (data) {
jQuery.each(data, function (field, d) {
var notes = indexed = ' ';
if(d.notes) {notes=d.notes;}
if(d.indexed) {indexed='&#x2714';}
if (d.notes) { notes = d.notes; }
if (d.indexed) { indexed = '&#x2714'; }
jQuery('.indexed-field-table > tbody:last').append('<tr><td>' + field + '</td><td>' + indexed + '</td><td><span class="italic">' + d.type + '</span></td><td>' + notes + '</td>');
});
jQuery('.indexed-field-table').DataTable({
"iDisplayLength": 50,
"lengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
"columns": [
{"width":"290px"},
{ "width": "290px" },
null,
null,
null
Expand All @@ -41,8 +41,7 @@ jQuery(document).ready(function() {
cache: false,
type: "GET",
dataType: "json",
success: function (data, Status, jqXHR)
{
success: function (data, Status, jqXHR) {
if (data.format == DATA_FORMAT_VERSION) {
appendResponses(Releases, data.versions);
}
Expand All @@ -57,7 +56,7 @@ function appendResponses(rel, res) {
jQuery.each(res, function (index, val) {
var t = new Date(val["release_date"].split("T")[0].split('-'));
if (done.indexOf(val.target_version) == -1) {
if (!(t in rel)) {rel[t] = [];}
if (!(t in rel)) { rel[t] = []; }
rel[t].push(val);
done.push(val.target_version);
}
Expand All @@ -67,21 +66,58 @@ function appendResponses(rel, res) {
function displayReleases() {
// everything should be loaded and ready to display, first reverse sort all releases by date...
var releaseDates = Object.keys(Releases);
releaseDates.sort(function(a,b) {
releaseDates.sort(function (a, b) {
return new Date(b) - new Date(a);
});
// now compile the html
var html = '<p class="release-control-line"><a href="javascript:;" class="release-expand">Expand All</a>|<a href="javascript:;" class="release-collapse">Collapse All</a></p>'

// render releases
jQuery('#all-releases').html(`
<p class="release-control-line">
<a href="javascript:;" class="release-expand">Expand All</a>|
<a href="javascript:;" class="release-collapse">Collapse All</a>
</p>`)

jQuery.each(releaseDates, function (index, val) {
var tDate = val.toString().split(" ").slice(1,4); tDate[1] += ","; tDate = tDate.join(" ");
html += '<div class="release-pane"><p class="release-date">' + tDate + '</p>';

var rDate = new Date(val)
var tDate = rDate.toDateString().slice(4)
var hDate = rDate.toISOString().substr(0, 10).replace(/-/g, '')

$release = $('<div>', {
class: "release-pane",
id: hDate,
})
.append($('<h4>', {
class: "release-date",
text: tDate
})
.append($('<a>', {
class: "headerlink",
href: "#" + hDate,
title: "Permalink to this release",
text: '¶'
})))

jQuery.each(Releases[val], function (rIndex, rVal) {
html += '<div><a href="javascript:;" class="release-link" data-url="' + rVal.url + '">Build version <span class="release-version">' + rVal['target_version'] + '</span></a><div class="release-info"></div></div>';
});
html += '</div>'
$release.append($('<div>')
.append($('<a>', {
"href": "javascript:;",
"class": "release-link",
"data-url": rVal.url,
"text": 'Build version '
})
.append($('<span>', {
class: "release-version",
html: rVal['target_version']
}))
).append($('<div>', {
class: "release-info"
})))
})

jQuery('#all-releases').append($release)
});
// show the html
jQuery('#all-releases').html(html);

// attach click handlers for each pop down link
jQuery('.release-link').click(function () {
if (!(jQuery(this).siblings('.release-info').hasClass('loaded'))) {
Expand Down Expand Up @@ -110,9 +146,13 @@ function displayReleases() {
}
});
// add expand collapse click handlers
jQuery('.release-collapse').click(function () {jQuery('.release-info').slideUp();});
jQuery('.release-collapse').click(function () { jQuery('.release-info').slideUp(); });
jQuery('.release-expand').click(function () {
jQuery('.release-info.loaded').slideDown();
jQuery('.release-info:not(.loaded)').siblings('.release-link').click();
});

if (window.location.hash) {
location.href = window.location.hash
}
}

0 comments on commit 4d40a8e

Please sign in to comment.