src/interface.js
// createMenuItemGroup() - Creates a sub-group for a set of related streams
Creates a sub-group for a set of related streams
Creates a sub - group for a set of related streams
function createMenuItemGroup(streams)
	{
		var itemGroup = document.createElement("div"),
		    size = document.createElement("div"),
		    mainLink = document.createElement("a"),
		    mainId = nextId ++;
		itemGroup.className = "ytd-item-group";
		itemGroup.style.minWidth = streams.length * 64 + 48 + "px";
		size.className = "ytd-item-size yt-uix-button-menu-item";
		mainLink.className = "ytd-item ytd-item-main yt-uix-button-menu-item";
		mainLink.setAttribute("id", "ytd-" + mainId);
		mainLink.setAttribute("title", formatTitle(streams[0]));
		links.push({ stream: streams[0], anchor: mainLink });
		updateLink(StreamMap.getURL(streams[0]), "ytd-" + mainId);
		if (rtl)
			mainLink.style.marginLeft = (streams.length - 1) * 64 + "px";
		else
			mainLink.style.marginRight = (streams.length - 1) * 64 + "px";
		mainLink.addEventListener("contextmenu", function(e) {
			e.stopPropagation();
		}, false);
		size.appendChild(document.createTextNode(streams[0].height + "p\u00a0"));
		mainLink.appendChild(size);
		mainLink.appendChild(document.createTextNode((streams[0].stereo3d ? "3D " : "") + streams[0].container));
		itemGroup.appendChild(mainLink);
		for (var i = 1, max = streams.length; i < max; i ++)
		{
			var subLink = document.createElement("a"),
			    subId = nextId ++;
			subLink.className = "ytd-item-sub yt-uix-button-menu-item";
			subLink.setAttribute("id", "ytd-" + subId);
			subLink.setAttribute("title", formatTitle(streams[i]));
			if (streams[i].audio)
				Audio.updateLink(streams[i], subLink);
			else
			{
				links.push({ stream: streams[i], anchor: subLink });
				updateLink(StreamMap.getURL(streams[i]), "ytd-" + subId);
			}
			if (rtl)
				subLink.style.left = (streams.length - i - 1) * 64 + "px";
			else
				subLink.style.right = (streams.length - i - 1) * 64 + "px";
			subLink.addEventListener("contextmenu", function(e) {
				e.stopPropagation();
			}, false);
			subLink.appendChild(document.createTextNode(
				(streams[i].audio ? streams[i].acodec : (streams[i].stereo3d ? "3D " : "") + streams[i].container)
			));
			itemGroup.appendChild(subLink);
		}
		return itemGroup;
	}
function createMenuItemGroup ( streams ) { var itemGroup = document . createElement ( "div" ) , size = document . createElement ( "div" ) , mainLink = document . createElement ( "a" ) , mainId = nextId ++ ; itemGroup . className = "ytd-item-group" ; itemGroup . style . minWidth = streams . length * 64 + 48 + "px" ; size . className = "ytd-item-size yt-uix-button-menu-item" ; mainLink . className = "ytd-item ytd-item-main yt-uix-button-menu-item" ; mainLink . setAttribute ( "id" , "ytd-" + mainId ) ; mainLink . setAttribute ( "title" , formatTitle ( streams [ 0 ] ) ) ; links . push ( { stream : streams [ 0 ] , anchor : mainLink } ) ; updateLink ( StreamMap . getURL ( streams [ 0 ] ) , "ytd-" + mainId ) ; if ( rtl ) mainLink . style . marginLeft = ( streams . length - 1 ) * 64 + "px" ; else mainLink . style . marginRight = ( streams . length - 1 ) * 64 + "px" ; mainLink . addEventListener ( "contextmenu" , function ( e ) { e . stopPropagation ( ) ; } , false ) ; size . appendChild ( document . createTextNode ( streams [ 0 ] . height + "p\u00a0" ) ) ; mainLink . appendChild ( size ) ; mainLink . appendChild ( document . createTextNode ( ( streams [ 0 ] . stereo3d ? "3D " : "" ) + streams [ 0 ] . container ) ) ; itemGroup . appendChild ( mainLink ) ; for ( var i = 1 , max = streams . length ; i < max ; i ++ ) { var subLink = document . createElement ( "a" ) , subId = nextId ++ ; subLink . className = "ytd-item-sub yt-uix-button-menu-item" ; subLink . setAttribute ( "id" , "ytd-" + subId ) ; subLink . setAttribute ( "title" , formatTitle ( streams [ i ] ) ) ; if ( streams [ i ] . audio ) Audio . updateLink ( streams [ i ] , subLink ) ; else { links . push ( { stream : streams [ i ] , anchor : subLink } ) ; updateLink ( StreamMap . getURL ( streams [ i ] ) , "ytd-" + subId ) ; } if ( rtl ) subLink . style . left = ( streams . length - i - 1 ) * 64 + "px" ; else subLink . style . right = ( streams . length - i - 1 ) * 64 + "px" ; subLink . addEventListener ( "contextmenu" , function ( e ) { e . stopPropagation ( ) ; } , false ) ; subLink . appendChild ( document . createTextNode ( ( streams [ i ] . audio ? streams [ i ] . acodec : ( streams [ i ] . stereo3d ? "3D " : "" ) + streams [ i ] . container ) ) ) ; itemGroup . appendChild ( subLink ) ; } return itemGroup ; }
createMenuItemGroup() - Creates a sub-group for a set of related streams
createMenuItemGroup () - Creates a sub - group for a set of related streams
// Create the button group and the size label ("360p", "480p", etc.) // Create the main video link // Prevent right-click closing the menu in Chrome // Append the main link to the button group // Create each sublink // Prevent right-click closing the menu in Chrome // Append the sublink to the button group