Posted by Roy

Print Book Now Available!

The print version of Enyo: Up and Running is now available at O’Reilly!  Click the image below:

Enyo: Up and Running

Enyo: Up and Running

I’m pleased to announce that my book Enyo: Up and Running is now available for pre-order. Enyo: Up and Running is a book designed to help JavaScript programmers get up-to-speed with Enyo. I wrote it to guide you step-by-step through the various pieces of Enyo.

I’m very proud of the result and think that you’ll be able to use Enyo to produce native quality apps using just JavaScript, HTML and CSS.

MoDevEast Presentations

My MoDevEast presentations are now available on YouTube and Slideshare. For those of you not familiar with it, MoDevEast is an annual mobile developer conference held on the East Coast. In addition to MoDevEast, the MoDev folks have local meetup groups and put on several other conferences, including MoDevTablet and MoDevUX.

I was fortunate enough to be able to run a workshop on Thursday and a give a short presentation about Enyo on Friday.

On Friday, I gave a shorter, higher-level presentation about Enyo.  You may note that I make good (re-)use of my slide deck:

MoDev Meetup Presentation

Here’s a presentation about the Enyo JavaScript framework that I gave to the MoDev meetup group in November 2012:

Following the presentation we had a panel discussion on cross-platform best practices. Here’s the video of that:

MoDevTablet Enyo Presentation

In September I gave a presentation to the MoDevTablet conference. The talk was titled HTML5 Apps: Write Once, Deploy Anywhere and it covered app development using the Enyo JavaScript framework.  Below is the video of the presentation and the Slideshare slide deck I used.

Mudlet Mapper Script

One of the things I used to like to do in my spare time was tinker with MUDs. It’s been a long time since I last played with them. I used to have a pretty extensive set of scripts for Dragon’s Gate, back when I played and programmed for it. I even had a plugin I wrote for zMud.

These days my primary machine is a Mac. I had searched a few times for Mac MUD clients and hadn’t really found anything good. When I started playing around on Shattered Isles I saw they recommended Mudlet. I had never found it before when I was doing my searches so I thought I’d give it a try.

I’m pleasantly surprised with Mudlet. It provides a pretty robust set of features and is easily programmable with Lua. One of the features it touted was a mapper. I’m big in to mapping, particularly if it can help with getting around MUDs. Obviously, I wanted a mapper for Shattered Isles.

The fruits of that labor are now available on the Shattered Isles forum. As I add new features I’ll attempt to keep the post up-to-date. I’ve recently added the ability for it to download updates to maps and the script. At some point I’m hoping we’ll be able to set up SI so it will auto-download the scripts (and maps?) to the players. We’ll see!

Creating a Table of Contents in Concrete5

I recently had a requirement where I needed to create an article template for a site running on Concrete5. The articles needed to have a table of contents displayed in a box next to the article. Further, I wanted to come up with a solution that didn’t rely on JavaScript. I did what I normally do and turned to my good friend Google to see what other people had done.

The first part, creating a table of contents in PHP, turned out to be pretty simple.  I found a question on StackOverflow that was pretty close to what I needed. The code needed a good bit of tweaking to get working, but I was able to create something that at least got the job done. However, not only did I need to feed it the contents of the block/area I wanted a table of contents for, I also needed to modify the contents to have anchor tags for quick navigation.

This part proved to be a little more difficult. I had hoped that Concrete5 had a block or area function that would output the HTML into a variable for me. Unfortunately, there is no such method. Fortunately, while Googling an answer I came across a post about getting the contents of a block. I had completely forgotten about PHP’s functions for capturing output. I could use ob_start() and ob_get_clean() to capture the results of an Area’s display() function:

$a = new Area('Main');
ob_start();
$a->display($c);
$html = ob_get_clean();

I could then take the results and pass them to my table of contents function. In the function, I modified the passed-in HTML then displayed it and also returned the table of contents so I could place it into a variable to display later in my template.

I’m certain it could be a lot cleaner, and, if I get motivated, I may turn it into a real-live block that can be dropped onto a page.

Preventing Auto-Fill in Android WebView

Working with the Android WebView can be very frustrating. One thing that was driving me nuts was that as I tried to fill out forms in a WebView it would offer suggestions from things I had typed before. It proved pretty difficult to search for a solution to the problem.

The first thing I found was a suggestion to set auto-complete=”off” on the form and/or the element. Unfortunately, that didn’t work at all in the WebView. However, I did waste a lot of time testing that out.

I tried a lot of different searches:  “webkit form input autofill”, “webkit form input autocomplete”, “android WebView disable autocomplete” and other permutations I can’t even remember. I even found this unanswered StackOverflow question.

It turns out that it’s very simple to disable the feature, just difficult to find it! It’s as simple as:

     webview.getSettings().setSaveFormData(false);

That’s it!  Pesky problem solved.

Update:  Kamal on StackOverflow added the following two lines:

     WebView.getSettings().setSavePassword(false);
     WebView.clearFormData();

I haven’t tested those two changes but they do seem very likely to help!

Android and Number Inputs in Forms

I had a form with a single input box and a hidden submit button that I had been using for getting user input in a form on a WebView. The input was supposed to be a number so I wanted the number soft keyboard to come up when the field was selected. Simply changing the input type to number gave me the functionality I wanted. Unfortunately, once I did this, pressing enter no longer submitted the form.  It appears the numeric keyboard on Android doesn’t do a submit (at least, if the input type is number).

Google searches were pretty fruitless, though I did find this unanswered StackOverflow question.

I did confirm that the keyboard doesn’t send any keys whatsoever. I was at a bit of a loss as to how to fix this problem.

The solution I hit on, which may be sub-optimal but met the needs I had, was to add a text input field and position it off the screen. I then added an onfocus script that set the text input to disabled and submitted the form. This gave me the behavior I wanted and didn’t add extraneous fields to the form. One more Android bug tackled.

Here’s the code and a sample page:

function numberFix() {
    numfix.disabled = true;
    theform.submit();
}
<form id="theform"><input id="thetext" type="number" />
  <input id="numfix" style="margin-left: -999px;" onfocus="numberFix()" type="text" />
  <input style="height: 0px; width: 0px; border: none; padding: 0px;" tabindex="999" type="submit" />
</form>
Tagged , ,

Hello world!

Welcome aboard! Don’t expect a lot. I’m reserving this place for random thoughts, mostly about programming and things I’m interested in. I realized I have been hoarding knowledge over the years and I decided to share what I can whenever I think to. Don’t expect much and you won’t be disappointed!