diff --git a/.jshintrc b/.jshintrc index 0e16c7a7..d91acc38 100644 --- a/.jshintrc +++ b/.jshintrc @@ -16,7 +16,7 @@ "latedef" : false, // true: Require variables/functions to be defined before being used "newcap" : true, // true: Require capitalization of all constructor functions e.g. `new F()` "noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee` - "noempty" : true, // true: Prohibit use of empty blocks + "noempty" : false, // true: Prohibit use of empty blocks "nonbsp" : true, // true: Prohibit "non-breaking whitespace" characters. "nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment) "plusplus" : false, // true: Prohibit use of `++` & `--` @@ -26,11 +26,11 @@ // "single" : require single quotes // "double" : require double quotes "undef" : true, // true: Require all non-global variables to be declared (prevents global leaks) - "unused" : true, // Unused variables: + "unused" : "vars", // Unused variables: // true : all variables, last function parameter // "vars" : all variables only // "strict" : all variables, all function parameters - "strict" : true, // true: Requires all functions run in ES5 Strict Mode + "strict" : false, // true: Requires all functions run in ES5 Strict Mode "maxparams" : false, // {int} Max number of formal params allowed per function "maxdepth" : false, // {int} Max depth of nested blocks (within functions) "maxstatements" : false, // {int} Max number statements per function @@ -42,15 +42,14 @@ "asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons) "boss" : false, // true: Tolerate assignments where comparisons would be expected "debug" : false, // true: Allow debugger statements e.g. browser breakpoints. - "eqnull" : false, // true: Tolerate use of `== null` - "es5" : true, // true: Allow ES5 syntax (ex: getters and setters) + "eqnull" : true, // true: Tolerate use of `== null` "esnext" : true, // true: Allow ES.next (ES6) syntax (ex: `const`) "moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features) // (ex: `for each`, multiple try/catch, function expression…) "evil" : false, // true: Tolerate use of `eval` and `new Function()` "expr" : false, // true: Tolerate `ExpressionStatement` as Programs "funcscope" : false, // true: Tolerate defining variables inside control statements - "globalstrict" : false, // true: Allow global "use strict" (also enables 'strict') + "globalstrict" : true, // true: Allow global "use strict" (also enables 'strict') "iterator" : false, // true: Tolerate using the `__iterator__` property "lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block "laxbreak" : false, // true: Tolerate possibly unsafe line breakings @@ -72,7 +71,7 @@ "couch" : false, // CouchDB "devel" : true, // Development/debugging (alert, confirm, etc) "dojo" : false, // Dojo Toolkit - "jasmine" : false, // Jasmine + "jasmine" : true, // Jasmine "jquery" : false, // jQuery "mocha" : true, // Mocha "mootools" : false, // MooTools @@ -91,6 +90,8 @@ // Custom Globals "globals" : { // additional predefined global variables "angular" : true, + "module" : true, + "inject" : true, "baw" : true } } diff --git a/Gruntfile.js b/Gruntfile.js index 1bbbd3bd..6f011c90 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,3 +1,4 @@ +/* jshint node:true */ module.exports = function (grunt) { var modRewrite = require("connect-modrewrite"), @@ -29,7 +30,7 @@ module.exports = function (grunt) { /** * Load in our build configuration file. */ - var userConfig = require('./buildConfig/build.config.js'); + var userConfig = require("./buildConfig/build.config.js"); /** * Load in the special vendor template. @@ -42,11 +43,11 @@ module.exports = function (grunt) { /** * Process the build option. */ - userConfig.usePhantomJs = grunt.option('use-phantomjs') === true; + userConfig.usePhantomJs = grunt.option("use-phantomjs") === true; - var development = grunt.option('development') === true, - staging = grunt.option('staging') === true, - production = grunt.option('production') === true, + var development = grunt.option("development") === true, + staging = grunt.option("staging") === true, + production = grunt.option("production") === true, sumBuildOptions = development + staging + production; grunt.log.writeln("FLAGS::\n", grunt.option.flags()); @@ -72,18 +73,18 @@ module.exports = function (grunt) { if (development) { grunt.log.ok("Development build selected"); userConfig.build_configs.current = userConfig.build_configs.development; - userConfig.build_configs.current.key = 'development'; + userConfig.build_configs.current.key = "development"; } if (staging) { grunt.log.ok("Staging build selected"); userConfig.build_configs.current = userConfig.build_configs.staging; - userConfig.build_configs.current.key = 'staging'; + userConfig.build_configs.current.key = "staging"; userConfig.usePhantomJs = true; } if (production) { grunt.log.ok("Production build selected"); userConfig.build_configs.current = userConfig.build_configs.production; - userConfig.build_configs.current.key = 'production'; + userConfig.build_configs.current.key = "production"; userConfig.usePhantomJs = true; } @@ -100,8 +101,8 @@ module.exports = function (grunt) { */ pkg: grunt.file.readJSON("package.json"), - sassDestName: '<%= pkg.name %>-<%= pkg.version %>.css', - sassDest: '<%= build_dir %>/assets/styles/<%= sassDestName %>', + sassDestName: "<%= pkg.name %>-<%= pkg.version %>.css", + sassDest: "<%= build_dir %>/assets/styles/<%= sassDestName %>", /** * The banner is the comment that is placed at the top of our compiled @@ -109,13 +110,13 @@ module.exports = function (grunt) { * pairs are evaluated based on this very configuration object. */ meta: { - banner: '/**\n' + - ' * <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' + - ' * <%= pkg.homepage %>\n' + - ' *\n' + - ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' + - ' * Licensed <%= pkg.licenses.type %> <<%= pkg.licenses.url %>>\n' + - ' */\n' + banner: "/**\n" + + " * <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today(\"yyyy-mm-dd\") %>\n" + + " * <%= pkg.homepage %>\n" + + " *\n" + + " * Copyright (c) <%= grunt.template.today(\"yyyy\") %> <%= pkg.author %>\n" + + " * Licensed <%= pkg.licenses.type %> <<%= pkg.licenses.url %>>\n" + + " */\n" }, /** @@ -126,8 +127,8 @@ module.exports = function (grunt) { options: { from: "6dec81ca099cf2cc7840b02d2f27ff8bffbce954", //to: "HEAD" - dest: 'CHANGELOG.md', - template: 'buildConfig/changelog.tpl' + dest: "CHANGELOG.md", + template: "buildConfig/changelog.tpl" } } }, @@ -142,16 +143,16 @@ module.exports = function (grunt) { "bower.json" ], commit: false, - commitMessage: 'chore(release): v%VERSION%', + commitMessage: "chore(release): v%VERSION%", commitFiles: [ "package.json", "client/bower.json" ], createTag: false, - tagName: 'v%VERSION%', - tagMessage: 'Version %VERSION%', + tagName: "v%VERSION%", + tagMessage: "Version %VERSION%", push: false, - pushTo: 'origin' + pushTo: "origin" } }, @@ -163,14 +164,14 @@ module.exports = function (grunt) { // sometimes clean is run when processedSass is not defined // In this case, it is necessary to not provide an empty string because grunt complains // so provide an always negative match instead - src: ['<%= app_files.processedSass || "!?" %>'], - filter: 'isFile' + src: ["<%= app_files.processedSass || \"!?\" %>"], + filter: "isFile" }, others: { src: [ - '<%= build_dir %>', - '<%= compile_dir %>', - '<%= es6_dir %>' + "<%= build_dir %>", + "<%= compile_dir %>", + "<%= es6_dir %>" ] } }, @@ -184,9 +185,9 @@ module.exports = function (grunt) { build_app_assets: { files: [ { - src: ['**'], - dest: '<%= build_dir %>/assets/', - cwd: 'src/assets', + src: ["**"], + dest: "<%= build_dir %>/assets/", + cwd: "src/assets", expand: true, nonull: true } @@ -198,8 +199,8 @@ module.exports = function (grunt) { var template = { //src: [ '<%= vendor_files.assets %>' ], - dest: '<%= build_dir %>/assets/', - cwd: '.', + dest: "<%= build_dir %>/assets/", + cwd: ".", expand: true, flatten: true, nonull: true @@ -235,7 +236,7 @@ module.exports = function (grunt) { // if srcPath contain .tpl.js // for now since the angular templates use tpl as well, // we'll cheat and just use a direct file reference - var bc = grunt.config('build_configs'); + var bc = grunt.config("build_configs"); if (srcPath.indexOf(bc.configFile) >= 0) { // then process as template! @@ -247,7 +248,7 @@ module.exports = function (grunt) { }, files: [ { - src: ['<%= app_files.js %>', "**/!(*.spec).js.map"], + src: ["<%= app_files.js %>", "**/!(*.spec).js.map"], // copy transpiled es6 JS into dest dir dest: "<%= build_dir %>/", cwd: "<%= es6_dir %>", @@ -262,9 +263,9 @@ module.exports = function (grunt) { }, files: [ { - src: ['<%= vendor_files.js %>'], - dest: '<%= build_dir %>/', - cwd: '.', + src: ["<%= vendor_files.js %>"], + dest: "<%= build_dir %>/", + cwd: ".", expand: true, nonull: true } @@ -273,9 +274,9 @@ module.exports = function (grunt) { compile_assets: { files: [ { - src: ['**'], - dest: '<%= compile_dir %>/assets', - cwd: '<%= build_dir %>/assets', + src: ["**"], + dest: "<%= compile_dir %>/assets", + cwd: "<%= build_dir %>/assets", expand: true, nonull: true } @@ -311,14 +312,14 @@ module.exports = function (grunt) { */ build_css: { options: { - banner: '<%= meta.banner %>' + banner: "<%= meta.banner %>" }, nonull: true, src: [ - '<%= vendor_files.css %>', - '<%= build_dir %>/assets/styles/*.css' + "<%= vendor_files.css %>", + "<%= build_dir %>/assets/styles/*.css" ], - dest: '<%= sassDest %>' + dest: "<%= sassDest %>" }, /** * The `compile_js` target is the concatenation of our application source @@ -326,7 +327,7 @@ module.exports = function (grunt) { */ compile_js: { options: { - banner: '<%= meta.banner %>' + banner: "<%= meta.banner %>" }, nonull: true, src: [ @@ -335,13 +336,13 @@ module.exports = function (grunt) { return userConfig.build_dir + "/" + file; }); }()), - 'buildConfig/module.prefix', - '<%= build_dir %>/src/**/*.js', - '<%= html2js.app.dest %>', - '<%= html2js.common.dest %>', - 'buildConfig/module.suffix' + "buildConfig/module.prefix", + "<%= build_dir %>/src/**/*.js", + "<%= html2js.app.dest %>", + "<%= html2js.common.dest %>", + "buildConfig/module.suffix" ], - dest: '<%= compile_dir %>/assets/<%= pkg.name %>-<%= pkg.version %>.js' + dest: "<%= compile_dir %>/assets/<%= pkg.name %>-<%= pkg.version %>.js" } }, @@ -351,17 +352,17 @@ module.exports = function (grunt) { uglify: { compile: { options: { - banner: '<%= meta.banner %>' + banner: "<%= meta.banner %>" }, files: { - "<%= concat.compile_js.dest %>": '<%= concat.compile_js.dest %>' + "<%= concat.compile_js.dest %>": "<%= concat.compile_js.dest %>" } } }, sass: { - build: ['sassTemplate', 'sassReal:build', 'clean:processedSass'], - compile: ['sassTemplate', 'sassReal:compile', 'clean:processedSass'] + build: ["sassTemplate", "sassReal:build", "clean:processedSass"], + compile: ["sassTemplate", "sassReal:compile", "clean:processedSass"] }, /** @@ -372,22 +373,22 @@ module.exports = function (grunt) { options: {}, build: { options: { - imagePath: '<%= build_configs.current.siteDir %>assets/img', - outputStyle: 'expanded', - sourceComments: 'normal' /*'map', + imagePath: "<%= build_configs.current.siteDir %>assets/img", + outputStyle: "expanded", + sourceComments: "normal" /*'map', sourceMap: '<%= sassDestName %>.map'*/ }, - src: '<%= app_files.processedSass %>', - dest: '<%= sassDest %>' + src: "<%= app_files.processedSass %>", + dest: "<%= sassDest %>" }, compile: { options: { - imagePath: '<%= build_configs.current.siteDir %>assets/img', - outputStyle: 'compressed', - sourceComments: 'none' + imagePath: "<%= build_configs.current.siteDir %>assets/img", + outputStyle: "compressed", + sourceComments: "none" }, - src: '<%= app_files.processedSass %>', - dest: '<%= sassDest %>' + src: "<%= app_files.processedSass %>", + dest: "<%= sassDest %>" } }, @@ -404,13 +405,13 @@ module.exports = function (grunt) { jshintrc: ".jshintrc" }, src: [ - '<%= app_files.js %>' + "<%= app_files.js %>" ], test: [ - '<%= app_files.jsunit %>' + "<%= app_files.jsunit %>" ], gruntfile: [ - 'Gruntfile.js' + "Gruntfile.js" ] }, @@ -426,12 +427,12 @@ module.exports = function (grunt) { */ app: { options: { - base: 'src/app', + base: "src/app", // produce only one module singleModule: true }, - src: ['<%= app_files.atpl %>'], - dest: '<%= build_dir %>/templates-app.js' + src: ["<%= app_files.atpl %>"], + dest: "<%= build_dir %>/templates-app.js" }, /** @@ -439,10 +440,10 @@ module.exports = function (grunt) { */ common: { options: { - base: 'src' + base: "src" }, - src: ['<%= app_files.ctpl %>'], - dest: '<%= build_dir %>/templates-common.js' + src: ["<%= app_files.ctpl %>"], + dest: "<%= build_dir %>/templates-common.js" } }, @@ -451,7 +452,7 @@ module.exports = function (grunt) { */ karma: { options: { - configFile: '<%= build_dir %>/karma-unit.js' + configFile: "<%= build_dir %>/karma-unit.js" }, unit: { port: 9019, @@ -475,14 +476,14 @@ module.exports = function (grunt) { * `src` property contains the list of included files. */ build: { - dir: '<%= build_dir %>', + dir: "<%= build_dir %>", src: [ - '<%= vendor_files.js %>', - '<%= build_dir %>/src/**/*.js', - '<%= html2js.common.dest %>', - '<%= html2js.app.dest %>', - '<%= vendor_files.css %>', - '<%= build_dir %>/assets/styles/*' + "<%= vendor_files.js %>", + "<%= build_dir %>/src/**/*.js", + "<%= html2js.common.dest %>", + "<%= html2js.app.dest %>", + "<%= vendor_files.css %>", + "<%= build_dir %>/assets/styles/*" ] }, @@ -492,11 +493,11 @@ module.exports = function (grunt) { * file. Now we're back! */ compile: { - dir: '<%= compile_dir %>', + dir: "<%= compile_dir %>", src: [ - '<%= concat.compile_js.dest %>', - '<%= vendor_files.css %>', - '<%= build_dir %>/assets/styles/*.css' + "<%= concat.compile_js.dest %>", + "<%= vendor_files.css %>", + "<%= build_dir %>/assets/styles/*.css" ] } }, @@ -507,12 +508,12 @@ module.exports = function (grunt) { */ karmaconfig: { unit: { - dir: '<%= build_dir %>', + dir: "<%= build_dir %>", src: [ - '<%= vendor_files.js %>', - '<%= html2js.app.dest %>', - '<%= html2js.common.dest %>', - '<%= test_files.js %>' + "<%= vendor_files.js %>", + "<%= html2js.app.dest %>", + "<%= html2js.common.dest %>", + "<%= test_files.js %>" ] } }, @@ -523,9 +524,9 @@ module.exports = function (grunt) { connect: { server: { options: { - hostname: '*', + hostname: "*", port: 8080, - base: './<%= build_dir %>', + base: "./<%= build_dir %>", //debug: true, livereload: true, middleware: function (connect, options) { @@ -536,11 +537,11 @@ module.exports = function (grunt) { modRewrite([ // for source maps - '^/assets/styles/vendor(.*) /vendor$1 [L]', - '^/assets/styles/src(.*) /src$1 [L]', + "^/assets/styles/vendor(.*) /vendor$1 [L]", + "^/assets/styles/src(.*) /src$1 [L]", // this rule should match anything under assets and basically not rewrite it - '^/assets(.*) /assets$1 [L]', + "^/assets(.*) /assets$1 [L]", // this rule matches anything without an extension @@ -553,12 +554,12 @@ module.exports = function (grunt) { // with or without a querystring // if matched, the root (index.html) is sent back instead. // from there, angular deals with the route information - '!(\\/[^\\.\\/\\?]+\\.\\w+) / [L]' + "!(\\/[^\\.\\/\\?]+\\.\\w+) / [L]" ]), // disable all caching function (req, res, next) { - req.headers['if-none-match'] = 'no-match-for-this'; + req.headers["if-none-match"] = "no-match-for-this"; next(); }, @@ -602,8 +603,8 @@ module.exports = function (grunt) { * your Gruntfile changes, it will automatically be reloaded! */ gruntfile: { - files: 'Gruntfile.js', - tasks: ['jshint:gruntfile'], + files: "Gruntfile.js", + tasks: ["jshint:gruntfile"], options: { livereload: false } @@ -615,10 +616,10 @@ module.exports = function (grunt) { */ jssrc: { files: [ - '<%= app_files.js %>' + "<%= app_files.js %>" ], // recent modification: files are copied before unit tests are run! - tasks: ['jshint:src', 'babel:transpile_appjs', 'copy:build_appjs', 'karma:unit:run' ] + tasks: ["jshint:src", "babel:transpile_appjs", "copy:build_appjs", "karma:unit:run" ] }, /** @@ -627,17 +628,17 @@ module.exports = function (grunt) { */ assets: { files: [ - 'src/assets/**/*' + "src/assets/**/*" ], - tasks: ['copy:build_app_assets'] + tasks: ["copy:build_app_assets"] }, /** * When index.html changes, we need to compile it. */ html: { - files: ['<%= app_files.html %>'], - tasks: ['index:build'] + files: ["<%= app_files.html %>"], + tasks: ["index:build"] }, /** @@ -645,18 +646,18 @@ module.exports = function (grunt) { */ tpls: { files: [ - '<%= app_files.atpl %>', - '<%= app_files.ctpl %>' + "<%= app_files.atpl %>", + "<%= app_files.ctpl %>" ], - tasks: ['html2js'] + tasks: ["html2js"] }, /** * When the CSS files change, we need to compile and minify them. */ sass: { - files: ['src/**/*.scss'], - tasks: ['sass:build', 'concat:build_css'] + files: ["src/**/*.scss"], + tasks: ["sass:build", "concat:build_css"] }, /** @@ -665,9 +666,9 @@ module.exports = function (grunt) { */ jsunit: { files: [ - '<%= app_files.jsunit %>' + "<%= app_files.jsunit %>" ], - tasks: ['babel:transpile_appjs', 'jshint:test', 'karma:unit:run'], + tasks: ["babel:transpile_appjs", "jshint:test", "karma:unit:run"], options: { livereload: false } @@ -687,31 +688,31 @@ module.exports = function (grunt) { * `delta`) and then add a new task called `watch` that does a clean build * before watching for changes. */ - grunt.renameTask('watch', 'delta'); - grunt.registerTask('watch', ['build', 'karma:unit', 'connect', 'delta']); + grunt.renameTask("watch", "delta"); + grunt.registerTask("watch", ["build", "karma:unit", "connect", "delta"]); /** * The default task is to build and compile. */ - grunt.registerTask('default', ['build', 'compile']); + grunt.registerTask("default", ["build", "compile"]); /** * The `build` task gets your app ready to run for development and testing. */ - grunt.registerTask('build', [ - 'clean', 'html2js', 'jshint', 'sass:build', - 'concat:build_css', 'copy:build_app_assets', 'copy:build_vendor_assets', - 'babel:transpile_appjs', 'copy:build_appjs', 'copy:build_vendorjs', 'index:build', 'karmaconfig', - 'karma:continuous' + grunt.registerTask("build", [ + "clean", "html2js", "jshint", "sass:build", + "concat:build_css", "copy:build_app_assets", "copy:build_vendor_assets", + "babel:transpile_appjs", "copy:build_appjs", "copy:build_vendorjs", "index:build", "karmaconfig", + "karma:continuous" ]); /** * The `compile` task gets your app ready for deployment by concatenating and * minifying your code. */ - grunt.registerTask('compile', [ - 'sass:compile', 'concat:build_css', 'copy:compile_assets', 'concat:compile_js', 'uglify', - 'index:compile' + grunt.registerTask("compile", [ + "sass:compile", "concat:build_css", "copy:compile_assets", "concat:compile_js", "uglify", + "index:compile" ]); /** @@ -738,26 +739,26 @@ module.exports = function (grunt) { * the list into variables for the template to use and then runs the * compilation. */ - grunt.registerMultiTask('index', 'Process index.html template', function () { - var dirRE = new RegExp('^(' + grunt.config('build_dir') + '|' + grunt.config('compile_dir') + ')\/', 'g'); + grunt.registerMultiTask("index", "Process index.html template", function () { + var dirRE = new RegExp("^(" + grunt.config("build_dir") + "|" + grunt.config("compile_dir") + ")\/", "g"); var jsFiles = filterForJS(this.filesSrc).map(function (file) { - return file.replace(dirRE, ''); + return file.replace(dirRE, ""); }); var cssFiles = filterForCSS(this.filesSrc).map(function (file) { - return file.replace(dirRE, ''); + return file.replace(dirRE, ""); }); - var mainCss = (grunt.config('sassDest')).replace(dirRE, ''); + var mainCss = (grunt.config("sassDest")).replace(dirRE, ""); - grunt.file.copy('src/index.html', this.data.dir + '/index.html', { + grunt.file.copy("src/index.html", this.data.dir + "/index.html", { process: function (contents, path) { return grunt.template.process(contents, { data: { - build_configs: grunt.config('build_configs'), + build_configs: grunt.config("build_configs"), scripts: jsFiles, styles: cssFiles, mainStyle: mainCss, - version: grunt.config('pkg.version') + version: grunt.config("pkg.version") } }); } @@ -768,9 +769,9 @@ module.exports = function (grunt) { * This task handles the template processing for the main sass file. * It injects itself as a task that occurs before the sass task. */ - grunt.renameTask('sass', 'sassReal'); - grunt.registerTask('sassTemplate', 'Transforming sass file', function () { - var mainScss = grunt.config('app_files.sass'); + grunt.renameTask("sass", "sassReal"); + grunt.registerTask("sassTemplate", "Transforming sass file", function () { + var mainScss = grunt.config("app_files.sass"); var processedScss = path.join(path.dirname(mainScss), path.basename(mainScss, ".tpl.scss")) + ".scss.processed"; //debugger; var scssPartials = grunt.file.expand("src/**/_*.scss"); @@ -804,7 +805,7 @@ module.exports = function (grunt) { }); - grunt.config.set('app_files.processedSass', processedScss); + grunt.config.set("app_files.processedSass", processedScss); grunt.log.write("Temp file: " + processedScss); @@ -820,7 +821,7 @@ module.exports = function (grunt) { }); }); - grunt.registerMultiTask('sass', function () { + grunt.registerMultiTask("sass", function () { grunt.task.run(this.data); }); @@ -830,12 +831,12 @@ module.exports = function (grunt) { * run, we use grunt to manage the list for us. The `buildConfig/karma-unit.tpl.js` files are * compiled as grunt templates for use by Karma. Yay! */ - grunt.registerMultiTask('karmaconfig', 'Process karma config templates', function () { + grunt.registerMultiTask("karmaconfig", "Process karma config templates", function () { var jsFiles = filterForJS(this.filesSrc); - var usePhantomJs = grunt.config('usePhantomJs'); + var usePhantomJs = grunt.config("usePhantomJs"); var vendorFiles = grunt.config("vendor_files.js"); - grunt.file.copy('buildConfig/karma-unit.tpl.js', grunt.config('build_dir') + '/karma-unit.js', { + grunt.file.copy("buildConfig/karma-unit.tpl.js", grunt.config("build_dir") + "/karma-unit.js", { process: function (contents, path) { return grunt.template.process(contents, { data: { diff --git a/buildConfig/build.config.js b/buildConfig/build.config.js index 9ef91a2e..d3bf9edb 100644 --- a/buildConfig/build.config.js +++ b/buildConfig/build.config.js @@ -9,8 +9,8 @@ module.exports = { * completely built. */ es6_dir: "es6", - build_dir: 'build', - compile_dir: 'bin', + build_dir: "build", + compile_dir: "bin", /** * The environment settings are loaded here. @@ -31,14 +31,14 @@ module.exports = { * app's unit tests. */ app_files: { - js: ['src/**/*.js', '!src/**/*.spec.js', '!src/assets/**/*.js'], - jsunit: ['src/**/*.spec.js'], + js: ["src/**/*.js", "!src/**/*.spec.js", "!src/assets/**/*.js"], + jsunit: ["src/**/*.spec.js"], - atpl: ['src/app/**/*.tpl.html'], - ctpl: ['src/common/**/*.tpl.html', 'src/components/**/*.tpl.html'], + atpl: ["src/app/**/*.tpl.html"], + ctpl: ["src/common/**/*.tpl.html", "src/components/**/*.tpl.html"], - html: ['src/index.html'], - sass: ['src/sass/application.tpl.scss'] + html: ["src/index.html"], + sass: ["src/sass/application.tpl.scss"] }, /** @@ -46,7 +46,7 @@ module.exports = { */ test_files: { js: [ - 'vendor/angular-mocks/angular-mocks.js' + "vendor/angular-mocks/angular-mocks.js" ] }, @@ -70,86 +70,86 @@ module.exports = { */ vendor_files: { jsWrapWithModule: [ - 'vendor/d3/d3.js', - 'vendor/momentjs/moment.js', - 'vendor/lodash/lodash.js', - 'vendor/bowser/bowser.js', - 'vendor/humanize-duration/humanize-duration.js', - 'vendor/round-date/roundDate.js' + "vendor/d3/d3.js", + "vendor/momentjs/moment.js", + "vendor/lodash/lodash.js", + "vendor/bowser/bowser.js", + "vendor/humanize-duration/humanize-duration.js", + "vendor/round-date/roundDate.js" ], js: [ "node_modules/babel/node_modules/babel-core/browser-polyfill.js", - 'vendor/jquery/dist/jquery.js', - 'vendor/angular/angular.js', + "vendor/jquery/dist/jquery.js", + "vendor/angular/angular.js", - 'buildConfig/externalModule.js', + "buildConfig/externalModule.js", // TODO: THIS IS TERRIBLE! REMOVE UI ASAP... OR AT LEAST ONLY INCLUDE RELEVANT COMPONENTS - 'vendor/jquery-ui/jquery-ui.js', + "vendor/jquery-ui/jquery-ui.js", // NOTE: bootstrap css imported in application.tpl.scss // NOTE: bootstrap's own JS not needed because angular-bootstrap does the same job // and without the jQuery dependency! //~~"/vendor/bootstrap-sass/assets/javascripts/bootstrap.js",~~ - 'vendor/angular-bootstrap/ui-bootstrap-tpls.js', - 'vendor/ng-form-group/index.js', + "vendor/angular-bootstrap/ui-bootstrap-tpls.js", + "vendor/ng-form-group/index.js", - 'vendor/momentjs/moment.js', - 'vendor/humanize-duration/humanize-duration.js', - 'vendor/round-date/roundDate.js', + "vendor/momentjs/moment.js", + "vendor/humanize-duration/humanize-duration.js", + "vendor/round-date/roundDate.js", - 'vendor/angular-route/angular-route.js', + "vendor/angular-route/angular-route.js", - 'vendor/angular-resource/angular-resource.js', + "vendor/angular-resource/angular-resource.js", // TODO: the following line is dodgy and bloats the app //'vendor/angular-ui-utils/ui-utils.js', - 'vendor/lodash/lodash.js', + "vendor/lodash/lodash.js", // This library is all split up - we are using the boneskull version atm, // but we started off using the deciphernic version - 'vendor/angular-tags/dist/angular-tags-0.3.1-tpls.js', + "vendor/angular-tags/dist/angular-tags-0.3.1-tpls.js", - 'vendor/angular-sanitize/angular-sanitize.js', + "vendor/angular-sanitize/angular-sanitize.js", // draggabilly - 'vendor/classie/classie.js', - 'vendor/eventEmitter/EventEmitter.js', - 'vendor/eventie/eventie.js', - 'vendor/get-style-property/get-style-property.js', + "vendor/classie/classie.js", + "vendor/eventEmitter/EventEmitter.js", + "vendor/eventie/eventie.js", + "vendor/get-style-property/get-style-property.js", // get-size depends on get-style-property... it has to come after it - 'vendor/get-size/get-size.js', - 'vendor/draggabilly/draggabilly.js', + "vendor/get-size/get-size.js", + "vendor/draggabilly/draggabilly.js", - 'vendor/d3/d3.js', + "vendor/d3/d3.js", - 'vendor/bowser/bowser.js', + "vendor/bowser/bowser.js", - 'vendor/angular-growl-v2/build/angular-growl.js', + "vendor/angular-growl-v2/build/angular-growl.js", - 'vendor/angular-local-storage/dist/angular-local-storage.js', + "vendor/angular-local-storage/dist/angular-local-storage.js", - 'vendor/angular-loading-bar/build/loading-bar.js' + "vendor/angular-loading-bar/build/loading-bar.js" ], css: [ // NOTE: bootstrap css imported in application.tpl.scss - 'vendor/hint.css/hint.css', + "vendor/hint.css/hint.css", // TODO: remove bloat - 'vendor/jquery-ui/themes/redmond/jquery-ui.css', + "vendor/jquery-ui/themes/redmond/jquery-ui.css", - 'vendor/angular-tags/dist/angular-tags-0.3.1.css', + "vendor/angular-tags/dist/angular-tags-0.3.1.css", - 'vendor/angular-growl-v2/build/angular-growl.css', + "vendor/angular-growl-v2/build/angular-growl.css", - 'vendor/angular-loading-bar/build/loading-bar.css' + "vendor/angular-loading-bar/build/loading-bar.css" ], assets: [ // jquery-ui is stoopid, special case function (template) { - template.src = 'vendor/jquery-ui/themes/redmond/images/**'; + template.src = "vendor/jquery-ui/themes/redmond/images/**"; template.dest += "styles/images/"; return template; diff --git a/buildConfig/karma-unit.tpl.js b/buildConfig/karma-unit.tpl.js index 95378ebd..cacf8f36 100644 --- a/buildConfig/karma-unit.tpl.js +++ b/buildConfig/karma-unit.tpl.js @@ -1,7 +1,7 @@ module.exports = function (config) { - var fileJson = '[<% scripts.forEach( function ( file, index, array ) { %>"<%= file %>"<%= index == array.length - 1 ? "": ","%> <% }); %>]', - vendorJson = '[<% vendorFiles.forEach( function ( file, index, array ) { %>"<%= file %>"<%= index == array.length - 1 ? "": ","%> <% }); %>]', + var fileJson = '[<% scripts.forEach( function ( file, index, array ) { %>"<%= file %>"<%= index == array.length - 1 ? "": ","%> <% }); %>]', // jshint ignore:line + vendorJson = '[<% vendorFiles.forEach( function ( file, index, array ) { %>"<%= file %>"<%= index == array.length - 1 ? "": ","%> <% }); %>]', // jshint ignore:line browserToUse = "<%= usePhantomJs ? 'PhantomJS' : 'Chrome' %>", useLineCov = "<%= usePhantomJs %>" === "true"; @@ -13,7 +13,7 @@ module.exports = function (config) { /** * From where to look for files, starting with the location of this file. */ - configObject.basePath = '../'; + configObject.basePath = "../"; /** * This is the list of file patterns to load into the browser during testing. @@ -22,8 +22,8 @@ module.exports = function (config) { "vendor/objectdiff/objectDiff.js", "vendor/jasmine-expect/dist/jasmine-matchers.js" ].concat(JSON.parse(fileJson).concat([ - 'es6/**/*.js', - 'es6/**/*.spec.js' + "es6/**/*.js", + "es6/**/*.spec.js" ])); // HACK!: use vendor files out of the build directory since they undergo a transform on build @@ -33,41 +33,41 @@ module.exports = function (config) { }); configObject.exclude = [ - 'es6/assets/**/*.js' + "es6/assets/**/*.js" ]; - configObject.frameworks = [ 'jasmine' ]; + configObject.frameworks = [ "jasmine" ]; configObject.plugins = [ - 'karma-jasmine', - 'karma-firefox-launcher', + "karma-jasmine", + "karma-firefox-launcher", /*'karma-chrome-launcher',*/ - require('../node_modules/karma-chrome-launcher'), - 'karma-phantomjs-launcher', + require("../node_modules/karma-chrome-launcher"), + "karma-phantomjs-launcher", /*require('../node_modules/karma-phantomjs-launcher'),*/ "karma-sourcemap-loader" ]; configObject.preprocessors = { - '**/*.js': ['sourcemap'] + '**/*.js': ["sourcemap"] }; /** * How to report, by default. 'dots', 'progress' */ - configObject.reporters = ['dots']; + configObject.reporters = ["dots"]; /** * Set up the coverage reporter */ if (useLineCov) { configObject.coverageReporter = { - type: 'lcov', - dir: 'coverage/' + type: "lcov", + dir: "coverage/" }; - configObject.reporters.push('coverage'); - configObject.plugins.push('karma-coverage'); - configObject.preprocessors['es6/**/!(*.spec)+(.js)'] = 'coverage'; + configObject.reporters.push("coverage"); + configObject.plugins.push("karma-coverage"); + configObject.preprocessors["es6/**/!(*.spec)+(.js)"] = "coverage"; } /** @@ -76,7 +76,7 @@ module.exports = function (config) { */ configObject.port = 9018; configObject.runnerPort = 9100; - configObject.urlRoot = '/'; + configObject.urlRoot = "/"; /** * Disable file watching by default. diff --git a/buildConfig/vendorTemplateProcessing.js b/buildConfig/vendorTemplateProcessing.js index 5d9855ea..16dd3a4c 100644 --- a/buildConfig/vendorTemplateProcessing.js +++ b/buildConfig/vendorTemplateProcessing.js @@ -1,9 +1,9 @@ module.exports = function(grunt, template, callbackName, includeFiles) { - var fs = require('fs'), + var fs = require("fs"), path = require("path"), - _ = require('lodash'); + _ = require("lodash"); var vendorTemplate = fs.readFileSync(template, "utf-8"), includeFiles = includeFiles || []; diff --git a/package.json b/package.json index 78d2a18c..48a0e638 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ }, "scripts": { "watch": "grunt watch", + "watch-force": "grunt watch --force", "build": "grunt", "setup": "npm install && bower install", "start": "npm run watch", diff --git a/src/app/accounts/accounts.js b/src/app/accounts/accounts.js index 72ff1e3e..0cf7b054 100644 --- a/src/app/accounts/accounts.js +++ b/src/app/accounts/accounts.js @@ -1,10 +1,10 @@ -var accountsModule = angular.module('bawApp.accounts', []); +var accountsModule = angular.module("bawApp.accounts", []); accountsModule.config(function config( ) { }); -accountsModule.controller('AccountsCtrl', ['$scope', '$resource', '$routeParams', +accountsModule.controller("AccountsCtrl", ["$scope", "$resource", "$routeParams", /** diff --git a/src/app/annotationLibrary/item.js b/src/app/annotationLibrary/item.js index a00feda4..c82a4d10 100644 --- a/src/app/annotationLibrary/item.js +++ b/src/app/annotationLibrary/item.js @@ -198,7 +198,7 @@ angular }); $scope.audioEventCommentsEnabled = true; - $scope.createCommentForm.$setPristine(true) + $scope.createCommentForm.$setPristine(true); }, function audioEventCommentsFailure(response) { $scope.audioEventCommentsEnabled = false; diff --git a/src/app/annotationViewer/annotationViewer.js b/src/app/annotationViewer/annotationViewer.js index 48c58cb4..84e4a178 100644 --- a/src/app/annotationViewer/annotationViewer.js +++ b/src/app/annotationViewer/annotationViewer.js @@ -1,6 +1,6 @@ -var avModule = angular.module('bawApp.annotationViewer', ['bawApp.annotationViewer.gridLines']); +var avModule = angular.module("bawApp.annotationViewer", ["bawApp.annotationViewer.gridLines"]); -avModule.controller('AnnotationViewerCtrl', ['$scope', '$element', '$attrs', '$transclude', 'Tag', "lodash", +avModule.controller("AnnotationViewerCtrl", ["$scope", "$element", "$attrs", "$transclude", "Tag", "lodash", // TODO: possible optimisation evaluate these functions once per frame @@ -109,7 +109,7 @@ avModule.controller('AnnotationViewerCtrl', ['$scope', '$element', '$attrs', '$t }, 250); $scope.dragOptions = { - axis: 'x', + axis: "x", containment: true, useLeftTop: false, dragMove: function dragMoveSetPosition(scope, draggie, event, pointer) { diff --git a/src/app/annotationViewer/gridLines/gridLines.js b/src/app/annotationViewer/gridLines/gridLines.js index fd72bdda..fd9ace14 100644 --- a/src/app/annotationViewer/gridLines/gridLines.js +++ b/src/app/annotationViewer/gridLines/gridLines.js @@ -1,7 +1,7 @@ -var bawGLs = angular.module('bawApp.annotationViewer.gridLines', ['bawApp.configuration']); +var bawGLs = angular.module("bawApp.annotationViewer.gridLines", ["bawApp.configuration"]); -bawGLs.directive('gridLines', - [ 'conf.paths', +bawGLs.directive("gridLines", + [ "conf.paths", function (paths) { var defaultAxis = { @@ -109,11 +109,11 @@ bawGLs.directive('gridLines', var position = steps[j].position; - if (xOrY === 'y') { - element.style.top = (size - position) + 'px'; + if (xOrY === "y") { + element.style.top = (size - position) + "px"; } - else if (xOrY === 'x') { - element.style.left = position + 'px'; + else if (xOrY === "x") { + element.style.left = position + "px"; } } @@ -122,21 +122,21 @@ bawGLs.directive('gridLines', function drawLines(lineContainer, elementSize, xOrY, steps, formatter) { if (!steps) { - lineContainer.style.display = 'none'; + lineContainer.style.display = "none"; return; } diffElementsChildren(lineContainer, steps.length - 2, "div"); - var biggest = render(lineContainer, xOrY, elementSize, steps, false, true, formatter); + var biggest = render(lineContainer, xOrY, elementSize, steps, false, true, formatter); // jshint ignore:line // ensure grid lines are visible - lineContainer.style.display = ''; + lineContainer.style.display = ""; } function drawScales(scaleContainer, elementSize, xOrY, steps, formatter, titleElement, showTitle) { if (!steps) { - scaleContainer.style.display = 'none'; - titleElement.style.display = 'none'; + scaleContainer.style.display = "none"; + titleElement.style.display = "none"; return; } @@ -144,8 +144,8 @@ bawGLs.directive('gridLines', var biggest = render(scaleContainer, xOrY, elementSize, steps, true, false, formatter); if (showTitle) { - titleElement.style.display = ''; - if (xOrY == "x") { + titleElement.style.display = ""; + if (xOrY === "x") { titleElement.style.bottom = "-" + biggest + "em"; } else { @@ -153,18 +153,18 @@ bawGLs.directive('gridLines', } } else { - titleElement.style.display = 'none'; + titleElement.style.display = "none"; } // ensure scales are visible - scaleContainer.style.display = ''; + scaleContainer.style.display = ""; } return { scope: { configuration: "=configuration" }, - restrict: 'E', + restrict: "E", templateUrl: paths.site.files.gridLines, link: function linker(scope, $element, attributes, controller, transcludeFunction) { var element = $element[0]; @@ -196,8 +196,8 @@ bawGLs.directive('gridLines', newValue.step, newValue.numberOfLines); } - drawLines(xLineContainer, newValue.width, 'x', newValue.showGrid ? steps : undefined); - drawScales(xScaleContainer, newValue.width, 'x', newValue.showScale ? steps : undefined, newValue.labelFormatter, xTitle, newValue.showTitle); + drawLines(xLineContainer, newValue.width, "x", newValue.showGrid ? steps : undefined); + drawScales(xScaleContainer, newValue.width, "x", newValue.showScale ? steps : undefined, newValue.labelFormatter, xTitle, newValue.showTitle); }, true); scope.$watch(function () { @@ -213,8 +213,8 @@ bawGLs.directive('gridLines', newValue.step, newValue.numberOfLines); } - drawLines(yLineContainer, newValue.height, 'y', newValue.showGrid ? steps : undefined); - drawScales(yScaleContainer, newValue.height, 'y', newValue.showScale ? steps : undefined, newValue.labelFormatter, yTitle, newValue.showTitle); + drawLines(yLineContainer, newValue.height, "y", newValue.showGrid ? steps : undefined); + drawScales(yScaleContainer, newValue.height, "y", newValue.showScale ? steps : undefined, newValue.labelFormatter, yTitle, newValue.showTitle); }, true); } }; diff --git a/src/app/app.js b/src/app/app.js index c731689a..fdf52ec8 100644 --- a/src/app/app.js +++ b/src/app/app.js @@ -47,78 +47,78 @@ function whenDefaults(resourceName, singularResourceName, id, controllerMany, co ; } -var app = angular.module('baw', +angular.module("baw", [ - 'ngRoute', - 'ngResource', - 'ngSanitize', + "ngRoute", + "ngResource", + "ngSanitize", //'ui.select2', - 'ui.bootstrap', - 'ui.bootstrap.typeahead', - 'ui.bootstrap.tpls', - 'ng-form-group', // connects angular form validation with bootstrap classes - 'decipher.tags', - 'angular-growl', - 'LocalStorageModule', - 'angular-loading-bar', + "ui.bootstrap", + "ui.bootstrap.typeahead", + "ui.bootstrap.tpls", + "ng-form-group", // connects angular form validation with bootstrap classes + "decipher.tags", + "angular-growl", + "LocalStorageModule", + "angular-loading-bar", "bawApp.vendorServices", /* Loads all vendor libraries that are automatically wrapped in a module */ "url", /* a custom uri formatter */ - 'bawApp.configuration', /* a mapping of all static path configurations + "bawApp.configuration", /* a mapping of all static path configurations and a module that contains all app configuration */ - 'http-auth-interceptor', /* the auth module */ - 'angular-auth', /* the auth module */ - 'rails', /* a module designed to rewrite object keys on JSON objects */ + "http-auth-interceptor", /* the auth module */ + "angular-auth", /* the auth module */ + "rails", /* a module designed to rewrite object keys on JSON objects */ - 'templates-app', /* these are the precompiled templates */ - 'templates-common', + "templates-app", /* these are the precompiled templates */ + "templates-common", - 'bawApp.services.resource', // a custom wrapped around ngResource - 'bawApp.directives', /* our directives.js */ - 'bawApp.directives.ngAudio', /* our directives.js */ - 'bawApp.directives.toggleSwitch', + "bawApp.services.resource", // a custom wrapped around ngResource + "bawApp.directives", /* our directives.js */ + "bawApp.directives.ngAudio", /* our directives.js */ + "bawApp.directives.toggleSwitch", - 'bawApp.filters', /* our filters.js */ + "bawApp.filters", /* our filters.js */ - 'bawApp.services', /* our services.js */ + "bawApp.services", /* our services.js */ "bawApp.models", - 'audio-control', - 'draggabilly', + "audio-control", + "draggabilly", - 'bawApp.d3', /* our d3 controls */ + "bawApp.d3", /* our d3 controls */ - 'bawApp.accounts', - 'bawApp.annotationViewer', - 'bawApp.audioEvents', - 'bawApp.annotationLibrary', - 'bawApp.bookmarks', + "bawApp.accounts", + "bawApp.annotationViewer", + "bawApp.audioEvents", + "bawApp.annotationLibrary", + "bawApp.bookmarks", "bawApp.demo", - 'bawApp.error', - 'bawApp.home', - 'bawApp.listen', - 'bawApp.login', - 'bawApp.navigation', - 'bawApp.photos', - 'bawApp.projects', - 'bawApp.recordInformation', - 'bawApp.recordings', - 'bawApp.recordings.recentRecordings', - 'bawApp.search', - 'bawApp.tags', - 'bawApp.users', - 'bawApp.birdWalks', + "bawApp.error", + "bawApp.home", + "bawApp.listen", + "bawApp.login", + "bawApp.navigation", + "bawApp.photos", + "bawApp.projects", + "bawApp.recordInformation", + "bawApp.recordings", + "bawApp.recordings.recentRecordings", + "bawApp.search", + "bawApp.tags", + "bawApp.users", + "bawApp.birdWalks", "bawApp.visualize" ]) - .config(["$provide", '$routeProvider', '$locationProvider', '$httpProvider', 'conf.paths', 'conf.constants', '$sceDelegateProvider', 'growlProvider', 'localStorageServiceProvider', "cfpLoadingBarProvider", "$urlProvider", "casingTransformers", + .config(["$provide", "$routeProvider", "$locationProvider", "$httpProvider", "conf.paths", "conf.constants", "$sceDelegateProvider", "growlProvider", "localStorageServiceProvider", "cfpLoadingBarProvider", "$urlProvider", "casingTransformers", function ($provide, $routeProvider, $locationProvider, $httpProvider, paths, constants, $sceDelegateProvider, growlProvider, localStorageServiceProvider, cfpLoadingBarProvider, $urlProvider, casingTransformers) { // adjust security whitelist for resource urls var currentWhitelist = $sceDelegateProvider.resourceUrlWhitelist(); - currentWhitelist.push(paths.api.root+'/**'); + currentWhitelist.push(paths.api.root+"/**"); $sceDelegateProvider.resourceUrlWhitelist(currentWhitelist); @@ -127,7 +127,7 @@ var app = angular.module('baw', // routes $routeProvider. - when('/home', {templateUrl: '/assets/home.html', controller: 'HomeCtrl'}). + when("/home", {templateUrl: "/assets/home.html", controller: "HomeCtrl"}). //whenDefaults("projects", "project", ":projectId", 'ProjectsCtrl', 'ProjectCtrl'). //whenDefaults("sites", "site", ":siteId", 'SitesCtrl', 'SiteCtrl'). @@ -138,41 +138,41 @@ var app = angular.module('baw', //whenDefaults("audioEvents", "audioEvent", ":audioEventId", 'AudioEventsCtrl', 'AudioEventCtrl'). //whenDefaults("users", "user", ":userId", 'UsersCtrl', 'UserCtrl'). - when('/recordings', {templateUrl: '/assets/recordings.html', controller: 'RecordingsCtrl' }). - when('/recordings/:recordingId', - {templateUrl: '/assets/recording.html', controller: 'RecordingCtrl' }). + when("/recordings", {templateUrl: "/assets/recordings.html", controller: "RecordingsCtrl" }). + when("/recordings/:recordingId", + {templateUrl: "/assets/recording.html", controller: "RecordingCtrl" }). - when('/listen', {templateUrl: paths.site.files.recordings.recentRecordings, controller: 'RecentRecordingsCtrl', title: 'Listen'}). - when('/listen/:recordingId', {templateUrl: paths.site.files.listen, controller: 'ListenCtrl', title: ':recordingId', fullWidth: true}). + when("/listen", {templateUrl: paths.site.files.recordings.recentRecordings, controller: "RecentRecordingsCtrl", title: "Listen"}). + when("/listen/:recordingId", {templateUrl: paths.site.files.listen, controller: "ListenCtrl", title: ":recordingId", fullWidth: true}). //when('/listen/:recordingId/start=:start/end=:end', {templateUrl: paths.site.files.listen, controller: 'ListenCtrl'}). - when('/accounts', {templateUrl: '/assets/accounts_sign_in.html', controller: 'AccountsCtrl'}). - when('/accounts/:action', - {templateUrl: '/assets/accounts_sign_in.html', controller: 'AccountsCtrl'}). + when("/accounts", {templateUrl: "/assets/accounts_sign_in.html", controller: "AccountsCtrl"}). + when("/accounts/:action", + {templateUrl: "/assets/accounts_sign_in.html", controller: "AccountsCtrl"}). - when('/attribution', {templateUrl: '/assets/attributions.html'}). + when("/attribution", {templateUrl: "/assets/attributions.html"}). - when('/birdWalks', {templateUrl: paths.site.files.birdWalk.list, controller: 'BirdWalksCtrl', title: 'Bird Walks'}). - when('/birdWalks/:birdWalkId', {templateUrl: paths.site.files.birdWalk.detail, controller: 'BirdWalkCtrl', title: ':birdWalkId'}). + when("/birdWalks", {templateUrl: paths.site.files.birdWalk.list, controller: "BirdWalksCtrl", title: "Bird Walks"}). + when("/birdWalks/:birdWalkId", {templateUrl: paths.site.files.birdWalk.detail, controller: "BirdWalkCtrl", title: ":birdWalkId"}). // experiments - when('/experiments/:experiment', - {templateUrl: '/assets/experiment_base.html', controller: 'ExperimentsCtrl'}). + when("/experiments/:experiment", + {templateUrl: "/assets/experiment_base.html", controller: "ExperimentsCtrl"}). - when('/library', {templateUrl: paths.site.files.library.list, controller: 'AnnotationLibraryCtrl', title: 'Annotation Library' , fullWidth: true}). - when('/library/:recordingId', { + when("/library", {templateUrl: paths.site.files.library.list, controller: "AnnotationLibraryCtrl", title: "Annotation Library" , fullWidth: true}). + when("/library/:recordingId", { redirectTo: function (routeParams, path, search) { return "/library?audioRecordingId="+routeParams.recordingId;}, templateUrl: paths.site.files.library.list, title: ":recordingId" , fullWidth: true}). - when('/library/:recordingId/audio_events', { + when("/library/:recordingId/audio_events", { redirectTo: function (routeParams, path, search) { return "/library?audioRecordingId="+routeParams.recordingId;}, - title: 'Audio Events' }). - when('/library/:recordingId/audio_events/:audioEventId', {templateUrl: paths.site.files.library.item, controller: 'AnnotationItemCtrl', title: 'Annotation :audioEventId'}). + title: "Audio Events" }). + when("/library/:recordingId/audio_events/:audioEventId", {templateUrl: paths.site.files.library.item, controller: "AnnotationItemCtrl", title: "Annotation :audioEventId"}). - when(paths.site.ngRoutes.demo.d3, {templateUrl: paths.site.files.demo.d3, controller: 'D3TestPageCtrl', title: 'D3 Test Page' }). - when(paths.site.ngRoutes.demo.rendering, {templateUrl: paths.site.files.demo.rendering, controller: 'RenderingCtrl', title: 'Rendering' , fullWidth: true }). - when(paths.site.ngRoutes.demo.bdCloud, {templateUrl: paths.site.files.demo.bdCloud2014, controller: 'BdCloud2014Ctrl', title: 'BDCloud2014 demo' , fullWidth: true }). + when(paths.site.ngRoutes.demo.d3, {templateUrl: paths.site.files.demo.d3, controller: "D3TestPageCtrl", title: "D3 Test Page" }). + when(paths.site.ngRoutes.demo.rendering, {templateUrl: paths.site.files.demo.rendering, controller: "RenderingCtrl", title: "Rendering" , fullWidth: true }). + when(paths.site.ngRoutes.demo.bdCloud, {templateUrl: paths.site.files.demo.bdCloud2014, controller: "BdCloud2014Ctrl", title: "BDCloud2014 demo" , fullWidth: true }). when(paths.site.ngRoutes.visualize, { templateUrl: paths.site.files.visualize, @@ -182,12 +182,12 @@ var app = angular.module('baw', }). // missing route page - when('/', {templateUrl: paths.site.files.home, controller: 'HomeCtrl'}). - when('/404', {templateUrl: paths.site.files.error404, controller: 'ErrorCtrl'}). - when('/404?path=:errorPath', {templateUrl: paths.site.files.error404, controller: 'ErrorCtrl'}). + when("/", {templateUrl: paths.site.files.home, controller: "HomeCtrl"}). + when("/404", {templateUrl: paths.site.files.error404, controller: "ErrorCtrl"}). + when("/404?path=:errorPath", {templateUrl: paths.site.files.error404, controller: "ErrorCtrl"}). otherwise({ redirectTo: function (params, location, search) { - return '/404?path=' + location; + return "/404?path=" + location; } }); @@ -200,10 +200,10 @@ var app = angular.module('baw', // the default accept type is ` "application/json, text/plain, */*" ` // for angular. This causes rails to do stupid shit for things like 403s... with old header it gives a 302 // and redirects to HTML page. WTF. - $httpProvider.defaults.headers['common']['Accept'] = 'application/json'; + $httpProvider.defaults.headers.common.Accept = "application/json"; // configure angular-growl - growlProvider.globalPosition('top-center'); + growlProvider.globalPosition("top-center"); // configure local storage provider with our own namespace localStorageServiceProvider.setPrefix(constants.namespace); @@ -221,7 +221,7 @@ var app = angular.module('baw', cfpLoadingBarProvider.latencyThreshold = 200; // add a standard way to add ignores to http objects - $provide.decorator('cfpLoadingBar', ["$delegate", function ($delegate) { + $provide.decorator("cfpLoadingBar", ["$delegate", function ($delegate) { $delegate.ignore = function ($httpConfig) { return $httpConfig && ($httpConfig.ignoreLoadingBar = true, $httpConfig) || $httpConfig; }; @@ -230,7 +230,7 @@ var app = angular.module('baw', }]) - .run(['$rootScope', '$location', '$route', '$http', 'Authenticator', 'AudioEvent', 'conf.paths', 'UserProfile', 'ngAudioEvents', '$url', "predictiveCache", "conf.constants", + .run(["$rootScope", "$location", "$route", "$http", "Authenticator", "AudioEvent", "conf.paths", "UserProfile", "ngAudioEvents", "$url", "predictiveCache", "conf.constants", function ($rootScope, $location, $route, $http, Authenticator, AudioEvent, paths, UserProfile, ngAudioEvents, $url, predictiveCache, constants) { // embed configuration for easy site-wide binding @@ -250,7 +250,7 @@ var app = angular.module('baw', api.updatePreferences(); } }; - eventCallbacks["autoPlay"] = function(event, api, value) { + eventCallbacks.autoPlay = function(event, api, value) { if(api.profile.preferences.autoPlay !== value) { api.profile.preferences.autoPlay = value; api.updatePreferences(); @@ -268,7 +268,7 @@ var app = angular.module('baw', if (badKeys.indexOf(key) >= 0) { return "[Can't do that]"; } - if (typeof val == "object") { + if (typeof val === "object") { if (seen.indexOf(val) >= 0) { return ""; } @@ -316,7 +316,7 @@ var app = angular.module('baw', // $scope.alertType = "alert-error"; // $scope.alertMessage = "Failed to change routes :("; // $scope.active = ""; - $location.path('/404?path='); + $location.path("/404?path="); }); //https://docs.angularjs.org/api/ngRoute/service/$route @@ -359,7 +359,7 @@ var app = angular.module('baw', $rootScope.loggedIn = false; - $rootScope.$watch('userData', function () { + $rootScope.$watch("userData", function () { var token = $rootScope.authorisationToken, userData = $rootScope.userData; $rootScope.loggedIn = (token && userData) ? true : false; @@ -373,8 +373,8 @@ var app = angular.module('baw', }]) - .controller('AppCtrl', - ['$scope', '$location', 'conf.constants', 'growl', '$timeout', 'localStorageService', "bowser", + .controller("AppCtrl", + ["$scope", "$location", "conf.constants", "growl", "$timeout", "localStorageService", "bowser", function AppCtrl($scope, $location, constants, growl, $timeout, localStorageService, bowser) { $scope.showDebugUi = function () { @@ -387,7 +387,7 @@ var app = angular.module('baw', }; $scope.activePath = function activePath(pathFragment) { - return $location.path().indexOf(pathFragment) != -1; + return $location.path().indexOf(pathFragment) !== -1; }; /*$scope.getWidth = function () { return ($scope.$parent.fullWidth ? 'container-liquid' : 'container'); diff --git a/src/app/app.spec.js b/src/app/app.spec.js index ac9a3630..849dab17 100644 --- a/src/app/app.spec.js +++ b/src/app/app.spec.js @@ -1,6 +1,6 @@ -describe('AppCtrl', function() { +describe("AppCtrl", function() { - it('should pass a dummy test', function() { + it("should pass a dummy test", function() { expect(true).toBeTruthy(); }); }); \ No newline at end of file diff --git a/src/app/audioControl/volumeControl.js b/src/app/audioControl/volumeControl.js index eab939c1..bf426193 100644 --- a/src/app/audioControl/volumeControl.js +++ b/src/app/audioControl/volumeControl.js @@ -35,7 +35,7 @@ acds.directive("volumeControl", ["$parse", function ($parse) { }); // bind from the inputs to the model - muteButton.addEventListener('click', function() { + muteButton.addEventListener("click", function() { scope.$apply(function() { scope.model.muted = !scope.model.muted; }); @@ -46,7 +46,7 @@ acds.directive("volumeControl", ["$parse", function ($parse) { scope.model.volume = parseFloat(slider.value) / 100; }); } - slider.addEventListener('input', sliderChanged); + slider.addEventListener("input", sliderChanged); //slider.click(); } }; diff --git a/src/app/audioEvents/audioEvents.js b/src/app/audioEvents/audioEvents.js index 3d8eb19e..373aa50b 100644 --- a/src/app/audioEvents/audioEvents.js +++ b/src/app/audioEvents/audioEvents.js @@ -1,8 +1,8 @@ -angular.module('bawApp.audioEvents', []) +angular.module("bawApp.audioEvents", []) - .controller('AudioEventsCtrl', ['$scope', '$resource', 'AudioEvent', + .controller("AudioEventsCtrl", ["$scope", "$resource", "AudioEvent", function AudioEventsCtrl($scope, $resource, Project) { - $scope.audioEventsResource = $resource('/audioEvents', {}); + $scope.audioEventsResource = $resource("/audioEvents", {}); $scope.audioEvents = $scope.audioEventsResource.query(); $scope.links = function (key) { @@ -14,8 +14,8 @@ angular.module('bawApp.audioEvents', []) }; }]) - .controller('AudioEventCtrl', - ['$scope', '$resource', '$routeParams', 'AudioEvent', + .controller("AudioEventCtrl", + ["$scope", "$resource", "$routeParams", "AudioEvent", function AudioEventCtrl($scope, $resource, $routeParams, AudioEvent) { }]); diff --git a/src/app/birdWalks/birdWalks.js b/src/app/birdWalks/birdWalks.js index 929ade20..0e04c0ca 100644 --- a/src/app/birdWalks/birdWalks.js +++ b/src/app/birdWalks/birdWalks.js @@ -1,5 +1,5 @@ -angular.module('bawApp.birdWalks', []) - .controller('BirdWalksCtrl', ['$scope', '$resource', '$routeParams', '$route', '$http', 'BirdWalkService', 'conf.paths', +angular.module("bawApp.birdWalks", []) + .controller("BirdWalksCtrl", ["$scope", "$resource", "$routeParams", "$route", "$http", "BirdWalkService", "conf.paths", function BirdWalksCtrl($scope, $resource, $routeParams, $route, $http, BirdWalkService, paths) { // set up results $scope.results = { @@ -12,29 +12,30 @@ angular.module('bawApp.birdWalks', []) $scope.imagesPath = paths.site.files.birdWalk.imagesAbsolute; // download bird walk specification - BirdWalkService.getUrl(paths.site.files.birdWalk.specAbsolute, 'birdWalkSpec', $scope, null); - BirdWalkService.getUrl(paths.site.files.birdWalk.statsAbsolute, 'birdWalkStats', $scope, null); + BirdWalkService.getUrl(paths.site.files.birdWalk.specAbsolute, "birdWalkSpec", $scope, null); + BirdWalkService.getUrl(paths.site.files.birdWalk.statsAbsolute, "birdWalkStats", $scope, null); }]) - .controller('BirdWalkCtrl', ['$scope', '$resource', '$routeParams', '$route', '$http', 'BirdWalkService', 'conf.paths', + .controller("BirdWalkCtrl", ["$scope", "$resource", "$routeParams", "$route", "$http", "BirdWalkService", "conf.paths", function BirdWalkCtrl($scope, $resource, $routeParams, $route, $http, BirdWalkService, paths) { // constants - var CURRENT_LOCATION_ZOOM = 8; + //var CURRENT_LOCATION_ZOOM = 8; // initialise $scope.imagesPath = paths.site.files.birdWalk.imagesAbsolute; $scope.params = $routeParams; - BirdWalkService.getUrl(paths.site.files.birdWalk.statsAbsolute, 'birdWalkStats', $scope, null); - BirdWalkService.getUrl(paths.site.files.birdWalk.specAbsolute, 'birdWalkSpec', $scope, function () { + BirdWalkService.getUrl(paths.site.files.birdWalk.statsAbsolute, "birdWalkStats", $scope, null); + BirdWalkService.getUrl(paths.site.files.birdWalk.specAbsolute, "birdWalkSpec", $scope, function () { // set up page display $scope.walkDetails = $scope.spec.birdWalkSpec.walks[$scope.params.birdWalkId]; $scope.locationDetails = $scope.spec.birdWalkSpec.locations[$scope.walkDetails.locationName]; - var overviewLocation = new google.maps.LatLng( + throw new Error ("google not defined");/* + var overviewLocation;= new google.maps.LatLng( // jshint ignore:line $scope.walkDetails.overviewLocation.latitude, $scope.walkDetails.overviewLocation.longitude); - $scope.locationMap = $scope.createMap('locationMap', overviewLocation, CURRENT_LOCATION_ZOOM); + $scope.locationMap = $scope.createMap("locationMap", overviewLocation, CURRENT_LOCATION_ZOOM); var bounds = new google.maps.LatLngBounds(); $scope.walkDetails.waypoints.forEach(function(waypoint){ @@ -51,13 +52,15 @@ angular.module('bawApp.birdWalks', []) bounds.extend(overviewLocation); } - $scope.locationMap.fitBounds(bounds); + $scope.locationMap.fitBounds(bounds);*/ }); //$scope.spec.birdWalkSpec.walks - +/* $scope.createMap = function (elementId, LatLng, zoom) { + throw new Error("google is not defined"); + return new google.maps.Map( document.getElementById(elementId), { @@ -67,10 +70,10 @@ angular.module('bawApp.birdWalks', []) } ); }; - +*/ $scope.createMarker = function (map, LatLng, title) { - - var marker = new MarkerWithLabel({ + throw new Error("MarkerWithLabel is not defined"); + /*var marker = new MarkerWithLabel({ position: LatLng, draggable: true, raiseOnDrag: true, @@ -86,6 +89,7 @@ angular.module('bawApp.birdWalks', []) // map: map, // title: title // }); +*/ }; diff --git a/src/app/bookmarks/bookmarks.js b/src/app/bookmarks/bookmarks.js index 1ba1ece6..a89cfe55 100644 --- a/src/app/bookmarks/bookmarks.js +++ b/src/app/bookmarks/bookmarks.js @@ -1,9 +1,9 @@ -angular.module('bawApp.bookmarks', []) +angular.module("bawApp.bookmarks", []) - .controller('BookmarksCtrl', - ['$scope', '$resource', 'Bookmark', + .controller("BookmarksCtrl", + ["$scope", "$resource", "Bookmark", function BookmarksCtrl($scope, $resource, Bookmark) { - $scope.bookmarksResource = $resource('/bookmarks', {}); + $scope.bookmarksResource = $resource("/bookmarks", {}); $scope.bookmarks = $scope.bookmarksResource.query(); $scope.links = function (key) { @@ -14,8 +14,8 @@ angular.module('bawApp.bookmarks', []) alert("deleting bookmark {0}!".format(id)); }; }]) - .controller('BookmarkCtrl', - ['$scope', '$resource', '$routeParams', 'Bookmark', + .controller("BookmarkCtrl", + ["$scope", "$resource", "$routeParams", "Bookmark", function AudioEventCtrl($scope, $resource, $routeParams, Bookmark) { }]); \ No newline at end of file diff --git a/src/app/d3Bindings/audioView/audioView.js b/src/app/d3Bindings/audioView/audioView.js index a8beec23..61cd447c 100644 --- a/src/app/d3Bindings/audioView/audioView.js +++ b/src/app/d3Bindings/audioView/audioView.js @@ -8,9 +8,9 @@ angular.module("bawApp.d3.audioView", ["bawApp.vendorServices.auto"]) // d3 functions // private properties - globals, formatters, magic numbers - var parseFormat = d3.time.format("%Y-%m-%dT%H:%M:%S%Z"), - keyYearFormat = d3.time.format("%Y"), + var keyYearFormat = d3.time.format("%Y"), keyMonthFormat = d3.time.format("%m"); + // parseFormat = d3.time.format("%Y-%m-%dT%H:%M:%S%Z") var updateData = function updateData(json) { // change data so it is nested properly @@ -30,7 +30,7 @@ angular.module("bawApp.d3.audioView", ["bawApp.vendorServices.auto"]) .enter() .append("div") .text(function (d) {return d.key; }) - .attr('class', 'year'); + .attr("class", "year"); yearsData.exit().remove(); @@ -41,9 +41,9 @@ angular.module("bawApp.d3.audioView", ["bawApp.vendorServices.auto"]) monthData .enter() - .append('div') + .append("div") .text(function (d) {return d.key; }) - .attr('class', 'month'); + .attr("class", "month"); // select the first available month so there is something to work with var selectedMonthData = [data[0]]; @@ -56,9 +56,9 @@ angular.module("bawApp.d3.audioView", ["bawApp.vendorServices.auto"]) displayedYearData .enter() - .append('div') + .append("div") .text(function (d) {return d.key; }) - .attr('class', 'day'); + .attr("class", "day"); @@ -78,7 +78,7 @@ angular.module("bawApp.d3.audioView", ["bawApp.vendorServices.auto"]) // you can use the jQuery / d3 objects here (use the injected d3 instance) // where possible avoid jQuery - var element = $element[0]; + //var element = $element[0]; // watch for changes on scope data $scope.$watch(function () { diff --git a/src/app/d3Bindings/calendarView/calendarView.js b/src/app/d3Bindings/calendarView/calendarView.js index de9bea12..29119066 100644 --- a/src/app/d3Bindings/calendarView/calendarView.js +++ b/src/app/d3Bindings/calendarView/calendarView.js @@ -21,13 +21,7 @@ angular.module("bawApp.d3.calendarView", ["bawApp.vendorServices.auto"]) minYear = 2007, firstYear = null, //new Date().getFullYear(), lastYear = null, //2007 - colourDomain = [0, 100],//domain is input values, usually x - colourRangeStart = 0, // range is output values, usually y - colourRangeStop = 10, - colourRangeStep = 1, - defaultSelection = [ - {name: '-- Everything --', id: null} - ]; + colourRangeStop = 10; var color = d3.scale.quantize() .domain([0, 25]) @@ -41,13 +35,13 @@ angular.module("bawApp.d3.calendarView", ["bawApp.vendorServices.auto"]) for (var i = 0; i < json.length; i++) { var item = json[i]; var recordedDate = moment(item.recordedDate); - var key = recordedDate.format('YYYY-MM-DD'); + var key = recordedDate.format("YYYY-MM-DD"); var itemYear = parseInt(recordedDate.year()); - if (firstYear == null || itemYear > firstYear) { + if (firstYear === null || itemYear > firstYear) { firstYear = itemYear; } - if (lastYear == null || itemYear < lastYear) { + if (lastYear === null || itemYear < lastYear) { lastYear = itemYear; } @@ -59,7 +53,7 @@ angular.module("bawApp.d3.calendarView", ["bawApp.vendorServices.auto"]) } // get the max number of recordings in a day - if (colourRangeStop == null || data[key] > colourRangeStop) { + if (colourRangeStop === null || data[key] > colourRangeStop) { colourRangeStop = data[key]; } } @@ -197,7 +191,7 @@ angular.module("bawApp.d3.calendarView", ["bawApp.vendorServices.auto"]) // you can use the jQuery / d3 objects here (use the injected d3 instance) // where possible avoid jQuery - var element = $element[0]; + //var element = $element[0]; // TODO: merge options with defaults @@ -219,7 +213,7 @@ angular.module("bawApp.d3.calendarView", ["bawApp.vendorServices.auto"]) $scope.$watch(function () { return $scope.options.singleColor; }, function (n, o) { - if (n != o && $scope.data) { + if (n !== o && $scope.data) { updateFunction($scope.options); } }); diff --git a/src/app/d3Bindings/dotView/dotView.js b/src/app/d3Bindings/dotView/dotView.js index 4fad6ba0..742250c6 100644 --- a/src/app/d3Bindings/dotView/dotView.js +++ b/src/app/d3Bindings/dotView/dotView.js @@ -17,8 +17,8 @@ angular.module("bawApp.d3.dotView", ["bawApp.vendorServices.auto"]) // {"hoursOfDay": [[0,3],[1, 2], [2,6], [5, 1], ... [23, 1]], "year": 2012} // get start and end in +10 timezone - var start = moment(value.recordedDate).zone('+10:00'); - var end = moment(value.recordedDate).add(value.durationSeconds, 'seconds').zone('+10:00'); + var start = moment(value.recordedDate).zone("+10:00"); + var end = moment(value.recordedDate).add(value.durationSeconds, "seconds").zone("+10:00"); var startYear = start.year(); var startHour = start.hour(); @@ -26,14 +26,16 @@ angular.module("bawApp.d3.dotView", ["bawApp.vendorServices.auto"]) var minHour = Math.min(startHour, endHour); var maxHour = Math.max(startHour, endHour); + var found; for (var i = minHour; i <= maxHour; i++) { var hour = i; var foundYear = false; - angular.forEach(that.items, function (valueItem, keyItem) { + for (var j = 0; j < that.items.length; j++) { + let valueItem = that.items[j]; if (valueItem.year === startYear) { foundYear = true; var foundHour = false; - angular.forEach(valueItem.hoursOfDay, function (valueHours, keyHours) { + angular.forEach(valueItem.hoursOfDay, (valueHours, keyHours) => { var existingHour = valueHours[0]; if (hour === existingHour) { foundHour = true; @@ -45,15 +47,15 @@ angular.module("bawApp.d3.dotView", ["bawApp.vendorServices.auto"]) if (!foundHour) { // add hour and count if it does not exist - valueItem.hoursOfDay.push([hour, 1]) + valueItem.hoursOfDay.push([hour, 1]); } } - }); + } if (!foundYear) { that.items.push({"year": startYear, "hoursOfDay": [ [hour, 1] - ]}) + ]}); } } }); @@ -116,60 +118,60 @@ angular.module("bawApp.d3.dotView", ["bawApp.vendorServices.auto"]) .attr("transform", "translate(0," + 0 + ")") .call(xAxis); + function getFill(d) { + return c(dataIndex); + } + + function getX(d, i) { + return xScale(d[0]); + } + + function getRadius(d) { + return rScale(d[1]); + } + for (var j = 0; j < data.length; j++) { var dataIndex = j; var g = svg.append("g").attr("class", "journal"); var circles = g.selectAll("circle") - .data(data[j]['hoursOfDay']) + .data(data[j].hoursOfDay) .enter() .append("circle"); var text = g.selectAll("text") - .data(data[j]['hoursOfDay']) + .data(data[j].hoursOfDay) .enter() .append("text"); var rScale = d3.scale.linear() - .domain([0, d3.max(data[j]['hoursOfDay'], function (d) { + .domain([0, d3.max(data[j].hoursOfDay, function (d) { return d[1]; })]) .range([2, 9]); circles - .attr("cx", function (d, i) { - return xScale(d[0]); - }) + .attr("cx", getX) .attr("cy", j * 20 + 20) - .attr("r", function (d) { - return rScale(d[1]); - }) - .style("fill", function (d) { - return c(dataIndex); - }); + .attr("r", getRadius) + .style("fill", getFill); text .attr("y", j * 20 + 25) - .attr("x", function (d, i) { - return xScale(d[0]) - 5; - }) + .attr("x", (d, i) => xScale(d[0]) - 5) .attr("class", "value") .text(function (d) { return d[1]; }) - .style("fill", function (d) { - return c(dataIndex); - }) + .style("fill", (d) => c(dataIndex)) .style("display", "none"); g.append("text") .attr("y", j * 20 + 25) .attr("x", width + 20) .attr("class", "label") - .text(that.truncate(data[j]['year'], 30, "...")) - .style("fill", function (d) { - return c(dataIndex); - }) + .text(that.truncate(data[j].year, 30, "...")) + .style("fill", (d) => c(dataIndex)) .on("mouseover", that.mouseover) .on("mouseout", that.mouseout); } @@ -191,14 +193,14 @@ angular.module("bawApp.d3.dotView", ["bawApp.vendorServices.auto"]) // you can use the jQuery / d3 objects here (use the injected d3 instance) // where possible avoid jQuery - var element = $element[0]; + //var element = $element[0]; // watch for changes on scope data $scope.$watch(function () { return $scope.data; }, function (newValue, oldValue) { if (newValue) { - $scope.details = new DotViewDetails('audioRecordingDots', newValue); + $scope.details = new DotViewDetails("audioRecordingDots", newValue); } }); diff --git a/src/app/d3Bindings/eventDistribution/distributionDetail.js b/src/app/d3Bindings/eventDistribution/distributionDetail.js index d65fb6bd..9c471c64 100644 --- a/src/app/d3Bindings/eventDistribution/distributionDetail.js +++ b/src/app/d3Bindings/eventDistribution/distributionDetail.js @@ -81,7 +81,7 @@ angular } function updateExtent(extent) { - if (extent.length != 2) { + if (extent.length !== 2) { throw new Error("Can't handle this many dimensions"); } @@ -514,15 +514,15 @@ angular currentScale = fullDifference / visibleDifference, tx = vl; - if (scaleUpper == -Infinity) { + if (scaleUpper === -Infinity) { scaleUpper = Infinity; } - if (tx == Infinity || isNaN(tx)) { + if (tx === Infinity || isNaN(tx)) { tx = 0; } - if (currentScale == Infinity || currentScale == -Infinity || isNaN(currentScale)) { + if (currentScale === Infinity || currentScale === -Infinity || isNaN(currentScale)) { currentScale = 1; } diff --git a/src/app/d3Bindings/eventDistribution/distributionOverview.js b/src/app/d3Bindings/eventDistribution/distributionOverview.js index 88b6acd4..1373cc07 100644 --- a/src/app/d3Bindings/eventDistribution/distributionOverview.js +++ b/src/app/d3Bindings/eventDistribution/distributionOverview.js @@ -95,7 +95,7 @@ angular } function updateExtent(extent) { - if (extent.length != 2) { + if (extent.length !== 2) { throw new Error("Can't handle this many dimensions"); } diff --git a/src/app/d3Bindings/eventDistribution/distributionVisualisation.js b/src/app/d3Bindings/eventDistribution/distributionVisualisation.js index dfc26ceb..f90ab479 100644 --- a/src/app/d3Bindings/eventDistribution/distributionVisualisation.js +++ b/src/app/d3Bindings/eventDistribution/distributionVisualisation.js @@ -66,7 +66,7 @@ angular margin = { top: 23, right: 0, - left: 120 /* yAxisWidth*/, + left: 68 + yAxisWidth, bottom: 0 + xAxisHeight }, @@ -509,7 +509,7 @@ angular clickDate = xScale.invert(coordinates[0]); // now see if there is a match for the date! - var {url, roundedDate} = isNavigatable(clickDate); + var {url} = isNavigatable(clickDate); if (url) { console.warn( @@ -584,7 +584,7 @@ angular s = focusStemPath.stems, r = focusStemPath.root; - return `m-${hw} 0 l0 ${s} l${w} 0 l0 -${s} m-${hw} ${s} l0 ${r}` + return `m-${hw} 0 l0 ${s} l${w} 0 l0 -${s} m-${hw} ${s} l0 ${r}`; } }; } diff --git a/src/app/d3Bindings/eventDistribution/eventDistributionController.js b/src/app/d3Bindings/eventDistribution/eventDistributionController.js index 21398f23..4a9ddaa1 100644 --- a/src/app/d3Bindings/eventDistribution/eventDistributionController.js +++ b/src/app/d3Bindings/eventDistribution/eventDistributionController.js @@ -63,13 +63,13 @@ angular var humanDuration = difference === 0 ? "" : moment.duration(difference).humanize(); var selectedLane = self.detail.selectedCategory || self.data.lanes[0] || ""; - if (source != "DistributionOverview") { + if (source !== "DistributionOverview") { tryUpdateExtent("overview", newExtent); } - if (source != "DistributionDetail") { + if (source !== "DistributionDetail") { self.detail.updateExtent(newExtent); } - if (source != "DistributionVisualisation") { + if (source !== "DistributionVisualisation") { self.visualisation.updateMiddle(middlePointBetweenDates(newExtent), selectedLane); var visualizationMiddle = self.visualisation.visibleDuration; var humanized = visualizationMiddle && moment.duration(visualizationMiddle, "seconds").humanize() || ""; diff --git a/src/app/d3Bindings/terrainView/terrainView.js b/src/app/d3Bindings/terrainView/terrainView.js index 1351c668..5b388449 100644 --- a/src/app/d3Bindings/terrainView/terrainView.js +++ b/src/app/d3Bindings/terrainView/terrainView.js @@ -119,16 +119,16 @@ angular.module("bawApp.d3.terrainView", ["bawApp.vendorServices.auto"]) // {"datetime": "2014-09-10 15:00:00", "value": 5} // get start and end in +10 timezone - var start = moment(value.recordedDate).zone('+10:00'); - var end = moment(value.recordedDate).add(value.durationSeconds, 'seconds').zone('+10:00'); + var start = moment(value.recordedDate).zone("+10:00"); + var end = moment(value.recordedDate).add(value.durationSeconds, "seconds").zone("+10:00"); - var momentFormatString = 'YYYY-MM-DDTHH:00:00ZZ'; + var momentFormatString = "YYYY-MM-DDTHH:00:00ZZ"; // loop from start to end of recording, adding a minute each time. - var diff = end.diff(start.clone().startOf('hour'), 'hours'); + var diff = end.diff(start.clone().startOf("hour"), "hours"); for (var step = 0; step <= diff; step++) { - var current = start.clone().startOf('hour').add(step, 'hour'); + var current = start.clone().startOf("hour").add(step, "hour"); var currentFormatted = current.format(momentFormatString); if (!dataStructure[currentFormatted]) { dataStructure[currentFormatted] = 1; @@ -204,13 +204,13 @@ angular.module("bawApp.d3.terrainView", ["bawApp.vendorServices.auto"]) // you can use the jQuery / d3 objects here (use the injected d3 instance) // where possible avoid jQuery - var element = $element[0]; + //var element = $element[0]; // watch for changes on scope data $scope.$watch(function () { return $scope.data; }, function (newValue, oldValue) { - if (newValue && newValue != oldValue) { + if (newValue && newValue !== oldValue) { getData(newValue); } }); diff --git a/src/app/d3Bindings/timelineView/timelineView.js b/src/app/d3Bindings/timelineView/timelineView.js index c778340d..1fcd39f5 100644 --- a/src/app/d3Bindings/timelineView/timelineView.js +++ b/src/app/d3Bindings/timelineView/timelineView.js @@ -22,7 +22,7 @@ angular.module("bawApp.d3.timelineView", ["bawApp.vendorServices.auto"]) // build data structure angular.forEach(jsonResponse, function (value, key) { // ensure siteId is in lanes - if (that.lanes.indexOf(value.siteId) == -1) { + if (that.lanes.indexOf(value.siteId) === -1) { that.lanes.push(value.siteId); } @@ -31,7 +31,7 @@ angular.module("bawApp.d3.timelineView", ["bawApp.vendorServices.auto"]) "lane": that.lanes.indexOf(value.siteId), "id": value.id, "start": moment(value.recordedDate).unix(), - "end": moment(value.recordedDate).add(value.durationSeconds, 'seconds').unix() + "end": moment(value.recordedDate).add(value.durationSeconds, "seconds").unix() }); }); @@ -314,7 +314,7 @@ angular.module("bawApp.d3.timelineView", ["bawApp.vendorServices.auto"]) // you can use the jQuery / d3 objects here (use the injected d3 instance) // where possible avoid jQuery - var element = $element[0]; + //var element = $element[0]; // watch for changes on scope data $scope.$watch( @@ -323,7 +323,7 @@ angular.module("bawApp.d3.timelineView", ["bawApp.vendorServices.auto"]) }, function (newValue, oldValue) { if (newValue) { - $scope.details = new Details('audioRecordingTimeline', newValue); + $scope.details = new Details("audioRecordingTimeline", newValue); } }); diff --git a/src/app/demo/rendering.js b/src/app/demo/rendering.js index 9c00dbc4..ad491a1a 100644 --- a/src/app/demo/rendering.js +++ b/src/app/demo/rendering.js @@ -23,7 +23,7 @@ angular.module("bawApp.demo.rendering", []) ]; $scope.render = function () { console.log("loading csv"); - renderStart = performance.now(); + renderStart = window.performance.now(); var requests = csvFiles.map(function (path) { return $http.get(path); }); @@ -38,7 +38,7 @@ angular.module("bawApp.demo.rendering", []) var renderStart, parseStart, paintStart, contentLength; function parseCsv(responses) { console.log("parsing csv", renderStart); - parseStart = performance.now(); + parseStart = window.performance.now(); contentLength = 0; var data = responses.map(function (response) { contentLength += (+response.headers("content-length")); @@ -50,7 +50,7 @@ angular.module("bawApp.demo.rendering", []) function renderCsv(data) { console.log("rendering csv"); - paintStart = performance.now(); + paintStart = window.performance.now(); // ALL OF THIS DIRECT CANVAS MANIPULATION // SHOULD BE REFACTORED INTO A DIRECTIVE! @@ -68,7 +68,7 @@ angular.module("bawApp.demo.rendering", []) canvas.width = 1440; canvas.height = height; - var context = canvas.getContext('2d'), + var context = canvas.getContext("2d"), imageData = context.getImageData(0, 0, width, height), imgData = imageData.data; @@ -109,8 +109,8 @@ angular.module("bawApp.demo.rendering", []) } context.putImageData(imageData, 0, 0); - console.debug("Done", performance.now()); - var end = performance.now(); + console.debug("Done", window.performance.now()); + var end = window.performance.now(); $scope.transferTime = Math.round(parseStart - renderStart); $scope.parseTime = Math.round(paintStart - parseStart); $scope.paintTime = Math.round(end - paintStart); @@ -138,7 +138,7 @@ angular.module("bawApp.demo.rendering", []) //. "C:\Program Files\ImageMagick-6.9.0-Q16\convert.exe" -crop 1435x1@ .\eabad986-56d9-47b5-bec6-47458ffd3eae_101023-0000.ACI-ENT-EVN-trimmed72.png tiles/tile_%d.png $scope.loadTiles60 = function () { $scope.tiles60 = []; - tileStart = performance.now(); + tileStart = window.performance.now(); for (var i = min60; i < max60; i++) { // i == minute of day if (i % 60) { @@ -150,17 +150,17 @@ angular.module("bawApp.demo.rendering", []) $scope.increment = function() { tileCount++; if (tileCount >= 24) { - $scope.tileLoadTime = Math.round(performance.now() - tileStart); + $scope.tileLoadTime = Math.round(window.performance.now() - tileStart); } }; } ] -).directive('onLoad', function() { +).directive("onLoad", function() { return { - restrict: 'A', + restrict: "A", link: function(scope, element, attrs) { - element.bind('load', function() { + element.bind("load", function() { //call the function that was passed scope.$apply(attrs.onLoad); }); diff --git a/src/app/error/error.js b/src/app/error/error.js index ba70dd29..f5a3b51c 100644 --- a/src/app/error/error.js +++ b/src/app/error/error.js @@ -7,8 +7,8 @@ // //$httpProvider.defaults.headers. // // common['X-CSRF-Token'] = $['meta[name=csrf-token]'].attr('content'); //}); -angular.module('bawApp.error', []) - .controller('ErrorCtrl', ['$scope', +angular.module("bawApp.error", []) + .controller("ErrorCtrl", ["$scope", function ErrorCtrl($scope) { diff --git a/src/app/home/home.js b/src/app/home/home.js index ef084dbc..cffd3ac0 100644 --- a/src/app/home/home.js +++ b/src/app/home/home.js @@ -1,6 +1,6 @@ -angular.module('bawApp.home', []) +angular.module("bawApp.home", []) - .controller('HomeCtrl', ['$scope', '$resource', '$routeParams', 'Project', + .controller("HomeCtrl", ["$scope", "$resource", "$routeParams", "Project", function HomeCtrl($scope, $resource, $routeParams, Project) { /* // testing some es6 features diff --git a/src/app/listen/listen.js b/src/app/listen/listen.js index 6ebe3dc9..e76adbba 100644 --- a/src/app/listen/listen.js +++ b/src/app/listen/listen.js @@ -1,28 +1,28 @@ -angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead']) - - .controller('ListenCtrl', ['$scope', - '$resource', - '$location', - '$routeParams', - '$route', - '$q', - 'conf.paths', - 'conf.constants', - '$url', +angular.module("bawApp.listen", ["decipher.tags", "ui.bootstrap.typeahead"]) + + .controller("ListenCtrl", ["$scope", + "$resource", + "$location", + "$routeParams", + "$route", + "$q", + "conf.paths", + "conf.constants", + "$url", "lodash", - 'ngAudioEvents', - 'AudioRecording', - 'Media', + "ngAudioEvents", + "AudioRecording", + "Media", "baw.models.Media", - 'AudioEvent', - 'Tag', + "AudioEvent", + "Tag", "baw.models.Tag", - 'Taggings', - 'Site', - 'Project', - 'UserProfile', - 'UserProfileEvents', - 'Bookmark', + "Taggings", + "Site", + "Project", + "UserProfile", + "UserProfileEvents", + "Bookmark", "moment", /** * The listen controller. @@ -140,8 +140,8 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead']) }); // update urls on login events - $scope.$on('event:auth-loginRequired', function(){ if($scope.model.media) {$scope.model.media.formatPaths();} }); - $scope.$on('event:auth-loginConfirmed', function(){ if($scope.model.media) {$scope.model.media.formatPaths();} }); + $scope.$on("event:auth-loginRequired", function(){ if($scope.model.media) {$scope.model.media.formatPaths();} }); + $scope.$on("event:auth-loginConfirmed", function(){ if($scope.model.media) {$scope.model.media.formatPaths();} }); var media = MediaService .get( @@ -155,8 +155,8 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead']) $scope.model.media = new Media(value.data); var // moment works by reference - need to parse the date twice - sigh - absoluteStartChunk = moment($scope.model.media.recordedDate).add(parseFloat($scope.model.media.startOffset), 's'), - absoluteEndChunk = moment($scope.model.media.recordedDate).add(parseFloat($scope.model.media.endOffset), 's'); + absoluteStartChunk = moment($scope.model.media.recordedDate).add(parseFloat($scope.model.media.startOffset), "s"), + absoluteEndChunk = moment($scope.model.media.recordedDate).add(parseFloat($scope.model.media.endOffset), "s"); $scope.startOffsetAbsolute = absoluteStartChunk.format("HH:mm:ss"); $scope.endOffsetAbsolute = absoluteEndChunk.format("HH:mm:ss"); @@ -349,7 +349,7 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead']) if (!$scope.model.audioRecording) { return undefined; } - return moment($scope.model.audioRecording.recordedDate).add($scope.model.audioRecording.durationSeconds, 's').format("YYYY-MMM-DD, HH:mm:ss"); + return moment($scope.model.audioRecording.recordedDate).add($scope.model.audioRecording.durationSeconds, "s").format("YYYY-MMM-DD, HH:mm:ss"); }; @@ -388,7 +388,7 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead']) var baseDate = moment($scope.model.media.recordedDate), recordingOffset = parseFloat($scope.model.media.startOffset), - absolute = baseDate.add('s', recordingOffset + chunkOffset); + absolute = baseDate.add("s", recordingOffset + chunkOffset); return absolute.format("HH:mm:ss.SSS"); }; @@ -408,7 +408,7 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead']) return undefined; } - return moment($scope.model.media.recordedDate).add($scope.jumpToMinute, 'm').format("YYYY-MMM-DD, HH:mm:ss"); + return moment($scope.model.media.recordedDate).add($scope.jumpToMinute, "m").format("YYYY-MMM-DD, HH:mm:ss"); }; @@ -541,7 +541,7 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead']) // see: https://github.com/QutBioacoustics/baw-client/issues/227 event.targetScope.srcTags.indexOf = function myOwnHackyIndexOf(item) { if (item.name) { - return this.findIndex(c => c.text == item.name); + return this.findIndex(c => c.text === item.name); } else { // revert back to the standard implementation @@ -553,28 +553,28 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead']) var hackyCleaningOfFakeTags = function(arr) { arr.forEach(function(current, index) { if (!(current instanceof TagModel)) { - var real = $scope.tags.find(c => c.text == current.name); + var real = $scope.tags.find(c => c.text === current.name); arr[index] = real; } }); }; - $scope.$on('decipher.tags.initialized', function (event) { + $scope.$on("decipher.tags.initialized", function (event) { event.stopPropagation(); hackIndexOf(event); - console.debug('decipher.tags.initialized', arguments); + console.debug("decipher.tags.initialized", arguments); }); - $scope.$on('decipher.tags.keyup', function (event) { + $scope.$on("decipher.tags.keyup", function (event) { hackIndexOf(event); event.stopPropagation(); - console.debug('decipher.tags.keyup', arguments); + console.debug("decipher.tags.keyup", arguments); }); - $scope.$on('decipher.tags.added', function (event, addedTag) { + $scope.$on("decipher.tags.added", function (event, addedTag) { hackIndexOf(event); event.stopPropagation(); - console.debug('decipher.tags.added', arguments); + console.debug("decipher.tags.added", arguments); var taggingParameters = { recordingId: recordingId, @@ -585,7 +585,7 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead']) // HACK: find a proper tag when the tag is fake tag if (!addedTag.tag.id) { - var actualTagIndex = $scope.tags.findIndex(c => c.text == addedTag.tag.name); + var actualTagIndex = $scope.tags.findIndex(c => c.text === addedTag.tag.name); addedTag.tag = $scope.tags[actualTagIndex]; // MORE HACKS! repair its cache of deleted fake tags as well hackyCleaningOfFakeTags(event.targetScope._deletedSrcTags); @@ -600,7 +600,7 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead']) $scope.model.selectedAudioEvent.tags[index] = addedTag.tag; console.assert( - $scope.model.selectedAudioEvent.tags.length == + $scope.model.selectedAudioEvent.tags.length === $scope.model.selectedAudioEvent.taggings.length, "The taggings array and tags array are out of sync, this is bad"); @@ -610,18 +610,18 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead']) console.error("Tagging creation failed", response); }); }); - $scope.$on('decipher.tags.addfailed', function (event) { + $scope.$on("decipher.tags.addfailed", function (event) { hackIndexOf(event); event.stopPropagation(); - console.debug('decipher.tags.addfailed', arguments); + console.debug("decipher.tags.addfailed", arguments); }); - $scope.$on('decipher.tags.removed', function (event, removedTag) { + $scope.$on("decipher.tags.removed", function (event, removedTag) { hackIndexOf(event); event.stopPropagation(); - console.debug('decipher.tags.removed', arguments); + console.debug("decipher.tags.removed", arguments); var index = _.findIndex($scope.model.selectedAudioEvent.taggings, function (value) { - return value.tagId = removedTag.tag.id; + return value.tagId === removedTag.tag.id; }); var oldTagging = $scope.model.selectedAudioEvent.taggings[index]; @@ -632,7 +632,7 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead']) }; console.assert( - $scope.model.selectedAudioEvent.tags.length == + $scope.model.selectedAudioEvent.tags.length === $scope.model.selectedAudioEvent.taggings.length, "The taggings array and tags array are out of sync, this is bad"); diff --git a/src/app/listen/listen.tpl.html b/src/app/listen/listen.tpl.html index afee7fc2..7186fbf4 100644 --- a/src/app/listen/listen.tpl.html +++ b/src/app/listen/listen.tpl.html @@ -341,7 +341,5 @@

Stats

{{currentOffsetRecording()}} - - \ No newline at end of file diff --git a/src/app/login/login.js b/src/app/login/login.js index 11353bbf..7fbb8ff6 100644 --- a/src/app/login/login.js +++ b/src/app/login/login.js @@ -1,7 +1,7 @@ -angular.module('bawApp.login', []) +angular.module("bawApp.login", []) - .controller('LoginCtrl', - ['$scope', '$http', '$location', 'authService', 'AuthenticationProviders', 'Authenticator', + .controller("LoginCtrl", + ["$scope", "$http", "$location", "authService", "AuthenticationProviders", "Authenticator", function LoginCtrl($scope, $http, $location, authService, AuthenticationProviders, Authenticator) { $scope.submit = function (provider) { @@ -9,7 +9,7 @@ angular.module('bawApp.login', []) var authProvider = AuthenticationProviders[provider]; if (!authProvider) { - console.error('Unknown provider', authProvider, provider); + console.error("Unknown provider", authProvider, provider); throw "LoginCtrl:submit: Unknown Provider!"; } @@ -36,7 +36,7 @@ angular.module('bawApp.login', []) $scope.requireMoreInformation = null; $scope.additionalInformation = null; $scope.login = function () { - $scope.$emit('event:auth-loginRequired'); + $scope.$emit("event:auth-loginRequired"); }; $scope.logout = function () { @@ -47,7 +47,7 @@ angular.module('bawApp.login', []) provider = $scope.$root.userData.providerId; } catch (e) { - console.error('Error getting provider id', e); + console.error("Error getting provider id", e); } if (provider) { @@ -60,8 +60,8 @@ angular.module('bawApp.login', []) }; $scope.cancelLogin = function () { - $location.path('/'); - $scope.$emit('event:auth-loginCancelled'); + $location.path("/"); + $scope.$emit("event:auth-loginCancelled"); }; diff --git a/src/app/navigation/navigation.js b/src/app/navigation/navigation.js index a20e6858..59175d5a 100644 --- a/src/app/navigation/navigation.js +++ b/src/app/navigation/navigation.js @@ -1,16 +1,16 @@ -angular.module('bawApp.navigation', []) +angular.module("bawApp.navigation", []) - .directive('navigation', ['conf.paths', function (paths) { + .directive("navigation", ["conf.paths", function (paths) { return { - restrict: 'E', + restrict: "E", templateUrl: paths.site.files.navigation }; }]) .controller( - 'NavigationCtrl', - ['$scope', '$resource', '$route', '$routeParams', '$location', 'breadcrumbs', + "NavigationCtrl", + ["$scope", "$resource", "$route", "$routeParams", "$location", "breadcrumbs", function NavigationCtrl($scope, $resource, $route, $routeParams, $location, breadcrumbs) { $scope.$location = $location; $scope.$route = $route; diff --git a/src/app/photos/photos.js b/src/app/photos/photos.js index 14074843..3d03b9bb 100644 --- a/src/app/photos/photos.js +++ b/src/app/photos/photos.js @@ -1,8 +1,8 @@ -angular.module('bawApp.photos', []) +angular.module("bawApp.photos", []) - .controller('PhotosCtrl', ['$scope', '$resource', 'Photo', + .controller("PhotosCtrl", ["$scope", "$resource", "Photo", function PhotosCtrl($scope, $resource, Photo) { - $scope.photosResource = $resource('/photos', {}); + $scope.photosResource = $resource("/photos", {}); $scope.photos = $scope.photosResource.query(); $scope.links = function (key) { @@ -10,7 +10,7 @@ angular.module('bawApp.photos', []) }; }]) - .controller('PhotoCtrl', ['$scope', '$resource', '$routeParams', 'Photo', + .controller("PhotoCtrl", ["$scope", "$resource", "$routeParams", "Photo", function PhotoCtrl($scope, $resource, $routeParams, Photo) { @@ -20,7 +20,7 @@ angular.module('bawApp.photos', []) $scope.editing = $routeParams.editing === "edit"; $scope.photo = photoResource.get(routeArgs, function () { - $scope.links = PhotosCtrl.linkList($scope.photo.id); + //$scope.links = PhotosCtrl.linkList($scope.photo.id); $scope.original = angular.copy($scope.project); diff --git a/src/app/projects/project_details.tpl.html b/src/app/projects/project_details.tpl.html index 72b9b50a..b93b4ba8 100644 --- a/src/app/projects/project_details.tpl.html +++ b/src/app/projects/project_details.tpl.html @@ -116,6 +116,4 @@

New Photo

- - \ No newline at end of file diff --git a/src/app/projects/projects.js b/src/app/projects/projects.js index fcd6ee2b..e1d1fde6 100644 --- a/src/app/projects/projects.js +++ b/src/app/projects/projects.js @@ -1,8 +1,8 @@ -angular.module('bawApp.projects', []) +angular.module("bawApp.projects", []) - .controller('ProjectsCtrl', ['$scope', '$resource', 'Project', + .controller("ProjectsCtrl", ["$scope", "$resource", "Project", function ProjectsCtrl($scope, $resource, Project) { - $scope.projectsResource = $resource('/projects', {}); + $scope.projectsResource = $resource("/projects", {}); $scope.projects = $scope.projectsResource.query(); $scope.links = function (key) { @@ -10,7 +10,7 @@ angular.module('bawApp.projects', []) }; }]) - .controller('ProjectCtrl', ['$scope', '$location', '$resource', '$routeParams', 'Project', 'Site', 'Photo', 'AudioEvent', + .controller("ProjectCtrl", ["$scope", "$location", "$resource", "$routeParams", "Project", "Site", "Photo", "AudioEvent", function ProjectCtrl($scope, $location, $resource, $routeParams, Project, Site, Photo, AudioEvent) { var self = this; @@ -46,7 +46,7 @@ angular.module('bawApp.projects', []) $scope.isEditing = $routeParams.editing === "edit"; - $scope.isCreating = $routeParams.projectId === 'new'; + $scope.isCreating = $routeParams.projectId === "new"; $scope.isCreatingOrEditing = $scope.isEditing || $scope.isCreating; @@ -62,7 +62,7 @@ angular.module('bawApp.projects', []) // }; $scope.project = projectResource.get(routeArgs, function () { - $scope.links = ProjectsCtrl.linkList($scope.project.id); + //$scope.links = ProjectsCtrl.linkList($scope.project.id); $scope.original = angular.copy($scope.project); @@ -98,19 +98,19 @@ angular.module('bawApp.projects', []) }; $scope.deletePhoto = function (photoToDelete) { - console.log('deletePhoto', photoToDelete); + console.log("deletePhoto", photoToDelete); var doit = confirm("Are you sure you want to delete this photo from uri {0} ?".format(photoToDelete.uri)); if (doit) { var index = $scope.project.photos.indexOf(photoToDelete); if (index > -1) { - var removedPhoto = $scope.project.photos.splice(index, 1); + $scope.project.photos.splice(index, 1); } } }; $scope.addPhoto = function addPhoto(newPhoto) { - console.log('addPhoto', newPhoto); + console.log("addPhoto", newPhoto); if (newPhoto) { $scope.project.photos.push(newPhoto); } diff --git a/src/app/recordInformation/recordInformation.js b/src/app/recordInformation/recordInformation.js index a9ff5d08..05a18e21 100644 --- a/src/app/recordInformation/recordInformation.js +++ b/src/app/recordInformation/recordInformation.js @@ -1,6 +1,6 @@ -angular.module('bawApp.recordInformation', []) +angular.module("bawApp.recordInformation", []) -.controller('RecordInformationCtrl', null); +.controller("RecordInformationCtrl", null); //function RecordInformationCtrl($scope, $element, $attrs, $transclude, $resource) { // // console.log($scope); diff --git a/src/app/recordings/recentRecordings/recentRecordings.js b/src/app/recordings/recentRecordings/recentRecordings.js index ab904f96..3c246f47 100644 --- a/src/app/recordings/recentRecordings/recentRecordings.js +++ b/src/app/recordings/recentRecordings/recentRecordings.js @@ -49,7 +49,7 @@ angular.module("bawApp.recordings.recentRecordings", []) }); $scope.navigate = function navigate($event, link) { - if ($event.target.nodeName.toLowerCase() == "a") { + if ($event.target.nodeName.toLowerCase() === "a") { return; } diff --git a/src/app/recordings/recordings.js b/src/app/recordings/recordings.js index 3ad0c493..9b38bff4 100644 --- a/src/app/recordings/recordings.js +++ b/src/app/recordings/recordings.js @@ -1,16 +1,16 @@ -angular.module('bawApp.recordings', []) +angular.module("bawApp.recordings", []) -.controller('RecordingsCtrl', ['$scope', '$resource', +.controller("RecordingsCtrl", ["$scope", "$resource", function RecordingsCtrl($scope, $resource) { - $scope.recordingsResource = $resource('/audio_recordings', {}, { get: { method:'GET', params:{}, isArray: true }}); + $scope.recordingsResource = $resource("/audio_recordings", {}, { get: { method:"GET", params:{}, isArray: true }}); $scope.recordings = $scope.recordingsResource.get(); }]) -.controller('RecordingCtrl', ['$scope', '$resource', +.controller("RecordingCtrl", ["$scope", "$resource", function RecordingCtrl($scope, $resource) { - var recordingResource = $resource('/audio_recordings/:recordingId', {recordingId: '@id'}, { - get: { method:'GET', params:{recordingId: '@id'}, isArray: false } + var recordingResource = $resource("/audio_recordings/:recordingId", {recordingId: "@id"}, { + get: { method:"GET", params:{recordingId: "@id"}, isArray: false } }); $scope.recording = recordingResource.get({recordingId:1}); diff --git a/src/app/search/search.js b/src/app/search/search.js index ffe6da4d..771a61c9 100644 --- a/src/app/search/search.js +++ b/src/app/search/search.js @@ -1,12 +1,12 @@ -angular.module('bawApp.search', []) +angular.module("bawApp.search", []) -.controller('SearchesCtrl', ['$scope', '$resource', 'Search', +.controller("SearchesCtrl", ["$scope", "$resource", "Search", function SearchesCtrl($scope, $resource, Search) { // $scope.sitesResource = $resource('/sites', {}, { get: { method:'GET', params:{}, isArray: true }}); // $scope.sites = $scope.sitesResource.get(); }]) -.controller('SearchCtrl', ['$scope', '$resource', 'Search', +.controller("SearchCtrl", ["$scope", "$resource", "Search", function SearchCtrl($scope, $resource, Search) { // $scope.sitesResource = $resource('/sites', {}, { get: { method:'GET', params:{}, isArray: true }}); diff --git a/src/app/sites/sites.js b/src/app/sites/sites.js index 72ad09d5..75aee377 100644 --- a/src/app/sites/sites.js +++ b/src/app/sites/sites.js @@ -1,9 +1,9 @@ -angular.module('sites', []) +angular.module("sites", []) -.controller('SitesCtrl', ['$scope', '$resource', 'Site', +.controller("SitesCtrl", ["$scope", "$resource", "Site", function SitesCtrl($scope, $resource, Site) { - $scope.sitesResource = $resource('/sites', {}); + $scope.sitesResource = $resource("/sites", {}); $scope.sites = $scope.sitesResource.query(); $scope.links = function(key) { @@ -11,8 +11,8 @@ function SitesCtrl($scope, $resource, Site) { }; }]) -.controller('SiteCtrl', - ['$scope', '$resource', '$routeParams', 'Project', 'Site', 'AudioRecording', 'AudioEvent', +.controller("SiteCtrl", + ["$scope", "$resource", "$routeParams", "Project", "Site", "AudioRecording", "AudioEvent", function SiteCtrl($scope, $resource, $routeParams, Project, Site, AudioRecording, AudioEvent) { var siteResource = Site; var routeArgs = {siteId: $routeParams.siteId}; @@ -26,7 +26,7 @@ function SiteCtrl($scope, $resource, $routeParams, Project, Site, AudioRecording $scope.editing = $routeParams.editing === "edit"; $scope.site = siteResource.get(routeArgs, function () { - $scope.links = SitesCtrl.linkList($scope.site.id); + //$scope.links = SitesCtrl.linkList($scope.site.id); $scope.site.latitude = +($scope.site.latitude); $scope.site.longitude = +($scope.site.longitude); @@ -39,7 +39,7 @@ function SiteCtrl($scope, $resource, $routeParams, Project, Site, AudioRecording $scope["delete"] = function() { var doit = confirm("Are you sure you want to delete this site (id {0})?".format(this.site.id)); if (doit) { - siteResource.remove(this.site.id, function(){ console.log('success');}, function(){ console.log('error');}); + siteResource.remove(this.site.id, function(){ console.log("success");}, function(){ console.log("error");}); } }; diff --git a/src/app/tags/tags.js b/src/app/tags/tags.js index ca360d18..c7fd16a0 100644 --- a/src/app/tags/tags.js +++ b/src/app/tags/tags.js @@ -1,4 +1,4 @@ -angular.module('bawApp.tags', []) +angular.module("bawApp.tags", []) // these controller names conflicted with the angular-tags component. // since we don't use them they have been disabled. diff --git a/src/app/users/users.js b/src/app/users/users.js index 415a1cb1..aad05b2b 100644 --- a/src/app/users/users.js +++ b/src/app/users/users.js @@ -1,11 +1,9 @@ -angular.module('bawApp.users', []) +angular.module("bawApp.users", []) - .controller('UsersCtrl', ['$scope', '$location', '$resource', '$routeParams', 'User', + .controller("UsersCtrl", ["$scope", "$location", "$resource", "$routeParams", "moment", "User", - function UsersCtrl($scope, $location, $resource, $routeParams, User) { - - var self = this; + function UsersCtrl($scope, $location, $resource, $routeParams, moment, User) { var userResource = User; var routeArgs = {userId: $routeParams.userId}; @@ -18,11 +16,11 @@ angular.module('bawApp.users', []) ]) - .controller('UserCtrl', ['$scope', '$resource', '$routeParams', 'User', + .controller("UserCtrl", ["$scope", "$resource", "$routeParams", "User", function UsersCtrl($scope, $resource, $routeParams, User) { - $scope.usersResource = $resource('/users', {}); + $scope.usersResource = $resource("/users", {}); $scope.users = $scope.usersResource.query(); } diff --git a/src/app/visualize/visualize.js b/src/app/visualize/visualize.js index 651ec7b2..3216ada3 100644 --- a/src/app/visualize/visualize.js +++ b/src/app/visualize/visualize.js @@ -66,7 +66,7 @@ angular $scope.$watch(function() { return $scope.showOverview; }, function (newValue) { - if (UserProfile.profile && newValue != UserProfile.profile.preferences.visualize.showTemporalContext) { + if (UserProfile.profile && newValue !== UserProfile.profile.preferences.visualize.showTemporalContext) { UserProfile.profile.preferences.visualize.showTemporalContext = newValue; UserProfile.updatePreferences(); diff --git a/src/baw.configuration.tpl.js b/src/baw.configuration.tpl.js index cb8b457f..1b82f056 100644 --- a/src/baw.configuration.tpl.js +++ b/src/baw.configuration.tpl.js @@ -1,4 +1,4 @@ -angular.module('bawApp.configuration', ['url']) +angular.module("bawApp.configuration", ["url"]) /** * This module contains static paths that are stored centrally for easy configuration. @@ -41,8 +41,8 @@ angular.module('bawApp.configuration', ['url']) show: "/audio_recordings/{recordingId}/audio_events/{audioEventId}/taggings/{taggingId}" }, tag: { - list: '/tags/', - show: '/tags/{tagId}', + list: "/tags/", + show: "/tags/{tagId}", filter: "/tags/filter" }, media: { @@ -59,7 +59,7 @@ angular.module('bawApp.configuration', ['url']) filter: "/user_accounts/filter" }, audioEventComment: { - show: '/audio_events/{audioEventId}/comments/{audioEventCommentId}' + show: "/audio_events/{audioEventId}/comments/{audioEventCommentId}" }, bookmark: { show: "/bookmarks/{bookmarkId}" @@ -69,16 +69,16 @@ angular.module('bawApp.configuration', ['url']) } }, links: { - projects: '/projects', - home: '/', - project: '/projects/{projectId}', - site: '/projects/{projectId}/sites/{siteId}', - userAccounts: '/user_accounts/{userId}', - websiteStatus: '/website_status', - contactUs: '/contact_us', - disclaimers: '/disclaimers', - credits: '/credits', - ethicsStatement: '/ethics_statement', + projects: "/projects", + home: "/", + project: "/projects/{projectId}", + site: "/projects/{projectId}/sites/{siteId}", + userAccounts: "/user_accounts/{userId}", + websiteStatus: "/website_status", + contactUs: "/contact_us", + disclaimers: "/disclaimers", + credits: "/credits", + ethicsStatement: "/ethics_statement", login: "/errors/unauthorized" } @@ -88,31 +88,31 @@ angular.module('bawApp.configuration', ['url']) // The following intentionally are not prefixed with a '/' // static files files: { - error404: 'error/error_404.tpl.html', - home: 'home/home.tpl.html', - listen: 'listen/listen.tpl.html', - annotationViewer: 'annotationViewer/annotationViewer.tpl.html', - gridLines: 'annotationViewer/gridLines/gridLines.tpl.html', - annotationComments: 'annotationLibrary/comments/comments.tpl.html', + error404: "error/error_404.tpl.html", + home: "home/home.tpl.html", + listen: "listen/listen.tpl.html", + annotationViewer: "annotationViewer/annotationViewer.tpl.html", + gridLines: "annotationViewer/gridLines/gridLines.tpl.html", + annotationComments: "annotationLibrary/comments/comments.tpl.html", library: { - list: 'annotationLibrary/annotationLibrary.tpl.html', - item: 'annotationLibrary/annotationItem.tpl.html' + list: "annotationLibrary/annotationLibrary.tpl.html", + item: "annotationLibrary/annotationItem.tpl.html" }, - navigation: 'navigation/navigation.tpl.html', + navigation: "navigation/navigation.tpl.html", birdWalk: { - list: 'birdWalks/birdWalks.tpl.html', - detail: 'birdWalks/birdWalk.tpl.html', - spec: 'assets/bird_walk/bird_walk_spec.json', - stats: 'assets/bird_walk/bird_walk_stats.json', - images: 'assets/bird_walk/images/' + list: "birdWalks/birdWalks.tpl.html", + detail: "birdWalks/birdWalk.tpl.html", + spec: "assets/bird_walk/bird_walk_spec.json", + stats: "assets/bird_walk/bird_walk_stats.json", + images: "assets/bird_walk/images/" }, recordings: { - recentRecordings: 'recordings/recentRecordings/recentRecordings.tpl.html' + recentRecordings: "recordings/recentRecordings/recentRecordings.tpl.html" }, demo: { - d3: 'demo/d3TestPage.tpl.html', - rendering: 'demo/rendering.tpl.html', - bdCloud2014: 'demo/BDCloud2014Demo.tpl.html' + d3: "demo/d3TestPage.tpl.html", + rendering: "demo/rendering.tpl.html", + bdCloud2014: "demo/BDCloud2014Demo.tpl.html" }, d3Bindings: { eventDistribution: { @@ -197,7 +197,7 @@ angular.module('bawApp.configuration', ['url']) recursivePath(source[key], root); } else { - source[key + 'Absolute'] = joinPathFragments(root, source[key]); + source[key + "Absolute"] = joinPathFragments(root, source[key]); } } } @@ -277,6 +277,8 @@ angular.module('bawApp.configuration', ['url']) profiles: { "Media cache ahead": function bind($location, paths) { + const imageFormat = "png"; + const audioFormat = "mp3"; // request additional bits of media based the duration of the original request // do not make requests that would exceed the end of the recording function mediaProgressor(previous, data) { @@ -315,11 +317,11 @@ angular.module('bawApp.configuration', ['url']) request: [ // spectrogram function (counters, data) { - return formatMediaUrl(data.responseData.data.available.image["png"].url, counters); + return formatMediaUrl(data.responseData.data.available.image[imageFormat].url, counters); }, // mp3 function (counters, data) { - return formatMediaUrl(data.responseData.data.available.audio["mp3"].url, counters); + return formatMediaUrl(data.responseData.data.available.audio[audioFormat].url, counters); } ], progression: [ diff --git a/src/common/100-String.format.js b/src/common/100-String.format.js index 34afd6f9..cc6a8924 100644 --- a/src/common/100-String.format.js +++ b/src/common/100-String.format.js @@ -54,10 +54,10 @@ returns: 'some string with first value and second value injected using {property //returns true for null, undefined and empty string function isEmpty(obj) { - if (typeof obj == 'undefined' || obj === null || obj === '') { + if (typeof obj === "undefined" || obj === null || obj === "") { return true; } - if (typeof obj == 'number' && isNaN(obj)) { + if (typeof obj === "number" && isNaN(obj)) { return true; } return obj instanceof Date && isNaN(Number(obj)); @@ -67,21 +67,21 @@ returns: 'some string with first value and second value injected using {property // don't expose this method, it isn't safe for use outside this script function getFormatter(obj) { //it's a string, undefined or null, use default toString method - if (typeof obj == "string" || typeof obj == "undefined" || obj === null) { + if (typeof obj === "string" || typeof obj === "undefined" || obj === null) { return String.prototype.toString; } //it has a format method - if (typeof obj.format == "function") { + if (typeof obj.format === "function") { return obj.format; } //determine the constructor base & prototype to use var ctor = (function(o) { - if (typeof o == 'number') { + if (typeof o === "number") { return Number; } - if (typeof o == 'boolean') { + if (typeof o === "boolean") { return Boolean; } return o.constructor; @@ -89,17 +89,17 @@ returns: 'some string with first value and second value injected using {property var proto = ctor.prototype; //prototype has a format method use it (why was it overriden/deleted from the instance?) - if (proto && typeof proto.format == 'function') { + if (proto && typeof proto.format === "function") { return ctor.prototype.format; } //object has a toString method use it - if (typeof obj.toString == 'function') { + if (typeof obj.toString === "function") { return obj.toString; } //prototype has a toString method use it - if (proto && typeof proto.toString == 'function') { + if (proto && typeof proto.toString === "function") { return proto.toString; } @@ -128,7 +128,7 @@ returns: 'some string with first value and second value injected using {property try { return formatter.call(obj,""); } catch(err1) { - if (typeof console != "undefined") { + if (typeof console !== "undefined") { (console.error || console.log)(err1); } return ""; //unable to format @@ -153,7 +153,7 @@ returns: 'some string with first value and second value injected using {property } //it's a string, return it as-is - if (typeof source == "string") { + if (typeof source === "string") { return String(source); } @@ -179,13 +179,13 @@ returns: 'some string with first value and second value injected using {property var params = args.slice(1); //only one param - if (params.length == 1) { + if (params.length === 1) { //set the params to the instance of the one param params = params[0]; //use an empty string for null and undefined valuse if (params === null || params === undef) { - return ['']; + return [""]; } //reference to the type of params @@ -240,18 +240,18 @@ returns: 'some string with first value and second value injected using {property var ret = source.replace( /\{\{|\}\}|\{([^}: ]+?)(?::([^}]*?))?\}/g, function(match, num, format) { - if (match == "{{") { + if (match === "{{") { //unescape the nested { return "{"; } - if (match == "}}") { + if (match === "}}") { //unescape the nested } return "}"; } - if (typeof params[num] == "undefined") { + if (typeof params[num] === "undefined") { //if there was only one parameter, and the match is "0", and there's no "0" in params, use the params as the binding formatter //should fix "... {0:...}".toFormat(singleItem) - if (num === "0" && outerLength == 2) { + if (num === "0" && outerLength === 2) { var str2 = stringFromAny(params, format); if (trimObject) { diff = null; @@ -275,17 +275,17 @@ returns: 'some string with first value and second value injected using {property } //main string formatter - if (typeof String.format != "function") { + if (typeof String.format !== "function") { String.format = stringformat; } - if (typeof String.asFormat != "function") { + if (typeof String.asFormat !== "function") { String.asFormat = stringformat; } //create a format method for string instances - if (typeof String.prototype.format != "function") { - String.prototype.format = function() { + if (typeof String.prototype.format !== "function") { + String.prototype.format = function() { // jshint ignore:line var args = Array.prototype.slice.call(arguments); args.unshift(this); args.unshift(false); @@ -293,13 +293,13 @@ returns: 'some string with first value and second value injected using {property }; } - if (typeof String.prototype.formatReturnUnused != "function") { + if (typeof String.prototype.formatReturnUnused !== "function") { /** * A string formatter that takes in arguments, returns a formatted string, and returns any unused arguments. * @param {Object} lookup - The lookup hash * @returns {Object.} The formatted string along with any unused arguments */ - String.prototype.formatReturnUnused = function() { + String.prototype.formatReturnUnused = function() { // jshint ignore:line var args = Array.prototype.slice.call(arguments); args.unshift(this); args.unshift(true); @@ -307,8 +307,8 @@ returns: 'some string with first value and second value injected using {property }; } - if (typeof String.prototype.asFormat != "function") { - String.prototype.asFormat = function() { + if (typeof String.prototype.asFormat !== "function") { + String.prototype.asFormat = function() { // jshint ignore:line var args = Array.prototype.slice.call(arguments); args.unshift(this); args.unshift(false); diff --git a/src/common/cssRules.js b/src/common/cssRules.js index b1c47361..5794412e 100644 --- a/src/common/cssRules.js +++ b/src/common/cssRules.js @@ -24,10 +24,10 @@ if (cssRules && cssRules.length > 0) { for (var j = 0; j < cssRules.length; j++) { var rule = cssRules[j]; - var selector = rule.hasOwnProperty('selectorText') ? rule.selectorText.toLowerCase().trim() : ''; + var selector = rule.hasOwnProperty("selectorText") ? rule.selectorText.toLowerCase().trim() : ""; //console.log(selector); - if (selector == ruleName) { - if (deleteFlag == 'delete') { + if (selector === ruleName) { + if (deleteFlag === "delete") { if (styleSheet.cssRules) { styleSheet.deleteRule(j); } else { @@ -47,7 +47,7 @@ } function killCSSRule(ruleName) { - return getCSSRule(ruleName, 'delete'); + return getCSSRule(ruleName, "delete"); } function addCSSRule(ruleName) { @@ -56,7 +56,7 @@ if (document.styleSheets[0].addRule) { document.styleSheets[0].addRule(ruleName, null, 0); } else { - document.styleSheets[0].insertRule(ruleName, ' { }', 0); + document.styleSheets[0].insertRule(ruleName, " { }", 0); } } } diff --git a/src/common/functions.js b/src/common/functions.js index 6f131b41..876ca098 100644 --- a/src/common/functions.js +++ b/src/common/functions.js @@ -32,7 +32,7 @@ Math.randomInt = function getRandomInt(min, max) { Math.isInt = function isInt(value) { return !isNaN(value) && - parseInt(Number(value)) == value && + parseInt(Number(value)) === value && !isNaN(parseInt(value, 10)); }; @@ -50,39 +50,39 @@ Math.isInt = function isInt(value) { */ function decimalAdjust(type, value, exp) { // If the exp is undefined or zero... - if (typeof exp === 'undefined' || +exp === 0) { + if (typeof exp === "undefined" || +exp === 0) { return Math[type](value); } value = +value; exp = +exp; // If the value is not a number or the exp is not an integer... - if (isNaN(value) || !(typeof exp === 'number' && exp % 1 === 0)) { + if (isNaN(value) || !(typeof exp === "number" && exp % 1 === 0)) { return NaN; } // Shift - value = value.toString().split('e'); - value = Math[type](+(value[0] + 'e' + (value[1] ? (+value[1] - exp) : -exp))); + value = value.toString().split("e"); + value = Math[type](+(value[0] + "e" + (value[1] ? (+value[1] - exp) : -exp))); // Shift back - value = value.toString().split('e'); - return +(value[0] + 'e' + (value[1] ? (+value[1] + exp) : exp)); + value = value.toString().split("e"); + return +(value[0] + "e" + (value[1] ? (+value[1] + exp) : exp)); } // Decimal round if (!Math.round10) { Math.round10 = function(value, exp) { - return decimalAdjust('round', value, exp); + return decimalAdjust("round", value, exp); }; } // Decimal floor if (!Math.floor10) { Math.floor10 = function(value, exp) { - return decimalAdjust('floor', value, exp); + return decimalAdjust("floor", value, exp); }; } // Decimal ceil if (!Math.ceil10) { Math.ceil10 = function(value, exp) { - return decimalAdjust('ceil', value, exp); + return decimalAdjust("ceil", value, exp); }; } @@ -93,7 +93,7 @@ Math.isInt = function isInt(value) { * IndexOf Shim */ if (!Array.prototype.indexOf) { - Array.prototype.indexOf = function (what, i) { + Array.prototype.indexOf = function (what, i) { // jshint ignore:line i = i || 0; var L = this.length; while (i < L) { @@ -112,7 +112,7 @@ if (!Array.prototype.indexOf) { */ if (!Array.prototype.filter) { - Array.prototype.filter = function (fun /*, thisp */) { + Array.prototype.filter = function (fun /*, thisp */) { // jshint ignore:line "use strict"; if (this == null) { @@ -120,8 +120,8 @@ if (!Array.prototype.filter) { } var t = Object(this); - var len = t.length >>> 0; - if (typeof fun != "function") { + var len = t.length >>> 0; // jshint ignore:line + if (typeof fun !== "function") { throw new TypeError(); } @@ -156,11 +156,11 @@ if (!Array.prototype.filter) { (function requestAnimationFramePolyfill() { var lastTime = 0, - vendors = ['ms', 'moz', 'webkit', 'o']; + vendors = ["ms", "moz", "webkit", "o"]; for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { - window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame']; - window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame']; + window.requestAnimationFrame = window[vendors[x] + "RequestAnimationFrame"]; + window.cancelAnimationFrame = window[vendors[x] + "CancelAnimationFrame"] || window[vendors[x] + "CancelRequestAnimationFrame"]; } if (!window.requestAnimationFrame) { @@ -198,7 +198,7 @@ if (!Array.prototype.filter) { var i, j, t; for (i = 1; i < list.length; i++) { j = Math.floor(Math.random() * (1 + i)); // choose j in [0..i] - if (j != i) { + if (j !== i) { t = list[i]; // swap list[i] and list[j] list[i] = list[j]; list[j] = t; @@ -243,7 +243,7 @@ if (!Array.prototype.filter) { var output = number.toString(); if (!paddingCharacter) { - paddingCharacter = '0'; + paddingCharacter = "0"; } while (padLoop < paddingDigits) { padLoop++; @@ -256,8 +256,8 @@ if (!Array.prototype.filter) { baw.stringTrunc = function (str, n, useWordBoundary) { var toLong = str.length > n, s_ = toLong ? str.substr(0, n - 1) : str; - s_ = useWordBoundary && toLong ? s_.substr(0, s_.lastIndexOf(' ')) : s_; - return toLong ? s_ + '…' : s_; + s_ = useWordBoundary && toLong ? s_.substr(0, s_.lastIndexOf(" ")) : s_; + return toLong ? s_ + "…" : s_; }; /** @@ -266,7 +266,7 @@ if (!Array.prototype.filter) { * @returns {string} */ baw.secondsToDurationFormat = function secondsToDurationFormat(seconds) { - if (typeof seconds != 'number') { + if (typeof seconds !== "number") { seconds = parseFloat(seconds); } @@ -290,7 +290,7 @@ if (!Array.prototype.filter) { // default format [+/-d days] HH:mm:ss.fff var dayComponent = Math.floor(totalDays); if (dayComponent !== 0) { - result += dayComponent.toString() + ( dayComponent == 1 ? " day " : " days "); + result += dayComponent.toString() + ( dayComponent === 1 ? " day " : " days "); } result += baw.stringPad(Math.floor(totalHours) % 24, 2) + ":"; @@ -316,7 +316,7 @@ if (!Array.prototype.filter) { }; baw.isPowerOfTwo = function isPowerOfTwo(x) { - return (x & (x - 1)) === 0; + return (x & (x - 1)) === 0; // jshint ignore:line }; baw.closestPowerOfTwoBelow = function closestPowerOfTwoBelow(x) { @@ -325,16 +325,16 @@ if (!Array.prototype.filter) { }; baw.popUpWindow = function popUpWindow(provider_url, width, height, callback) { - var screenX = typeof window.screenX != 'undefined' ? window.screenX : window.screenLeft, - screenY = typeof window.screenY != 'undefined' ? window.screenY : window.screenTop, - outerWidth = typeof window.outerWidth != 'undefined' ? window.outerWidth : document.body.clientWidth, - outerHeight = typeof window.outerHeight != 'undefined' ? window.outerHeight : (document.body.clientHeight - 22), + var screenX = typeof window.screenX !== undefined ? window.screenX : window.screenLeft, + screenY = typeof window.screenY !== undefined ? window.screenY : window.screenTop, + outerWidth = typeof window.outerWidth !== undefined ? window.outerWidth : document.body.clientWidth, + outerHeight = typeof window.outerHeight !== undefined ? window.outerHeight : (document.body.clientHeight - 22), left = parseInt(screenX + ((outerWidth - width) / 2), 10), top = parseInt(screenY + ((outerHeight - height) / 2.5), 10), - features = ('width=' + width + ',height=' + height + ',left=' + left + ',top=' + top); + features = ("width=" + width + ",height=" + height + ",left=" + left + ",top=" + top); var returneddata = 0; - var newWindow = window.open(provider_url, 'Login', features); + var newWindow = window.open(provider_url, "Login", features); newWindow.returneddata = returneddata; function callbackOnClose() { @@ -362,7 +362,7 @@ if (!Array.prototype.filter) { function Angular() { this.isUndefined = function isUndefined(value) { - return typeof value == 'undefined'; + return typeof value === "undefined"; }; } @@ -374,23 +374,23 @@ if (!Array.prototype.filter) { // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys if (!Object.keys) { Object.keys = (function () { - 'use strict'; + "use strict"; var hasOwnProperty = Object.prototype.hasOwnProperty, - hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'), + hasDontEnumBug = !({toString: null}).propertyIsEnumerable("toString"), dontEnums = [ - 'toString', - 'toLocaleString', - 'valueOf', - 'hasOwnProperty', - 'isPrototypeOf', - 'propertyIsEnumerable', - 'constructor' + "toString", + "toLocaleString", + "valueOf", + "hasOwnProperty", + "isPrototypeOf", + "propertyIsEnumerable", + "constructor" ], dontEnumsLength = dontEnums.length; return function (obj) { - if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) { - throw new TypeError('Object.keys called on non-object'); + if (typeof obj !== "object" && (typeof obj !== "function" || obj === null)) { + throw new TypeError("Object.keys called on non-object"); } var result = [], prop, i; diff --git a/src/common/jquery.drawabox.js b/src/common/jquery.drawabox.js index bb5cae07..9c900198 100644 --- a/src/common/jquery.drawabox.js +++ b/src/common/jquery.drawabox.js @@ -24,28 +24,28 @@ return { posx: posx - 1, posy: posy - 1 }; }; - var elementPosition = function (obj) { + var elementPosition = function (obj) { // jshint ignore:line var curleft = 0; var curtop = 0; if (obj && obj.offsetParent) { do { curleft += obj.offsetLeft; curtop += obj.offsetTop; - } while (obj = obj.offsetParent); + } while (obj === obj.offsetParent); } return { posx: curleft, posy: curtop }; }; var setBoxBoxPosition = function ($box, startPos, currentPos) { if (startPos.x > currentPos.x) { - $box.css('left', currentPos.x + 'px'); + $box.css("left", currentPos.x + "px"); } else { - $box.css('left', startPos.x + 'px'); + $box.css("left", startPos.x + "px"); } if (startPos.y > currentPos.y) { - $box.css('top', currentPos.y + 'px'); + $box.css("top", currentPos.y + "px"); } else { - $box.css('top', startPos.y + 'px'); + $box.css("top", startPos.y + "px"); } }; @@ -60,14 +60,14 @@ var mousedown = function (e) { // only want to handle clicks on container, not on existing boxs - if (e.target != this || e.which != 1) { + if (e.target !== this || e.which !== 1) { return; } e.preventDefault(); var $thisMouseDown = $(this); - var dataMouseDown = $thisMouseDown.data('drawboxes'); + var dataMouseDown = $thisMouseDown.data("drawboxes"); // do not execute if no more boxs allowed if (dataMouseDown.maxChildrenReached) { @@ -93,7 +93,7 @@ var mouseup = function (e) { var $thisMouseUp = $(this); - var dataMouseUp = $thisMouseUp.data('drawboxes'); + var dataMouseUp = $thisMouseUp.data("drawboxes"); var wasMouseDownSet = dataMouseUp.mousedown; var currentBoxId = dataMouseUp.currentMouseDragBoxId; @@ -103,7 +103,7 @@ return; } - var $box = $('#' + currentBoxId); + var $box = $("#" + currentBoxId); // 02-Feb-14, ANT: removed, seems redundant, removal does not seem to affect functionality //$box.draggable({ containment: 'parent' }) // .resizable({ containment: 'parent', handles: 'all' }); @@ -116,18 +116,18 @@ dataMouseUp.options.boxResized($box); }; - var dataIdKey = 'data-id'; + var dataIdKey = "data-id"; function createBox($parent, contextData, width, height, top, left, uniqueId, silent) { if (contextData === undefined) { throw "Context data must be given"; } - var closeIconTemplate = ''; + var closeIconTemplate = ""; uniqueId = uniqueId || (-1 * Number.Unique()); - $('.boxItem').attr(SELECTED_ATTRIBUTE, false); + $(".boxItem").attr(SELECTED_ATTRIBUTE, false); var newId = "boxItem_" + uniqueId; if (!silent) { @@ -140,15 +140,15 @@ // removed 'overflow:hidden' from default style... it was messing up a trick i was trying to do - $parent.append('
' + closeIconTemplate + '
'); + $parent.append("
" + closeIconTemplate + "
"); - var $newBox = $('#' + newId); + var $newBox = $("#" + newId); $newBox.attr(dataIdKey, uniqueId); // add selection highlight function raiseSelectCallback() { - $('.boxItem').attr(SELECTED_ATTRIBUTE, false); + $(".boxItem").attr(SELECTED_ATTRIBUTE, false); var $t = $(this); $t.attr(SELECTED_ATTRIBUTE, true); contextData.options.boxSelected($t); @@ -173,12 +173,12 @@ if (contextData.options.showOnly !== true) { // add delete click handler - $('#' + newId + ' span').click(function () { + $("#" + newId + " span").click(function () { var $t = $(this).parent(), $container = $t.parent(); $t.remove(); - contextData.maxChildrenReached = maxChildrenCheck($container.data('drawboxes').options.maxBoxes, $container); + contextData.maxChildrenReached = maxChildrenCheck($container.data("drawboxes").options.maxBoxes, $container); contextData.options.boxDeleted($t); }); @@ -192,17 +192,17 @@ // temporary function used for testing a bug // window.hack = function(left, top) {$newBox.css({left:left, top:top}); contextData.options.boxMoved($newBox)}; $newBox.draggable({ - containment: 'parent', + containment: "parent", drag: function (event, ui) { contextData.options.boxMoving($newBox); }, stop: function (event, ui) { contextData.options.boxMoved($newBox); } }); } if (left) { - $newBox.css('left', left + 'px'); + $newBox.css("left", left + "px"); } if (top) { - $newBox.css('top', top + 'px'); + $newBox.css("top", top + "px"); } contextData.maxChildrenReached = maxChildrenCheck(contextData.options.maxBoxes, $newBox); @@ -219,7 +219,7 @@ var mousemove = function (e) { var $thisMouseMove = $(this); - var dataMouseMove = $thisMouseMove.data('drawboxes'); + var dataMouseMove = $thisMouseMove.data("drawboxes"); var wasMouseDownSet = dataMouseMove.mousedown; @@ -262,7 +262,7 @@ setBoxBoxPosition($newBox, startClickPos, currentPos); } } else { - var $box = $('#' + currentBoxId); + var $box = $("#" + currentBoxId); $box.width(xdiff); $box.height(ydiff); setBoxBoxPosition($box, startClickPos, currentPos); @@ -277,7 +277,7 @@ return 0; } var pos = cssValue.indexOf("px"); - if (pos == -1) { + if (pos === -1) { //throw new Error("Non pixel quantity given, cannot convert:" + cssValue); return NaN; } else { @@ -304,8 +304,8 @@ top: removePx($element.css("top")), width: removePx($element.css("width")) + BORDER_MODEL_DIFFERANCE, // box model - border not included in widths height: removePx($element.css("height")) + BORDER_MODEL_DIFFERANCE, // box model - border not included in widths - selected: (!!selectedAttr) && selectedAttr == "true", - hovering: (!!hoveringAttr) && hoveringAttr == "true" + selected: (!!selectedAttr) && selectedAttr == "true", // jshint ignore:line + hovering: (!!hoveringAttr) && hoveringAttr == "true" // jshint ignore:line }; }; @@ -379,13 +379,13 @@ return this.each(function () { var $this = $(this); - var data = $this.data('drawboxes'); + var data = $this.data("drawboxes"); if (!data) { // If the plugin hasn't been initialized yet // Do more setup stuff here - $this.data('drawboxes', { + $this.data("drawboxes", { target: $this, mousedown: false, mousedownPos: { posx: 0, posy: 0 }, @@ -424,7 +424,7 @@ // return all the boxes made by this plugin var $this = $(this), - data = $this.data('drawboxes'); + data = $this.data("drawboxes"); var boxes = []; @@ -507,7 +507,7 @@ throw "An element with that id already exists, cannot insert"; } - var newBox = createBox($this, $this.data('drawboxes'),0, 0, 0, 0, id, true); + var newBox = createBox($this, $this.data("drawboxes"),0, 0, 0, 0, id, true); result.push(newBox); }); return result; @@ -518,12 +518,12 @@ return this.each(function () { var $this = $(this), - data = $this.data('drawboxes'); + data = $this.data("drawboxes"); // jshint ignore:line // Namespacing FTW - $(window).unbind('.drawabox'); + $(window).unbind(".drawabox"); //data.tooltip.remove(); - $this.removeData('drawboxes'); + $this.removeData("drawboxes"); }); }; @@ -532,12 +532,12 @@ if (methods[method]) { return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); - } else if (typeof method === 'object' || !method) { + } else if (typeof method === "object" || !method) { return methods.init.apply(this, arguments); } else { - $.error('Method ' + method + ' does not exist on jQuery.drawabox'); + $.error("Method " + method + " does not exist on jQuery.drawabox"); } }; -})(jQuery); \ No newline at end of file +})(jQuery); // jshint ignore:line \ No newline at end of file diff --git a/src/common/markerwithlabel.js b/src/common/markerwithlabel.js index 9d78d5e3..fae1aedb 100644 --- a/src/common/markerwithlabel.js +++ b/src/common/markerwithlabel.js @@ -33,7 +33,7 @@ */ /*jslint browser:true */ -/*global document,google */ +/*globals document */ (function (window, google) { if (!google) { diff --git a/src/components/directives/auth.js b/src/components/directives/auth.js index 7b30f491..6e07f295 100644 --- a/src/components/directives/auth.js +++ b/src/components/directives/auth.js @@ -1,41 +1,42 @@ -angular.module('angular-auth', ['http-auth-interceptor']) +angular.module("angular-auth", ["http-auth-interceptor"]) /** * This directive will find itself inside HTML as a class, * and will remove that class, so CSS will remove loading image and show app content. * It is also responsible for showing/hiding login form. */ - .directive('bawAuth', ["$window", "$location", "$url", "conf.paths", "conf.constants", + .directive("bawAuth", ["$window", "$location", "$url", "conf.paths", "conf.constants", function ($window, $location, $url, paths, constants) { return { - restrict: 'AC', + restrict: "AC", link: function (scope, elem, attrs) { //once Angular is started, remove class: - elem.removeClass('waiting-for-angular'); + elem.removeClass("waiting-for-angular"); - var login = elem.find('#login-holder'); - var main = elem.find('#content'); + var login = elem.find("#login-holder"); + var main = elem.find("#content"); login.hide(); var isLoginBoxOpen = function(){ - var loginHolderElm = $('#login-holder'); - var mainElm = $('#content'); + throw new Error("Dependent on jQuery!"); + /*var loginHolderElm = $("#login-holder"); + var mainElm = $("#content"); var doCheck = { - loginIsVisible: loginHolderElm.is(':visible'), - loginIsHidden: loginHolderElm.is(':hidden'), - mainIsVisible: mainElm.is(':visible'), - mainIsHidden: mainElm.is(':hidden') + loginIsVisible: loginHolderElm.is(":visible"), + loginIsHidden: loginHolderElm.is(":hidden"), + mainIsVisible: mainElm.is(":visible"), + mainIsHidden: mainElm.is(":hidden") }; var loginVisible = doCheck.loginIsVisible && !doCheck.loginIsHidden; //var mainVisible = doCheck.mainIsVisible && !doCheck.mainIsHidden; //var isAnimating = loginHolderElm.is(':animated'); - return loginVisible; + return loginVisible;*/ }; - scope.$on('event:auth-loginRequired', function () { + scope.$on("event:auth-loginRequired", function () { // temporary hack - send login requests to rails var url = paths.api.links.loginAbsolute; @@ -59,7 +60,7 @@ angular.module('angular-auth', ['http-auth-interceptor']) }*/ }); - scope.$on('event:auth-loginConfirmed', function () { + scope.$on("event:auth-loginConfirmed", function () { var isOpen = isLoginBoxOpen(); if(isOpen){ @@ -69,7 +70,7 @@ angular.module('angular-auth', ['http-auth-interceptor']) } }); - scope.$on('event:auth-loginCancelled', function () { + scope.$on("event:auth-loginCancelled", function () { var isOpen = isLoginBoxOpen(); if(isOpen){ diff --git a/src/components/directives/baw-toggle/bawToggle.js b/src/components/directives/baw-toggle/bawToggle.js index 0db64f2d..f316fd4d 100644 --- a/src/components/directives/baw-toggle/bawToggle.js +++ b/src/components/directives/baw-toggle/bawToggle.js @@ -85,7 +85,7 @@ angular.module("bawApp.directives.toggleSwitch", ["ng"]) //console.debug("controller function", $scope.$id); $scope.disabled = $scope.disabled || false; - $scope.modeNormalized = $scope.mode == "push-toggle" ? "push-toggle" : "slide-toggle"; + $scope.modeNormalized = $scope.mode === "push-toggle" ? "push-toggle" : "slide-toggle"; $scope.toggle = function toggle() { if (!$scope.disabled) { diff --git a/src/components/directives/bawAnnotationViewer.js b/src/components/directives/bawAnnotationViewer.js index 471bed91..211831b5 100644 --- a/src/components/directives/bawAnnotationViewer.js +++ b/src/components/directives/bawAnnotationViewer.js @@ -1,10 +1,10 @@ -var bawds = bawds || angular.module('bawApp.directives', ['bawApp.configuration', "bawApp.directives.ui.bootstrap"]); +var bawds = bawds || angular.module("bawApp.directives", ["bawApp.configuration", "bawApp.directives.ui.bootstrap"]); -bawds.directive('bawAnnotationViewer', - [ 'conf.paths', - 'bawApp.unitConverter', - 'AudioEvent', - 'Tag', +bawds.directive("bawAnnotationViewer", + [ "conf.paths", + "bawApp.unitConverter", + "AudioEvent", + "Tag", "lodash", function (paths, unitConverter, AudioEvent, Tag, _) { @@ -40,7 +40,7 @@ bawds.directive('bawAnnotationViewer', // note the last argument sets up the watcher for compare equality (not reference). // this may cause memory / performance issues if the model gets too big later on - var deregisterer = scope.$watch(watcherFunc, modelUpdated, true); + var deregisterer = scope.$watch(watcherFunc, modelUpdated, true); // jshint ignore:line } @@ -50,7 +50,7 @@ bawds.directive('bawAnnotationViewer', */ function watchAudioEventCollection(scope) { - var deregisterCollection = scope.$watchCollection(function () { + var deregisterCollection = scope.$watchCollection(function () { // jshint ignore:line return scope.model.audioEvents; }, modelCollectionUpdated); } @@ -82,8 +82,8 @@ bawds.directive('bawAnnotationViewer', }); } - scope.$watch('model.media.spectrogram.url', updateUnitConverters); - scope.$image[0].addEventListener('load', function () { + scope.$watch("model.media.spectrogram.url", updateUnitConverters); + scope.$image[0].addEventListener("load", function () { // dom event, not in $digest cycle, thus apply scope.$apply(function () { updateUnitConverters(); @@ -171,7 +171,7 @@ bawds.directive('bawAnnotationViewer', // post assertion if (action === DRAWABOX_ACTION_SELECT) { - console.assert(annotation.isDirty == wasDirty, + console.assert(annotation.isDirty === wasDirty, "AnnotationEditor:drawaboxUpdatesModel: Post condition failed for selection triggering a isDirty state"); } else { @@ -197,7 +197,7 @@ bawds.directive('bawAnnotationViewer', width = scope.model.converters.toWidth(annotation.endTimeSeconds, annotation.startTimeSeconds), height = scope.model.converters.toHeight(annotation.highFrequencyHertz, annotation.lowFrequencyHertz); - drawaboxInstance.drawabox('setBox', annotation.__localId__, top, left, height, width, + drawaboxInstance.drawabox("setBox", annotation.__localId__, top, left, height, width, annotation.selected); } @@ -346,7 +346,7 @@ bawds.directive('bawAnnotationViewer', else { // should clean up resources for delete console.assert(action === serverAction.remove, "The remaining case must be a delete server action"); - console.assert(count == 1, "There should be no more actions enqueued after a delete"); + console.assert(count === 1, "There should be no more actions enqueued after a delete"); // we could integrate the updated value from the server here but // a) there's no point, its just being removed from the model anyway @@ -358,7 +358,7 @@ bawds.directive('bawAnnotationViewer', // this, by reference, gets rid of the element. _.remove(scope.model.audioEvents, function (value) { - return value.__localId__ == oldValue.__localId__; + return value.__localId__ === oldValue.__localId__; }); // FYI - this will result in @@ -441,10 +441,10 @@ bawds.directive('bawAnnotationViewer', var element; // does the annotation's box exist in the DOM? - var exists = drawaboxInstance.drawabox('exists', value.__localId__); + var exists = drawaboxInstance.drawabox("exists", value.__localId__); if (exists[0] === false) { // if not, add the annotation into the DOM - element = drawaboxInstance.drawabox('insert', value.__localId__)[0][0]; + element = drawaboxInstance.drawabox("insert", value.__localId__)[0][0]; } else { // the element already exists @@ -474,12 +474,12 @@ bawds.directive('bawAnnotationViewer', /****/ return { - restrict: 'AE', + restrict: "AE", scope: { - model: '=model' + model: "=model" }, - controller: 'AnnotationViewerCtrl', - require: '', // ngModel? + controller: "AnnotationViewerCtrl", + require: "", // ngModel? templateUrl: paths.site.files.annotationViewer, // compile: function(element, attributes, transclude) { // // transform DOM diff --git a/src/components/directives/directives.js b/src/components/directives/directives.js index 3e98bcab..9f1454eb 100644 --- a/src/components/directives/directives.js +++ b/src/components/directives/directives.js @@ -1,13 +1,13 @@ -var bawds = bawds || angular.module('bawApp.directives', [ - 'bawApp.configuration', +var bawds = bawds || angular.module("bawApp.directives", [ + "bawApp.configuration", "bawApp.directives.ui.bootstrap" ]); -bawds.directive('bawRecordInformation', function () { +bawds.directive("bawRecordInformation", function () { return { - restrict: 'AE', + restrict: "AE", scope: false, /* priority: ??? */ // controller: 'RecordInformationCtrl', @@ -27,24 +27,10 @@ bawds.directive('bawRecordInformation', function () { }; }); -bawds.directive('bawDebugInfo', function () { +bawds.directive("bawJsonBinding", function () { return { - restrict: 'AE', - replace: true, - template: '
Debug info {{showOrHideDebugInfo}}
', - link: function (scope, element, attrs) { - if (!scope.print) { - //console.warn("baw-debug-info missing parent scope, no print function"); - scope.print = bawApp.print; - } - } - }; -}); - -bawds.directive('bawJsonBinding', function () { - return { - restrict: 'A', - require: 'ngModel', + restrict: "A", + require: "ngModel", link: function (scope, element, attr, ngModel) { function catchParseErrors(viewValue) { @@ -52,10 +38,10 @@ bawds.directive('bawJsonBinding', function () { try { result = angular.fromJson(viewValue); } catch (e) { - ngModel.$setValidity('bawJsonBinding', false); - return ''; + ngModel.$setValidity("bawJsonBinding", false); + return ""; } - ngModel.$setValidity('bawJsonBinding', true); + ngModel.$setValidity("bawJsonBinding", true); return result; } @@ -66,14 +52,14 @@ bawds.directive('bawJsonBinding', function () { }); // ensures formatters are run on input blur -bawds.directive('renderOnBlur', function () { +bawds.directive("renderOnBlur", function () { return { - require: 'ngModel', - restrict: 'A', + require: "ngModel", + restrict: "A", link: function (scope, elm, attrs, ctrl) { - elm.bind('blur', function () { + elm.bind("blur", function () { var viewValue = ctrl.$modelValue; - for (var i in ctrl.$formatters) { + for (var i in ctrl.$formatters) { // jshint ignore:line viewValue = ctrl.$formatters[i](viewValue); } ctrl.$viewValue = viewValue; @@ -84,10 +70,10 @@ bawds.directive('renderOnBlur', function () { }); -bawds.directive('isGuid', function () { +bawds.directive("isGuid", function () { return { - require: 'ngModel', + require: "ngModel", link: function (scope, elm, attrs, ctrl) { var isList = typeof attrs.ngList !== "undefined"; @@ -105,11 +91,11 @@ bawds.directive('isGuid', function () { if (valid) { // it is valid - ctrl.$setValidity('isGuid', true); + ctrl.$setValidity("isGuid", true); return viewValue; } else { // it is invalid, return undefined (no model update) - ctrl.$setValidity('isGuid', false); + ctrl.$setValidity("isGuid", false); return undefined; } }); @@ -119,12 +105,12 @@ bawds.directive('isGuid', function () { // implements infinite scrolling // http://jsfiddle.net/vojtajina/U7Bz9/ -bawds.directive('whenScrolled', function () { +bawds.directive("whenScrolled", function () { return function (scope, elm, attr) { var raw = elm[0]; - elm.bind('scroll', function () { - console.log('scrolled'); + elm.bind("scroll", function () { + console.log("scrolled"); if (raw.scrollTop + raw.offsetHeight >= raw.scrollHeight) { scope.$apply(attr.whenScrolled); } @@ -136,18 +122,18 @@ bawds.directive('whenScrolled', function () { /** * A cross record element checker */ -bawds.directive('bawChecked', ['$parse', function ($parse) { +bawds.directive("bawChecked", ["$parse", function ($parse) { // a cache of elements for each radio group var library = {}; return { - restrict: 'A', + restrict: "A", link: function radioInputType(scope, element, attr) { // make the name unique, if not defined if (baw.angularCopies.isUndefined(attr.name)) { - element.attr('name', Number.Unique()); + element.attr("name", Number.Unique()); } var getter = $parse(attr.bawChecked); @@ -193,14 +179,14 @@ bawds.directive('bawChecked', ['$parse', function ($parse) { scope.$apply(function () { assigner(scope, isChecked); - if (newest.e[0] != event.target) { + if (newest.e[0] !== event.target) { newest.a(newest.s, !isChecked); } }); } - element.bind('click', updateModel); + element.bind("click", updateModel); } }; @@ -213,11 +199,11 @@ bawds.directive('bawChecked', ['$parse', function ($parse) { * * ONLY one way binding supported at the moment */ -bawds.directive('bawTranslateX', function () { +bawds.directive("bawTranslateX", function () { function getSupportedTransform() { - var prefixes = 'transform WebkitTransform MozTransform OTransform msTransform'.split(' '); - var div = document.createElement('div'); + var prefixes = "transform WebkitTransform MozTransform OTransform msTransform".split(" "); + var div = document.createElement("div"); for(var i = 0; i < prefixes.length; i++) { if(div && div.style[prefixes[i]] !== undefined) { return prefixes[i]; @@ -232,16 +218,16 @@ bawds.directive('bawTranslateX', function () { } return { - restrict: 'A', + restrict: "A", link: function (scope, elements, attributes, controller) { var element = elements[0]; function leftWatcher(newValue, oldValue) { - element.style[transformProperty] = '' + newValue.toFixed(3) + 'px'; + element.style[transformProperty] = "" + newValue.toFixed(3) + "px"; } function transformWatcher(newValue, oldValue) { - element.style[transformProperty] = 'translate3d(' + newValue.toFixed(3) + 'px, 0, 0)'; + element.style[transformProperty] = "translate3d(" + newValue.toFixed(3) + "px, 0, 0)"; } var watcher = getSupportedTransform() ? transformWatcher : leftWatcher; @@ -251,13 +237,13 @@ bawds.directive('bawTranslateX', function () { }; }); -bawds.directive('bawImageLoaded', ['$timeout', '$parse', function ($timeout, $parse) { +bawds.directive("bawImageLoaded", ["$timeout", "$parse", function ($timeout, $parse) { return { - restrict: 'A', + restrict: "A", link: function (scope, elements, attr) { var element = elements[0]; if (element.nodeName !== "IMG") { - throw 'Cannot put bawImageLoaded element on an element that is not a '; + throw "Cannot put bawImageLoaded element on an element that is not a "; } var getter = $parse(attr.bawImageLoaded); @@ -268,7 +254,7 @@ bawds.directive('bawImageLoaded', ['$timeout', '$parse', function ($timeout, $pa element.onload = function () { assigner(scope, element.complete); }; - +/* function checkLater() { $timeout(function () { assigner(scope, element.complete); @@ -277,16 +263,16 @@ bawds.directive('bawImageLoaded', ['$timeout', '$parse', function ($timeout, $pa checkLater(); //} }, 1000); - } + }*/ } }; }]); -bawds.directive('bawInjectTransformers', function () { +bawds.directive("bawInjectTransformers", function () { return { - restrict: 'A', - require: 'ngModel', + restrict: "A", + require: "ngModel", priority: -1, link: function (scope, element, attr, ngModel) { var local = scope.$eval(attr.bawInjectTransformers); diff --git a/src/components/directives/drag.js b/src/components/directives/drag.js index a6dbbeb4..13fe1516 100644 --- a/src/components/directives/drag.js +++ b/src/components/directives/drag.js @@ -36,7 +36,8 @@ ngDragabilly.directive("draggie", dragEnd: angular.noop }; - var transformProperty = getStyleProperty('transform'); + // TODO: make getStyleProperty a module + var transformProperty = getStyleProperty("transform"); // jshint ignore:line return { restrict: "A", @@ -69,7 +70,7 @@ ngDragabilly.directive("draggie", var reposition = function useTransformPositioning(element, position) { element.style.left = 0; element.style.left = 0; - element.style[transformProperty] = 'translate3d( ' + position.x + 'px, ' + position.y + 'px, 0)'; + element.style[transformProperty] = "translate3d( " + position.x + "px, " + position.y + "px, 0)"; }; draggie.on("dragEnd", function (draggie, event, pointer) { @@ -90,7 +91,7 @@ ngDragabilly.directive("draggie", scope.$watch(function () { return scope.options.enabled; }, function (newValue, oldValue) { - if (newValue == oldValue) { + if (newValue === oldValue) { return; } diff --git a/src/components/directives/input[type=range].js b/src/components/directives/input[type=range].js index a4767e7b..49dfb29c 100644 --- a/src/components/directives/input[type=range].js +++ b/src/components/directives/input[type=range].js @@ -1,8 +1,8 @@ -var bawds = bawds || angular.module('bawApp.directives', ['bawApp.configuration', "bawApp.directives.ui.bootstrap"]); +var bawds = bawds || angular.module("bawApp.directives", ["bawApp.configuration", "bawApp.directives.ui.bootstrap"]); bawds.directive("ngSlider", function () { return { - restrict: 'A', + restrict: "A", link: function (scope, $element, attrs) { var element = $element[0]; diff --git a/src/components/directives/ngAudio.js b/src/components/directives/ngAudio.js index b23510b4..375872c8 100644 --- a/src/components/directives/ngAudio.js +++ b/src/components/directives/ngAudio.js @@ -1,4 +1,4 @@ -var ngAudio = ngAudio || angular.module('bawApp.directives.ngAudio', ['bawApp.configuration', "bawApp.directives.ui.bootstrap"]); +var ngAudio = ngAudio || angular.module("bawApp.directives.ngAudio", ["bawApp.configuration", "bawApp.directives.ui.bootstrap"]); ngAudio.constant("ngAudioEvents", { @@ -156,7 +156,7 @@ ngAudio.directive("ngAudio", ["ngAudioEvents", "$parse", function (ngAudioEvents } } else { - scope.currentState = event && event.type || 'unknown'; + scope.currentState = event && event.type || "unknown"; updateObject(element, scope); } @@ -220,7 +220,7 @@ ngAudio.directive("ngAudio", ["ngAudioEvents", "$parse", function (ngAudioEvents var target = scope.$eval(attributes.ngAudio); if (target) { var position = element.currentTime; - if (target.position != position) { + if (target.position !== position) { //scope.$safeApply2(function () { target.position = position; //}); diff --git a/src/components/directives/ngEval.js b/src/components/directives/ngEval.js index 392e92c2..ab506d22 100644 --- a/src/components/directives/ngEval.js +++ b/src/components/directives/ngEval.js @@ -1,8 +1,8 @@ -var bawds = bawds || angular.module('bawApp.directives', ['bawApp.configuration', "bawApp.directives.ui.bootstrap"]); +var bawds = bawds || angular.module("bawApp.directives", ["bawApp.configuration", "bawApp.directives.ui.bootstrap"]); bawds.directive("ngEval", function () { return { - restrict: 'A', + restrict: "A", link: function (scope, element, attrs) { // HACK: this is a horrible, horrible way to do this! diff --git a/src/components/directives/ngGoogleMaps.js b/src/components/directives/ngGoogleMaps.js index ee98d728..e35e2c42 100644 --- a/src/components/directives/ngGoogleMaps.js +++ b/src/components/directives/ngGoogleMaps.js @@ -2,7 +2,9 @@ * NOTE: this was copied from angular-ui. At some point this file should be deleted. */ -var bawds = bawds || angular.module('bawApp.directives', ['bawApp.configuration', "bawApp.directives.ui.bootstrap"]); +/* globals google*/ + +var bawds = bawds || angular.module("bawApp.directives", ["bawApp.configuration", "bawApp.directives.ui.bootstrap"]); /* Start map directives */ /** stolen from angular ui @@ -11,12 +13,12 @@ var bawds = bawds || angular.module('bawApp.directives', ['bawApp.configuration' //Setup map events from a google map object to trigger on a given element too, //then we just use ui-event to catch events from an element function bindMapEvents(scope, eventsStr, googleObject, element) { - angular.forEach(eventsStr.split(' '), function (eventName) { + angular.forEach(eventsStr.split(" "), function (eventName) { //Prefix all googlemap events with 'map-', so eg 'click' //for the googlemap doesn't interfere with a normal 'click' event var $event = { - type: 'map-' + eventName + type: "map-" + eventName }; google.maps.event.addListener(googleObject, eventName, function (evt) { element.triggerHandler(angular.extend({}, $event, evt)); @@ -29,11 +31,11 @@ function bindMapEvents(scope, eventsStr, googleObject, element) { }); var $eventOnce = { - type: 'map-once-' + eventName + type: "map-once-" + eventName }; google.maps.event.addListenerOnce(googleObject, eventName, function (evt) { element.triggerHandler(angular.extend({}, $eventOnce, evt)); - console.log('addListenerOnce', $eventOnce); + console.log("addListenerOnce", $eventOnce); //We create an $apply if it isn't happening. we need better support for this //We don't want to use timeout because tons of these events fire at once, //and we only need one $apply @@ -45,16 +47,16 @@ function bindMapEvents(scope, eventsStr, googleObject, element) { }); } -bawds.directive('bawMap', ['ui.config', '$parse', function (uiConfig, $parse) { +bawds.directive("bawMap", ["ui.config", "$parse", function (uiConfig, $parse) { - var mapEvents = 'bounds_changed center_changed click dblclick drag dragend ' + - 'dragstart heading_changed idle maptypeid_changed mousemove mouseout ' + - 'mouseover projection_changed resize rightclick tilesloaded tilt_changed ' + - 'zoom_changed'; + var mapEvents = "bounds_changed center_changed click dblclick drag dragend " + + "dragstart heading_changed idle maptypeid_changed mousemove mouseout " + + "mouseover projection_changed resize rightclick tilesloaded tilt_changed " + + "zoom_changed"; var options = uiConfig.map || {}; return { - restrict: 'A', + restrict: "A", //doesn't work as E for unknown reason link: function (scope, elm, attrs) { var opts = angular.extend({}, options, scope.$eval(attrs.uiOptions)); @@ -69,10 +71,10 @@ bawds.directive('bawMap', ['ui.config', '$parse', function (uiConfig, $parse) { }; }]); -bawds.directive('bawMapInfoWindow', ['ui.config', '$parse', '$compile', function (uiConfig, $parse, $compile) { +bawds.directive("bawMapInfoWindow", ["ui.config", "$parse", "$compile", function (uiConfig, $parse, $compile) { - var infoWindowEvents = 'closeclick content_change domready ' + - 'position_changed zindex_changed'; + var infoWindowEvents = "closeclick content_change domready " + + "position_changed zindex_changed"; var options = uiConfig.mapInfoWindow || {}; return { @@ -93,7 +95,7 @@ bawds.directive('bawMapInfoWindow', ['ui.config', '$parse', '$compile', function google maps has them stored. So we just replace the infowindow element with an empty div. (we don't just straight remove it from the dom because straight removing things from the dom can mess up angular) */ - elm.replaceWith('
'); + elm.replaceWith("
"); //Decorate infoWindow.open to $compile contents before opening var _open = infoWindow.open; @@ -114,7 +116,7 @@ bawds.directive('bawMapInfoWindow', ['ui.config', '$parse', '$compile', function function mapOverlayDirective(directiveName, events) { bawds.directive(directiveName, [function () { return { - restrict: 'A', + restrict: "A", link: function (scope, elm, attrs) { scope.$watch(attrs[directiveName], function (newObject) { bindMapEvents(scope, events, newObject, elm); @@ -124,16 +126,16 @@ function mapOverlayDirective(directiveName, events) { }]); } -mapOverlayDirective('bawMapMarker', 'animation_changed click clickable_changed cursor_changed ' + 'dblclick drag dragend draggable_changed dragstart flat_changed icon_changed ' + 'mousedown mouseout mouseover mouseup position_changed rightclick ' + 'shadow_changed shape_changed title_changed visible_changed zindex_changed'); +mapOverlayDirective("bawMapMarker", "animation_changed click clickable_changed cursor_changed " + "dblclick drag dragend draggable_changed dragstart flat_changed icon_changed " + "mousedown mouseout mouseover mouseup position_changed rightclick " + "shadow_changed shape_changed title_changed visible_changed zindex_changed"); -mapOverlayDirective('bawMapPolyline', 'click dblclick mousedown mousemove mouseout mouseover mouseup rightclick'); +mapOverlayDirective("bawMapPolyline", "click dblclick mousedown mousemove mouseout mouseover mouseup rightclick"); -mapOverlayDirective('bawMapPolygon', 'click dblclick mousedown mousemove mouseout mouseover mouseup rightclick'); +mapOverlayDirective("bawMapPolygon", "click dblclick mousedown mousemove mouseout mouseover mouseup rightclick"); -mapOverlayDirective('bawMapRectangle', 'bounds_changed click dblclick mousedown mousemove mouseout mouseover ' + 'mouseup rightclick'); +mapOverlayDirective("bawMapRectangle", "bounds_changed click dblclick mousedown mousemove mouseout mouseover " + "mouseup rightclick"); -mapOverlayDirective('bawMapCircle', 'center_changed click dblclick mousedown mousemove ' + 'mouseout mouseover mouseup radius_changed rightclick'); +mapOverlayDirective("bawMapCircle", "center_changed click dblclick mousedown mousemove " + "mouseout mouseover mouseup radius_changed rightclick"); -mapOverlayDirective('bawMapGroundOverlay', 'click dblclick'); +mapOverlayDirective("bawMapGroundOverlay", "click dblclick"); /* End map directives */ \ No newline at end of file diff --git a/src/components/filters/filters.js b/src/components/filters/filters.js index f3b8cd7b..91d5ee24 100644 --- a/src/components/filters/filters.js +++ b/src/components/filters/filters.js @@ -1,6 +1,6 @@ /* http://docs.angularjs.org/#!angular.filter */ - var bawfs = bawfs || angular.module('bawApp.filters', []); + var bawfs = bawfs || angular.module("bawApp.filters", []); /* http://stackoverflow.com/questions/11873570/angularjs-for-loop-with-numbers-ranges @@ -9,7 +9,7 @@ do something */ - bawfs.filter('range', function() { + bawfs.filter("range", function() { return function(input, total) { total = baw.parseInt(total); for (var i=0; i= 0) { + if ((headers().Accept || "").indexOf("application/json") >= 0) { if (data === undefined || data === null) { return; @@ -136,13 +136,13 @@ angular * Configure the default $httpRequest */ .config([ - '$httpProvider', + "$httpProvider", /* We are in the config phase - traditional services are not available yet * Thus we must make a reference to the factory's provider. * This is also why the $gets are necessary below! */ - 'casingTransformers', - 'railsFieldRenamingTransformerProvider', + "casingTransformers", + "railsFieldRenamingTransformerProvider", function ($httpProvider, casingTransformers, railsFieldRenamingTransformerProvider) { diff --git a/src/components/services/audioEventComment.js b/src/components/services/audioEventComment.js index c31abaf0..9d5ea95d 100644 --- a/src/components/services/audioEventComment.js +++ b/src/components/services/audioEventComment.js @@ -3,11 +3,11 @@ angular .factory( "AudioEventComment", [ - "bawResource", 'conf.paths', + "bawResource", "conf.paths", function (bawResource, paths) { return bawResource( paths.api.routes.audioEventComment.showAbsolute, - {audioEventId: "@audioEventId", audioEventCommentId: '@audioEventCommentId'}); + {audioEventId: "@audioEventId", audioEventCommentId: "@audioEventCommentId"}); } ] ); \ No newline at end of file diff --git a/src/components/services/authenticator.js b/src/components/services/authenticator.js index c1d0ac22..4b706b64 100644 --- a/src/components/services/authenticator.js +++ b/src/components/services/authenticator.js @@ -1,10 +1,12 @@ angular .module("bawApp.services.authenticator", []) .factory( - 'Authenticator', + "Authenticator", [ - '$rootScope', 'authService', '$http', 'conf.paths', + "$rootScope", "authService", "$http", "conf.paths", function ($rootScope, authService, $http, paths) { + const authHeader = "Authorization"; + // As soon as the module is initiated... // WARNING: Cookies required for this to work checkLogin(); @@ -16,7 +18,7 @@ angular $rootScope.$safeApply($rootScope, function () { that.authToken = null; $rootScope.userData = null; - $http.defaults.headers.common["Authorization"] = null; + $http.defaults.headers.common[authHeader] = null; console.log("Logout successful", data); }); @@ -46,9 +48,9 @@ angular } that.authToken = data.authToken; - $http.defaults.headers.common["Authorization"] = 'Token token="' + + $http.defaults.headers.common[authHeader] = "Token token=\"" + that.authToken + - '"'; + "\""; $rootScope.$safeApply($rootScope, function () { $rootScope.userData = data; @@ -61,7 +63,7 @@ angular $rootScope.$safeApply($rootScope, function () { that.authToken = null; $rootScope.userData = null; - $http.defaults.headers.common["Authorization"] = null; + $http.defaults.headers.common[authHeader] = null; if (config && config.url === paths.api.routes.security.pingAbsolute) { return; @@ -128,14 +130,14 @@ angular } }]) .factory( - 'AuthenticationProviders', + "AuthenticationProviders", [ - '$rootScope', 'authService', '$http', 'Authenticator', '$q', '$url', + "$rootScope", "authService", "$http", "Authenticator", "$q", "$url", function ($rootScope, authService, $http, Authenticator, $q, $url) { - var signOutPath = '/security/sign_out'; + var signOutPath = "/security/sign_out"; function signOut() { - $http({method: 'GET', url: signOutPath}) + $http({method: "GET", url: signOutPath}) .success(Authenticator.logoutSuccess) .error(Authenticator.logoutFailure); } @@ -150,8 +152,8 @@ angular // 1. Send the assertion to your backend for verification and to create a session. // 2. Update your UI. $http({ - method: 'POST', - url: '/security/auth/browser_id/callback', + method: "POST", + url: "/security/auth/browser_id/callback", data: {assertion: assertion} }) .success(Authenticator.loginSuccess) @@ -216,14 +218,14 @@ angular }, "google": { login: function () { - openIdLogin('https://www.google.com/accounts/o8/id'); + openIdLogin("https://www.google.com/accounts/o8/id"); }, logout: signOut, requires: null }, "yahoo": { login: function () { - openIdLogin('https://me.yahoo.com'); + openIdLogin("https://me.yahoo.com"); }, logout: signOut, requires: null @@ -238,28 +240,28 @@ angular }, "facebook": { login: function () { - openAuthLogin('facebook'); + openAuthLogin("facebook"); }, logout: signOut, requires: null }, "github": { login: function () { - openAuthLogin('github'); + openAuthLogin("github"); }, logout: signOut, requires: null }, "twitter": { login: function () { - openAuthLogin('twitter'); + openAuthLogin("twitter"); }, logout: signOut, requires: null }, "windowslive": { login: function () { - openAuthLogin('windowslive'); + openAuthLogin("windowslive"); }, logout: signOut, requires: null diff --git a/src/components/services/bawResource.js b/src/components/services/bawResource.js index 8bf6a0ff..09ac681b 100644 --- a/src/components/services/bawResource.js +++ b/src/components/services/bawResource.js @@ -29,7 +29,7 @@ angular var convertedPath = uriConvert(path); var a = actions || {}; - a.update = a.update || {method: 'PUT'}; + a.update = a.update || {method: "PUT"}; a.query = a.query || {method: "GET", isArray: false}; var resource = $resource(convertedPath, paramDefaults, a); diff --git a/src/components/services/bawResource.spec.js b/src/components/services/bawResource.spec.js index 151f84fd..ee59e88f 100644 --- a/src/components/services/bawResource.spec.js +++ b/src/components/services/bawResource.spec.js @@ -2,11 +2,11 @@ describe("The bawResource service", function () { var $httpBackend, bawResource, $rootScope; - beforeEach(module('bawApp.services')); + beforeEach(module("bawApp.services")); beforeEach(inject(["$injector", "bawResource", "$rootScope", "$http", function ($injector, providedBawResource, _$rootScope, $http) { - $httpBackend = $injector.get('$httpBackend'); - $http.defaults.headers.common["Authorization"] = "SOME AUTH TOKEN"; + $httpBackend = $injector.get("$httpBackend"); + $http.defaults.headers.common.Authorization = "SOME AUTH TOKEN"; $httpBackend.when("GET", "/test").respond({data:[], meta:{}}); @@ -43,6 +43,7 @@ describe("The bawResource service", function () { }); $httpBackend.flush(); + expect(result).toBeDefined(); expect(pass).toBeTrue(); done(); diff --git a/src/components/services/birdWalk.js b/src/components/services/birdWalk.js index d26a3858..ac6c323f 100644 --- a/src/components/services/birdWalk.js +++ b/src/components/services/birdWalk.js @@ -1,9 +1,9 @@ angular .module("bawApp.services.birdWalkService", []) .factory( - 'BirdWalkService', + "BirdWalkService", [ - "$rootScope", '$location', '$route', '$routeParams', '$http', + "$rootScope", "$location", "$route", "$routeParams", "$http", function ($rootScope, $location, $route, $routeParams, $http) { var birdWalkService = {}; @@ -14,8 +14,8 @@ angular }) .success(function (data, status, headers, config) { console.info("Downloading resource " + downloadUrl + " succeeded.", data); - if (!theScope['spec']) { - theScope['spec'] = {}; + if (!theScope.spec) { + theScope.spec = {}; } theScope.spec[storeProperty] = data; diff --git a/src/components/services/bookmark.spec.js b/src/components/services/bookmark.spec.js index 438b4119..b8ba7c9a 100644 --- a/src/components/services/bookmark.spec.js +++ b/src/components/services/bookmark.spec.js @@ -2,7 +2,7 @@ describe("The bookmark service", function () { var bawResource; - beforeEach(module('bawApp.services')); + beforeEach(module("bawApp.services")); beforeEach(inject(["Bookmark", function (providedBawResource) { bawResource = providedBawResource; diff --git a/src/components/services/breadcrumbs.js b/src/components/services/breadcrumbs.js index 3264b410..ca904eb9 100644 --- a/src/components/services/breadcrumbs.js +++ b/src/components/services/breadcrumbs.js @@ -4,13 +4,13 @@ angular .module("bawApp.services.breadcrumbs", []) .factory( - 'breadcrumbs', + "breadcrumbs", [ - '$rootScope', - '$location', - '$route', - '$routeParams', - 'conf.paths', + "$rootScope", + "$location", + "$route", + "$routeParams", + "conf.paths", function ($rootScope, $location, $route, $routeParams, paths) { var breadcrumbs = []; @@ -22,21 +22,21 @@ angular for (key in obj) { if (obj.hasOwnProperty(key)) { // console.log(key); - if (key == propName) { + if (key === propName) { return obj[key]; } } } - console.log('did not find match', propName, obj); + console.log("did not find match", propName, obj); return null; }; var replaceValuesWithPlaceholders = function replaceValuesWithPlaceholders(params, path) { - var key, prefix = ':'; + var key, prefix = ":"; for (key in params) { if (params.hasOwnProperty(key)) { var value = params[key]; - if (path && path.indexOf(value) != -1) { + if (path && path.indexOf(value) !== -1) { // replace only the first match path = path.replace(value, prefix + key); } @@ -46,12 +46,12 @@ angular }; var replacePlaceholdersWithValues = function replaceValuesWithPlaceholders(params, path) { - var key, prefix = ':'; + var key, prefix = ":"; for (key in params) { if (params.hasOwnProperty(key)) { var value = params[key]; var prefixedKey = prefix + key; - if (path && path.indexOf(prefixedKey) != -1) { + if (path && path.indexOf(prefixedKey) !== -1) { // replace only the first match path = path.replace(prefixedKey, value); } @@ -62,7 +62,7 @@ angular //we want to update breadcrumbs only when a route is actually changed //as $location.path() will get updated imediatelly (even if route change fails!) - $rootScope.$on('$routeChangeSuccess', function (event, current) { + $rootScope.$on("$routeChangeSuccess", function (event, current) { // use routes to create breadcrumbs // use $routeParams to replace any instances of params in current.title @@ -70,10 +70,10 @@ angular var currentPath = $location.path(), currentParams = $route.current.params, allRoutes = $route.routes; - var pathElements = currentPath.split('/'), result = [], i; + var pathElements = currentPath.split("/"), result = [], i; var breadcrumbPath = function (index) { - return '/' + (pathElements.slice(0, index + 1)).join('/'); + return "/" + (pathElements.slice(0, index + 1)).join("/"); }; // remove first item (usually an empty string) @@ -99,7 +99,7 @@ angular } // add home as first item in result array - result.unshift({name: 'Home', path: paths.api.root, title: 'Home', target: "_self"}); + result.unshift({name: "Home", path: paths.api.root, title: "Home", target: "_self"}); breadcrumbs = result; }); diff --git a/src/components/services/media.js b/src/components/services/media.js index f5ec9556..482e3da8 100644 --- a/src/components/services/media.js +++ b/src/components/services/media.js @@ -3,22 +3,22 @@ angular .factory( "Media", [ - '$resource', "bawResource", 'conf.paths', + "$resource", "bawResource", "conf.paths", function ($resource, bawResource, paths) { // create resource for rest requests to media api var mediaResource = $resource(bawResource.uriConvert(paths.api.routes.media.showAbsolute), { - recordingId: '@recordingId', - format: '@format' + recordingId: "@recordingId", + format: "@format" }); // this is a read only service, remove unnecessary methods // keep GET - delete mediaResource["save"]; - delete mediaResource["query"]; - delete mediaResource["remove"]; - delete mediaResource["delete"]; + delete mediaResource.save; + delete mediaResource.query; + delete mediaResource.remove; + delete mediaResource.delete; return mediaResource; } diff --git a/src/components/services/predictiveCache.js b/src/components/services/predictiveCache.js index 9d8737ea..fdf6ba2c 100644 --- a/src/components/services/predictiveCache.js +++ b/src/components/services/predictiveCache.js @@ -120,7 +120,7 @@ angular throw new Error("count must be a positive integer"); } - if (acceptableVerbs.indexOf(settings.method) == -1) { + if (acceptableVerbs.indexOf(settings.method) === -1) { throw new Error("A valid http method is required"); } @@ -349,6 +349,6 @@ angular return settings; }; }]) - .config(['$httpProvider', function ($httpProvider) { + .config(["$httpProvider", function ($httpProvider) { $httpProvider.interceptors.push("predictiveCacheInterceptor"); }]); \ No newline at end of file diff --git a/src/components/services/predictiveCache.spec.js b/src/components/services/predictiveCache.spec.js index 11727902..55915729 100644 --- a/src/components/services/predictiveCache.spec.js +++ b/src/components/services/predictiveCache.spec.js @@ -4,7 +4,7 @@ describe("The predictiveCache service", function () { $httpProvider; beforeEach(module("bawApp.services", function (_$httpProvider_) { $httpProvider = _$httpProvider_; - $httpProvider.defaults.headers.common["Authorization"] = "SOME AUTH TOKEN"; + $httpProvider.defaults.headers.common.Authorization = "SOME AUTH TOKEN"; })); //beforeEach(module("baw")); @@ -541,7 +541,7 @@ describe("The predictiveCache service", function () { testProfile.progression = progressionTest.in; expect(function () { - var profile = predictiveCache(testProfile); + predictiveCache(testProfile); }).toThrowError("progression must be an array of numbers/functions"); }); }); diff --git a/src/components/services/queryBuilder.js b/src/components/services/queryBuilder.js index 245da6d7..f40780a9 100644 --- a/src/components/services/queryBuilder.js +++ b/src/components/services/queryBuilder.js @@ -334,7 +334,7 @@ angular Query.prototype[operatorKey] = function (field, value) { var operator = operatorKey; - if (arguments.length == 1) { + if (arguments.length === 1) { value = field; field = undefined; } diff --git a/src/components/services/site.js b/src/components/services/site.js index a1158866..5638ba8d 100644 --- a/src/components/services/site.js +++ b/src/components/services/site.js @@ -3,7 +3,7 @@ angular .factory( "Site", [ - '$resource', "bawResource", "$http", 'conf.paths', "lodash", "QueryBuilder", "baw.models.Site", + "$resource", "bawResource", "$http", "conf.paths", "lodash", "QueryBuilder", "baw.models.Site", function ($resource, bawResource, $http, paths, _, QueryBuilder, SiteModel) { var resource = bawResource(paths.api.routes.site.flattenedAbsolute, {siteId: "@siteId"}); diff --git a/src/components/services/tag.js b/src/components/services/tag.js index b2c6aaf1..8a75c526 100644 --- a/src/components/services/tag.js +++ b/src/components/services/tag.js @@ -15,7 +15,7 @@ angular var wrappedMethod = resource[method]; resource[method] = function (params, data, success, error) { - if (arguments.length != 4) { + if (arguments.length !== 4) { throw "we are doing some funky stuff on this resource method... expecting exactly 4 arguments [params, data, success, error]"; } @@ -29,7 +29,7 @@ angular } - var resource = $resource(bawResource.uriConvert(paths.api.routes.tag.showAbsolute), {tagId: '@tagId'}, {}); + var resource = $resource(bawResource.uriConvert(paths.api.routes.tag.showAbsolute), {tagId: "@tagId"}, {}); var tagsCache = new Map(); @@ -97,7 +97,7 @@ angular // optimise for most common case // also: on load, only incomplete tags will be listed --> the tag resolver then runs for every tag, just below - if (first && first.typeOfTag == TagModel.tagTypes.commonName) { + if (first && first.typeOfTag === TagModel.tagTypes.commonName) { return first; } else { @@ -107,10 +107,10 @@ angular return; } - if (value.typeOfTag == TagModel.tagTypes.commonName && !commonName) { + if (value.typeOfTag === TagModel.tagTypes.commonName && !commonName) { commonName = value; } - if (value.typeOfTag == TagModel.tagTypes.speciesName && !speciesName) { + if (value.typeOfTag === TagModel.tagTypes.speciesName && !speciesName) { speciesName = value; } if (!firstOther) { diff --git a/src/components/services/taggings.js b/src/components/services/taggings.js index cba26f30..c2a2a7e7 100644 --- a/src/components/services/taggings.js +++ b/src/components/services/taggings.js @@ -3,13 +3,13 @@ angular .factory( "Taggings", [ - '$resource', "bawResource", 'conf.paths', + "$resource", "bawResource", "conf.paths", function ($resource, bawResource, paths) { var resource = bawResource(paths.api.routes.tagging.showAbsolute, { - recordingId: '@recordingId', - audioEventId: '@audioEventId', - taggingId: '@taggingId' + recordingId: "@recordingId", + audioEventId: "@audioEventId", + taggingId: "@taggingId" }); return resource; diff --git a/src/components/services/unitConverters.spec.js b/src/components/services/unitConverters.spec.js index 96bc15d8..5fda41c2 100644 --- a/src/components/services/unitConverters.spec.js +++ b/src/components/services/unitConverters.spec.js @@ -3,7 +3,7 @@ describe("The unitConverter service", function () { var unitConverter; var inputArgs = {}; - beforeEach(module('bawApp.services.unitConverter')); + beforeEach(module("bawApp.services.unitConverter")); beforeEach(inject(["bawApp.unitConverter", function (providedUnitConverted) { unitConverter = providedUnitConverted; diff --git a/src/components/services/url.js b/src/components/services/url.js index 89802838..479ab8c9 100644 --- a/src/components/services/url.js +++ b/src/components/services/url.js @@ -8,12 +8,12 @@ angular function fixedEncodeURIComponent(str) { str = str || ""; return encodeURIComponent(str) - .replace(/!/g, '%21') - .replace(/'/g, '%27') - .replace(/\(/g, '%28') - .replace(/\)/g, '%29') - .replace(/\*/g, '%2A') - .replace(/%20/g, '+'); + .replace(/!/g, "%21") + .replace(/'/g, "%27") + .replace(/\(/g, "%28") + .replace(/\)/g, "%29") + .replace(/\*/g, "%2A") + .replace(/%20/g, "+"); } /** @@ -29,14 +29,14 @@ angular */ function encodeUriQuery(val, pctEncodeSpaces) { if (angular.isUndefined(val) || val === null) { - return ''; + return ""; } return encodeURIComponent(val). - replace(/%40/gi, '@'). - replace(/%3A/gi, ':'). - replace(/%24/g, '$'). - replace(/%2C/gi, ','). - replace(/%20/g, (pctEncodeSpaces ? '%20' : '+')); + replace(/%40/gi, "@"). + replace(/%3A/gi, ":"). + replace(/%24/g, "$"). + replace(/%2C/gi, ","). + replace(/%20/g, (pctEncodeSpaces ? "%20" : "+")); } function toKeyValue(obj, validateKeys, _tokenRenamer) { @@ -46,7 +46,7 @@ angular if (validateKeys) { // only add key value pair if value is not undefined, not null, and is not an empty string var valueIsEmptyString = angular.isString(value) && value.length < 1; - if (angular.isUndefined(value) || value == null || valueIsEmptyString || value === false) { + if (angular.isUndefined(value) || value === null || valueIsEmptyString || value === false) { return; } } @@ -54,11 +54,11 @@ angular var encodedKey = encodeUriQuery(tokenRenamer(key), /* encode spaces */ true); // Angular does this: if value is true, just include the key without a value - var encodedValue = value === true ? '' : '=' + encodeUriQuery(value, /* encode spaces */ true); + var encodedValue = value === true ? "" : "=" + encodeUriQuery(value, /* encode spaces */ true); parts.push(encodedKey + encodedValue); }); - return parts.length ? parts.join('&') : ''; + return parts.length ? parts.join("&") : ""; } function formatUri(uri, values, tokenRenamer) { diff --git a/src/components/services/url.spec.js b/src/components/services/url.spec.js index 5bc9c7d1..e5a909ed 100644 --- a/src/components/services/url.spec.js +++ b/src/components/services/url.spec.js @@ -15,25 +15,25 @@ describe("The url service", function () { }); var myQuery = { - blah: '1', + blah: "1", tornado: "attack", something: null, hello: true, bye: false, - 'chocolate-chips': 'ring-ring', - monkeys: 'dancing dancing', + "chocolate-chips": "ring-ring", + monkeys: "dancing dancing", imNotHere: undefined, - imEmpty: '' + imEmpty: "" }; it("encodes a querystring", function () { var result = $url.toKeyValue(myQuery); - expect(result).toBe('blah=1&tornado=attack&something=&hello&bye=false&chocolate-chips=ring-ring&monkeys=dancing%20dancing&imNotHere=&imEmpty='); + expect(result).toBe("blah=1&tornado=attack&something=&hello&bye=false&chocolate-chips=ring-ring&monkeys=dancing%20dancing&imNotHere=&imEmpty="); }); it("encodes a querystring without empty values", function () { var result = $url.toKeyValue(myQuery, true); - expect(result).toBe('blah=1&tornado=attack&hello&chocolate-chips=ring-ring&monkeys=dancing%20dancing'); + expect(result).toBe("blah=1&tornado=attack&hello&chocolate-chips=ring-ring&monkeys=dancing%20dancing"); }); diff --git a/src/components/services/vendorServices/externals.js b/src/components/services/vendorServices/externals.js index 9eded3c4..fcaffb62 100644 --- a/src/components/services/vendorServices/externals.js +++ b/src/components/services/vendorServices/externals.js @@ -70,7 +70,7 @@ angular d3.selection.prototype.clipPath = function(clipUrl) { var funcIriRegex = /url\(#(.*)\)/; - if (arguments.length == 1) { + if (arguments.length === 1) { var match = funcIriRegex.exec(clipUrl), newUrl = clipUrl; if (match) { diff --git a/src/sass/_layout.scss b/src/sass/_layout.scss index f224ec85..565cb468 100644 --- a/src/sass/_layout.scss +++ b/src/sass/_layout.scss @@ -47,14 +47,6 @@ a.disabled { } -baw-debug-info { - margin-top: 2em; -} - - - - - /* General Classes -----------------------------------------------------------------------------*/ .short-guid {