{"id":6884,"date":"2021-05-18T19:30:42","date_gmt":"2021-05-18T19:30:42","guid":{"rendered":"https:\/\/max-drake.cc\/?p=6884"},"modified":"2021-05-18T19:30:49","modified_gmt":"2021-05-18T19:30:49","slug":"web-browser-time-capture-store-to-file","status":"publish","type":"post","link":"https:\/\/max-drake.cc\/?p=6884","title":{"rendered":"Web browser time capture &#038; store to file"},"content":{"rendered":"\n<p>There seem to be a lot of time sheet apps on the web. A lot of them have a free service and also a paid service. So you have to log in to access them and also to store your data. <\/p>\n\n\n\n<p>There is this simple timer that just ticks along but you can&#8217;t store the information anywhere, it just has the stop watch. Not really a lot of use if you are trying to assign work time to a project. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"306\" data-src=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/04\/2021-04-10-12_03_51-23h5m-\u2014-Mozilla-Firefox-1024x306.jpg\" alt=\"\" class=\"wp-image-6885 lazyload\" data-srcset=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/04\/2021-04-10-12_03_51-23h5m-\u2014-Mozilla-Firefox-1024x306.jpg 1024w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/04\/2021-04-10-12_03_51-23h5m-\u2014-Mozilla-Firefox-300x90.jpg 300w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/04\/2021-04-10-12_03_51-23h5m-\u2014-Mozilla-Firefox-768x229.jpg 768w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/04\/2021-04-10-12_03_51-23h5m-\u2014-Mozilla-Firefox-1536x459.jpg 1536w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/04\/2021-04-10-12_03_51-23h5m-\u2014-Mozilla-Firefox-2048x612.jpg 2048w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/04\/2021-04-10-12_03_51-23h5m-\u2014-Mozilla-Firefox-50x15.jpg 50w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/04\/2021-04-10-12_03_51-23h5m-\u2014-Mozilla-Firefox-167x50.jpg 167w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/04\/2021-04-10-12_03_51-23h5m-\u2014-Mozilla-Firefox-100x30.jpg 100w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/04\/2021-04-10-12_03_51-23h5m-\u2014-Mozilla-Firefox-335x100.jpg 335w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/04\/2021-04-10-12_03_51-23h5m-\u2014-Mozilla-Firefox-640x191.jpg 640w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/04\/2021-04-10-12_03_51-23h5m-\u2014-Mozilla-Firefox-1920x573.jpg 1920w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/04\/2021-04-10-12_03_51-23h5m-\u2014-Mozilla-Firefox-scaled.jpg 1600w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/306;\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Project requirements<\/h3>\n\n\n\n<p>So I started to look around and items that I thought would be a useful browser tool would be:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Works online and offline- Most people use their browser all the time, so having a tab with timer would be useful<\/li><li>It would allow it to be accessed from a mobile <\/li><li>It could store to local storage (ie Storage in browser) <\/li><li>It would need to read &amp; write to a physical file on device (PC or mobile) where the user can choose that file (and maybe type) so that they can store information locally .<\/li><li>Item above is not as simple as it seems as it wants to store to local storage so you then have to write it from local storage to a file <\/li><li>You would need to somehow assign projects, maybe through a project list with radio buttons or a pull down list<\/li><li>Nice to add a note on what you were doing on the project. <\/li><li>Simple vanilla JS , so no Node.js or JS Query so anyone can download and use. Also if libraries are to be called they will be part of a download. I want simple code that can work on most browsers without anyone having to load too much into the page to make it work. <\/li><\/ol>\n\n\n\n<p>In fact, all the items that I went through in the exercise for Time Capture exe file that I went through. See <a href=\"https:\/\/max-drake.cc\/2021\/04\/01\/ahk-time-capture-app-development\/\">AHK Time Capture App development<\/a> article.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Information to start with<\/h4>\n\n\n\n<p>There are a few Stop Watch timers and YouTube Videos on the topic. eg , so getting the code for that is not a problem. I actually used  the code from (<a href=\"https:\/\/code-boxx.com\/simple-javascript-stopwatch\/\">https:\/\/code-boxx.com\/simple-javascript-stopwatch\/<\/a>) to put in the html, I didn&#8217;t  use the CSS part, just the buttons &amp; js. <\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"Create a Stopwatch using HTML, CSS, and JavaScript\" width=\"678\" height=\"381\" data-src=\"https:\/\/www.youtube.com\/embed\/1INmsFnD-u4?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" data-load-mode=\"1\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>There are even some videos on getting files from local drive and saving them, via a download link , the article <strong><a rel=\"noreferrer noopener\" href=\"https:\/\/thirteenov.ciihuy.com\/how-can-we-read-and-write-a-file-using-javascript\/\" target=\"_blank\">How can we read and write a file using JavaScript<\/a><\/strong> has the code to run. <\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"JavaScript Read and Write File\" width=\"678\" height=\"381\" data-src=\"https:\/\/www.youtube.com\/embed\/0ArXvgoFtXQ?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" data-load-mode=\"1\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>This got me so far, as the code is written to Local Storage and it gives you a link, so it is only part way there, the following video takes the local storage file and makes it an actual file on your hard drive. <\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"generate downloadable files in the browser using Blob and URL API\" width=\"678\" height=\"509\" data-src=\"https:\/\/www.youtube.com\/embed\/_HZdLuGL8Ho?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" data-load-mode=\"1\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>Another method is to use the filesaver.js library. This may be a better way to go <\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"Write And Create File Using FileSaver.js\" width=\"678\" height=\"381\" data-src=\"https:\/\/www.youtube.com\/embed\/imtbcclbu3c?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" data-load-mode=\"1\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>This one has a simple example of fileSaver.js<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"FileSaver.js Basic Tutorial to Save or Download a File in Javascript\" width=\"678\" height=\"381\" data-src=\"https:\/\/www.youtube.com\/embed\/kwfoEb0-DQI?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" data-load-mode=\"1\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>After getting into this project I found the issue was saving files to PC from browser. Also, if you do it on a mobile it&#8217;ll save a file to the mobile, not the PC you are doing work on. <\/p>\n\n\n\n<p>I&#8217;d been able to save an individual duration, for a specific project, to a file, but then I ended up with multiple files that I needed to combine at some later time, or look at an automated process that would combine them into a single file and delete the original files that it combined. <\/p>\n\n\n\n<p>The alternative was a database. <\/p>\n\n\n\n<p>That is when I decided that the process was too sophisticated. If I was to create a free tool then it needed to be easy to setup by others and either you design the install to do a creation of a database (so you are managing the process for others) or you are at risk of others with minimal knowledge having issues setting things up. <\/p>\n\n\n\n<p>This is when I stepped back from the project, it was becoming too complex and similar to other paid solutions. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">End comment<\/h3>\n\n\n\n<p>I thought it would be a bit complex but the file storing on PC was a real issue. <\/p>\n\n\n\n<p>Overall the build would have been too complex, but it was a good exercise to go through to get an understanding of the process. In the ends I think you needed a remote server so that you could access and store data in a database that is accessible from anywhere, which is a standard commercial process but a bit more sophisticated than I wanted. <\/p>\n\n\n\n<p>You could use Google Sheets as an Endpoint, but that is basically a GlideApp or adding a bit of GAS coding to a Google sheet. I&#8217;d already been down that path and was not interested in pursuing that for what my main objectives. <\/p>\n\n\n\n<p>So a PWA app was what it was ending up being and I didn&#8217;t pursue it further. An explore and failure I suppose. Just somewhere I didn&#8217;t want to spend my time and resources. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>There seem to be a lot of time sheet apps on the web. A lot of them have a free service and also a paid service. So you have to log in to access them and also to store your data. There is this simple timer that just ticks along but you can&#8217;t store the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6902,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[204,42],"tags":[],"class_list":["post-6884","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-automation","category-productivity"],"featured_image_src":"https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/05\/pexels-cottonbro-5185178-600x400.jpg","featured_image_src_square":"https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/05\/pexels-cottonbro-5185178-600x600.jpg","author_info":{"display_name":"Max Drake","author_link":"https:\/\/max-drake.cc\/?author=1"},"_links":{"self":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts\/6884","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6884"}],"version-history":[{"count":0,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts\/6884\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/media\/6902"}],"wp:attachment":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6884"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6884"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6884"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}