mirror of
https://github.com/Investigamer/cardconjurer.git
synced 2025-07-27 05:14:53 -05:00
better imports
This commit is contained in:
@@ -218,7 +218,7 @@ include('../globalHTML/header-1.php');
|
|||||||
</div>
|
</div>
|
||||||
<h5 class='margin-bottom padding input-description'>Or enter a card name (and index)</h5>
|
<h5 class='margin-bottom padding input-description'>Or enter a card name (and index)</h5>
|
||||||
<div class='input-grid margin-bottom'>
|
<div class='input-grid margin-bottom'>
|
||||||
<input id='art-name' type='text' placeholder='Enter Card Name' class='input' onchange='fetchScryfallData(this.value, artFromScryfall);'>
|
<input id='art-name' type='text' placeholder='Enter Card Name' class='input' onchange='fetchScryfallData(this.value, artFromScryfall, true);'>
|
||||||
<input id='art-index' type='number' value=1 max=1 min=1 class='input' onchange='changeArtIndex();'>
|
<input id='art-index' type='number' value=1 max=1 min=1 class='input' onchange='changeArtIndex();'>
|
||||||
</div>
|
</div>
|
||||||
<h5 class='margin-bottom padding input-description'>And credit the artist</h5>
|
<h5 class='margin-bottom padding input-description'>And credit the artist</h5>
|
||||||
@@ -384,10 +384,25 @@ include('../globalHTML/header-1.php');
|
|||||||
<div id='creator-menu-import' class='hidden'>
|
<div id='creator-menu-import' class='hidden'>
|
||||||
<div class='readable-background margin-bottom padding'>
|
<div class='readable-background margin-bottom padding'>
|
||||||
<h5 class='padding margin-bottom input-description'>Import a real card by name (and index)</h5>
|
<h5 class='padding margin-bottom input-description'>Import a real card by name (and index)</h5>
|
||||||
<div class='padding input-grid'>
|
<div class='input-grid margin-bottom'>
|
||||||
<input class='input' type='text' onchange='fetchScryfallData(this.value, importCard);' placeholder='Enter Card Name'>
|
<input id='import-name' class='input' type='text' onchange='fetchScryfallData(this.value, importCard);' placeholder='Enter Card Name'>
|
||||||
<input id='import-index' class='input' type='number' onchange='changeCardIndex();' value=1 max=1 min=1>
|
<input id='import-index' class='input' type='number' onchange='changeCardIndex();' value=1 max=1 min=1>
|
||||||
</div>
|
</div>
|
||||||
|
<h5 class='padding input-description'>Select a language for card imports (not all languages will always be available)</h5>
|
||||||
|
<select class='input' id='import-language' onchange='fetchScryfallData(document.querySelector("#import-name").value, importCard);'>
|
||||||
|
<option value="en">English</option>
|
||||||
|
<option value="es">Spanish</option>
|
||||||
|
<option value="fr">French</option>
|
||||||
|
<option value="de">German</option>
|
||||||
|
<option value="it">Italian</option>
|
||||||
|
<option value="pt">Portuguese</option>
|
||||||
|
<option value="ja">Japanese</option>
|
||||||
|
<option value="ko">Korean</option>
|
||||||
|
<option value="ru">Russian</option>
|
||||||
|
<option value="zhs">Simplified Chinese</option>
|
||||||
|
<option value="zht">Traditional Chinese</option>
|
||||||
|
<option value="ph">Phyrexian</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class='readable-background margin-bottom padding'>
|
<div class='readable-background margin-bottom padding'>
|
||||||
<h5 class='padding margin-bottom input-description'>Save your current card</h5>
|
<h5 class='padding margin-bottom input-description'>Save your current card</h5>
|
||||||
@@ -453,5 +468,5 @@ include('../globalHTML/header-1.php');
|
|||||||
</h4>
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script defer src='/js/creator-13.js'></script>
|
<script defer src='/js/creator-14.js'></script>
|
||||||
<?php include('../globalHTML/footer.php'); ?>
|
<?php include('../globalHTML/footer.php'); ?>
|
@@ -964,7 +964,12 @@ function autoFitArt() {
|
|||||||
artEdited();
|
artEdited();
|
||||||
}
|
}
|
||||||
function artFromScryfall(scryfallResponse) {
|
function artFromScryfall(scryfallResponse) {
|
||||||
scryfallArt = scryfallResponse.data;
|
// importedData = scryfallResponse.data;
|
||||||
|
// importedData.forEach(card => {
|
||||||
|
|
||||||
|
// });
|
||||||
|
// scryfallArt = scryfallResponse.data;
|
||||||
|
scryfallArt = scryfallResponse;
|
||||||
document.querySelector('#art-index').value = 1;
|
document.querySelector('#art-index').value = 1;
|
||||||
document.querySelector('#art-index').max = scryfallArt.length;
|
document.querySelector('#art-index').max = scryfallArt.length;
|
||||||
changeArtIndex();
|
changeArtIndex();
|
||||||
@@ -1187,7 +1192,7 @@ async function downloadCard() {
|
|||||||
}
|
}
|
||||||
//IMPORT/SAVE TAB
|
//IMPORT/SAVE TAB
|
||||||
function importCard(cardObject) {
|
function importCard(cardObject) {
|
||||||
scryfallCard = cardObject.data;
|
scryfallCard = cardObject;
|
||||||
document.querySelector('#import-index').value = 1;
|
document.querySelector('#import-index').value = 1;
|
||||||
document.querySelector('#import-index').max = scryfallCard.length;
|
document.querySelector('#import-index').max = scryfallCard.length;
|
||||||
changeCardIndex();
|
changeCardIndex();
|
||||||
@@ -1252,11 +1257,8 @@ function changeCardIndex() {
|
|||||||
document.querySelector('#text-editor').value = card.text[Object.keys(card.text)[selectedTextIndex]].text;
|
document.querySelector('#text-editor').value = card.text[Object.keys(card.text)[selectedTextIndex]].text;
|
||||||
textEdited();
|
textEdited();
|
||||||
//art
|
//art
|
||||||
scryfallArt = scryfallCard;
|
|
||||||
document.querySelector('#art-name').value = cardToImport.name;
|
document.querySelector('#art-name').value = cardToImport.name;
|
||||||
document.querySelector('#art-index').value = 1;
|
fetchScryfallData(cardToImport.name, artFromScryfall, true);
|
||||||
document.querySelector('#art-index').max = scryfallArt.length;
|
|
||||||
changeArtIndex();
|
|
||||||
//set symbol
|
//set symbol
|
||||||
document.querySelector('#set-symbol-code').value = cardToImport.set;
|
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);
|
||||||
@@ -1492,18 +1494,49 @@ function stretchSVGReal(data, frameObject) {
|
|||||||
return returnData;
|
return returnData;
|
||||||
}
|
}
|
||||||
//SCRYFALL STUFF MAY BE CHANGED IN THE FUTURE
|
//SCRYFALL STUFF MAY BE CHANGED IN THE FUTURE
|
||||||
function fetchScryfallData(cardName, callback = console.log) {
|
function fetchScryfallData(cardName, callback = console.log, searchUniqueArt = '') {
|
||||||
var xhttp = new XMLHttpRequest();
|
var xhttp = new XMLHttpRequest();
|
||||||
xhttp.onreadystatechange = function() {
|
xhttp.onreadystatechange = function() {
|
||||||
if (this.readyState == 4 && this.status == 200) {
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
callback(JSON.parse(this.responseText));
|
responseCards = [];
|
||||||
// JSON.parse(this.responseText);
|
importedCards = JSON.parse(this.responseText).data;
|
||||||
|
importedCards.forEach(card => {
|
||||||
|
if ('card_faces' in card) {
|
||||||
|
card.card_faces.forEach(face => {
|
||||||
|
face.set = card.set;
|
||||||
|
face.rarity = card.rarity;
|
||||||
|
if (card.lang != 'en') {
|
||||||
|
face.oracle_text = face.printed_text;
|
||||||
|
face.name = face.printed_name;
|
||||||
|
face.type_line = face.printed_type_line;
|
||||||
|
}
|
||||||
|
responseCards.push(face);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if (card.lang != 'en') {
|
||||||
|
card.oracle_text = card.printed_text;
|
||||||
|
card.name = card.printed_name;
|
||||||
|
card.type_line = card.printed_type_line;
|
||||||
|
}
|
||||||
|
responseCards.push(card);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
callback(responseCards);
|
||||||
} else if (this.readyState == 4 && this.status == 404) {
|
} else if (this.readyState == 4 && this.status == 404) {
|
||||||
notify('No cards found for "' + cardName + '"', 5);
|
notify(`No cards found for "${cardName}" in "${cardLanguageSelect.options[cardLanguageSelect.selectedIndex].text}" language.`, 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xhttp.open('GET', 'https://api.scryfall.com/cards/search?order=released&unique=art&q=name%3D' + cardName.replace(/ /g, '_'), true);
|
var uniqueArt = '';
|
||||||
|
if (searchUniqueArt) {
|
||||||
|
uniqueArt = '&unique=art';
|
||||||
|
}
|
||||||
|
cardLanguageSelect = document.querySelector('#import-language');
|
||||||
|
xhttp.open('GET', `https://api.scryfall.com/cards/search?order=released&include_extras=true${uniqueArt}&q=lang%3D${cardLanguageSelect.value}%20name%3D${cardName.replace(/ /g, '_')}`, true);
|
||||||
|
try {
|
||||||
xhttp.send();
|
xhttp.send();
|
||||||
|
} catch {
|
||||||
|
console.log('Scryfall API search failed.')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//Initialization
|
//Initialization
|
||||||
if (!localStorage.getItem('autoLoadFrameVersion')) {
|
if (!localStorage.getItem('autoLoadFrameVersion')) {
|
Reference in New Issue
Block a user