Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DilemmaGX committed Dec 13, 2023
1 parent 76bc6e2 commit 36e6ec8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
6 changes: 5 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ <h1>Static Badge Maker</h1>
<br>
<div id="alerts"></div>
<div class="input-group input-group">
<select style="width: 20%;" id="source" class="form-select" aria-label="Default select example">
<option value="default" selected>Default</option>
<option value="feather">Feather</option>
</select>
<input id="logo" style="width: 20%" type="text" class="form-control" placeholder="Logo">
<input id="left" style="width: 20%" type="text" class="form-control" placeholder="Left Text">
<input id="right" style="width: 50%" type="text" class="form-control" placeholder="Right Text">
<input id="right" style="width: 40%" type="text" class="form-control" placeholder="Right Text">
</div>
<br>
<div class="input-group mb-3">
Expand Down
39 changes: 22 additions & 17 deletions src/static.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
function g_url(left = "", right, color = "default", style = "flat", logo = "", logoColor = "default") {
function g_url(left = "", right, color = "default", style = "flat", logo = "", logoColor = "default", source="default") {
var url = "https://custom-icon-badges.demolab.com/badge/";
left += "-" || "";
if (right != "") {
url += left + right + "-" + color + "?style=" + style;
if (logo != "") {
url += "&logo=" + logo + "&logoColor=" + logoColor;
}
return url;
if(source!="default"){
return url+"&logoSource="+source;
} else {
return url;
}
}
}

function g_html(left = "", right, color = "default", style = "flat", logo = "", logoColor = "default", link) {
var url = g_url(left, right, color, style, logo, logoColor);
function g_html(left = "", right, color = "default", style = "flat", logo = "", logoColor = "default", link, source="default") {
var url = g_url(left, right, color, style, logo, logoColor,source);
var html;
if (link !== "") {
if (!RegExp("^https?:\/\/").test(link)) {
link = "http://" + link;
}
html = '<a href="' + link + '"><img src="' + url + '"></a>';
} else {
html = "<img src=" + url + ">";
html = '<img src="' + url + '">';
}
return html;
}

function g_md(left = "", right, color = "default", style = "flat", logo = "", logoColor = "default", link) {
var url = g_url(left, right, color, style, logo, logoColor);
function g_md(left = "", right, color = "default", style = "flat", logo = "", logoColor = "default", link, source="default") {
var url = g_url(left, right, color, style, logo, logoColor,source);
var md;
if (link !== "") {
if (!RegExp("^https?:\/\/").test(link)) {
Expand All @@ -38,8 +42,8 @@ function g_md(left = "", right, color = "default", style = "flat", logo = "", lo
return md;
}

function g_ad(left = "", right, color = "default", style = "flat", logo = "", logoColor = "default", link) {
var url = g_url(left, right, color, style, logo, logoColor);
function g_ad(left = "", right, color = "default", style = "flat", logo = "", logoColor = "default", link, source="default") {
var url = g_url(left, right, color, style, logo, logoColor,source);
var ad;
if (link !== "") {
if (!RegExp("^https?:\/\/").test(link)) {
Expand All @@ -52,8 +56,8 @@ function g_ad(left = "", right, color = "default", style = "flat", logo = "", lo
return ad;
}

function g_rst(left = "", right, color = "default", style = "flat", logo = "", logoColor = "default", link) {
var url = g_url(left, right, color, style, logo, logoColor);
function g_rst(left = "", right, color = "default", style = "flat", logo = "", logoColor = "default", link, source="default") {
var url = g_url(left, right, color, style, logo, logoColor,source);
var rst;
if (link !== "") {
if (!RegExp("^https?:\/\/").test(link)) {
Expand All @@ -77,6 +81,7 @@ function auto() {
console.log(logoColor);
var color = document.getElementById("color").value;
var link = document.getElementById("link").value;
var source = document.getElementById("source").value;

var o_img = document.getElementById("o_img");
var o_url = document.getElementById("o_url");
Expand All @@ -95,12 +100,12 @@ function auto() {
logoColor = "default";
}

o_img.innerHTML = g_html(left, right, color, style, logo, logoColor, link)
o_url.innerHTML = "<pre><code>" + g_url(left, right, color, style, logo, logoColor).replace(/</g, '&lt;').replace(/>/g, '&gt;') + "</pre></code>"
o_html.innerHTML = "<pre><code>" + g_html(left, right, color, style, logo, logoColor, link).replace(/</g, '&lt;').replace(/>/g, '&gt;') + "</pre></code>";
o_md.innerHTML = "<pre><code>" + g_md(left, right, color, style, logo, logoColor, link).replace(/</g, '&lt;').replace(/>/g, '&gt;') + "</pre></code>";
o_ad.innerHTML = "<pre><code>" + g_ad(left, right, color, style, logo, logoColor, link).replace(/</g, '&lt;').replace(/>/g, '&gt;') + "</pre></code>";
o_rst.innerHTML = "<pre><code>" + g_rst(left, right, color, style, logo, logoColor, link).replace(/</g, '&lt;').replace(/>/g, '&gt;')+ "</pre></code>";
o_img.innerHTML = g_html(left, right, color, style, logo, logoColor, link, source);
o_url.innerHTML = "<pre><code>" + g_url(left, right, color, style, logo, logoColor, source).replace(/</g, '&lt;').replace(/>/g, '&gt;') + "</pre></code>";
o_html.innerHTML = "<pre><code>" + g_html(left, right, color, style, logo, logoColor, link, source).replace(/</g, '&lt;').replace(/>/g, '&gt;') + "</pre></code>";
o_md.innerHTML = "<pre><code>" + g_md(left, right, color, style, logo, logoColor, link, source).replace(/</g, '&lt;').replace(/>/g, '&gt;') + "</pre></code>";
o_ad.innerHTML = "<pre><code>" + g_ad(left, right, color, style, logo, logoColor, link, source).replace(/</g, '&lt;').replace(/>/g, '&gt;') + "</pre></code>";
o_rst.innerHTML = "<pre><code>" + g_rst(left, right, color, style, logo, logoColor, link, source).replace(/</g, '&lt;').replace(/>/g, '&gt;')+ "</pre></code>";
}

function copy(id) {
Expand Down

0 comments on commit 36e6ec8

Please sign in to comment.