AphasiaWeb Fixes
I’ve fixed a few more lingering bugs or incomplete features on our AphasiaWeb project:
- 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 frompost.videoURL
. Switching both to usepost.videoURL
fixed that problem. - 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. - 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)
. - 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')
. - 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:
- We need a splash screen and icon.
- Can we detect no network connection?
- Reorienting the device messes with the page’s natural size.