procrastitracker icon indicating copy to clipboard operation
procrastitracker copied to clipboard

Load PT database in javascript

Open easz opened this issue 8 years ago • 8 comments

Issue #19

The js lib may let user analyze PT database in a modem way (e.g. html5 tool chain...)

demo https://easz.github.io/procrastitracker/tools/js/demo.html

easz avatar Jun 24 '17 06:06 easz

Also, the demo gives me URIError: URI malformed when loading one of my file. And Uncaught TypeError: Failed to execute 'readAsArrayBuffer' on 'FileReader': parameter 1 is not of type 'Blob'. at HTMLInputElement.<anonymous> (demo.html:59). .PT file I am loading is about 1 meg.

aardappel avatar Jun 24 '17 15:06 aardappel

yes, you can just put a link in the docs. Otherwise I feel also sorry to make a lot of PR update....

About the error, I will take a look again and try to figure out the possible problem. What kind of browser did you use?

easz avatar Jun 24 '17 17:06 easz

I don't mind PRs, I am just pointing out the consequences :)

I'm on Chrome 58.0.3029.110 (64-bit) Windows 10.

aardappel avatar Jun 24 '17 17:06 aardappel

I will test it next week on Windows and in the meanwhile I just added some debug log

easz avatar Jun 24 '17 19:06 easz

about URIError: URI malformed: I had also this problem before I decode data into utf8 string. It should be fixed now.

About Uncaught TypeError: Failed to execute 'readAsArrayBuffer' on 'FileReader': parameter 1 is not of type 'Blob': I could not reproduce the problem and it shouldn't be file size issue... Anyway I have only PT file with about few hundred kbytes to test.. :) on Chrome Version 59.0.3071.115 (Official Build) (64-bit) Windows 7

easz avatar Jun 28 '17 08:06 easz

Still get the same error on https://easz.github.io/procrastitracker/tools/js/demo.html

aardappel avatar Jun 28 '17 18:06 aardappel

which error?

Uncaught TypeError: Failed to execute 'readAsArrayBuffer' on 'FileReader': parameter 1 is not of type 'Blob'? I can open a huge zip file (>4MB) without error. The File input, FileReader and zlib.js should be OK.

URIError: URI malformed: I assume the byte data for strings in PT database is encoded as UTF8 Now I make a fail-back to latin1 encoding and give out warning log. It should not break parsing process any more.

Could you try the demo again and open web development console to see what errors and warnings are logged?

I use decodeURIComponent(escape(str)) to decode string data as UTF8 encoding. On Windows 7 (64 bit).

The decoding may fail if there is some string data is not well encoded (or un/escape) in database. Probably link to https://github.com/aardappel/procrastitracker/blob/68bb9b3d456dee5facc0c961151ad45a25307ea2/src/timercallback.h#L76

thanks for helping :)

easz avatar Jun 29 '17 07:06 easz

Ok, demo now works. It is indeed UTF-8

aardappel avatar Jun 29 '17 16:06 aardappel