Version Checking Scriptlet

From Audacity Wiki
Revision as of 16:08, 26 March 2017 by James (talk | contribs) (Category:Webdev)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Scriptlet

There is now a Scriptlet on our WordPress site to check version numbers, and give feedback on the status of the Audacity version. For example it can tell you you are using a version that has not been released yet. We can also use it to inform a user that they are using an alpha version, an RC or a release version.

Audacity has been modified so it now passes a CommitID and date and time of compilation to the script. We can fill in specific messages for specific CommitIDs.

Here is the current script:

<div id="ver_status"></div>
<script type="text/javascript">
    // Stop at the first match.
    versions = [
        "-alpha-",
        "<h2>Get the Official Released Version of Audacity</h2><br>The version of Audacity you are using is an Alpha test version. We strongly recommend that you use our latest stable released version, which has full documentation and support.",
        "from_ver=2.2.",
        "<h2>You are using a future version of Audacity</h2>It is not ready for production use yet.",
        "CommitId",
        "<h2>Get an official Version of Audacity</h2><br>You are using an unknown version of Audacity.",
// from here on there is no CommitID
        "from_ver=2.1.3",
        "<h2>You are using an old or unofficial version of Audacity 2.1.3</h2>This version was never officially released, and is not suitable for production use.",
        "from_ver=2.1.2",
        "<h2>You are using the current version of Audacity</h2>Congratulations.  You are up to date.",
        "from_ver=2.1",
        "<h2>New Version Available</h2>You are using an old version of Audacity.",
        "from_ver=2.",
        "<h2>New Version Available</h2>You are using a very old version of Audacity.",
        "from_ver=1.",
        "<h2>New Version Available</h2>You are using an ancient version of Audacity.",
    ];
    ver_status = document.getElementById( "ver_status");
    urlText = window.location.href;
    for( i=0;i<versions.length;i+=2){
        if( urlText.indexOf( versions[i] ) !== -1 ){
            ver_status.innerHTML = versions[i+1];
            break;

        }
    }
</script>

And here is how it looks on the download page.

Once you are on the download page, you can edit the URL to see how it responds to changes in the URL.