diff options
author | teramako | 2008-09-22 16:03:41 +0000 |
---|---|---|
committer | teramako | 2008-09-22 16:03:41 +0000 |
commit | 45302a33da999c7beccb5250b6d8d6e0978f5793 (patch) | |
tree | c8ef99b9890882ccb1d8391f56667869faf7db1d | |
parent | be4d8ebf619cb3129b5ae90c1e62dcd89f25aa14 (diff) | |
download | vimperator-plugins-45302a33da999c7beccb5250b6d8d6e0978f5793.tar.bz2 |
* URLのAnchor化
* 画像URLの表示
* YouTubeの表示
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@19744 d0d07461-0603-4401-acd4-de1884942a52
-rw-r--r-- | haiku.js | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -84,7 +84,9 @@ ]]></style>.toSource()
.replace(/(?:\r?\n|\r)[ \t]*/g, " ") +
statuses.map(function(status) {
- var text = status.text.substr(status.keyword.length + 1);
+ var text = status.text;
+ if (text.indexOf(status.keyword+"=") == 0) text = status.text.substr(status.keyword.length + 1);
+ text = convert(text);
return <>
<img src={status.user.profile_image_url}
alt={status.user.screen_name}
@@ -100,6 +102,26 @@ //liberator.log(html);
liberator.echo(html, true);
}
+ function convert(str){
+ function createHTML(all, extension){
+ var str = '';
+ if (/\.(jpe?g|gif|png|bmp)$/.test(extension)){
+ str = '<img src="'+all+'"/>';
+ } else if (/^http:\/\/www\.youtube\.com\/(?:watch\?v=|v\/)([-\w]+)$/.test(all)){
+ var url = "http://www.youtube.com/v/" + RegExp.$1;
+ str = '<a href="#" class="hl-URL">' + url + '</a>\n' +
+ '<div><object height="250" width="300">' +
+ '<param name="movie" value="' + url + '">' +
+ '<param name="wmode" value="transparent">' +
+ '<embed src="' + url + '" type="application/x-shockwave-flash" wmode="transparent" height="250" width="300">' +
+ '</object></div>';
+ } else {
+ str = '<a href="#" class="hl-URL">'+all+'</a>';
+ }
+ return str;
+ }
+ return str.replace(/https?:\/\/[^\/]+?\/([^\s]*)/g, createHTML);
+ }
liberator.commands.addUserCommand(["haiku"], "Change Haiku status",
function(arg, special){
var password;
|