Javascript check Opera Mini

So today I got caught on the weird-side of mobile web-development, that is to create consistent javascript on major mobile browsers. The good news is Android and IPhone are using webkit so it’s kind of easy. The Bad News is Opera Mini.

Don’t get me wrong, I love opera mini. But the different java-script engine behavior could cause headache sometimes. After googling for a while I stumbled on this http://dev.opera.com/articles/view/javascript-support-in-opera-mini-4/ that mention some things to consider:

  1. Opera Mini JS has a limited DOM event
  2. No background scripting
  3. Very limited AJAX support

And the most important thing is this snippet to check whether we are inside Opera Mini (of course you can use PHP or Server Side script as a better method)

is_operamini = Object.prototype.toString.call(window.operamini) === "[object OperaMini]";

So to avoid more headache, I just treat opera-mini as a non-javascript-capable browser *smirk*

Create Dwoo plugin that is reusing another plugin

I am using Dwoo template http://dwoo.org/ for my PHP project, and Dwoo allow me to create custom plugins. each plugin is stored inside php file, and Dwoo will be the one that handle the plugin lazy-loads.

But how one plugin can reuse another plugin? I can’t find anything on google about that, so I take a look at how
the compiled-code call plugin.

    if (function_exists('Dwoo_Plugin_input')===false) {
        $dwoo->getLoader()->loadPlugin('input');
    }

Ah, simple! so my plugin can also use the same way to call another plugin. Here is the code for my ‘password’ plugin that is reusing ‘input’ plugin to generate HTML field

function Dwoo_Plugin_password(Dwoo $dwoo, array $rest = array()) {
    if (function_exists('Dwoo_Plugin_input')===false) {
        $dwoo->getLoader()->loadPlugin('input');
    }
    $rest['type'] = 'password';
    $rest['autocomplete'] = 'off';
    return Dwoo_Plugin_input($dwoo,$rest);
}

Dwoo FTW!