Save key stroke events to spreadsheet +timings - javascript

As part of my college dissertation I am trying to test out how usable several different types of number entry keyboard interfaces are. To do this I need to record each key press my participants make and the timings of each key press. It is not enough just to record what they submit on a form as I need to monitor how many errors they see and correct also. I am hoping to somehow write this information to a .csv/spreadsheet to analyse after the experiments.
My supervisor suggested creating a webpage and using javascript for this but unfortunately I am a total beginner. My knowledge is limited to HTML. Could somebody please help me or suggest a place where I could find more information on this subject? I have been searching the web for the last couple of days with very little luck. Essentially I want to do something like in this example http://javascript.info/tutorial/keyboard-events#test-stand-test-stand except to write it to an external file on my computer and with the inclusion of timings for the key presses.
Many thanks,
A desperate student.

You cannot write JavaScript directly to a file. You could instead send the data to the server to save a file in the .csv format to a specified location. Alternatively you could output the data in a format which copies easily into excel.
I suggest setting up a Node.js server and using jQuery+AJAX to send the data to your server via POST request then saving a .csv file on the server.

Related

Using network data and run functions by calling a python file from a userscript

I'm a total stranger to JavaScript and very new to Python. Please pardon my ignorance if any!
I have an internal website which allows me to download release reports. I have an idea to create a userscript to download the release report in a CSV.
This is how the flow is
User lands on a release report page
Makes a selection and clicks on a button
This shows release data in raw format (which is extremely crude and not user friendly). A download JSON button is present on the page which can let you download the data in JSON format
I observed on step 2 an API call is made with a release ID which is of course dynamic.
My plan is to
show a button download CSV when Download JSON button is available - I have completed this
Intercept the GET request whose request URL is dynamic and fetch the JSON
Flatten this JSON and create a CSV with whatever I need - I have this right now with python.
My questions are -
Is it possible to fetch network request headers - since the URL will be dynamic I have to rely on the last call the browser made? I know the format but a regex request URL will not work (I realised later how obviously silly that was)
My JSON normalising code is in python. Since the JSON itself is very dynamic and complex I used Pandas but I have no idea if I can even invoke it through a JavaScript.
Is there a better way to do this using just Python maybe? Maybe I shouldn't rely on a userscript, is there an alternative to work with a browser for this specific task?
I'm looking for any direction or even a possible different approach.
Many thanks.
I can't seem to get 'Requests' made by the browser. I'm exploring chrome.webrequests for this but not sure if I can integrate all these things together. I'm also thinking if selenium could ease any of these tasks.

Web visitor data storing without database/server

I have a research project which is focusing on understanding user's curiosity and connecting to Free WIFI including remote areas where internet is poor here.
To do this, we developed simple webpages with the first as a Visitor's form where we need a user/visitor to enter their data and let it be retrieved, saved or viewed later as user logs. We want to do this by simply having a Router and a Flash disk where the webfiles and data storing system will be...No server!
Is this very possible with Javascript, xml and or any other languages anyone has ever done this? That is except Javascript's LocalStorage which in this say, the user will be the one to have his/her own data.
This is an unusual request really. I agree a relational DB would be the best choice. Of course you can just save to text file (xml or not) and later use that file in Excel or so. That would be my choice.
You can probably store data with LocalStorage, and allow user to save data by exporting a .JSON or .CSV or something like that.
You can give the user a file to download by doing a window.open() on a Data URI containing the text of the JSON or CSV:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs

Methods to pull data and display on web browser

Please look at my project architecture below.
I intend to use Arduino as Web server and pull data into the SQL database of my PC. I have installed XAMPP, so I have the apache server and MySQL running in my PC. I have verified that data from Arduino is updating a table in the SQL DB.
Question:
I'm not a web-developer and I have been exploring different ways of pulling data from the SQL DB and showing it on web-page.
My requirements:
Pull live data from the SQL DB (as it gets updated) and show it on web page
Plot graphs of recorded parameters from the db as and when required. I understand that Flot is a tool which can do that.
Make a drawing as shown in the image above and populate that with dynamic values (numbers) or change colors of objects (such as green/red)
Methods I have come across so far
Use PHP to pull the data and show on webpage. Use HTML/Javascript/jQuery to create such drawing and populate with image and values
Use Python to pull data and use HTML/Javascript/jQuery (I know only HTML among these)
Use Visual Basic to pull data directly from Arduino and display it in a form. For this option, I'm not sure if plotting data is possible or not.
This of-course is a broad question and as I said I'm not a web developer. But I'm in no hurry. I have couple of months of time to invest and learn the different languages involved.
I wish the answers could guide me to a better solution than I know or chose one among the others or just point out plus-and-minus of each of the options
You can use EventSource at JavaScript to stream data from PHP or Python the the HTML document.

Can I access Notes documents/collections via client side JS?

I wanted to know if it's possible to handle notes views and document collections via client side scripting in Xpages?
The story so far....I am building a HR system that includes a full absence section (holidays, sickness, other absence etc). I have coded a button in the notes client that creates an Excel spreadsheet showing a calendar of the last 12 months absences for the current user based on the absence documents (getview, getalldocumentsbykey into collection). It loops the collection using various fields (incuding multi value fields) in each document to calculate absence length, full/half days etc and marks them on the sheet in different colours with hyperlinks to access the documents.
It also calulates other things like the Bradford Factor rating and does calculations around the users working days.
Anywho, I've been challenged to get the entire system working in a browser, removing any need for the notes client, so....back to my original question, I need to be able to get a collection of documents from a notes view via a key that I can then access the field on via client side javascript.
Is this possible? I can provide more info if required...
Have you considered the Notes Browser Plugin? It is supposed to let you run the Notes Based Apps through the browser without modifying the code.
Here is a write up about it
I think you should go for REST. In Domino, it can provide data from views/documents in JSON format which you can use in client side JavaScript natively.
For more info try searching google and ddwiki, for example this tutorial video.
Edited to put emphasis on &ReadViewEntries and add detail
Doing it purely on the browser-side would probably best be done by fetching DXL or JSON using the &ReadViewEntries URL command, and then writing Javascript to process the data and do the equivalent of the CreateObject call locally. You can find the doc for &ReadViewEntries here. (#Panu has already mentioned DDS, which is also a good idea.)
Or see here for some sample code that shows a technique that a Domino web agent written in LotusScript can use to create data that will be sent to the browser with a content-type header that causes it to be opened in Excel. I haven't verified this particular code, but I've seen other references to the technique. This particular code might not give you as much control as you want -- e.g., colors and links, but I think it would also be possible to actually generate the data as XML in the xlsx format and send that down similarly.
You can access all Domino objects from client side JavaScript vith Java and CORBA. You just need a small applet that returns Session to javascript. Here are instructions from Designer help:
http://www-12.lotus.com/ldd/doc/domino_notes/rnext/help6_designer.nsf/9/0d05bb3cec358f7085256c54004bdbff
However as Per suggested nowadays a combination of client and server side Javascript in XPages are usually used instead of CORBA. Domino Data Service is the latest way to get data from server to (for example) client side javascript.
You may also want to take a look at Apache POI with which you can create Excel files in server side. ActiveX works only in IE althought there are plugins to get it working on other browsers.
edit
What I usually do with "combination of client and server side Javascript" is to use dojo.xhrGet (or xhrPost) in client side. On server I have an XPage (earlier agent) which collects the data and returns it in JSON format.
Panu

html: price listing based on email

I am building a website for a customer who may not be very computer literate. This person knows how to use email. How can I build a website (purely html, javascript) where he can email his latest prices and the website automatically updates itself. I dont think he would be literate enough to FTP file some where. Is it possible?
How to build a secure login page and redirect to order page using only javascript and html?
How to create secure administrative section on javascript/html only website?
I would advise you to create a nice admin web interface, and teach him how to use it. Or, agree some kind of Excel format for product prices, and teach the steps of uploading a csv file. Doing things by email would complicate things in my opinion.
As in the website receives the email as data input? That's probably not going to work very well. Also, if the client is as you imply, expect those emails to be poorly formatted, filled with typos, etc. It's not a very good data entry medium by any means.
The ideal solution would be to build an admin page into the website where the client can enter the information in as controlled a manner as possible, validating the information on the spot rather than through an email (would the server send a reply email for invalid data? that would get infuriating quickly). A simple and intuitive UI should be able to overcome any computer literacy issues he may have.
I don't think this can be done purely in HTML/Javascript. It would need a server component. You would have to set up some sort of POP3 or IMAP listener that polls a mail server for correctly formatted email then dumps that into a database to update the site. Certainly not trivial.
I would build an administration portion of the site to allow the customer to log in and enter the data...no matter how illiterate, they certainly can be trained. ;-)
You could make the mail your prices thing work by just regulary checking a specific mailbox (over POP3 for example).
But that's something you won't be able to do in only pure html / javascript (and consider this: you would also need to store the mailbox credentials in client side code then!)
Email is a store-and-forward, asynchronous transport. You can use it to transport:
plain text (the body of an email)
styled text (the html body of a MIME email)
attached files
But none of those options will work well in your use case. You'd have to try to parse the body of the email if you were looking in the body for update information. -- Bad idea
And if you're using email to transport ordered data such as csv or Excel files, uploading the files directly to the website would enable a much better user interface.
You shouldn't use Excel files either since it will be too complicated for your user--he'd need to get the column (field) names exactly right, the content cells would also need to be exactly right, etc. Eg I use an excel file for input on one of my systems and a constant problem is zip/postal codes since they look like numbers but can have significant leading zeroes. Few users know how to enter them...
Recommendation create a set of web forms in the administrative section of the website. Your customer will be happy and you'll be even happier due to lower volume of support calls.

Categories

Resources