Skip to content

Commit

Permalink
Format tags via JS to remove hypens and uppercase words.
Browse files Browse the repository at this point in the history
  • Loading branch information
LongForWisdom committed Jan 9, 2024
1 parent c88a4ae commit 166b77a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
6 changes: 3 additions & 3 deletions _includes/bounty-tags.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
{% else %}
<div class="bounty-tag-status-default"></div>
{% endif %}
<p> {{bounty.status | downcase}} </p>
<p data-format="tag"> {{bounty.status}} </p>
</div>
{% for skillset in include.bounty.skillsets %}
<div class="bounty-tag flex-stack-left">
<div class="bounty-tag-skillset"></div>
<p> {{skillset | downcase}} </p>
<p data-format="tag"> {{skillset}} </p>
</div>
{% endfor %}
{% for tag in include.bounty.tags %}
<div class="bounty-tag flex-stack-left">
<div class="bounty-tag-tag"></div>
<p> {{tag | downcase}} </p>
<p data-format="tag"> {{tag}} </p>
</div>
{% endfor %}
</div>
2 changes: 1 addition & 1 deletion _includes/filter-item.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% assign filterPair = include.filter | split: ":" %}
<div>
<input class="substituted" aria-hidden="true" name="filter" type="checkbox" id="inlineCheckbox-{{include.filter}}" value="{{include.filter}}" onchange="filterBounties(); saveParams();" {% if include.checked==true %}checked{% endif %}>
<label for="inlineCheckbox-{{include.filter}}">{{filterPair[1]}}</label>
<label data-format="tag" for="inlineCheckbox-{{include.filter}}">{{filterPair[1]}}</label>
</div>
20 changes: 19 additions & 1 deletion _includes/js/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ document.addEventListener("DOMContentLoaded", function() {
setRelativeTimeString(dates.nextGMCPayout - Date.now(), "bounty-payout");
setRelativeTimeString(dates.nextBountyCutoff - Date.now(), "bounty-cutoff");
formatRewards();
formatTags();
});

function getDates()
Expand Down Expand Up @@ -81,4 +82,21 @@ function formatRewards()
}
element.innerHTML = useformat.format(element.dataset.rewardvalue);
});
}
}

function formatTags()
{
let elements = Array.from(document.querySelectorAll('[data-format="tag"]'));
elements.forEach(function(element)
{
let unformattedTag = element.innerHTML;
let formattedTag = "";
let splitArray = unformattedTag.split('-');
splitArray.forEach(function(word)
{
word = word.trim();
formattedTag = formattedTag.concat(word[0].toUpperCase(), word.slice(1), ' ');
});
element.innerHTML = formattedTag;
});
}

0 comments on commit 166b77a

Please sign in to comment.