saving set symbols

This commit is contained in:
Kyle
2021-10-01 15:34:21 -07:00
parent 688ed23cda
commit 8fffb3e530
2 changed files with 63 additions and 3 deletions

View File

@@ -322,10 +322,22 @@ include('../globalHTML/header-1.php');
<button class='input' onclick='resetSetSymbol();'>Reset Set Symbol</button> <button class='input' onclick='resetSetSymbol();'>Reset Set Symbol</button>
</div> </div>
</div> </div>
<div class='readable-background padding'> <div class='readable-background padding margin-bottom'>
<h5 class='padding margin-bottom input-description'>Clears the Set Symbol, making it blank</h5> <h5 class='padding margin-bottom input-description'>Clears the Set Symbol, making it blank</h5>
<button class='input margin-bottom' onclick='uploadSetSymbol(blank.src);'>Remove Set Symbol</button> <button class='input margin-bottom' onclick='uploadSetSymbol(blank.src);'>Remove Set Symbol</button>
</div> </div>
<div class='readable-background padding'>
<h5 class='input-description margin-bottom'>Lock the set symbol code (saves between reloads)</h5>
<label class='checkbox-container input margin-bottom'>Lock set symbol code
<input id='lockSetSymbolCode' type='checkbox' onchange='lockSetSymbolCode();'>
<span class='checkmark'></span>
</label>
<h5 class='input-description margin-bottom'>Lock the set symbol URL (saves between reloads)</h5>
<label class='checkbox-container input'>Lock set symbol URL
<input id='lockSetSymbolURL' type='checkbox' onchange='lockSetSymbolURL();'>
<span class='checkmark'></span>
</label>
</div>
</div> </div>
<div id='creator-menu-watermark' class='hidden'> <div id='creator-menu-watermark' class='hidden'>
<div class='readable-background padding margin-bottom'> <div class='readable-background padding margin-bottom'>
@@ -599,6 +611,7 @@ include('../globalHTML/header-1.php');
<h4>Elry</h4> <h4>Elry</h4>
<h4>Edward E.</h4> <h4>Edward E.</h4>
<h4>Blake M.</h4> <h4>Blake M.</h4>
<h4>Avery D.</h4>
</div> </div>
<h4 class='margin-bottom'>And of course, thank you to all of those who have made donations in the past.</h4> <h4 class='margin-bottom'>And of course, thank you to all of those who have made donations in the past.</h4>
<div class='supporters margin-bottom'> <div class='supporters margin-bottom'>

View File

@@ -1325,12 +1325,18 @@ function uploadSetSymbol(imageSource, otherParams) {
} }
function setSymbolEdited() { function setSymbolEdited() {
card.setSymbolSource = setSymbol.src; card.setSymbolSource = setSymbol.src;
if (document.querySelector('#lockSetSymbolURL').checked) {
localStorage.setItem('lockSetSymbolURL', card.setSymbolSource);
}
card.setSymbolX = document.querySelector('#setSymbol-x').value / card.width; card.setSymbolX = document.querySelector('#setSymbol-x').value / card.width;
card.setSymbolY = document.querySelector('#setSymbol-y').value / card.height; card.setSymbolY = document.querySelector('#setSymbol-y').value / card.height;
card.setSymbolZoom = document.querySelector('#setSymbol-zoom').value / 100; card.setSymbolZoom = document.querySelector('#setSymbol-zoom').value / 100;
drawCard(); drawCard();
} }
function resetSetSymbol() { function resetSetSymbol() {
if (card.setSymbolBounds == undefined) {
return;
}
document.querySelector('#setSymbol-x').value = Math.round(scaleX(card.setSymbolBounds.x)); document.querySelector('#setSymbol-x').value = Math.round(scaleX(card.setSymbolBounds.x));
document.querySelector('#setSymbol-y').value = Math.round(scaleY(card.setSymbolBounds.y)); document.querySelector('#setSymbol-y').value = Math.round(scaleY(card.setSymbolBounds.y));
var setSymbolZoom; var setSymbolZoom;
@@ -1354,6 +1360,9 @@ function resetSetSymbol() {
} }
function fetchSetSymbol() { function fetchSetSymbol() {
var setCode = document.querySelector('#set-symbol-code').value.toLowerCase() || 'cmd'; var setCode = document.querySelector('#set-symbol-code').value.toLowerCase() || 'cmd';
if (document.querySelector('#lockSetSymbolCode').checked) {
localStorage.setItem('lockSetSymbolCode', setCode);
}
var setRarity = document.querySelector('#set-symbol-rarity').value.toLowerCase() || 'c'; var setRarity = document.querySelector('#set-symbol-rarity').value.toLowerCase() || 'c';
if (['cc', 'logan', 'joe'].includes(setCode.toLowerCase())) { if (['cc', 'logan', 'joe'].includes(setCode.toLowerCase())) {
uploadSetSymbol(fixUri(`/img/setSymbols/${setCode.toLowerCase()}-${setRarity}.svg`), 'resetSetSymbol'); uploadSetSymbol(fixUri(`/img/setSymbols/${setCode.toLowerCase()}-${setRarity}.svg`), 'resetSetSymbol');
@@ -1361,6 +1370,20 @@ function fetchSetSymbol() {
imageURL('http://gatherer.wizards.com/Handlers/Image.ashx?type=symbol&set=' + setCode + '&size=large&rarity=' + setRarity, uploadSetSymbol, 'resetSetSymbol'); imageURL('http://gatherer.wizards.com/Handlers/Image.ashx?type=symbol&set=' + setCode + '&size=large&rarity=' + setRarity, uploadSetSymbol, 'resetSetSymbol');
} }
} }
function lockSetSymbolCode() {
var savedValue = '';
if (document.querySelector('#lockSetSymbolCode').checked) {
savedValue = document.querySelector('#set-symbol-code').value;
}
localStorage.setItem('lockSetSymbolCode', savedValue);
}
function lockSetSymbolURL() {
var savedValue = '';
if (document.querySelector('#lockSetSymbolURL').checked) {
savedValue = card.setSymbolSource;
}
localStorage.setItem('lockSetSymbolURL', savedValue);
}
//WATERMARK TAB //WATERMARK TAB
function uploadWatermark(imageSource, otherParams) { function uploadWatermark(imageSource, otherParams) {
watermark.src = imageSource; watermark.src = imageSource;
@@ -1660,9 +1683,13 @@ function changeCardIndex() {
document.querySelector('#art-name').value = cardToImport.name; document.querySelector('#art-name').value = cardToImport.name;
fetchScryfallData(cardToImport.name, artFromScryfall, true); fetchScryfallData(cardToImport.name, artFromScryfall, true);
//set symbol //set symbol
document.querySelector('#set-symbol-code').value = cardToImport.set; if (!document.querySelector('#lockSetSymbolCode').checked) {
document.querySelector('#set-symbol-code').value = cardToImport.set;
}
document.querySelector('#set-symbol-rarity').value = cardToImport.rarity.slice(0, 1); document.querySelector('#set-symbol-rarity').value = cardToImport.rarity.slice(0, 1);
fetchSetSymbol(); if (!document.querySelector('#lockSetSymbolURL').checked) {
fetchSetSymbol();
}
} }
function loadAvailableCards(cardKeys = JSON.parse(localStorage.getItem('cardKeys'))) { function loadAvailableCards(cardKeys = JSON.parse(localStorage.getItem('cardKeys'))) {
if (!cardKeys) { if (!cardKeys) {
@@ -2020,6 +2047,26 @@ if ('number' in defaultCollector) {
document.querySelector('#info-number').value = date.getFullYear(); document.querySelector('#info-number').value = date.getFullYear();
} }
// lock set symbol code (user defaults)
if (!localStorage.getItem('lockSetSymbolCode')) {
localStorage.setItem('lockSetSymbolCode', '');
}
document.querySelector('#lockSetSymbolCode').checked = '' != localStorage.getItem('lockSetSymbolCode');
if (document.querySelector('#lockSetSymbolCode').checked) {
document.querySelector('#set-symbol-code').value = localStorage.getItem('lockSetSymbolCode');
fetchSetSymbol();
}
// lock set symbol url (user defaults)
if (!localStorage.getItem('lockSetSymbolURL')) {
localStorage.setItem('lockSetSymbolURL', '');
}
document.querySelector('#lockSetSymbolURL').checked = '' != localStorage.getItem('lockSetSymbolURL');
if (document.querySelector('#lockSetSymbolURL').checked) {
setSymbol.src = localStorage.getItem('lockSetSymbolURL');
}
// Load / init whatever // Load / init whatever
loadScript('/js/frames/groupStandard-3.js'); loadScript('/js/frames/groupStandard-3.js');
loadAvailableCards(); loadAvailableCards();