diff options
author | binji@chromium.org <binji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-07 19:32:40 +0000 |
---|---|---|
committer | binji@chromium.org <binji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-07 19:32:40 +0000 |
commit | 15d749459edf57adef241738c837730b58fa44a3 (patch) | |
tree | 84995819a5fda6e58e4a468d02b9ef46398d2aa1 /native_client_sdk/src/web | |
parent | 7fd1039423b41450b5cbdcb7d0f38198ca1320ae (diff) | |
download | chromium_src-15d749459edf57adef241738c837730b58fa44a3.zip chromium_src-15d749459edf57adef241738c837730b58fa44a3.tar.gz chromium_src-15d749459edf57adef241738c837730b58fa44a3.tar.bz2 |
[NaCl SDK] Some improvements to the manifest viewer page.
* Highlight the ">>> Looking for..." lines
* Show the "Missing archives" lines in red.
* Show the trunk revision for each bundle. This is often more useful than the
revision, because you can more easily see if a change is available in that
SDK. (not sure what this is going to do after flag day)
* Show the Chrome version for each bundle.
BUG=none
R=sbc@chromium.org
NOTRY=true
Review URL: https://codereview.chromium.org/269243004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@268896 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'native_client_sdk/src/web')
-rw-r--r-- | native_client_sdk/src/web/manifest.html | 168 |
1 files changed, 138 insertions, 30 deletions
diff --git a/native_client_sdk/src/web/manifest.html b/native_client_sdk/src/web/manifest.html index 7da5a3f..4b6a075 100644 --- a/native_client_sdk/src/web/manifest.html +++ b/native_client_sdk/src/web/manifest.html @@ -45,6 +45,18 @@ td a { padding: 3px; } + + #log > span { + display: block; + } + + #log > span.highlight { + font-weight: bold; + } + + #log > span.missing { + color: #f00; + } </style> <body> <h1>NaCl SDK Manifest Viewer</h1> @@ -55,8 +67,8 @@ </tbody> </table> <h2>Most recent upload log:</h2> - <pre id="log"> - </pre> + <div id="log"> + </div> <script type="application/javascript"> function loadText(url, callback) { var xhr = new XMLHttpRequest(); @@ -66,7 +78,7 @@ if (xhr.status == 200) { callback(xhr.responseText); } else { - alert("Failed to load: error " + xhr.status); + console.log("Failed to load "+url+": error " + xhr.status); } } } @@ -96,49 +108,145 @@ // Create the column headers. var tr = document.createElement('tr'); var columns = [ - 'name', 'version', 'revision', 'win', 'mac', 'linux', 'all' + 'name', 'version', 'revision', 'trunk_revision', 'chrome_version', 'win', 'mac', 'linux', 'all' ]; - for (var i = 0; i < columns.length; ++i) { + columns.forEach(function(column) { var td = document.createElement('td'); - var text = document.createTextNode(columns[i]); + var text = document.createTextNode(column); td.appendChild(text); tr.appendChild(td); - } + }); columnsElm.appendChild(tr); - var platforms = ['win', 'mac', 'linux', 'all']; - - for (var i = 0; i < data.length; ++i) { + data.forEach(function(row) { var tr = document.createElement('tr'); - for (var j = 0; j < columns.length; ++j) { + columns.forEach(function(column) { var td = document.createElement('td'); - var node; - if (platforms.indexOf(columns[j]) != -1) { - var archives = data[i].archives; - for (var k = 0; k < archives.length; ++k) { - if (columns[j] == archives[k].host_os) { - var url = archives[k].url; - var lastSlash = url.lastIndexOf('/'); - var nextDot = url.indexOf('.', lastSlash); - name = url.substr(lastSlash + 1, nextDot - lastSlash - 1); - node = document.createElement('a'); - node.setAttribute('href', url); - node.appendChild(document.createTextNode(name)); - td.appendChild(node); - } - } - } else { - node = document.createTextNode(data[i][columns[j]]); + var node = makeCell(row, column); + if (node) { td.appendChild(node); } tr.appendChild(td); - } + }); rowsElm.appendChild(tr); + }); + } + + function makeCell(row, column) { + var platforms = ['win', 'mac', 'linux', 'all']; + + if (platforms.indexOf(column) !== -1) { + return makePlatformCell(row, column); + } else if (column === 'trunk_revision') { + return makeTrunkRevisionCell(row); + } else if (column === 'chrome_version') { + return makeChromeVersionCell(row); + } else { + return document.createTextNode(row[column]); } } + function makePlatformCell(row, column) { + var archives = row.archives; + for (var k = 0; k < archives.length; ++k) { + if (column !== archives[k].host_os) { + continue; + } + + // Convert the URL to a short name: + // https://.../36.0.1974.2/naclsdk_linux.tar.bz2 -> naclsdk_linux + var url = archives[k].url; + var lastSlash = url.lastIndexOf('/'); + var nextDot = url.indexOf('.', lastSlash); + var name = url.substr(lastSlash + 1, nextDot - lastSlash - 1); + + var node = document.createElement('a'); + node.setAttribute('href', url); + node.appendChild(document.createTextNode(name)); + return node; + } + return null; + } + + function makeTrunkRevisionCell(row) { + var url = row.archives[0].url; + var version = versionFromUrl(url); + if (version) { + var node = document.createTextNode(''); + baseTrunkRevisionFromVersion(version, function(node) { + return function(revision) { + node.textContent = revision; + }; + }(node)); + return node; + } + return null; + } + + function makeChromeVersionCell(row) { + var url = row.archives[0].url; + var version = versionFromUrl(url); + if (version) { + return document.createTextNode(version); + } + return null; + } + + function versionFromUrl(url) { + // Extract the Chrome version from an archive URL. + // It should look something like: + // https://storage.googleapis.com/nativeclient-mirror/nacl/nacl_sdk/36.0.1974.2/naclsdk_win.tar.bz2 + var lastSlash = url.lastIndexOf('/'); + var penultimateSlash = url.lastIndexOf('/', lastSlash - 1); + // The version is between these two slashes. + var version = url.substr(penultimateSlash + 1, + lastSlash - penultimateSlash - 1); + // It is a chrome version if it matches one of these regexes: + if (/trunk\.\d+/.test(version)) { + // Trunk version. + return version; + } else if (/\d+\.\d+\.\d+\.\d+/.test(version)) { + // Branch version. + return version; + } else { + // Not a version. + return null; + } + } + + function baseTrunkRevisionFromVersion(version, callback) { + if (version.indexOf('trunk', 0) === 0) { + callback(version.substr(6)); // Skip "trunk." + } else { + revisionFromVersion(baseTrunkVersionFromVersion(version), callback); + } + } + + function baseTrunkVersionFromVersion(version) { + var lastDot = version.lastIndexOf('.'); + return version.substr(0, lastDot) + '.0'; + } + + function revisionFromVersion(version, callback) { + var url = 'http://omahaproxy.appspot.com/revision.json?version='+version; + loadJson(url, function(data) { + callback(data.chromium_revision); + }); + } + function displayLog(text) { - document.getElementById('log').textContent = text; + var lines = text.split('\n'); + var logEl = document.getElementById('log'); + lines.forEach(function (line) { + var spanEl = document.createElement('span'); + spanEl.textContent = line; + if (line.indexOf('>>>', 0) === 0) { + spanEl.classList.add('highlight'); + } else if (line.indexOf('Missing archives') !== -1) { + spanEl.classList.add('missing'); + } + logEl.appendChild(spanEl); + }); } loadJson('naclsdk_manifest2.json', display); |