jslint
This commit is contained in:
parent
c92573e3dc
commit
8b30070a86
3 changed files with 21 additions and 30 deletions
|
@ -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']);
|
||||
};
|
||||
|
|
41
js/cast.js
41
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;
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue