From 8b30070a86ea395b8380153bd69fdaaece97d17c Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Wed, 22 Jun 2016 12:02:48 +0200 Subject: [PATCH] jslint --- Gruntfile.js | 7 +++++-- js/cast.js | 41 ++++++++++++++--------------------------- package.json | 3 ++- 3 files changed, 21 insertions(+), 30 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 1d05fad..e18273a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -41,7 +41,9 @@ module.exports = function (grunt) { }, tests: { src: ['tests/*.php'] - }, + } + }, + jslint: { js: { src: ['js/*.js'] }, @@ -72,9 +74,10 @@ module.exports = function (grunt) { grunt.loadNpmTasks('grunt-phpcs'); grunt.loadNpmTasks('grunt-phpunit'); grunt.loadNpmTasks('grunt-contrib-compress'); + grunt.loadNpmTasks('grunt-jslint'); grunt.registerTask('default', ['uglify', 'cssmin']); - grunt.registerTask('lint', ['phpcs']); + grunt.registerTask('lint', ['phpcs', 'jslint']); grunt.registerTask('test', ['phpunit']); grunt.registerTask('release', ['default', 'githash', 'compress']); }; diff --git a/js/cast.js b/js/cast.js index 22d6e7a..d391c3e 100644 --- a/js/cast.js +++ b/js/cast.js @@ -3,14 +3,12 @@ var launchBtn, disabledBtn, stopBtn; var session, currentMedia; -function receiverListener(e) -{ +function receiverListener(e) { 'use strict'; console.log('receiverListener', e); } -function onMediaDiscovered(how, media) -{ +function onMediaDiscovered(how, media) { 'use strict'; console.log('onMediaDiscovered', how); currentMedia = media; @@ -20,8 +18,7 @@ function onMediaDiscovered(how, media) } } -function sessionListener(e) -{ +function sessionListener(e) { 'use strict'; session = e; session.addMediaListener(onMediaDiscovered.bind(this, 'addMediaListener')); @@ -30,48 +27,41 @@ function sessionListener(e) } } -function onStopCast() -{ +function onStopCast() { 'use strict'; stopBtn.classList.add('cast_hidden'); launchBtn.classList.remove('cast_hidden'); } -function stopCast() -{ +function stopCast() { 'use strict'; session.stop(onStopCast); } -function onMediaError() -{ +function onMediaError() { 'use strict'; console.log('onMediaError'); stopCast(); } -function onRequestSessionSuccess(e) -{ +function onRequestSessionSuccess(e) { 'use strict'; session = e; var videoLink = document.getElementById('video_link'), videoURL = videoLink.dataset.video, mediaInfo = new chrome.cast.media.MediaInfo(videoURL, 'video/' + videoLink.dataset.ext), request = new chrome.cast.media.LoadRequest(mediaInfo); session.loadMedia(request, onMediaDiscovered.bind(this, 'loadMedia'), onMediaError); } -function onLaunchError(e) -{ +function onLaunchError(e) { 'use strict'; console.log('onLaunchError', e.description); } -function launchCast() -{ +function launchCast() { 'use strict'; chrome.cast.requestSession(onRequestSessionSuccess, onLaunchError); } -function onInitSuccess() -{ +function onInitSuccess() { 'use strict'; launchBtn = document.getElementById('cast_btn_launch'); disabledBtn = document.getElementById('cast_disabled'); @@ -84,21 +74,18 @@ function onInitSuccess() } } -function onError() -{ +function onError() { 'use strict'; console.log('onError'); } -function initializeCastApi() -{ +function initializeCastApi() { 'use strict'; var sessionRequest = new chrome.cast.SessionRequest(chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID), apiConfig = new chrome.cast.ApiConfig(sessionRequest, sessionListener, receiverListener, chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED); chrome.cast.initialize(apiConfig, onInitSuccess, onError); } -function loadCastApi(loaded, errorInfo) -{ +function loadCastApi(loaded, errorInfo) { 'use strict'; if (loaded) { initializeCastApi(); @@ -107,4 +94,4 @@ function loadCastApi(loaded, errorInfo) } } -window['__onGCastApiAvailable'] = loadCastApi; +window.__onGCastApiAvailable = loadCastApi; diff --git a/package.json b/package.json index 5e4480d..57997fd 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "grunt-phpunit": "~0.3.6", "grunt-contrib-compress": "~1.2.0", "bower": "~1.7.1", - "grunt-githash": "~0.1.3" + "grunt-githash": "~0.1.3", + "grunt-jslint": "~1.1.14" }, "repository": { "type": "git",