Created
May 25, 2009 11:39
-
-
Save FND/117506 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
| <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |
| <head> | |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
| <title>jQuery simpleLogin plugin</title> | |
| <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script> | |
| <script src="scripts/main.js" type="text/javascript"></script> | |
| <script type="text/javascript"> | |
| /*<![CDATA[*/ | |
| jQuery.noConflict(); | |
| /*]]>*/ | |
| </script> | |
| <script type="text/javascript"> | |
| /*<![CDATA[*/ | |
| (function($) { | |
| $.fn.simpleLogin = function(options) { | |
| var opts = $.extend({}, $.fn.simpleLogin.defaults, options); | |
| var form = $('<form action="" />').attr("id", opts.containerId); | |
| var el = $("<fieldset />"). | |
| append("<legend>Login Details</legend>"). // TODO: i18n | |
| appendTo(form); | |
| el = $("<dl />").appendTo(el); | |
| $("<dt />").text(opts.usernameLabel).appendTo(el); | |
| $("<dd />"). | |
| append('<input type="text" />'). | |
| appendTo(el); | |
| $("<dt />").text(opts.passwordLabel).appendTo(el); | |
| $("<dd />"). | |
| append('<input type="password" />'). | |
| appendTo(el); | |
| $("<fieldset />"). | |
| append("<legend>Submit</legend>"). // TODO: i18n | |
| append('<input type="submit" value="OK" />'). // TODO: i18n | |
| append('<input type="reset" value="Cancel" />'). // TODO: i18n | |
| appendTo(form); | |
| form.appendTo(this); | |
| form.submit(opts.submit); | |
| }; | |
| $.fn.simpleLogin.defaults = { | |
| containerId: "login", | |
| submit: function() { return false; }, | |
| usernameLabel: "Username", | |
| passwordLabel: "Password" | |
| }; | |
| })(jQuery); | |
| /*]]>*/ | |
| </script> | |
| <script type="text/javascript"> | |
| /*<![CDATA[*/ | |
| // DEBUG | |
| jQuery(function() { | |
| jQuery(document.body).simpleLogin({ | |
| submit: function() { | |
| var username = jQuery("input[type=text]", this).val(); | |
| var password = jQuery("input[type=password]", this).val(); | |
| console.log(username, password); | |
| var host = "http://tiddlyweb.peermore.com"; | |
| if(document.location.protocol.indexOf("http") == -1 && | |
| window.Components && window.netscape && | |
| window.netscape.security) { | |
| window.netscape.security.PrivilegeManager. | |
| enablePrivilege("UniversalBrowserRead"); | |
| } | |
| jQuery.post(host, { user: username, password: password }, | |
| function() { console.log({ args: arguments }); }); | |
| return false; | |
| } | |
| }); | |
| }); | |
| /*]]>*/ | |
| </script> | |
| </head> | |
| <body> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment