| script.appendChild(d.createTextNode("\n(function(){\n\n\tfunction addEvent(obj, type, fn){\n\t\tif(obj.attachEvent){\n\t\t\tobj['e'+type+fn] = fn;\n\t\t\tobj[type+fn] = function(){obj['e'+type+fn](window.event);}\n\t\t\tobj.attachEvent('on'+type, obj[type+fn]);\n\t\t}else\n\t\t\tobj.addEventListener( type, fn, false );\n\t}\n\n\tfunction removeEvent(obj, type, fn){\n\t\tif(obj.detachEvent){\n\t\t\tobj.detachEvent('on'+type, obj[type+fn]);\n\t\t\tobj[type+fn] = null;\n\t\t}else\n\t\t\tobj.removeEventListener( type, fn, false );\n\t}\n\n\tfunction cloneArray(arr){\n\t\tvar res = [];\n\t\tfor(var i=0,l=arr.length;i<l;i++){\n\t\t\tres[i] = arr[i];\n\t\t}\n\t\treturn res;\n\t}\n\t\n\tvar tubewall = {\n\n\t\tregLink: \/^https?:\\\/\\\/www\\.youtube\\.com\\\/watch\\?(?:.*&)?v=([_\\-\\d\\w]+)\/gi,\n\t\tregPlayer: \/^https?:\\\/\\\/www\\.youtube\\.com\\\/v\\\/([_\\-\\d\\w]+)\/gi,\n\n\t\trun: function(){\n\t\t\tvar p = tubewall.process;\n\t\t\taddEvent(document, 'DOMNodeInserted', function(e){\n\t\t\t\tp((e.target||e.srcElement));\n\t\t\t});\n\t\t\tp();\n\t\t},\n\n\t\tprocess: function(elem){\n\t\t\ttubewall.processLink(elem);\n\t\t\ttubewall.processPlayer(elem);\n\t\t},\n\n\t\tprocessLink: function(elem){\n\t\t\telem = elem || document;\n\n\t\t\tif(!elem.getElementsByTagName)\n\t\t\t\treturn;\n\n\t\t\tvar a = elem.getElementsByTagName('a');\n\t\t\n\t\t\tfor(var i=0,l = a.length; i<l; i++){\n\t\t\t\tvar m;\n\t\t\t\twhile((m = tubewall.regLink.exec(a[i].href)) != null){\n\t\t\t\t\ta[i].href = \"http:\\\/\\\/tubewall.isgreat.org\\\/watch\\\/{videoId}\".replace('{videoId}',m[1]);\n\t\t\t\t\ta[i].className += ' tubewall-link';\n\t\t\t\t\tif(window.location.host.indexOf('www.google.com') != -1){\n\t\t\t\t\t\ta[i].setAttribute('onmousedown',''); \/\/\u53bb\u6389\u94fe\u63a5\u8ffd\u8e2a\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t},\n\n\t\tprocessPlayer: function(elem){\n\t\t\telem = elem || document;\n\n\t\t\tif(!elem.getElementsByTagName)\n\t\t\t\treturn;\n\t\t\t\n\t\t\ttubewall._replaceObject(elem);\n\t\t\ttubewall._replaceEmbed(elem);\n\t\t},\n\n\t\t_replaceObject: function(elem){\n\n\t\t\tvar objects = cloneArray(elem.getElementsByTagName('object'));\n\n\t\t\tfor(var i=0,li = objects.length; i<li; i++) {\n\t\t\t\tvar o = objects[i];\n\t\t\t\tvar params = o.getElementsByTagName('param');\n\t\t\t\tvar width = o.getAttribute('width');\n\t\t\t\tvar height = o.getAttribute('height');\n\t\t\t\n\t\t\t\tfor(var j=0,lj = params.length; j<lj; j++) {\n\t\t\t\t\tvar p = params[j];\n\t\t\t\t\tvar n = p.getAttribute('name');\n\t\t\t\t\tvar v = p.getAttribute('value');\n\t\t\t\t\tvar m = null;\n\t\t\t\t\tif(n == 'movie' && (m = tubewall.regPlayer.exec(v)) != null){\n\t\t\t\t\t\tvar player = tubewall.createPlayer(m[1],width,height);\n\t\t\t\t\t\to.parentNode.insertBefore(player, o.nextSibling);\n\t\t\t\t\t\to.parentNode.removeChild(o);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\t\t},\n\n\t\t_replaceEmbed: function(elem){\n\n\t\t\tvar embed = cloneArray(elem.getElementsByTagName('embed'));\n\n\t\t\tfor(var i=0,l = embed.length; i<l; i++) {\n\t\t\t\tvar e = embed[i];\n\t\t\t\tvar src = e.getAttribute('src');\n\t\t\t\tvar width = e.getAttribute('width');\n\t\t\t\tvar height = e.getAttribute('height');\n\t\t\t\tvar m = null;\n\t\t\t\twhile((m = tubewall.regPlayer.exec(src)) != null){\n\t\t\t\t\tvar player = tubewall.createPlayer(m[1],width,height);\n\t\t\t\t\te.parentNode.insertBefore(player, e.nextSibling);\n\t\t\t\t\te.parentNode.removeChild(e);\n\t\t\t\t\tsrc = null;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t\n\t\tlistCache: {},\n\n\t\tcreatePlayer: function(videoId, width, height){\n\t\t\twidth = width || 640;\n\t\t\theight = height || 505;\n\n\t\t\tvar flashvars = 'file='+ encodeURIComponent(\"http:\\\/\\\/tubewall.isgreat.org\\\/cloud-tube\\\/lite.php?id={videoId}&video.mp4\".replace('{videoId}',videoId));\n\n\t\t\tvar player = document.createElement('div');\n\t\t\tplayer.className = 'tubewall-player';\n\n\t\t\tvar playerFlash = document.createElement('div');\n\t\t\tplayerFlash.className = 'tubewall-player-flash';\n\n\t\t\tvar playerToolbar = document.createElement('div');\n\t\t\tplayerToolbar.className = 'tubewall-player-toolbar';\n\n\t\t\tvar title = document.createElement('span');\n\t\t\ttitle.innerHTML = '<b>~Cloud Tube~<\/b>';\n\n\t\t\tvar showList = document.createElement('input');\n\t\t\tshowList.setAttribute('type','button');\n\t\t\tshowList.setAttribute('value','Download');\n\t\t\taddEvent(showList, 'click', function(){\n\t\t\t\tif(tubewall.listCache[videoId]){\n\t\t\t\t\tplayerToolbar.appendChild(tubewall.listCache[videoId]);\n\t\t\t\t}else{\n\t\t\t\t\ttubewall.getDownloadList(videoId, function(json){\n\t\t\t\t\t\ttubewall.listCache[videoId] = tubewall.createList(json);\n\t\t\t\t\t\tplayerToolbar.appendChild(tubewall.listCache[videoId]);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t\tplayerToolbar.appendChild(title);\n\t\t\tplayerToolbar.appendChild(showList);\n\n\t\t\tvar src = \"http:\\\/\\\/developer.longtailvideo.com\\\/player\\\/tags\\\/mediaplayer-5.0\\\/player.swf\";\n\n\t\t\tplayerFlash.innerHTML='<object width=\"480\" height=\"385\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\">'\n\t\t\t\t+ '<param name=\"movie\" value=\"'+src+'\"><\/param>'\n\t\t\t\t+ '<param name=\"allowFullScreen\" value=\"true\"><\/param>'\n\t\t\t\t+ '<param name=\"allowscriptaccess\" value=\"always\"><\/param>'\n\t\t\t\t+ '<param name=\"flashvars\" value=\"'+flashvars+'\"><\/param>'\n\t\t\t\t+'<embed '\n\t\t\t\t+' src=\"'+src+'\"'\n\t\t\t\t+' quality=\"high\"'\n\t\t\t\t+' allowfullscreen=\"true\"'\n\t\t\t\t+' wmode=\"Transparent\"'\n\t\t\t\t+' type=\"application\/x-shockwave-flash\"'\n\t\t\t\t+' width=\"'+width+'\"'\n\t\t\t\t+' height=\"'+height+'\"'\n\t\t\t\t+' flashvars=\"'+flashvars+'\"'\n\t\t\t\t+' ><\/embed>'\n\t\t\t+'<\/object>'\n\t\t\t;\n\n\t\t\tplayer.appendChild(playerFlash);\n\t\t\tplayer.appendChild(playerToolbar);\n\n\t\t\treturn player;\n\n\t\t},\n\n\t\tcreateList: function(list){\n\t\t\tvar s = document.createElement('select'),o;\n\t\t\to = document.createElement('option');\n\t\t\to.innerHTML = '== Select a format ==';\n\t\t\ts.appendChild(o);\n\t\t\tfor(var i = 0, l = list.length; i<l; i++){\n\t\t\t\to = document.createElement('option');\n\t\t\t\to.setAttribute('value', list[i]['url']);\n\t\t\t\to.innerHTML = list[i]['name'];\n\t\t\t\ts.appendChild(o);\n\t\t\t}\n\t\t\taddEvent(s,'change',function(e){\n\t\t\t\tvar t=(e.target || e.srcElement);\n\t\t\t\tvar url = t.options[t.selectedIndex].value;\n\t\t\t\tif(url!=null&&url!='')\n\t\t\t\t\twindow.location = url;\n\t\t\t});\n\t\t\treturn s;\n\t\t},\n\n\t\tjsonpCount: Number(new Date),\n\n\t\tgetDownloadList: function(videoId, callback){\n\n\t\t\tvar jp = 'tubewall_list_' + tubewall.jsonpCount ++;\n\n\t\t\twindow[jp] = function(json){\n\n\t\t\t\tcallback(json);\n\n\t\t\t\twindow[jp] = undefined;\n\t\t\t\ttry{\n\t\t\t\t\tdelete window[jp];\n\t\t\t\t}catch(e){}\n\t\t\t\tif(head){\n\t\t\t\t\thead.removeChild(script);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tvar head = document.getElementsByTagName('head')[0] || document.documentElement;\n\t\t\tvar script = document.createElement('script');\n\t\t\tscript.src = \"http:\\\/\\\/tubewall.isgreat.org\\\/download\\\/list\\\/{videoId}?callback={jp}\".replace('{videoId}',videoId).replace('{jp}',jp);\n\t\t\thead.insertBefore(script, head.firstChild);\n\t\t\t\n\t\t}\n\t\t\n\t};\n\n\ttubewall.run();\n\n})();\n"));
| |