Changeset 34082
- Timestamp:
- 06/21/09 21:43:33 (4 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/vimperator-plugins/trunk/account_switcher.js
r34051 r34082 6 6 * @minVersion 2.1a1pre 7 7 * @author masa138 8 * @version 0.0. 48 * @version 0.0.5 9 9 * ==/VimperatorPlugin== 10 10 * … … 26 26 var afterSLine = targetElem.nextSibling; 27 27 var sbPannel = document.createElementNS(ns, 'statusbarpannel'); 28 var img = sbPannel.appendChild(document.createElementNS(ns, 'image')); 28 29 sbPannel.id = 'account-switcher-pannel'; 29 var img = document.createElementNS(ns, 'image');30 sbPannel.appendChild(img);31 30 32 31 var _services = { … … 89 88 90 89 function changeAccount(user) { 90 var service = services[accounts[user].host]; 91 if (service.host == null || service.logout == null) return; 92 91 93 var username = accounts[user].username; 92 94 var password = accounts[user].password; 93 var service = services[accounts[user].host];94 95 95 var req = new XMLHttpRequest(); 96 if (service.host == null) return; 97 if (service.logout == null) return; 98 var url = (service.logout.indexOf('http') == -1) ? service.host + service.logout : service.logout; 96 var url = (service.logout.indexOf('http') != 0) ? service.host + service.logout : service.logout; 99 97 req.open("POST", url, true); 100 98 req.onload = function(e) { 99 if (service.login == null || service.id == null || service.pw == null) return; 101 100 var req = new XMLHttpRequest(); 102 if (service.login == null) return; 103 var url = (service.login.indexOf('http') == -1) ? service.host + service.login : service.login; 101 var url = (service.login.indexOf('http') != 0) ? service.host + service.login : service.login; 104 102 req.open("POST", url, true); 105 103 req.onload = function(e) { … … 110 108 content.location.reload(); 111 109 } 112 if (service.host.match(/hatena\.ne\.jp/)) { 110 var needle = '.hatena.ne.jp'; 111 if (service.host.toLowerCase().lastIndexOf(needle) == service.host.length - needle.length) { 113 112 img.setAttribute('src', 'http://www.hatena.ne.jp/users/' + username.substr(0, 2) + '/' + username + '/profile_s.gif'); 114 113 if (!document.getElementById('account_switcher_pannel')) { … … 120 119 } 121 120 } 122 } 123 req.onerror = function(e) { liberator.echoerr('Login error in account_switcher.js'); } 121 }; 122 req.onerror = function(e) { liberator.echoerr('Login error in account_switcher.js'); }; 124 123 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 125 if (service.id == null || service.pw == null) return;126 124 req.send( 127 125 service.id + '=' + encodeURIComponent(username) + '&' + … … 129 127 ); 130 128 nowLogin[user.substr(user.lastIndexOf('@') + 1)] = user; 131 } 132 req.onerror = function(e) { liberator.echoerr('Logout error in account_switcher.js'); } 129 }; 130 req.onerror = function(e) { liberator.echoerr('Logout error in account_switcher.js'); }; 133 131 req.send(null); 134 132 } … … 136 134 commands.addUserCommand(["account"], "Change Account", 137 135 function(args) { 138 if ( !args) {136 if (!args) { 139 137 liberator.echo("Usage: account {username}@{servicename}"); 140 138 } else { … … 156 154 var user = args[i]; 157 155 if (user != '') { 158 compls = compls.filter(function(c) { return c[0].indexOf(user) != -1 });156 compls = compls.filter(function(c) c[0].indexOf(user) != -1); 159 157 } 160 158 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)