Closed xUser5000 closed 3 years ago
issued.["date-parts"]
. Accordingly, when calling the getDate()
function on a reference that has the property undefined, it throws an error saying "Cannot read properly 0 of undefined". I solved this bug by simply checking if the desired property is defined or not.Regarding the difference between maps and plain js objects, it turns out that objects are much faster than maps in initialization and assigning values to keys. Objects are not as flexible as maps, but, in this situation, I don't that much flexibility (e.g getSize(), delete()); I only need to add key-value pairs and then look up the reference that corresponds to a given key. In conclusion, plain objects are better suited for this task.
I've replaced the map with a plain js object and fixed minor UI bugs.
Now my question is: How to implement escaping in view.js
? Do I download a new library just for that or? I also want to know whether or not this is necessary because I already escape the JSON object passed to the view.
Now my question is: How to implement escaping in view.js?
That's all you need:
<li id="${encode(ref["id"])}">
That's all you need:
<li id="${encode(ref["id"])}">
But I don't have access to html-entites
from the view, so there are three options at hand:
encode()
function from scratch.const li = document.createElement("li");
li.textContent = ref["id"]; // Auto-escaping
But I don't have access to html-entites from the view, so there are three options at hand:
All these options are fine so it's up to you.
citation-popup/index.ts
was causing a bug. For instance, if I try to include a title like "This is an <art", it gets stringified to JSON peacefully but it breaks the HTML in the view. So, I had to encode the JSON string before passing it, then decode it when receiving it in the view.setTimeout()
for a fraction of a second).citation-popup/index.ts
and made the search field empty its contents after the user adds a reference to the selected area.OK, I've removed the use of the dictionary, replaced setTimeout()
with setInterval()
, and removed the redundant escaping in view.js
.
In addition to the above tasks, I stress tested the code with large .bib
files. I already did a stress test with a ~300KB file, but this time I tried much larger files.
I couldn't find a BibTeX file with 1GB of data so I downloaded this file. After that, I wrote a script that makes another copy of the file and then starts duplicating its contents over and over again until it reaches a certain size that I specify.
Intel Core i5-10210U (1.60GHz × 8)
16GB
240GB SSD
Ubuntu 20.04 64-bit
After adjusting the size parameter and observing what happens to the plugin when I execute the main command, I came up with the following conclusions:
512MB
(about equivalent to 536870912 Bytes
, which is about equivalent to 0x1FFFFFE8 Bytes
in Hexadecimal), nothing happens for one or two seconds then the below alert appears:
512MB
, nothing happens for about 20 seconds or so, then the call stack will not afford that much data and will throw an error like this:
<= 12MB
(which accounts for about 40,000
references), the plugin works fine and there are no issues at all.Looks good now, let's merge. Regarding the stress test, could you put this into a new issue instead please? (otherwise the info will be lost once the PR is closed)
What has been done
Demo
Bugs
The following bugs still need to be solved: