teaching machines

AphasiaWeb Fixes

January 18, 2013 by . Filed under aphasia, public.

I’ve fixed a few more lingering bugs or incomplete features on our AphasiaWeb project:
  1. Videos not working. The video files were not getting to the database insert function. The cause? On the client, I was writing to post.videoPath the URL after the upload finished, but I was reading from post.videoURL. Switching both to use post.videoURL fixed that problem.
  2. Video preview. I added a <video> tag to show the video during addition of a post. With <img>, a null src meant the element was invisible. Not so for video. I saw a black window when the video had not yet been recorded. As a workaround, I created an empty <div id="videoPreview"> instead. When the video gets recorded or picked, $("#videoPreview").html('<video src="path/to/video.mov" controls>') did the trick.
  3. When inserting text with quotation marks and apostrophes, they were getting escaped by somebody that wasn’t us. Effectively, this meant a lot of backslashes showed up in post titles and bodies. Either the prepared statements business or the magic quoting of PHP was to blame. To unescape, we have to call stripslashes($string).
  4. Wait until video uploaded. In order to let the user know that a long upload was taking place, I wanted to progress bar/animation. jQuery came to the rescue with $.mobile.loading('show') and $.mobile.loading('hide').
  5. Cookies to auto-authenticate. I ended up using jquery.cookie.js to simplify cookie management. On a successfully login, I store the userid with $.cookie('userid', userid, { expires: 50, path: '/' }). Later, I can retrieve it with $.cookie('userid') and delete it with $.removeCookie('userid') on logout.

Immediate problems that remain on my TODO list include:

  1. We need a splash screen and icon.
  2. Can we detect no network connection?
  3. Reorienting the device messes with the page’s natural size.