Resolve #4
This commit is contained in:
parent
8983a8d5ea
commit
fed7b3af79
@ -66,6 +66,7 @@ function Setup(){
|
|||||||
});
|
});
|
||||||
|
|
||||||
GetAvailableControllers().then((json) => {
|
GetAvailableControllers().then((json) => {
|
||||||
|
newMangaConnector.replaceChildren();
|
||||||
json.forEach(connector => {
|
json.forEach(connector => {
|
||||||
var option = document.createElement('option');
|
var option = document.createElement('option');
|
||||||
option.value = connector;
|
option.value = connector;
|
||||||
@ -140,6 +141,7 @@ function CreateManga(manga, connector){
|
|||||||
var connectorName = document.createElement('connector-name');
|
var connectorName = document.createElement('connector-name');
|
||||||
connectorName.innerText = connector;
|
connectorName.innerText = connector;
|
||||||
connectorName.className = "pill";
|
connectorName.className = "pill";
|
||||||
|
connectorName.style.backgroundColor = stringToColour(connector);
|
||||||
info.appendChild(connectorName);
|
info.appendChild(connectorName);
|
||||||
var mangaName = document.createElement('publication-name');
|
var mangaName = document.createElement('publication-name');
|
||||||
mangaName.innerText = manga.sortName;
|
mangaName.innerText = manga.sortName;
|
||||||
@ -487,3 +489,16 @@ function GetValidSelector(str){
|
|||||||
var clean = [...str.matchAll(/[a-zA-Z0-9]*-*_*/g)];
|
var clean = [...str.matchAll(/[a-zA-Z0-9]*-*_*/g)];
|
||||||
return clean.join('');
|
return clean.join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const stringToColour = (str) => {
|
||||||
|
let hash = 0;
|
||||||
|
str.split('').forEach(char => {
|
||||||
|
hash = char.charCodeAt(0) + ((hash << 5) - hash)
|
||||||
|
})
|
||||||
|
let colour = '#'
|
||||||
|
for (let i = 0; i < 3; i++) {
|
||||||
|
const value = (hash >> (i * 8)) & 0xff
|
||||||
|
colour += value.toString(16).padStart(2, '0')
|
||||||
|
}
|
||||||
|
return colour
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user