<commit_before>/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
/*global define */
define(function (require) {

    "use strict";

    var $               = require('jquery'),
        Backbone        = require('backbone'),
        Handlebars      = require('handlebars'),
        Helpers         = require('app/utils/HandlebarHelpers'),
        Marionette      = require('marionette'),
        HomeViews       = require('app/views/HomeViews'),
        HelpView        = require('app/views/HelpView'),
        ProjectViews    = require('app/views/ProjectViews'),
        DocumentViews   = require('app/views/DocumentViews'),
        SearchViews     = require('app/views/SearchViews'),
        AdaptViews      = require('app/views/AdaptViews'),
        projModel       = require('app/models/project'),
        chapterModel    = require('app/models/chapter'),
        AppRouter       = require('app/router'),
        FastClick       = require('fastclick'),
        PageSlider      = require('app/utils/pageslider'),
        slider          = new PageSlider($('body')),
        ProjectList     = null,
        lookupView      = null,
        helpView        = null,
        newProjectView  = null,
        editProjectView = null,
        copyProjectView = null,
        homeView        = null,
        importDocView   = null,
        db              = null,
        i18n            = require('i18n'),
        lang            = "",
        models          = [],
        locale          = "en-AU",  // default


        Application = Marionette.Application.extend({

            // app initialization code. Here we'll initialize localization with the current locale 
            initialize: function (options) {
                // add the UI regions (just the main "content" for now)
                this.addRegions({
                    main: '#main'
                });
                // main Region's show event handler -- we use it to do
                // page transition animations.
                this.main.on("show", function (view) {
                  // manipulate the `view` or do something extra
                  // with the region via `this`
                    slider.slidePage(view.$el);
                });
                // sqlitePlugin -- available on DeviceReady (mobile app)
                if (window.sqlitePlugin) {
                    this.db = window.sqlitePlugin.openDatabase({name: "AIM"});
                }
                // get the user's locale - mobile or web
                if (typeof navigator.globalization !== 'undefined') {
                    // on mobile phone
//                    navigator.globalization.getPreferredLanguage(
//                        function (language) {alert('language: ' + language.value + '\n');},
//                        function () {alert('Error getting language\n');}
//                    );
                    navigator.globalization.getLocaleName(
                        function (loc) {
//                            alert('locale: ' + loc.value + '\n');
                            locale = loc.value; 
                        },
                        function () {console.log('Error getting locale\n'); }
                    );
                } else {
//                    console.log("No navigator.globalization object - looking in browser");
                    // in web browser
                    lang = (navigator.languages) ? navigator.languages[0] : (navigator.language || navigator.userLanguage);
//                    console.log("lang: " + lang);
                    locale = lang.split("-")[0];
                }
//                console.log("locale:" + locale);<commit_msg>Use WebSQL when running in browser<commit_after>/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
/*global define */
define(function (require) {

    "use strict";

    var $               = require('jquery'),
        Backbone        = require('backbone'),
        Handlebars      = require('handlebars'),
        Helpers         = require('app/utils/HandlebarHelpers'),
        Marionette      = require('marionette'),
        HomeViews       = require('app/views/HomeViews'),
        HelpView        = require('app/views/HelpView'),
        ProjectViews    = require('app/views/ProjectViews'),
        DocumentViews   = require('app/views/DocumentViews'),
        SearchViews     = require('app/views/SearchViews'),
        AdaptViews      = require('app/views/AdaptViews'),
        projModel       = require('app/models/project'),
        chapterModel    = require('app/models/chapter'),
        AppRouter       = require('app/router'),
        FastClick       = require('fastclick'),
        PageSlider      = require('app/utils/pageslider'),
        slider          = new PageSlider($('body')),
        ProjectList     = null,
        lookupView      = null,
        helpView        = null,
        newProjectView  = null,
        editProjectView = null,
        copyProjectView = null,
        homeView        = null,
        importDocView   = null,
        db              = null,
        i18n            = require('i18n'),
        lang            = "",
        models          = [],
        locale          = "en-AU",  // default


        Application = Marionette.Application.extend({

            // app initialization code. Here we'll initialize localization with the current locale 
            initialize: function (options) {
                // add the UI regions (just the main "content" for now)
                this.addRegions({
                    main: '#main'
                });
                // main Region's show event handler -- we use it to do
                // page transition animations.
                this.main.on("show", function (view) {
                  // manipulate the `view` or do something extra
                  // with the region via `this`
                    slider.slidePage(view.$el);
                });
                // sqlitePlugin -- available on DeviceReady (mobile app)
                if (window.sqlitePlugin) {
                    this.db = window.sqlitePlugin.openDatabase({name: "AIM"});
                } else {
                    // running in browser -- use WebSQL (Chrome / Safari ONLY)
                    this.db = openDatabase('AIM', '1', 'AIM database', 2 * 1024 * 1024);
                }
                // get the user's locale - mobile or web
                if (typeof navigator.globalization !== 'undefined') {
                    // on mobile phone
//                    navigator.globalization.getPreferredLanguage(
//                        function (language) {alert('language: ' + language.value + '\n');},
//                        function () {alert('Error getting language\n');}
//                    );
                    navigator.globalization.getLocaleName(
                        function (loc) {
//                            alert('locale: ' + loc.value + '\n');
                            locale = loc.value;
                        },
                        function () {console.log('Error getting locale\n'); }
                    );
                } else {
//                    console.log("No navigator.globalization object - looking in browser");
                    // in web browser
                    lang = (navigator.languages) ? navigator.languages[0] : (navigator.language || navigator.userLanguage);
//                    console.log("lang: " + lang);
                    locale = lang.split("-")[0];
                }
//                console.log("locale:" + locale);
{'fraction_non_alphanumeric': 0.11737704918032787, 'fraction_numerical': 0.0036721311475409837, 'mean_word_length': 1.362453531598513, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5486262', 'n_tokens_mistral': 1896, 'n_tokens_neox': 1770, 'n_words': 431}