pregene js optimize + page layout update

This commit is contained in:
vvo
2022-10-17 22:31:29 +08:00
parent 56bce98422
commit 6685df201d
2 changed files with 41 additions and 54 deletions
@@ -1,78 +1,62 @@
function countPreGeneItems(preGeneItems, items_crew, items_stamp, items_subbg, items_bgm, items_nemsys) {
let totalItemsGot = 0
console.log(totalItemsGot)
totalItemsGot += items_crew.filter(crew => preGeneItems['crew'].includes(crew['id'])).length
console.log(totalItemsGot)
totalItemsGot += items_stamp.filter(stamp => preGeneItems['stamp'].includes(stamp['id'])).length
console.log(totalItemsGot)
totalItemsGot += items_subbg.filter(subbg => preGeneItems['subbg'].includes(subbg['id'])).length
console.log(totalItemsGot)
return totalItemsGot
}
$(document).ready(function() {
// let profile_data = JSON.parse(document.getElementById("data-pass").innerText);
function loadImages(itemList, itemType, userItems) {
let preGeneImageFetchURL = 'https://eacache.s.konaminet.jp/game/sdvx/common/images/pregene_item/'
itemList.forEach(item => {
let itemBrightness = userItems.find(userItem => userItem.id == item) != undefined ? 1 : 0.5
let imageUrl = 'static/asset/pregene_item/item_' + itemType + '_' + item + '.png'
$.get(imageUrl, function(data, textStatus) {
if (textStatus == "success") {
$('.' + itemType + '-items').append('<img style="width: 350px; padding: 10px; filter: brightness(' + itemBrightness + ')" src=' + imageUrl + '>')
}
}).fail(function(){
imageUrl = preGeneImageFetchURL + itemType + '/item_' + itemType + '_' + item + '.png'
$('.' + itemType + '-items').append('<img style="width: 350px; padding: 10px; filter: brightness(' + itemBrightness + ')" src=' + imageUrl + '>')
});
})
}
$(document).ready(function() {
if(document.getElementById("data-pass-unlock-all").innerText === 'true') {
$('.card-content').text("The \"Unlock All Valkyrie and Premium Items\" option is enabled. You wouldn't need this.")
$('#pregene-roll').attr('disabled')
return 0;
}
$('.input').hide()
$('.button').addClass('is-link')
let items_crew = JSON.parse(document.getElementById("data-pass-crew").innerText);
let items_stamp = JSON.parse(document.getElementById("data-pass-stamp").innerText);
let items_subbg = JSON.parse(document.getElementById("data-pass-subbg").innerText);
let items_bgm = JSON.parse(document.getElementById("data-pass-bgm").innerText);
let items_nemsys = JSON.parse(document.getElementById("data-pass-nemsys").innerText);
let unlock_all = (document.getElementById("data-pass-unlock-all").innerText === 'true');
let preGeneItems = {
'crew': [131],
'stamp': [69, 70, 71, 72, 73, 74, 75, 76, 77, 78],
'subbg': [166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185]
}
console.log('crew')
$('.item_banners').append('<div class=crew-items style="background-color: #3a3a3a; padding: 20px; border-radius: 6px;"></div><br>')
preGeneItems['crew'].forEach(crew => {
let itemBrightness = items_crew.find(item => item.id == subbg) != undefined ? 1 : 0.5
$.get('/static/asset/pregene_item/crew/item_crew_' + crew + '.png', function(data, textStatus) {
if (textStatus == "success") {
console.log(crew + " loaded");
}
}).fail(function(){
console.log(crew + " not loaded. file not exist")
$('.crew-items').append('<img style="width: 350px; padding: 10px; filter: brightness(' + itemBrightness + ')" src=' + preGeneImageFetchURL + 'crew/item_crew_' + crew + '.png>')
});
})
$('.count').text('Unlocked items: ' + countPreGeneItems(preGeneItems, items_crew, items_stamp, items_subbg, items_bgm, items_nemsys) + "/" + (preGeneItems['crew'].length + preGeneItems['stamp'].length + preGeneItems['subbg'].length))
$('.item_banners').append('<div style="padding: 5px"><h3>Nemsys Crew</h3></div>')
$('.item_banners').append('<div class=crew-items style="text-align: center; background-color: #3a3a3a; padding: 20px; border-radius: 6px;"></div><br>')
loadImages(preGeneItems['crew'], 'crew', items_crew)
console.log('stamp')
$('.item_banners').append('<div class=stamp-items style="background-color: #3a3a3a; padding: 20px; border-radius: 6px;"></div><br>')
preGeneItems['stamp'].forEach(stamp => {
let itemBrightness = items_stamp.find(item => item.id == stamp) != undefined ? 1 : 0.5
$.get('/static/asset/pregene_item/stamp/item_stamp_' + stamp + '.png', function(data, textStatus) {
if (textStatus == "success") {
console.log(stamp + " loaded");
}
}).fail(function(){
console.log(stamp + " not loaded. file not exist")
$('.stamp-items').append('<img style="width: 350px; padding: 10px; filter: brightness(' + itemBrightness + ')" src=' + preGeneImageFetchURL + 'stamp/item_stamp_' + stamp + '.png>')
});
})
$('.item_banners').append('<div style="padding: 5px"><h3>Appeal Stamp</h3></div>')
$('.item_banners').append('<div class=stamp-items style="text-align: center; background-color: #3a3a3a; padding: 20px; border-radius: 6px;"></div><br>')
loadImages(preGeneItems['stamp'], 'stamp', items_stamp)
console.log('subbg')
$('.item_banners').append('<div class=subbg-items style="background-color: #3a3a3a; padding: 20px; border-radius: 6px;"></div><br>')
preGeneItems['subbg'].forEach(subbg => {
let itemBrightness = items_subbg.find(item => item.id == subbg) != undefined ? 1 : 0.5
$.get('/static/asset/pregene_item/bg/item_bg_' + subbg + '.png', function(data, textStatus) {
if (textStatus == "success") {
console.log(subbg + " loaded");
}
}).fail(function(){
console.log(subbg + " not loaded. file not exist")
$('.subbg-items').append('<img style="width: 350px; padding: 10px; filter: brightness(' + itemBrightness + ')" src=' + preGeneImageFetchURL + 'bg/item_bg_' + subbg + '.png>')
});
})
$('.item_banners').append('<div style="padding: 5px"><h3>Submonitor BG</h3></div>')
$('.item_banners').append('<div class=bg-items style="text-align: center; background-color: #3a3a3a; padding: 20px; border-radius: 6px;"></div><br>')
loadImages(preGeneItems['subbg'], 'bg', items_subbg)
if(!unlock_all) {
$('.count').text(countPreGeneItems(preGeneItems, items_crew, items_stamp, items_subbg, items_bgm, items_nemsys) + "/" + (preGeneItems['crew'].length + preGeneItems['stamp'].length + preGeneItems['subbg'].length))
} else {
$('.card-content').text("Unlock all enabled.")
$('#pregene-roll').attr('disabled')
}
$('#pregene-roll').on('click', function() {
console.log('clique')
@@ -21,12 +21,15 @@ div
.card-header
p.card-header-title
span.icon
i.mdi.mdi-account-edit
i.mdi.mdi-star
| Premium Generator
.card-content
input.input(type="text" name="refid", value=refid readonly)
button(id="pregene-roll") Roll
div.count()
div(style="padding: 15px; text-align: center;")
div(style="padding: 5px")
h3.count()
input.input(type="text" name="refid", value=refid readonly)
button.button(id="pregene-roll" style="font-size: 20px") Roll
br()
div.item_banners()
div(hidden id='data-pass-crew') !{JSON.stringify(prem_items_crew)}