May 21, 2012

Weewar Status Notifier for Adobe Air

satellite dish 128 Weewar Status Notifier for Adobe Air

I’m pleased to announce the release of my first Adobe AIR application. This is a simple little desktop (not browser) app which checks your status on Weewar to see if you have any games waiting for your attention.

Revision 2.2 feature list:

  • Checks your status using the Weewar API
  • User settable interval between checks
  • You can force an update by clicking on the “games waiting” message.
  • Semitransparent, draggable window
  • Built with HTML, not Flash.
  • (New in version 1.1) If you have waiting games and you click on the message, you’ll open a new browser window and go to your headquarters.
  • (New in version 1.2) Works on Windows.
  • (New in version 1.3) Turns red when you have games waiting. Resizes to fit contents.
  • (New in version 1.4) Lists the games waiting for your attention
  • (New in version 1.5) Added the option to have the window always stay on top
  • (New in version 1.5) Changed the last checked display to show “xx minutes ago”
  • (New in version 1.7) Compatible with AIR Beta 2
  • (New in version 1.7) The window floats to the top automatically if you have waiting games. That way it doesn’t get buried but you don’t have to have it always floating on top of the other windows.
  • (New in version 2.0) Updated for Adobe Air 1.1
  • (New in version 2.2) You can now click on the “checked x minutes ago” status line to do an immediate status check.

Installation

  • Install the AIR Runtime. It is very small and fast.
  • Download Weewarify 2.2
  • Install the app by double-clicking on the downloaded installer.
  • The first time you run it, it should detect that you haven’t configured, and show you the configuration window. Put in your username and your “token” from your Weewar account page.
  • Click the icon on the top right to save and flip back to the status page.
  • That’s it, the program will now check Weewar every few minutes for you.
  • Important! If you let the installer run the app after install (which is the default), it doesn’t work. I have no idea why. Just quit and restart it. It will work when launched normally.
  • WARNING: Doesn’t work on Windows at the moment. I’ll fix very soon.

Open Source

Feel free to contribute, browse the source, report bugs, or request enhancements at Weewarify’s home on Launchpad

Related posts

Technorati Tags: , , ,

Why I didn't switch from jQuery to ExtJS after all

A while back, I wrote an article about why I was switching to ExtJS from jQuery. This remains one of the top ten pages on the site, despite the fact that I never really did switch. Checking it just now, I am certain that it is the most heavily commented article on the site.

The fact is that I started to switch, did a site or two, and then I quickly changed my mind.

There are four reasons I didn’t end up switching from trusty jQuery. Size, familiarity, purpose, and license.

[Read more...]

Technorati Tags: , , , ,

Mootools beats jQuery and Ext for AIR

When I recently updated an Adobe AIR app I’d written for AIR Beta 1, I found that I had to go to enormous lengths to continue being able to use ExtJs as a selection & effects library for it. This is due to “eval()” being prohibited in the base Javascript on any AIR app.

[Read more...]

How to do HTTP Basic Auth in Ajax

You can use HTTP Basic Authentication with Javascript/Ajax in just three steps. I’ll give you them in just a moment.

The Background

This morning, I was experimenting with Adobe AIR, writing a client to tell me whether I have games waiting for me to make a move on Weewar, and I needed to be able to use my username and “token” via Basic Auth to do that.

It was not easy to find how to do it. In fact, I had to connect a few dots to get it to work. Here you go:

Step 1

First, get Base64.js from Webtoolkit, and load it on your page. We need the encode routine from that library.

Step 2

Construct your Authorization header like so:


function make_base_auth(user, password) {
  var tok = user + ':' + pass;
  var hash = Base64.encode(tok);
  return "Basic " + hash;
}

Step 3

Use it in your Ajax call.


var auth = make_basic_auth('me','mypassword');
var url = 'http://example.com';

// RAW
xml = new XMLHttpRequest();
xml.setRequestHeader('Authorization', auth);
xml.open('GET',url)

// ExtJS
Ext.Ajax.request({
    url : url,
    method : 'GET',
    headers : { Authorization : auth }
});

// jQuery
$.ajax({
    url : url,
    method : 'GET',
    beforeSend : function(req) {
        req.setRequestHeader('Authorization', auth);
    }
});

[tags]ajax,javascript,extjs,xmlhttprequest,jquery[/tags]

Why I'm moving from jQuery to ExtJs

Update (21 Nov 2008): I changed my mind a few months later.

This week, I’ve switched favorite Javascript frameworks. I was a heavy jQuery user, and still think that the framework is very nice. As part of a discussion on the Satchmo-Developers list about what Javascript framework to use as the default for the Satchmo web shop framework, I ended up doing a survey of the best ones available.

This is highly debatable, of course. In the end, I simply ended up trying to optimize my based on these desires.

  • It should be nice to the global namespace. I dislike frameworks that pollute the air with all kinds of function names.
  • It should be fast.
  • It should have nice, easy to use effects.
  • It should have extremely capable DOM manipulation.
  • It should have great CSS selectors.
  • It should have a good window.onLoad mechanism.
  • It should not modify the base language. Prototype is right out! I really really hate that.
  • It should be terse. I do not like wordy frameworks as a matter of style & taste.
  • It should work well with Safari.
  • Based on these requirements, I narrowed my choices down to:

    I then made a web page, loaded each of these in, and tried out various DOM manipulations and effects using the FireBug console. This was a fair way to do it, because it is how I prefer to explore a new framework. I like good docs, of course, but I also like being able to exercise the framework in an intuitive manner.

    My results, in very short nutshell descriptions:

    jQuery

    Intuitive, easy to use, fast, great DOM manipulation, good effects. Great window.onLoad handler. Give it an A- grade.

    ExtJs

    Intuitive, very very extensive, great DOM manipulation, solid effects. The fastest to get things done when puzzling out on the commandline. Give it an A.

    Mochikit

    Very terse, much more “functional” in approach rather than class-oriented. Not good about polluting the global namespace. Yes, this is runtime-optional, but the alternative is very wordy. The functional approach (i.e. map(set, func) rather than $(selector).each(func)) is a bit off-putting actually. It makes it much harder to know what functions are appropriate to use with what objects. Give it a score of B+ due to my highly subjective sense of style.

    Dojo

    Too wordy. I dislike their framework for building widgets. I love their inclusion mechanism, but dislike that the reason for it is that Dojo is so huge. Give it a C.

    The winner: ExtJs

    In the end, I went with ExtJs. I am happily converting my existing code to use the framework, and encountering little resistance. It is a very easy conversion. I’ll still use jQuery for deployed clients, but all my new library code is going to be Ext based.

    [tags]javascript,jquery,extjs,mochikit,dojotoolkit,dojo[/tags]

    Cross-browser safe, readable Javascript style

    Over time and thousands of lines of professional Javascript programming, I’ve developed an almost bulletproof Javascript layout style. It is important to have one, even if you are the only person working on your script, because:

    • it helps you read the code more quickly
    • it helps you not forget browser "gotchas"
    • it makes your code more reusable from project to project

    My style rules

    • All functions and variables should live in their own namespace, not polluting the base context as much as possible. In other words, I never write simple “function foo(arg) { … };”, since that might conflict with other libraries implementations of "foo." Instead I always start every javascript source file by declaring my root namespace. I use "SSS" as the root, like so: "var SSS = SSS || {};"
    • Always put related functions together in their own namespace. For example, on a recent project codenamed "scr", I have three namespaces: SSS.scr, SSS.util and SSS.layout. This allows me to reuse useful and debugged code on different projects.
    • I put module-level variables at the top of the module namespace, then alphabetize all other functions.
    • I put a final declaration at the end of the array, "ZZZ : ‘do not remove’", which keeps me from making the IE and Safari deadly mistake of having a trailing comma at the end of the last function.

    An example javascript file using my style

    
    var SSS = SSS || {};
    
    SSS.scr = {
    
        active : 'switch-0',
        flag : false,
        initialized : false,
        log : false,
        update_depth : 0,
    
        add_delimited_field : function(field, count, delimiter, defval) {
            // example
        },
    
        calc_price : function() {
            // example
        },
    
        cents_to_dollars : function(val) {
            // I like this simple function, so I left it in.
            var d = Math.floor(val/100);
            var c = val % 100;
            if (c < 10) c = "0" + c;
            return d + '.' + c;
        },
    
        cleanup_names : function(adults, children, total) {
            // example
        },
    
        init : function() {
            // init stuff here
            SSS.scr.initialized = true;
        },
    
        ZZZ : "do not delete"
    }
    
    // jquery onload initializer
    $(function() {
         SSS.scr.init();
    });
    

    [tags]javascript,style[/tags]

    Enhancing FAQs with jQuery

    I’m so pleased by how useful and concise jQuery has been for my development of a dynamic FAQ module for Drupal. I can’t share that module yet, but I can talk about the jQuery that gives it a snappy and useful facelift.

    It isn’t original, of course. Just click-to-toggle questions on a faq page. What is original is how easily styled this solution is, and how concise the javascript used to get there. Add to that a reasonable markup scheme, not burdened with superfluous divs or ids, and I’m a happy developer.

    [Read more...]

    jQuery Selector Magic

    swings jQuery Selector MagicI’ve been working on a Drupal module to automatically make CSS-styled drop-down menus from the built-in menuing system. That’s been going great, and I’m really enjoying Drupal’s modular architecture and theming abilities. However, I ran into a little problem which was solved just perfectly by an elegant bit of jQuery Javascript.

    What I wanted to do was to mark a list active if any of its children were active. That’s a common design request. “Make this tab active if the current page is one of that tab’s children.” However, I’d written the menu routines recursively, and it just isn’t worth it to me to rewrite them to add this one little feature.

    [Read more...]

    Semitransparent rollovers made easy with JQuery

    I’m continuing to enjoy working with jQuery. This article shows a simple method for enabling semi-transparent rollovers which actually work on IE 6. Yes, you could use a .gif file for a crude version, but many effects, especially “glowing” effects just look much better if you use a format which supports alpha channel transparency.

    [Read more...]

    Simple, degradable Flash embedding using jQuery

    flash effect Simple, degradable Flash embedding using jQueryNow that I am doing professional web layouts for clients, I find myself appreciating the quick, easy, and well-documented jQuery library. I just don’t have time to hassle with Dojo and its size, widgets I don’t need, and messy documentation.

    Recently for one client I needed to use a flash sidebar. The image was a slowly rotating, “fanned picture” slideshow provided by my designer partner. This would be OK, except I really dislike all the tag soup of object embedding, especially on dozens of pages. Also, I wanted to make sure that the site wouldn’t look strange with Flash turned off. In that case, I wanted to use a simple freezeframe of the first slide from the image set.

    [Read more...]