function main()

in www/static/js/404.js [75:119]


    function main() {

        var url = window.location.href;

        if (!isDocsURL(url)) {
            return;
        }

        // get related URLs
        var rootURL = getRootURL(url);
        var devURL = getDevURL(url);
        var newURL  = transformOldURL(url);

        // try the root URL
        $.ajax({
            url: rootURL,
            statusCode: {

                // if the root exists, check if the new URL exists
                200: function () {
                    $.ajax({
                        url: newURL,
                        statusCode: {

                            // redirect to the new URL if it exists
                            200: function () {
                                showNewRedirect(newURL)
                            },

                            // if the new URL doesn't exist, redirect to root
                            404: function() {
                                showRootRedirect(rootURL)
                            }
                        }
                    });
                },

                // if root doesn't exist, assume that the version
                // is invalid and redirect to dev
                404: function () {
                    showDevRedirect(devURL)
                }
            }
        });
    }