jQuery Mobile Popup

by freedawirl

HTML

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.css">
<div data-role="page">
    <div data-role="content">
        <a id="trigger" href="#popupBasic" data-rel="dialog" data-role="button" data-rel="back">Open Popup</a>
    </div><!-- /content -->
</div><!-- /page -->

<form id="popupBasic">
    <fieldset>
        <label for="name">Please fill in a password:</label>
        <input type="text" name="name" id="name" value=""  data-theme="b" />
    </fieldset>

    <fieldset class="ui-grid-a">
        <div class="ui-block-a"><button type="submit" data-theme="d">Cancel</button></div>
        <div class="ui-block-b"><button type="submit" data-theme="b">Make PassHash</button></div>
    </fieldset>
</form>

JavaScript

//javascript:

// @TODO: inject jQuery, jQ Mobile and MD5 hash script into the page.
/*
    // Grab the domain from the window.locaion
    // Ask the user for a salt or password)
    // Generate MD5 hash
    
    optionally we could invoke an interface to let the user select which field the password should be  filled in.
    We could even store the selector to this field in localstorage if it is available.
    
    Otherwise we should either output the passhash or copy it to the pasteboard (is this possible in modern browsers without flash?
    
*/
$('#trigger').trigger('click');

$('#popupBasic').submit(function(oEvent){
    var sResult;
    
    oEvent.preventDefault();
    
    sResult = $(this).find('input').val();
    // @TODO: Validate sResult is not empty!
    
    alert(sResult);
    $(this).dialog('close')
        return false;
});