4 var providers_large = {
7 url: 'https://www.google.com/accounts/o8/id'
11 url: 'http://yahoo.com/'
15 label: 'Enter your AOL screenname.',
16 url: 'http://openid.aol.com/{username}'
20 label: 'Enter your OpenID.',
24 var providers_small = {
27 label: 'Enter your MyOpenID username.',
28 url: 'http://{username}.myopenid.com/'
32 label: 'Enter your Livejournal username.',
33 url: 'http://{username}.livejournal.com/'
37 label: 'Enter your Flickr username.',
38 url: 'http://flickr.com/{username}/'
42 label: 'Enter your Technorati username.',
43 url: 'http://technorati.com/people/technorati/{username}/'
47 label: 'Enter your Wordpress.com username.',
48 url: 'http://{username}.wordpress.com/'
52 label: 'Your Blogger account',
53 url: 'http://{username}.blogspot.com/'
57 label: 'Your Verisign username',
58 url: 'http://{username}.pip.verisignlabs.com/'
62 label: 'Your Vidoop username',
63 url: 'http://{username}.myvidoop.com/'
67 label: 'Your Verisign username',
68 url: 'http://{username}.pip.verisignlabs.com/'
72 label: 'Your ClaimID username',
73 url: 'http://claimid.com/{username}'
76 var providers = $.extend({}, providers_large, providers_small);
80 cookie_expires: 6*30, // 6 months.
81 cookie_name: 'openid_provider',
84 img_path: '/media/images/openid/',
89 init: function(input_id) {
91 var openid_btns = $('#openid_btns');
92 this.input_id = input_id;
94 $('#openid_choice').show();
95 //$('#openid_input_area').empty();
97 // add box for each provider
98 for (id in providers_large) {
99 openid_btns.append(this.getBoxHTML(providers_large[id], 'large', '.gif'));
101 if (providers_small) {
102 openid_btns.append('<br/>');
103 for (id in providers_small) {
104 openid_btns.append(this.getBoxHTML(providers_small[id], 'small', '.ico'));
108 var box_id = this.readCookie();
110 this.signin(box_id, true);
113 getBoxHTML: function(provider, box_size, image_ext) {
115 var box_id = provider["name"].toLowerCase();
116 return '<a title="'+provider["name"]+'" href="javascript: openid.signin(\''+ box_id +'\');"' +
117 ' style="background: #FFF url(' + this.img_path + box_id + image_ext+') no-repeat center center" ' + 'class="' + box_id + ' openid_' + box_size + '_btn"></a>';
120 /* Provider image click */
121 signin: function(box_id, onload) {
122 var provider = providers[box_id];
126 this.highlight(box_id);
127 this.setCookie(box_id);
129 $('#'+this.input_id).val(provider['url']);
130 var input = $('#'+this.input_id);
131 if(document.selection){
132 var r = document.all.openid_url.createTextRange();
133 var res = r.findText("{username}");
139 var text = input.val();
140 var searchText = "{username}";
141 var posStart = text.indexOf(searchText);
144 document.getElementById(this.input_id).setSelectionRange(posStart, posStart + searchText.length);
149 highlight: function (box_id) {
150 // remove previous highlight.
151 var highlight = $('#openid_highlight');
153 highlight.replaceWith($('#openid_highlight a')[0]);
155 // add new highlight.
156 $('.'+box_id).wrap('<div id="openid_highlight"></div>');
159 setCookie: function (value) {
160 var date = new Date();
161 date.setTime(date.getTime()+(this.cookie_expires*24*60*60*1000));
162 var expires = "; expires="+date.toGMTString();
163 document.cookie = this.cookie_name+"="+value+expires+"; path=" + this.cookie_path;
166 readCookie: function () {
167 var nameEQ = this.cookie_name + "=";
168 var ca = document.cookie.split(';');
169 for(var i=0;i < ca.length;i++) {
171 while (c.charAt(0)==' ') c = c.substring(1,c.length);
172 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);