Giter Site home page Giter Site logo

huntersim's People

Contributors

cltnschlosser avatar gardinit avatar peterschriever avatar watchyoursixx avatar whoinow avatar zazzie7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

huntersim's Issues

'Hunters in Raid' not properly stored in localStorage (naming mismatch)

The input field on the page has the ID 'huntersraid' and 'onchange' calls 'fightSettings()'

The 'fightSettings()' function correctly reads/parses the value, and then stores it in 'huntersraid' variable before calling 'storeData();'.

let huntinraid = document.getElementById("huntersraid").value;
huntersraid = parseInt(huntinraid);

The 'storeData()' function then attempts to save it in localStorage:

localStorage.setItem('huntraid',huntersinraid);

Issue: It reads it from the variable 'huntersinraid', but the actual value was stored in 'huntersraid' - thus it does not get updated in localStorage.

custom armor values don't save correctly

custom armor values don't save correctly due to how I'm loading/saving buffs. Will need to look at later, basically changing targets doesn't trigger the save data so it doesn't keep that data unless you change another setting

Race/Spec wrongly displayed after reloading

Even though in the settings I selected "Draenei" race and "BM 41/20/0" spec, whenever I reload the page it shows "Orc" and "SV 0/20/41" spec above the active gear.
image

Edit: Just to clarify, the settings are correctly saved/loaded, it is just not reflected on the "main page" upon reloading the page. Also, shouldn't there be a different icon for MM/SV specs?

'showSaveFilePicker' function (Export) not available in Firefox/Safari

Hi, I did some investigation on the exporting issue under Firefox and why simply nothing happens when clicking on the Export button.

The root-cause is that "showSaveFilePicker" does not exist in Firefox. It is still considered an experimental feature in general and Mozilla sees potential harmful use-cases due to which they don't want to add it (yet).
See here for browser-support: https://developer.mozilla.org/en-US/docs/Web/API/Window/showSaveFilePicker
image
And here for Mozilla's reasoning: https://mozilla.github.io/standards-positions/#native-file-system

Now because the function-call is inside a try-catch that has no "error-handling" (it simply sets the 'succes' variable to 'false'), it seems like nothing happens to the user:

    try {
        handle = await showSaveFilePicker(opts);
        success = true;
    } catch (e) {
        success = false;
    }

May I therefore propose an alternative solution for browsers that don't support "showSaveFilePicker" (mainly Firefox & Safari, and all mobile browsers), to instead open a new browser tab that simply shows the JSON content as plain-text so one can copy-paste it and save it manually in a file or wherever instead? This even could be done directly inside the "catch" part as a generic fallback solution.

Changing an item of a loaded set, also overwrites the set in localStorage ("by reference" issue)

Steps to reproduce:

  1. Load a custom set
  2. Change one item
  3. Load the same custom set again

Expected behavior:

"Old" item from the saved set is shown

Actual behavior:

The "new" changed item is still there

Root cause analysis:

When loading a (custom) set, in 'loadSet()' the set is read from "SavedSets" and a reference to its object is put in the 'gear' variable.

let activeset = SavedSets[val];
gear = activeset.data;

When an item is changed and 'selectItem(itemid)' is called, it overwrites the value(s) in 'gear'.

case 'shoulder':
    console.log("you selected "+ itemid);
    gear[activeslot] = { id: parseInt(itemid), gems: [], enchant: ench };
break;

Now since 'gear' is basically just a reference to the 'SavedSets[val].data' object, it is also changed there.


Simplified example and solution proposal:

Simple example to reproduce/understand this issue:

const myArray = [
    {
        'name': 'First Entry'
    },
    {
        'name': 'Second Entry'
    }
];

let firstObject = myArray[0]; // firstObject is just a reference to the first entry in the Array

console.log(myArray[0].name); // "First Entry"

firstObject.name = 'Changed Entry';

console.log(myArray[0].name); // "Changed Entry"

In order to fix it, you need to make a shallow/deep copy of the set when loading it. In case of above example, the following would result in a deep-copy:

const myArray = [
    {
        'name': 'First Entry'
    },
    {
        'name': 'Second Entry'
    }
];

let firstObject = JSON.parse(JSON.stringify(myArray[0])); // now an actual (deep) copy of the object is created

console.log(myArray[0].name); // "First Entry"

firstObject.name = 'Changed Entry';

console.log(myArray[0].name); // "First Entry"

Unequipping gems/enchants is not updated in localStorage['gear']

Unequipping a gem or enchant, does not trigger an update of the gear object in localStorage. It is only getting updated if a an actual gem/enchant is selected.

Thus in order to actually remove a gem/enchant from localStorage (and thus make it relevant for the DPS sim), you need to re-select a gem/enchant in another slot as this triggers a refresh of the whole localStorage['gear'].

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.