diff --git a/js/index.js b/js/index.js index cbab96880..7b896b782 100644 --- a/js/index.js +++ b/js/index.js @@ -218,6 +218,12 @@ function refreshLibrary() { if (versionInfo) versionInfo = " ("+versionInfo+")"; var readme = `Read more...`; var favourite = favourites.find(e => e == app.id); + + var username = "espruino"; + var githubMatch = window.location.href.match(/\/(\w+)\.github\.io/); + if(githubMatch) username = githubMatch[1]; + var url = `https://github.com/${username}/BangleApps/tree/master/apps/${app.id}`; + return `
${escapeHtml(app.name)}

@@ -225,7 +231,7 @@ function refreshLibrary() {

${escapeHtml(app.name)} ${versionInfo}

${escapeHtml(app.description)}${app.readme?`
${readme}`:""}

- See the code on GitHub + See the code on GitHub
@@ -242,22 +248,6 @@ function refreshLibrary() { var tab = document.querySelector("#tab-librarycontainer a"); tab.classList.add("badge"); tab.setAttribute("data-badge", appJSON.length); - //github icon onClick - htmlToArray(panelbody.getElementsByClassName("link-github")).forEach(link => { - - var username = window.location.href; - var url = "https://github.com/espruino/BangleApps/tree/master/apps/"+link.getAttribute("appid"); - if(!username.startsWith("https://banglejs.com/apps")){ - username = username.substr(0,username.lastIndexOf(".")); - if(username.startsWith("https://")){username=username.substr(8,username.length)} - if(username.startsWith("http://")){username=username.substr(7,username.length)} - if(username.startsWith("www.")){username=username.substr(4,username.length)} - username = username.substr(0,username.lastIndexOf(".")); - url = "https://github.com/"+username+"/BangleApps/tree/master/apps/"+link.getAttribute("appid"); - } - link.href=url; - - }); htmlToArray(panelbody.getElementsByTagName("button")).forEach(button => { button.addEventListener("click",event => { var button = event.currentTarget;