Skip to content

Commit

Permalink
Merge 96cc2cf into 694a0d6
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed May 23, 2019
2 parents 694a0d6 + 96cc2cf commit 06d195f
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 39 deletions.
3 changes: 2 additions & 1 deletion doc/res/common.js
Expand Up @@ -49,8 +49,9 @@ if ( document.location.protocol !== "file:"
elementEvent.category = "External links";
elementEvent.action = "Click external link";
elementEvent.nonInter = true;
} else
} else {
track = false;
}

if (track) {
_gaq.push([ "_trackEvent",
Expand Down
66 changes: 40 additions & 26 deletions doc/res/downloads.js
@@ -1,8 +1,9 @@
function twoDigits(number) {
if (number < 10)
if (number < 10) {
return "0"+number;
else
} else {
return number;
}
}

function fileSize(size) {
Expand All @@ -19,8 +20,9 @@ function fileSize(size) {
function versions(downloads) {
// Make sure that the jsonData variable is available

if (typeof jsonData === "undefined")
if (typeof jsonData === "undefined") {
return;
}

// Retrieve the size of our various downloadable files, should we be
// running this script from opencor.ws
Expand Down Expand Up @@ -225,10 +227,11 @@ function versions(downloads) {

versionAnchor = versionFolder;
} else {
if (downloads)
if (downloads) {
versionTitle = "Latest snapshot";
else
} else {
versionTitle = versionDay+" "+month(versionMonth)+" "+versionYear;
}

versionFolder = "snapshots/"+versionYear+"-"+twoDigits(versionMonth)+"-"+twoDigits(versionDay);
versionVersion = versionYear+"-"+twoDigits(versionMonth)+"-"+twoDigits(versionDay);
Expand All @@ -239,12 +242,13 @@ function versions(downloads) {

var downloadClass = "download";

if (versionType === 1)
if (versionType === 1) {
downloadClass += " official officialDownload";
else if ((versionType === 2) && downloads)
} else if ((versionType === 2) && downloads) {
downloadClass += " latest latestDownload";
else
} else {
downloadClass += " old oldDownload";
}

document.write("<div class=\""+downloadClass+"\">\n");
document.write(" <table>\n");
Expand All @@ -253,10 +257,11 @@ function versions(downloads) {
document.write(" <td>\n");
document.write(" "+versionTitle+"\n");

if (versionLicense == 1)
if (versionLicense == 1) {
document.write(" <span class=\"license\"><a href=\"https://opensource.org/licenses/Apache-2.0\">Apache v2.0</a></span>\n");
else if (versionLicense == 2)
} else if (versionLicense == 2) {
document.write(" <span class=\"license\"><a href=\"https://opensource.org/licenses/GPL-3.0\">GPL v3.0</a></span>\n");
}

document.write(" </td>\n");

Expand All @@ -269,10 +274,11 @@ function versions(downloads) {
document.write(" <td class=\"date\">\n");

if (downloads) {
if (versionDay && versionMonth && versionYear)
if (versionDay && versionMonth && versionYear) {
document.write(" ("+versionDay+" "+month(versionMonth)+" "+versionYear+")\n");
else
} else {
document.write(" (???)\n");
}
}

document.write(" </td>\n");
Expand All @@ -285,12 +291,13 @@ function versions(downloads) {

var versionClass;

if (versionType === 1)
if (versionType === 1) {
versionClass = "official";
else if ((versionType === 2) && downloads)
} else if ((versionType === 2) && downloads) {
versionClass = "latest";
else
} else {
versionClass = "old";
}

document.write("<div class=\"contents "+versionClass+"\">\n");
document.write(" <table class=\"version\">\n");
Expand All @@ -304,8 +311,9 @@ function versions(downloads) {
var nbOfPlatformsPerRow = 3;
var nbOfPlatforms = versionPlatforms.length;

while (nbOfPlatforms % nbOfPlatformsPerRow)
while (nbOfPlatforms % nbOfPlatformsPerRow) {
++nbOfPlatforms;
}

// Percentage of the total width to use for each platform

Expand Down Expand Up @@ -343,11 +351,13 @@ function versions(downloads) {

var platformClasses = "platform";

if (platformIndex >= nbOfPlatformsPerRow)
if (platformIndex >= nbOfPlatformsPerRow) {
platformClasses += " topSeparator";
}

if (platformLocalIndex)
if (platformLocalIndex) {
platformClasses += " leftSeparator";
}

document.write(" <td class=\""+platformClasses+"\" style=\"width: "+platformWidth+"\">\n");

Expand Down Expand Up @@ -390,19 +400,21 @@ function versions(downloads) {
var fileType;

if ( (fileExtension === ".exe")
|| (fileExtension === ".dmg"))
|| (fileExtension === ".dmg")) {
fileType = "Installer";
else if (fileExtension === ".zip")
} else if (fileExtension === ".zip") {
fileType = "ZIP file";
else if (fileExtension === ".tar.gz")
} else if (fileExtension === ".tar.gz") {
fileType = "Tarball file";
else
} else {
fileType = "???";
}

if (typeof fileBitness !== "undefined")
if (typeof fileBitness !== "undefined") {
fileBitness = " ("+fileBitness+"-bit)";
else
} else {
fileBitness = "";
}

// List the file for download

Expand Down Expand Up @@ -472,8 +484,9 @@ function versions(downloads) {
document.write(" <td class=\"topSeparator\">\n");
document.write(" <ul>\n");

for (var changeIndex = 0; changeIndex < versionChanges.length; ++changeIndex)
for (var changeIndex = 0; changeIndex < versionChanges.length; ++changeIndex) {
document.write(" <li><span class=\"changes\">"+versionChanges[changeIndex].change+"</span></li>");
}

document.write(" </ul>\n");
document.write(" </td>\n");
Expand All @@ -490,8 +503,9 @@ function versions(downloads) {
// anywhere on the document

$(document).keyup(function(event) {
if (event.keyCode === 27)
if (event.keyCode === 27) {
$("ul.downloadsMenu").css("visibility", "hidden");
}
});

$(document).click(function() {
Expand Down
5 changes: 3 additions & 2 deletions doc/res/downloads.php
Expand Up @@ -3,10 +3,11 @@ function downloads($dirName = "") {
$realDirName = ($dirName === "")?$_SERVER["DOCUMENT_ROOT"]."/downloads":$dirName;

foreach (array_diff(scandir($realDirName), array(".", "..")) as $fileName) {
if (is_dir($realDirName."/".$fileName))
if (is_dir($realDirName."/".$fileName)) {
downloads($realDirName."/".$fileName);
else if (strpos($fileName, "OpenCOR") !== false)
} else if (strpos($fileName, "OpenCOR") !== false) {
echo str_replace($_SERVER["DOCUMENT_ROOT"]."/downloads/", "", $realDirName."/".$fileName).",".filesize($realDirName."/".$fileName)."\n";
}
}
}

Expand Down
29 changes: 19 additions & 10 deletions doc/res/menu.js
Expand Up @@ -162,8 +162,9 @@ function doHeaderAndContentsMenu(pageName, relativePath, r, g, b, data) {

var menuItemIndent = "";

for (j = 0; j < menuItem.level; ++j)
for (j = 0; j < menuItem.level; ++j) {
menuItemIndent += "&nbsp;&nbsp;&nbsp;&nbsp;"
}

var menuItemLink = "";

Expand All @@ -174,19 +175,22 @@ function doHeaderAndContentsMenu(pageName, relativePath, r, g, b, data) {

var tableRowClasses = "menuItemTableRow";

if (i === menuItems.length-1)
if (i === menuItems.length-1) {
tableRowClasses += " lastMenuItem";
}

if (selectedMenuItem) {
tableRowClasses += " selectedMenuItem";

if (liId.length)
if (liId.length) {
subMenuSelected = subMenuCounter;
}
} else {
if (menuItemLink.length)
if (menuItemLink.length) {
tableRowClasses += " clickableMenuItem";
else
} else {
tableRowClasses += " nonClickableMenuItem";
}
}

var subMenuButton = "";
Expand All @@ -203,8 +207,9 @@ function doHeaderAndContentsMenu(pageName, relativePath, r, g, b, data) {
document.write(" <a href=\""+menuItemLink+"\">"+menuItemIndent+menuItem.label+"</a>\n");
document.write(" </div>\n");

if (subMenuButton.length)
if (subMenuButton.length) {
document.write(" "+subMenuButton+"\n");
}

document.write(" </div>\n");
document.write(" </div>\n");
Expand All @@ -226,8 +231,9 @@ function doHeaderAndContentsMenu(pageName, relativePath, r, g, b, data) {
for (i = 1; i <= subMenuCounter; ++i) {
var subMenuButton = $("ul.contentsMenu > li > ul > li > div > div > div#subMenu"+i);

if (i === subMenuSelected)
if (i === subMenuSelected) {
subMenuButton.css("display", "none");
}

showContentsSubMenu(subMenuButton, i === subMenuSelected);
}
Expand All @@ -242,8 +248,9 @@ function doHeaderAndContentsMenu(pageName, relativePath, r, g, b, data) {
if ($("ul.contentsMenu > li > ul").css("visibility") === "visible") {
$("ul.contentsMenu > li > ul").css("visibility", "hidden");
} else {
for (i = 1; i <= $("ul.contentsMenu > li > ul").attr("subMenus"); ++i)
for (i = 1; i <= $("ul.contentsMenu > li > ul").attr("subMenus"); ++i) {
showContentsSubMenu($("ul.contentsMenu > li > ul > li > div > div > div#subMenu"+i), i === subMenuSelected);
}

$("ul.contentsMenu > li > ul").css("visibility", "visible");
}
Expand All @@ -269,8 +276,9 @@ function doHeaderAndContentsMenu(pageName, relativePath, r, g, b, data) {
// Hide our contents menu if the ESC key is pressed

$(document).keyup(function(event) {
if (event.keyCode === 27)
if (event.keyCode === 27) {
$("ul.contentsMenu > li > ul").css("visibility", "hidden");
}
});

// Show/hide a given sub-menu
Expand All @@ -282,8 +290,9 @@ function doHeaderAndContentsMenu(pageName, relativePath, r, g, b, data) {
for (i = 1; i <= $("ul.contentsMenu > li > ul").attr("subMenus"); ++i) {
var subMenuButton = $("ul.contentsMenu > li > ul > li > div > div > div#subMenu"+i);

if (subMenuButton.hasClass("subMenuOpened"))
if (subMenuButton.hasClass("subMenuOpened")) {
showContentsSubMenu(subMenuButton, i === subMenuSelected);
}
}

showContentsSubMenu($(this), true);
Expand Down

0 comments on commit 06d195f

Please sign in to comment.