Skip to content

Commit

Permalink
if firefox and windows -> http (#407)
Browse files Browse the repository at this point in the history
change registry links to https for all except firefox on mac and windows.

Co-authored-by: Sebastien Valla <sv@massa.net>
  • Loading branch information
SebastienValla and Sebastien Valla authored Jan 12, 2023
1 parent f4ee779 commit 2641a6a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
24 changes: 20 additions & 4 deletions int/api/html/front/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@ function displayPlugins() {
entry.setAttribute("class", "nav-item");

var href = document.createElement("a");
href.setAttribute(
"href",
`http://${window.location.hostname}:${plugin.port}`
)
href.setAttribute("href", `http://${window.location.hostname}:${plugin.port}`);
href.setAttribute("class", "nav-link");

href.appendChild(document.createTextNode(plugin.name));
Expand All @@ -78,3 +75,22 @@ function displayPlugins() {
}

displayPlugins();

// isExcludedOSAndFirefox returns true if user uses Windows or Mac and Firefox
function isExcludedOSAndFirefox() {
// userAgent gets the os and navigator infos.
// ex : Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:108.0) Gecko/20100101 Firefox/108.0.
let userAgent = navigator.userAgent;

// isWindows checks if current os is Windows
let isWindows = userAgent.indexOf("Windows") != -1;

// isMac checks if current os is MacOS
let isMac = userAgent.indexOf("Macintosh") != -1;

// isFirefox checks if current navigator is Firefox
let isFirefox = userAgent.indexOf("Firefox") != -1;

return isFirefox && (isWindows || isMac);
}
window.isExcludedOSAndFirefox = isExcludedOSAndFirefox;
4 changes: 3 additions & 1 deletion int/api/html/front/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ function tableInsert(website) {
.getElementById("website-deployers-table")
.getElementsByTagName("tbody")[0];
const row = tBody.insertRow(-1);
const url = `//${website[NAME]}.massa:${window.location.port}/`;

const protocol = isExcludedOSAndFirefox() ? "http" : "https";
const url = `${protocol}://${website[NAME]}.massa:${window.location.port}/`;

// const cell0 = row.insertCell(); removed unit args class is available
const cell1 = row.insertCell();
Expand Down
4 changes: 3 additions & 1 deletion int/api/html/front/website.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ async function tableInsert(resp, count) {
.getElementById("website-deployers-table")
.getElementsByTagName("tbody")[0];
const row = tBody.insertRow(-1);
const url = `//${resp.name}.massa:${window.location.port}/`;

const protocol = isExcludedOSAndFirefox() ? "http" : "https";
const url = `${protocol}://${resp.name}.massa:${window.location.port}/`;

const cell0 = row.insertCell();
const cell1 = row.insertCell();
Expand Down

0 comments on commit 2641a6a

Please sign in to comment.