src/extensions/default/InAppNotifications/main.js
function _getNotificationInformation(_notificationInfoUrl) {
        // Last time the versionInfoURL was fetched
        var lastInfoURLFetchTime = PreferencesManager.getViewState("lastNotificationURLFetchTime");

        var result = new $.Deferred();
        var fetchData = false;
        var data;

        // If we don't have data saved in prefs, fetch
        data = PreferencesManager.getViewState("notificationInfo");
        if (!data) {
            fetchData = true;
        }

        // If more than 24 hours have passed since our last fetch, fetch again
        if (Date.now() > lastInfoURLFetchTime + ONE_DAY) {
            fetchData = true;
        }

        if (fetchData) {
            var lookupPromise = new $.Deferred(),
                localNotificationInfoUrl;

            // If the current locale isn't "en" or "en-US", check whether we actually have a
            // locale-specific notification target, and fall back to "en" if not.
            var locale = brackets.getLocale().toLowerCase();
            if (locale !== "en" && locale !== "en-us") {
                localNotificationInfoUrl = _notificationInfoUrl || _getVersionInfoUrl();
                // Check if we can reach a locale specific notifications source
                $.ajax({
                    url: localNotificationInfoUrl,
                    cache: false,
                    type: "HEAD"
                }).fail(function (jqXHR, status, error) {
                    // Fallback to "en" locale
                    localNotificationInfoUrl = _getVersionInfoUrl("en");
                }).always(function (jqXHR, status, error) {
                    lookupPromise.resolve();
                });
            } else {
                localNotificationInfoUrl = _notificationInfoUrl || _getVersionInfoUrl("en");
                lookupPromise.resolve();
            }

            lookupPromise.done(function () {
                $.ajax({
                    url: localNotificationInfoUrl,
                    dataType: "json",
                    cache: false
                }).done(function (notificationInfo, textStatus, jqXHR) {
                    lastInfoURLFetchTime = (new Date()).getTime();
                    PreferencesManager.setViewState("lastNotificationURLFetchTime", lastInfoURLFetchTime);
                    PreferencesManager.setViewState("notificationInfo", notificationInfo);
                    result.resolve(notificationInfo);
                }).fail(function (jqXHR, status, error) {
                    // When loading data for unit tests, the error handler is
                    // called but the responseText is valid. Try to use it here,
                    // but *don't* save the results in prefs.

                    if (!jqXHR.responseText) {
                        // Text is NULL or empty string, reject().
                        result.reject();
                        return;
                    }

                    try {
                        data = JSON.parse(jqXHR.responseText);
                        result.resolve(data);
                    } catch (e) {
                        result.reject();
                    }
                });
            });
        } else {
            result.resolve(data);
        }

        return result.promise();
    }
function _getNotificationInformation(_notificationInfoUrl) {
        // Last time the versionInfoURL was fetched
        var lastInfoURLFetchTime = PreferencesManager.getViewState("lastNotificationURLFetchTime");

        var result = new $.Deferred();
        var fetchData = false;
        var data;

        // If we don't have data saved in prefs, fetch
        data = PreferencesManager.getViewState("notificationInfo");
        if (!data) {
            fetchData = true;
        }

        // If more than 24 hours have passed since our last fetch, fetch again
        if (Date.now() > lastInfoURLFetchTime + ONE_DAY) {
            fetchData = true;
        }

        if (fetchData) {
            var lookupPromise = new $.Deferred(),
                localNotificationInfoUrl;

            // If the current locale isn't "en" or "en-US", check whether we actually have a
            // locale-specific notification target, and fall back to "en" if not.
            var locale = brackets.getLocale().toLowerCase();
            if (locale !== "en" && locale !== "en-us") {
                localNotificationInfoUrl = _notificationInfoUrl || _getVersionInfoUrl();
                // Check if we can reach a locale specific notifications source
                $.ajax({
                    url: localNotificationInfoUrl,
                    cache: false,
                    type: "HEAD"
                }).fail(function (jqXHR, status, error) {
                    // Fallback to "en" locale
                    localNotificationInfoUrl = _getVersionInfoUrl("en");
                }).always(function (jqXHR, status, error) {
                    lookupPromise.resolve();
                });
            } else {
                localNotificationInfoUrl = _notificationInfoUrl || _getVersionInfoUrl("en");
                lookupPromise.resolve();
            }

            lookupPromise.done(function () {
                $.ajax({
                    url: localNotificationInfoUrl,
                    dataType: "json",
                    cache: false
                }).done(function (notificationInfo, textStatus, jqXHR) {
                    lastInfoURLFetchTime = (new Date()).getTime();
                    PreferencesManager.setViewState("lastNotificationURLFetchTime", lastInfoURLFetchTime);
                    PreferencesManager.setViewState("notificationInfo", notificationInfo);
                    result.resolve(notificationInfo);
                }).fail(function (jqXHR, status, error) {
                    // When loading data for unit tests, the error handler is
                    // called but the responseText is valid. Try to use it here,
                    // but *don't* save the results in prefs.

                    if (!jqXHR.responseText) {
                        // Text is NULL or empty string, reject().
                        result.reject();
                        return;
                    }

                    try {
                        data = JSON.parse(jqXHR.responseText);
                        result.resolve(data);
                    } catch (e) {
                        result.reject();
                    }
                });
            });
        } else {
            result.resolve(data);
        }

        return result.promise();
    }
function _getNotificationInformation ( _notificationInfoUrl ) { // Last time the versionInfoURL was fetched var lastInfoURLFetchTime = PreferencesManager . getViewState ( "lastNotificationURLFetchTime" ) ; var result = new $ . Deferred ( ) ; var fetchData = false ; var data ; // If we don't have data saved in prefs, fetch data = PreferencesManager . getViewState ( "notificationInfo" ) ; if ( ! data ) { fetchData = true ; } // If more than 24 hours have passed since our last fetch, fetch again if ( Date . now ( ) > lastInfoURLFetchTime + ONE_DAY ) { fetchData = true ; } if ( fetchData ) { var lookupPromise = new $ . Deferred ( ) , localNotificationInfoUrl ; // If the current locale isn't "en" or "en-US", check whether we actually have a // locale-specific notification target, and fall back to "en" if not. var locale = brackets . getLocale ( ) . toLowerCase ( ) ; if ( locale !== "en" && locale !== "en-us" ) { localNotificationInfoUrl = _notificationInfoUrl || _getVersionInfoUrl ( ) ; // Check if we can reach a locale specific notifications source $ . ajax ( { url : localNotificationInfoUrl , cache : false , type : "HEAD" } ) . fail ( function ( jqXHR , status , error ) { // Fallback to "en" locale localNotificationInfoUrl = _getVersionInfoUrl ( "en" ) ; } ) . always ( function ( jqXHR , status , error ) { lookupPromise . resolve ( ) ; } ) ; } else { localNotificationInfoUrl = _notificationInfoUrl || _getVersionInfoUrl ( "en" ) ; lookupPromise . resolve ( ) ; } lookupPromise . done ( function ( ) { $ . ajax ( { url : localNotificationInfoUrl , dataType : "json" , cache : false } ) . done ( function ( notificationInfo , textStatus , jqXHR ) { lastInfoURLFetchTime = ( new Date ( ) ) . getTime ( ) ; PreferencesManager . setViewState ( "lastNotificationURLFetchTime" , lastInfoURLFetchTime ) ; PreferencesManager . setViewState ( "notificationInfo" , notificationInfo ) ; result . resolve ( notificationInfo ) ; } ) . fail ( function ( jqXHR , status , error ) { // When loading data for unit tests, the error handler is // called but the responseText is valid. Try to use it here, // but *don't* save the results in prefs. if ( ! jqXHR . responseText ) { // Text is NULL or empty string, reject(). result . reject ( ) ; return ; } try { data = JSON . parse ( jqXHR . responseText ) ; result . resolve ( data ) ; } catch ( e ) { result . reject ( ) ; } } ) ; } ) ; } else { result . resolve ( data ) ; } return result . promise ( ) ; }
Get a data structure that has information for all Brackets targeted notifications.

_notificationInfoUrl is used for unit testing.
Get a data structure that has information for all Brackets targeted notifications .