aardappel / procrastitracker

a Windows time tracking application
http://strlen.com/procrastitracker/
510 stars 54 forks source link

Load PT database in javascript #35

Open easz opened 7 years ago

easz commented 7 years ago

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

aardappel commented 7 years ago

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.

easz commented 7 years ago

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?

aardappel commented 7 years ago

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

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

easz commented 7 years ago

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

easz commented 7 years ago

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

aardappel commented 7 years ago

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

easz commented 7 years ago

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 :)

aardappel commented 7 years ago

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