| | 104 | } |
| | 105 | function convert(str){ |
| | 106 | function createHTML(all, extension){ |
| | 107 | var str = ''; |
| | 108 | if (/\.(jpe?g|gif|png|bmp)$/.test(extension)){ |
| | 109 | str = '<img src="'+all+'"/>'; |
| | 110 | } else if (/^http:\/\/www\.youtube\.com\/(?:watch\?v=|v\/)([-\w]+)$/.test(all)){ |
| | 111 | var url = "http://www.youtube.com/v/" + RegExp.$1; |
| | 112 | str = '<a href="#" class="hl-URL">' + url + '</a>\n' + |
| | 113 | '<div><object height="250" width="300">' + |
| | 114 | '<param name="movie" value="' + url + '">' + |
| | 115 | '<param name="wmode" value="transparent">' + |
| | 116 | '<embed src="' + url + '" type="application/x-shockwave-flash" wmode="transparent" height="250" width="300">' + |
| | 117 | '</object></div>'; |
| | 118 | } else { |
| | 119 | str = '<a href="#" class="hl-URL">'+all+'</a>'; |
| | 120 | } |
| | 121 | return str; |
| | 122 | } |
| | 123 | return str.replace(/https?:\/\/[^\/]+?\/([^\s]*)/g, createHTML); |