-
Notifications
You must be signed in to change notification settings - Fork 391
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #778 from captainsafia/safia/jan/refactor-badge
Move badge and path functions out of megafile
- Loading branch information
Showing
3 changed files
with
34 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
var BASE_URL = $("#base-url").data().url; | ||
var BADGE_URL = window.location.origin + BASE_URL + "badge_logo.svg"; | ||
|
||
export function markdownBadge(url) { | ||
// return markdown badge snippet | ||
return "[![Binder](" + BADGE_URL + ")](" + url + ")"; | ||
} | ||
|
||
export function rstBadge(url) { | ||
// return rst badge snippet | ||
return ".. image:: " + BADGE_URL + "\n :target: " + url; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export function getPathType() { | ||
// return path type. 'file' or 'url' | ||
const element = document.getElementById("url-or-file-selected"); | ||
return element.innerText.trim().toLowerCase(); | ||
} | ||
|
||
export function updatePathText() { | ||
var pathType = getPathType(); | ||
var text; | ||
if (pathType === "file") { | ||
text = "Path to a notebook file (optional)"; | ||
} else { | ||
text = "URL to open (optional)"; | ||
} | ||
const filePathElement = document.getElementById("filepath"); | ||
filePathElement.setAttribute("placeholder", text); | ||
|
||
const filePathElementLabel = document.querySelector("label[for=filepath]"); | ||
filePathElementLabel.innerText = text; | ||
} |