Displaying airs

This commit is contained in:
Audrey 2021-09-06 22:50:59 +02:00
parent 094c189d23
commit 456a085675

View File

@ -15,6 +15,45 @@
$(document).ready(fl_enhancer);
///////////
// STORY //
///////////
function update_airs_bar() {
if (!localStorage.FLE_airs) {
return;
}
let quirks = JSON.parse(localStorage.FLE_airs);
let html = '<div id="FLE-airs" style="text-align:left;">';
$.each(quirks, function( key, value ) {
html += '<div class="icon icon--inventory" style="margin:1px; margin-bottom:5px;"><img src="' + value.img + '"><span class="icon__value" style="font-size:12px; bottom:-7px; right:-7px; padding:1px 3px;">' + value.num + '</span></div>';
});
$('div#FLE-airs').remove();
$(html + '</div>').insertAfter('button.travel-button--infobar');
}
function get_airs_value() {
let updated = false;
let airs = {}
if (localStorage.FLE_airs) {
airs = JSON.parse(localStorage.FLE_airs);
}
// Airs from a Location (storylet requirement)
let airs_unlock = $('[alt^="You unlocked this with The Airs"]').first();
if (airs_unlock.length) {
console.log('airs detected');
let [_, txt, num] = airs_unlock.attr('alt').match(/You unlocked this with (The Airs.*?)(\d+)/);
if (!airs[txt]) {
airs[txt] = { 'num': num, 'img': airs_unlock.attr('src') };
}
updated = true;
}
if (updated) {
localStorage.setItem('FLE_airs', JSON.stringify(airs));
}
}
////////////
// BAZAAR //
////////////
@ -92,11 +131,10 @@ function get_quirks() {
let found = $( this ).find('span').prop('textContent').match(/(\w+)\s+(\d+)/);
if (found){
let [_, quirk, num] = found;
quirks[quirk] = {'num': num, img: $( this).find('img').prop('src')};
quirks[quirk] = {'num': num, 'img': $( this).find('img').prop('src')};
}
});
localStorage.setItem('FLE_quirks', JSON.stringify(quirks));
update_quirks_bar();
}
function get_contacts() {
@ -106,7 +144,7 @@ function get_contacts() {
if (found) {
let [_, type, faction, num] = found;
if (!contacts[faction]) {
contacts[faction] = {'Renown': 0, 'Favours': 0, img: $( this).find('img').prop('src')};
contacts[faction] = {'Renown': 0, 'Favours': 0, 'img': $( this).find('img').prop('src')};
}
contacts[faction][type] = num;
}
@ -152,9 +190,7 @@ function get_advantage() {
function possessions() {
get_advantage();
update_advantage_bar();
update_quirks_bar();
update_contacts_bar();
update_bar();
}
@ -192,6 +228,13 @@ function monitor_url_change() {
// GLOBAL //
////////////
function update_bar() {
update_airs_bar();
update_advantage_bar();
update_quirks_bar();
update_contacts_bar();
}
function cleanup() {
// Remove the banner
@ -220,10 +263,8 @@ function common() {
// Display CP and number of points required for the next level near the progress bar
display_stats_progress();
// Display contacts & quirks in the sidebar
update_advantage_bar();
update_quirks_bar();
update_contacts_bar();
// Display contacts, quirks, possessions & airs in the sidebar
update_bar();
}
function sleep(ms) {
@ -240,6 +281,10 @@ function go() {
items_total_value_displayed = false;
}
switch (url) {
case 'https://www.fallenlondon.com/':
get_airs_value();
update_bar();
break;
case 'https://www.fallenlondon.com/bazaar':
display_items_total_value();
break;