diff options
author | Timothy Gu <timothygu99@gmail.com> | 2015-07-06 00:30:36 (GMT) |
---|---|---|
committer | Timothy Gu <timothygu99@gmail.com> | 2015-07-06 00:30:36 (GMT) |
commit | 8cf0795e34e26a7c4bc728ae51af84767b250bad (patch) | |
tree | 0a8c9bb8e4cc546ded0aa154fa1a97d2a8b17082 | |
parent | 02ba99b5f749a8e5b33cce32ae07f90a1c0e8552 (diff) | |
parent | 1d875bb2ff7c23455b8f79c1eb421b1f40937f1c (diff) | |
download | mxe-8cf0795e34e26a7c4bc728ae51af84767b250bad.zip mxe-8cf0795e34e26a7c4bc728ae51af84767b250bad.tar.gz mxe-8cf0795e34e26a7c4bc728ae51af84767b250bad.tar.bz2 |
Merge pull request #638 from TobiX/index-versions-cache
index.html versions cache
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 11 | ||||
-rw-r--r-- | index.html | 36 |
3 files changed, 44 insertions, 4 deletions
@@ -4,5 +4,6 @@ /gits/ /log*/ /pkg +/versions.json /wip/ /tmp-* @@ -508,7 +508,7 @@ show-upstream-deps-%: .PHONY: clean clean: - rm -rf $(call TMP_DIR,*) $(PREFIX) build-matrix.html + rm -rf $(call TMP_DIR,*) $(PREFIX) build-matrix.html versions.json .PHONY: clean-pkg clean-pkg: @@ -664,3 +664,12 @@ build-matrix.html: $(foreach PKG,$(PKGS), $(TOP_DIR)/src/$(PKG).mk) @echo '</table>' >> $@ @echo '</body>' >> $@ @echo '</html>' >> $@ + + +versions.json: $(foreach PKG,$(PKGS), $(TOP_DIR)/src/$(PKG).mk) + @echo '{' > $@ + @{$(foreach PKG,$(PKGS), \ + echo ' "$(PKG)": \ + "$($(PKG)_VERSION)",';)} >> $@ + @echo ' "": null' >> $@ + @echo '}' >> $@ @@ -2565,6 +2565,25 @@ local-pkg-list: $(LOCAL_PKG_LIST)</pre> })(); } } + function loadVersionCache(doneCallback, errCallback) { + var request = new XMLHttpRequest(); + request.open('GET', 'versions.json', true); + request.onreadystatechange = function reqCallback() { + if (request.readyState === 4) { + if (request.status === 200) { + try { + var versions = JSON.parse(request.responseText); + doneCallback(versions); + } catch (e) { + errCallback(); + } + } else { + errCallback(); + } + } + } + request.send(); + } function resolveVersions(versions) { var resolvedVersions = {}; for (var package in versions) { @@ -2582,16 +2601,27 @@ local-pkg-list: $(LOCAL_PKG_LIST)</pre> for (package in packageElements) { var element = packageElements[package]; var version = resolvedVersions[package]; + var shorten = version.length > 12; + if (shorten) { + version = version.substring(0, 12); + } var versionEscaped = version.replace('&', '&').replace('<', '<').replace('>', '>'); + if (shorten) { + versionEscaped += '…'; + } var versionHtml = '<td class="version">' + versionEscaped + '</td>'; element.insertAdjacentHTML('afterend', versionHtml); } } (function main() { var packageElements = getPackageElements(); - loadVersions(packageElements, function doneCallback(versions) { - var resolvedVersions = resolveVersions(versions); - showVersions(packageElements, resolvedVersions); + loadVersionCache(function doneCallback(versions) { + showVersions(packageElements, versions); + }, function errCallback() { + loadVersions(packageElements, function doneCallback(versions) { + var resolvedVersions = resolveVersions(versions); + showVersions(packageElements, resolvedVersions); + }); }); })(); </script> |