mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-12 19:30:00 +01:00
Expand out offline app features for smoother cache clearing and version tracking (#1384)
* Add version number to bottom * Get latest version number from GitHub * Create versionManagement.js Fetching the latest and local version number is now done through versionManagement.js * Add popup to prompt for refresh when a new version is available A new version is available whenever the sw.js file is changed. * Add version number fixed in top right corner * Fix Codeclimate issues * Update versionManagement.js * Update versionManagement.js * Make update prompt appear at front of page Changed z-index * Delete unecessary code * Create task to automatically update sw.js Used grunt-text-replace * Uninstall semver * Add replace task to serve and production tasks * Update demo.js Make version statements more descriptive. * Update versionManagement.js Remove unused versionCompare function * Change URL for getting latest version Changed the URL for getting the latest NPM version to be based on the package.json file's attribute for "homepage". * Update index.html * Update demo.css * Added explanatory comments * Update versionManagement.js * Update versionManagement.js * Updates for readability Changed single-line comments to multiline comments. * Update versionManagement.js * Update versionManagement.js Co-authored-by: Harsh Khandeparkar <34770591+HarshKhandeparkar@users.noreply.github.com> Co-authored-by: Jeffrey Warren <jeff@unterbahn.com>
This commit is contained in:
committed by
Jeffrey Warren
parent
ab793bcf4e
commit
00ed0f148d
43
examples/lib/versionManagement.js
Normal file
43
examples/lib/versionManagement.js
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Functions for getting version information.
|
||||
* Note: these functions are not used by the service worker to check for updates;
|
||||
* the service worker updates whenever sw.js has changed.
|
||||
* sw.js is changed when grunt replace:version is run. This task is run during
|
||||
* grunt build, serve, and productions tasks.
|
||||
*/
|
||||
|
||||
const package = require('../../package.json');
|
||||
|
||||
/**
|
||||
* Get the current version number from package.json on the homepage.
|
||||
* @param {function} callback The function that uses the version number.
|
||||
*/
|
||||
function getLatestVersionNumber(callback) {
|
||||
// Get the homepage reference from the local package.json.
|
||||
var homepage = package.homepage;
|
||||
var request = new XMLHttpRequest();
|
||||
request.onreadystatechange = function() {
|
||||
if (request.readyState == 4 && request.status == 200) {
|
||||
var response = JSON.parse(this.responseText);
|
||||
var latestVersionNumber = response.version;
|
||||
|
||||
// Do something with the version number using a callback function.
|
||||
if (callback)
|
||||
callback(latestVersionNumber);
|
||||
}
|
||||
}
|
||||
|
||||
// Get the package.json file from online using a GET request.
|
||||
request.open("GET", homepage + "/package.json", true);
|
||||
request.send();
|
||||
}
|
||||
|
||||
// Get the version number from the local package.json file.
|
||||
function getLocalVersionNumber() {
|
||||
return package.version;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getLatestVersionNumber,
|
||||
getLocalVersionNumber
|
||||
}
|
||||
Reference in New Issue
Block a user