1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-05 10:39:25 +02:00

All JSHint trough webpack passes now.

This commit is contained in:
Gunther Brunner 2014-09-02 17:25:22 +09:00
parent 176bd002da
commit ce604d8211
21 changed files with 395 additions and 413 deletions

View file

@ -1,4 +1,5 @@
module.exports = function angularDraggabillyDirective(DraggabillyService) { module.exports =
function angularDraggabillyDirective(DraggabillyService, $parse) {
return { return {
restrict: 'AE', restrict: 'AE',
link: function (scope, element, attrs) { link: function (scope, element, attrs) {
@ -10,6 +11,7 @@ module.exports = function angularDraggabillyDirective(DraggabillyService) {
var options = angular.extend({ var options = angular.extend({
}, parsedAttrs) }, parsedAttrs)
/* jshint unused: false */
var draggie = new DraggabillyService(element[0], options) var draggie = new DraggabillyService(element[0], options)
} }
} }

View file

@ -1,39 +1,18 @@
// NOTE: Most of the detections stuff from Modernizr 3.0 // NOTE: Most of the detection stuff is from Modernizr 3.0
module.exports = function BrowserInfoServiceFactory() { module.exports = function BrowserInfoServiceFactory() {
var service = {} var service = {}
var domPrefixes = 'Webkit Moz O ms'.toLowerCase().split(' ')
function createElement() { function createElement() {
return document.createElement.apply(document, arguments) return document.createElement.apply(document, arguments)
} }
function hasEvent() {
return (function (undefined) {
function isEventSupportedInner(eventName, element) {
var isSupported
if (!eventName) {
return false
}
if (!element || typeof element === 'string') {
element = createElement(element || 'div')
}
eventName = 'on' + eventName
isSupported = eventName in element
return isSupported
}
return isEventSupportedInner
})()
}
function addTest(key, test) { function addTest(key, test) {
service[key] = (typeof test == 'function') ? test() : test service[key] = (typeof test == 'function') ? test() : test
} }
addTest('touch', function () { addTest('touch', function () {
return ('ontouchstart' in window) || window.DocumentTouch && return ('ontouchstart' in window) || window.DocumentTouch &&
document instanceof DocumentTouch document instanceof window.DocumentTouch
}) })
addTest('retina', function () { addTest('retina', function () {
@ -80,6 +59,26 @@ module.exports = function BrowserInfoServiceFactory() {
addTest('ua', navigator.userAgent) addTest('ua', navigator.userAgent)
//function hasEvent() {
// return (function (undefined) {
// function isEventSupportedInner(eventName, element) {
// var isSupported
// if (!eventName) {
// return false
// }
// if (!element || typeof element === 'string') {
// element = createElement(element || 'div')
// }
// eventName = 'on' + eventName
// isSupported = eventName in element
// return isSupported
// }
//
// return isEventSupportedInner
// })()
//}
// var domPrefixes = 'Webkit Moz O ms'.toLowerCase().split(' ')
// addTest('pointerevents', function () { // addTest('pointerevents', function () {
// var bool = false // var bool = false
// var i = domPrefixes.length // var i = domPrefixes.length

View file

@ -3,11 +3,9 @@ module.exports = function badgeIconDirective() {
restrict: 'EA', restrict: 'EA',
replace: true, replace: true,
scope: { scope: {
}, },
template: require('./badge-icon.jade'), template: require('./badge-icon.jade'),
link: function (scope, element, attrs) { link: function () {
} }
} }
} }

View file

@ -1,4 +1,4 @@
module.exports = function counterDirective($timeout, $$rAF) { module.exports = function counterDirective($timeout) {
return { return {
replace: false, replace: false,
scope: true, scope: true,
@ -52,7 +52,7 @@ module.exports = function counterDirective($timeout, $$rAF) {
} }
}) })
attrs.$observe('countFrom', function (val) { attrs.$observe('countFrom', function (/*val*/) {
start() start()
}) })

View file

@ -18,7 +18,7 @@ module.exports = function ServiceFactory($modal, $location) {
controller: ModalInstanceCtrl controller: ModalInstanceCtrl
}) })
modalInstance.result.then(function (selectedItem) { modalInstance.result.then(function (/*selectedItem*/) {
}, function () { }, function () {
}) })
} }

View file

@ -4,11 +4,9 @@ module.exports = function niceTabDirective() {
restrict: 'E', restrict: 'E',
replace: true, replace: true,
scope: { scope: {
}, },
template: require('./nice-tab.jade'), template: require('./nice-tab.jade'),
link: function (scope, element, attrs) { link: function () {
} }
} }
} }

View file

@ -4,14 +4,14 @@ module.exports = function niceTabsDirective() {
replace: true, replace: true,
template: require('./nice-tabs.jade'), template: require('./nice-tabs.jade'),
link: function (scope, element, attrs) { link: function (scope, element, attrs) {
// TODO: add support for 'key' for saving in localstorage // TODO: add support for 'key' for saving in Settings
// TODO: add support for 'direction=below' for below tabs // TODO: add support for 'direction=below' for below tabs
scope.$watch(attrs.tabs, function (newValue, oldValue) { scope.$watch(attrs.tabs, function (newValue) {
scope.tabs = newValue scope.tabs = newValue
}) })
scope.$watch(attrs.filter, function (newValue, oldValue) { scope.$watch(attrs.filter, function (newValue) {
scope.filter = newValue scope.filter = newValue
}) })

View file

@ -5,5 +5,4 @@ require('angular-growl')
module.exports = angular.module('stf/common-ui/notifications', [ module.exports = angular.module('stf/common-ui/notifications', [
'ngAnimate', 'ngAnimate',
'angular-growl' 'angular-growl'
]).config(['growlProvider', function (growlProvider) { ])
}])

View file

@ -1,8 +1,7 @@
module.exports = function tooltipsDirective() { module.exports = function tooltipsDirective() {
return { return {
restrict: 'A', restrict: 'A',
link: function (scope, element, attrs) { link: function () {
} }
} }
} }

View file

@ -71,7 +71,7 @@ module.exports = angular.module('stf.device-status', [])
}[text] || gettext('-') }[text] || gettext('-')
} }
}) })
.filter('displayDensity', function (gettext) { .filter('displayDensity', function () {
return function (text) { return function (text) {
return { return {
'0.5': 'LDPI', // (120 dpi) '0.5': 'LDPI', // (120 dpi)
@ -102,7 +102,7 @@ module.exports = angular.module('stf.device-status', [])
.filter('networkSubType', function (gettext) { .filter('networkSubType', function (gettext) {
return function (text) { return function (text) {
return { return {
'mobile_wifi': gettext('WiFi'), 'mobile_wifi': gettext('WiFi')
}[text] || text }[text] || text
} }
}) })

View file

@ -1,7 +1,7 @@
module.exports = function imageOnloadAnimateDirective($parse, $animate) { module.exports = function imageOnloadAnimateDirective($parse, $animate) {
return { return {
restrict: 'A', restrict: 'A',
link: function (scope, element, attrs) { link: function (scope, element) {
$animate.addClass(element, 'ng-image-not-loaded') $animate.addClass(element, 'ng-image-not-loaded')
element.bind('load', function () { element.bind('load', function () {
$animate.removeClass(element, 'ng-image-not-loaded') $animate.removeClass(element, 'ng-image-not-loaded')

View file

@ -1,4 +1,4 @@
module.exports = function imageOnloadDirective($parse) { module.exports = function imageOnloadDirective() {
return { return {
restrict: 'A', restrict: 'A',
link: function (scope, element, attrs) { link: function (scope, element, attrs) {

View file

@ -1,13 +1,12 @@
module.exports = function landscapeDirective(BrowserInfo, $document, $window, $rootScope) { module.exports =
function landscapeDirective(BrowserInfo, $document, $window) {
return { return {
restrict: 'A', restrict: 'A',
link: function (scope, element, attrs) { link: function (scope) {
var body = angular.element($document[0].body) var body = angular.element($document[0].body)
if (typeof $window.orientation !== 'undefined') { if (typeof $window.orientation !== 'undefined') {
if ($window.orientation === 0) { if ($window.orientation !== 0) {
//rotateGuest(true)
} else {
rotateGuest(false) rotateGuest(false)
} }
} }
@ -28,18 +27,20 @@ module.exports = function landscapeDirective(BrowserInfo, $document, $window, $r
} }
} }
function guestDisplayRotatated(eventData) { function guestDisplayRotated() {
var isPortrait = (window.innerHeight > window.innerWidth) var isPortrait = (window.innerHeight > window.innerWidth)
rotateGuest(isPortrait) rotateGuest(isPortrait)
} }
if (BrowserInfo.deviceorientation) { if (BrowserInfo.deviceorientation) {
window.addEventListener('orientationchange', guestDisplayRotatated, true) window.addEventListener('orientationchange', guestDisplayRotated,
true)
} }
function off() { function off() {
if (BrowserInfo.deviceorientation) { if (BrowserInfo.deviceorientation) {
window.removeEventListener('orientationchange', guestDisplayRotatated) window.removeEventListener('orientationchange',
guestDisplayRotated)
} }
} }

View file

@ -1,11 +1,12 @@
var _ = require('lodash') var _ = require('lodash')
module.exports = function logcatTableDirective($rootScope, $timeout, LogcatService) { module.exports =
function logcatTableDirective($rootScope, $timeout, LogcatService) {
return { return {
restrict: 'E', restrict: 'E',
replace: true, replace: true,
template: require('./logcat-table.jade'), template: require('./logcat-table.jade'),
link: function (scope, element, attrs) { link: function (scope, element) {
var autoScroll = true var autoScroll = true
var autoScrollDependingOnScrollPosition = true var autoScrollDependingOnScrollPosition = true
var scrollPosition = 0 var scrollPosition = 0

View file

@ -16,7 +16,8 @@ CanvasRender.prototype.draw = function (image) {
} }
CanvasRender.prototype.clear = function () { CanvasRender.prototype.clear = function () {
this.context.clearRect(0, 0, this.context.canvas.width, this.context.canvas.height) this.context.clearRect(0, 0, this.context.canvas.width,
this.context.canvas.height)
} }
@ -37,99 +38,95 @@ var Renderer = function (gl) {
* @type {WebGLRenderingContext} * @type {WebGLRenderingContext}
* @private * @private
*/ */
this.gl_ = gl; this.gl_ = gl
/** /**
* The WebGLProgram. * The WebGLProgram.
* @type {WebGLProgram} * @type {WebGLProgram}
* @private * @private
*/ */
this.program_ = gl.createProgram(); this.program_ = gl.createProgram()
/** /**
* @type {WebGLShader} * @type {WebGLShader}
* @private * @private
*/ */
this.vertexShader_ = this.compileShader_( this.vertexShader_ = this.compileShader_(
Renderer.vertexShaderSource_, gl.VERTEX_SHADER); Renderer.vertexShaderSource_, gl.VERTEX_SHADER)
/** /**
* @type {WebGLShader} * @type {WebGLShader}
* @private * @private
*/ */
this.fragmentShader_ = this.compileShader_( this.fragmentShader_ = this.compileShader_(
Renderer.fragmentShaderSource_, gl.FRAGMENT_SHADER); Renderer.fragmentShaderSource_, gl.FRAGMENT_SHADER)
/** /**
* Cached uniform locations. * Cached uniform locations.
* @type {Object.<string, WebGLUniformLocation>} * @type {Object.<string, WebGLUniformLocation>}
* @private * @private
*/ */
this.uniformLocations_ = {}; this.uniformLocations_ = {}
/** /**
* Cached attribute locations. * Cached attribute locations.
* @type {Object.<string, WebGLActiveInfo>} * @type {Object.<string, WebGLActiveInfo>}
* @private * @private
*/ */
this.attribLocations_ = {}; this.attribLocations_ = {}
/** /**
* A vertex buffer containing a single quad with xy coordinates from [-1,-1] * A vertex buffer containing a single quad with xy coordinates from [-1,-1]
* to [1,1] and uv coordinates from [0,0] to [1,1]. * to [1,1] and uv coordinates from [0,0] to [1,1].
* @private * @private
*/ */
this.quadVertexBuffer_ = gl.createBuffer(); this.quadVertexBuffer_ = gl.createBuffer()
gl.bindBuffer(gl.ARRAY_BUFFER, this.quadVertexBuffer_); gl.bindBuffer(gl.ARRAY_BUFFER, this.quadVertexBuffer_)
var vertices = new Float32Array( var vertices = new Float32Array(
[-1.0, -1.0, 0.0, 1.0, [-1.0, -1.0, 0.0, 1.0,
+1.0, -1.0, 1.0, 1.0, +1.0, -1.0, 1.0, 1.0,
-1.0, +1.0, 0.0, 0.0, -1.0, +1.0, 0.0, 0.0,
1.0, +1.0, 1.0, 0.0]); 1.0, +1.0, 1.0, 0.0])
gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW); gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW)
// Init shaders // Init shaders
gl.attachShader(this.program_, this.vertexShader_); gl.attachShader(this.program_, this.vertexShader_)
gl.attachShader(this.program_, this.fragmentShader_); gl.attachShader(this.program_, this.fragmentShader_)
gl.bindAttribLocation(this.program_, 0, 'vert'); gl.bindAttribLocation(this.program_, 0, 'vert')
gl.linkProgram(this.program_); gl.linkProgram(this.program_)
gl.useProgram(this.program_); gl.useProgram(this.program_)
gl.enableVertexAttribArray(0); gl.enableVertexAttribArray(0)
gl.enable(gl.DEPTH_TEST); gl.enable(gl.DEPTH_TEST)
gl.disable(gl.CULL_FACE); gl.disable(gl.CULL_FACE)
var count = gl.getProgramParameter(this.program_, gl.ACTIVE_UNIFORMS); var count = gl.getProgramParameter(this.program_, gl.ACTIVE_UNIFORMS)
for (var i = 0; i < /** @type {number} */(count); i++) { for (var i = 0; i < /** @type {number} */(count); i++) {
var infoU = gl.getActiveUniform(this.program_, i); var infoU = gl.getActiveUniform(this.program_, i)
this.uniformLocations_[infoU.name] = this.uniformLocations_[infoU.name] =
gl.getUniformLocation(this.program_, infoU.name); gl.getUniformLocation(this.program_, infoU.name)
} }
count = gl.getProgramParameter(this.program_, gl.ACTIVE_ATTRIBUTES); count = gl.getProgramParameter(this.program_, gl.ACTIVE_ATTRIBUTES)
for (var j = 0; j < /** @type {number} */(count); j++) { for (var j = 0; j < /** @type {number} */(count); j++) {
var infoA = gl.getActiveAttrib(this.program_, j); var infoA = gl.getActiveAttrib(this.program_, j)
this.attribLocations_[infoA.name] = this.attribLocations_[infoA.name] =
gl.getAttribLocation(this.program_, infoA.name); gl.getAttribLocation(this.program_, infoA.name)
}
} }
};
Renderer.prototype.finishInit = function () { Renderer.prototype.finishInit = function () {
this.draw(); this.draw()
}; }
Renderer.prototype.createDxtTexture = function ( Renderer.prototype.createDxtTexture =
dxtData function (dxtData, width, height, format) {
, width var gl = this.gl_
, height var tex = gl.createTexture()
, format gl.bindTexture(gl.TEXTURE_2D, tex)
) {
var gl = this.gl_;
var tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
gl.compressedTexImage2D( gl.compressedTexImage2D(
gl.TEXTURE_2D, gl.TEXTURE_2D,
0, 0,
@ -137,21 +134,21 @@ Renderer.prototype.createDxtTexture = function (
width, width,
height, height,
0, 0,
dxtData); dxtData)
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE)
//gl.generateMipmap(gl.TEXTURE_2D) //gl.generateMipmap(gl.TEXTURE_2D)
gl.bindTexture(gl.TEXTURE_2D, null); gl.bindTexture(gl.TEXTURE_2D, null)
return tex; return tex
}; }
Renderer.prototype.createRgb565Texture = function (rgb565Data, width, height) { Renderer.prototype.createRgb565Texture = function (rgb565Data, width, height) {
var gl = this.gl_; var gl = this.gl_
var tex = gl.createTexture(); var tex = gl.createTexture()
gl.bindTexture(gl.TEXTURE_2D, tex); gl.bindTexture(gl.TEXTURE_2D, tex)
gl.texImage2D( gl.texImage2D(
gl.TEXTURE_2D, gl.TEXTURE_2D,
0, 0,
@ -161,35 +158,35 @@ Renderer.prototype.createRgb565Texture = function (rgb565Data, width, height) {
0, 0,
gl.RGB, gl.RGB,
gl.UNSIGNED_SHORT_5_6_5, gl.UNSIGNED_SHORT_5_6_5,
rgb565Data); rgb565Data)
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE)
//gl.generateMipmap(gl.TEXTURE_2D) //gl.generateMipmap(gl.TEXTURE_2D)
gl.bindTexture(gl.TEXTURE_2D, null); gl.bindTexture(gl.TEXTURE_2D, null)
return tex; return tex
}; }
Renderer.prototype.drawTexture = function (texture, width, height) { Renderer.prototype.drawTexture = function (texture, width, height) {
var gl = this.gl_; var gl = this.gl_
// draw scene // draw scene
gl.clearColor(0, 0, 0, 1); gl.clearColor(0, 0, 0, 1)
gl.clearDepth(1.0); gl.clearDepth(1.0)
gl.viewport(0, 0, width, height); gl.viewport(0, 0, width, height)
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT); gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT)
gl.activeTexture(gl.TEXTURE0); gl.activeTexture(gl.TEXTURE0)
gl.bindTexture(gl.TEXTURE_2D, texture); gl.bindTexture(gl.TEXTURE_2D, texture)
gl.uniform1i(this.uniformLocations_.texSampler, 0); gl.uniform1i(this.uniformLocations_.texSampler, 0)
gl.enableVertexAttribArray(this.attribLocations_.vert); gl.enableVertexAttribArray(this.attribLocations_.vert)
gl.bindBuffer(gl.ARRAY_BUFFER, this.quadVertexBuffer_); gl.bindBuffer(gl.ARRAY_BUFFER, this.quadVertexBuffer_)
gl.vertexAttribPointer(this.attribLocations_.vert, 4, gl.FLOAT, gl.vertexAttribPointer(this.attribLocations_.vert, 4, gl.FLOAT,
false, 0, 0); false, 0, 0)
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4)
}; }
/** /**
@ -200,12 +197,12 @@ Renderer.prototype.drawTexture = function (texture, width, height) {
* @private * @private
*/ */
Renderer.prototype.compileShader_ = function (shaderSource, type) { Renderer.prototype.compileShader_ = function (shaderSource, type) {
var gl = this.gl_; var gl = this.gl_
var shader = gl.createShader(type); var shader = gl.createShader(type)
gl.shaderSource(shader, shaderSource); gl.shaderSource(shader, shaderSource)
gl.compileShader(shader); gl.compileShader(shader)
return shader; return shader
}; }
/** /**
@ -219,7 +216,7 @@ Renderer.vertexShaderSource_ = [
' gl_Position = vec4(vert.xy, 0.0, 1.0);', ' gl_Position = vec4(vert.xy, 0.0, 1.0);',
' v_texCoord = vert.zw;', ' v_texCoord = vert.zw;',
'}' '}'
].join('\n'); ].join('\n')
/** /**
@ -233,7 +230,7 @@ Renderer.fragmentShaderSource_ = [
'void main() {', 'void main() {',
' gl_FragColor = texture2D(texSampler, v_texCoord);', ' gl_FragColor = texture2D(texSampler, v_texCoord);',
'}' '}'
].join('\n'); ].join('\n')
// ------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------
@ -284,7 +281,7 @@ WebGLRender.prototype.setup = function () {
'void main(void) {' + 'void main(void) {' +
' gl_Position = vec4(aVertex, 0.0, 1.0);' + ' gl_Position = vec4(aVertex, 0.0, 1.0);' +
' vTex = aUV;' + ' vTex = aUV;' +
'}'; '}'
var fragmentShaderSrc = var fragmentShaderSrc =
'precision highp float;' + 'precision highp float;' +
@ -292,7 +289,7 @@ WebGLRender.prototype.setup = function () {
'uniform sampler2D sampler0;' + 'uniform sampler2D sampler0;' +
'void main(void){' + 'void main(void){' +
' gl_FragColor = texture2D(sampler0, vTex);' + ' gl_FragColor = texture2D(sampler0, vTex);' +
'}'; '}'
var vertShaderObj = this.ctx.createShader(this.ctx.VERTEX_SHADER) var vertShaderObj = this.ctx.createShader(this.ctx.VERTEX_SHADER)
var fragShaderObj = this.ctx.createShader(this.ctx.FRAGMENT_SHADER) var fragShaderObj = this.ctx.createShader(this.ctx.FRAGMENT_SHADER)
@ -316,18 +313,9 @@ WebGLRender.prototype.setup = function () {
this.vertexBuff = this.ctx.createBuffer() this.vertexBuff = this.ctx.createBuffer()
this.ctx.bindBuffer(this.ctx.ARRAY_BUFFER, this.vertexBuff) this.ctx.bindBuffer(this.ctx.ARRAY_BUFFER, this.vertexBuff)
this.ctx.bufferData( this.ctx.bufferData(
this.ctx.ARRAY_BUFFER this.ctx.ARRAY_BUFFER, new Float32Array([
, new Float32Array([ -1 / 8, 1 / 6, -1 / 8, -1 / 6, 1 / 8, -1 / 6, 1 / 8, 1 / 6
-1 / 8 ]), this.ctx.STATIC_DRAW
, 1 / 6
, -1 / 8
, -1 / 6
, 1 / 8
, -1 / 6
, 1 / 8
, 1 / 6
])
, this.ctx.STATIC_DRAW
) )
this.texBuff = this.ctx.createBuffer() this.texBuff = this.ctx.createBuffer()
@ -345,7 +333,6 @@ WebGLRender.prototype.setup = function () {
WebGLRender.prototype.draw = function (image) { WebGLRender.prototype.draw = function (image) {
// this.renderer.drawTexture(image, image.width, image.height) // this.renderer.drawTexture(image, image.width, image.height)
this.renderer.drawTexture(image, 643, 1149) this.renderer.drawTexture(image, 643, 1149)
} }
@ -353,14 +340,10 @@ WebGLRender.prototype.drawOld = function (image) {
var tex = this.ctx.createTexture() var tex = this.ctx.createTexture()
this.ctx.bindTexture(this.ctx.TEXTURE_2D, tex) this.ctx.bindTexture(this.ctx.TEXTURE_2D, tex)
this.ctx.texParameteri( this.ctx.texParameteri(
this.ctx.TEXTURE_2D this.ctx.TEXTURE_2D, this.ctx.TEXTURE_MIN_FILTER, this.ctx.NEAREST
, this.ctx.TEXTURE_MIN_FILTER
, this.ctx.NEAREST
) )
this.ctx.texParameteri( this.ctx.texParameteri(
this.ctx.TEXTURE_2D this.ctx.TEXTURE_2D, this.ctx.TEXTURE_MAG_FILTER, this.ctx.NEAREST
, this.ctx.TEXTURE_MAG_FILTER
, this.ctx.NEAREST
) )
/* /*
this.ctx.texParameteri( this.ctx.texParameteri(
@ -382,12 +365,8 @@ WebGLRender.prototype.drawOld = function (image) {
*/ */
this.ctx.generateMipmap(this.ctx.TEXTURE_2D) this.ctx.generateMipmap(this.ctx.TEXTURE_2D)
this.ctx.texImage2D( this.ctx.texImage2D(
this.ctx.TEXTURE_2D this.ctx.TEXTURE_2D, 0, this.ctx.RGBA, this.ctx.RGBA,
, 0 this.ctx.UNSIGNED_BYTE, image
, this.ctx.RGBA
, this.ctx.RGBA
, this.ctx.UNSIGNED_BYTE
, image
) )
this.ctx.enableVertexAttribArray(this.vloc) this.ctx.enableVertexAttribArray(this.vloc)
@ -416,14 +395,14 @@ function FastImageRender(canvasElement, options) {
if (that.options.raf) { if (that.options.raf) {
that.animLoop = function () { that.animLoop = function () {
that.raf = requireAnimationFrame(that.animLoop) that.raf = window.requireAnimationFrame(that.animLoop)
// separate render from drawing // separate render from drawing
// render // render
} }
} }
if (true) { // Loader
this.loader = new Image() this.loader = new Image()
this.loader.onload = function () { this.loader.onload = function () {
if (that.options.timeout) { if (that.options.timeout) {
@ -441,7 +420,6 @@ function FastImageRender(canvasElement, options) {
that.onError(this) that.onError(this)
} }
} }
}
if (this.options.render === 'webgl') { if (this.options.render === 'webgl') {
this.render = new WebGLRender(canvasElement, options) this.render = new WebGLRender(canvasElement, options)
@ -454,7 +432,7 @@ function FastImageRender(canvasElement, options) {
FastImageRender.prototype.destroy = function () { FastImageRender.prototype.destroy = function () {
cancelAnimationFrame(this.raf) window.cancelAnimationFrame(this.raf)
// delete onLoad & onError // delete onLoad & onError
} }
@ -472,11 +450,11 @@ FastImageRender.prototype.load = function (url, type) {
if (this.options.textureLoader) { if (this.options.textureLoader) {
if (!this.textureLoader) { if (!this.textureLoader) {
this.textureLoader = new TextureUtil.TextureLoader(this.render.ctx) this.textureLoader = new window.TextureUtil.TextureLoader(this.render.ctx)
} }
var texture = null var texture = null
if (type) { if (type) {
texture = this.render.ctx.createTexture(); texture = this.render.ctx.createTexture()
this.textureLoader.loadEx(url, texture, true, function () { this.textureLoader.loadEx(url, texture, true, function () {
if (typeof(that.onLoad) === 'function') { if (typeof(that.onLoad) === 'function') {
that.onLoad(texture) that.onLoad(texture)
@ -511,7 +489,7 @@ Object.defineProperty(FastImageRender.prototype, 'canvasWidth', {
set: function (width) { set: function (width) {
if (width) { if (width) {
if (width !== this.canvasElement.width) { if (width !== this.canvasElement.width) {
this.canvasElement.width = width; this.canvasElement.width = width
} }
} }
} }
@ -524,7 +502,7 @@ Object.defineProperty(FastImageRender.prototype, 'canvasHeight', {
set: function (height) { set: function (height) {
if (height) { if (height) {
if (height !== this.canvasElement.height) { if (height !== this.canvasElement.height) {
this.canvasElement.height = height; this.canvasElement.height = height
} }
} }
} }
@ -537,7 +515,7 @@ Object.defineProperty(FastImageRender.prototype, 'displayWidth', {
set: function (width) { set: function (width) {
if (width) { if (width) {
if (width !== this.canvasElement.width) { if (width !== this.canvasElement.width) {
this.canvasElement.width = width; this.canvasElement.width = width
} }
} }
} }
@ -550,7 +528,7 @@ Object.defineProperty(FastImageRender.prototype, 'displayHeight', {
set: function (height) { set: function (height) {
if (height) { if (height) {
if (height !== this.canvasElement.height) { if (height !== this.canvasElement.height) {
this.canvasElement.height = height; this.canvasElement.height = height
} }
} }
} }
@ -564,7 +542,7 @@ Object.defineProperty(FastImageRender.prototype, 'canvasStyleWidth', {
if (width) { if (width) {
var styleWidth = width + 'px' var styleWidth = width + 'px'
if (styleWidth !== this.canvasElement.style.width) { if (styleWidth !== this.canvasElement.style.width) {
this.canvasElement.style.width = styleWidth; this.canvasElement.style.width = styleWidth
} }
} }
} }
@ -578,7 +556,7 @@ Object.defineProperty(FastImageRender.prototype, 'canvasStyleHeight', {
if (height) { if (height) {
var styleHeight = height + 'px' var styleHeight = height + 'px'
if (styleHeight !== this.canvasElement.style.height) { if (styleHeight !== this.canvasElement.style.height) {
this.canvasElement.style.height = height; this.canvasElement.style.height = height
} }
} }
} }

View file

@ -1,29 +1,33 @@
var FastImageRender = require('./fast-image-render').FastImageRender var FastImageRender = require('./fast-image-render').FastImageRender
var _ = require('lodash') var _ = require('lodash')
module.exports = function DeviceScreenDirective($document, ScalingService, VendorUtil, PageVisibilityService, BrowserInfo, $timeout) { module.exports = function DeviceScreenDirective($document, ScalingService,
VendorUtil, PageVisibilityService, BrowserInfo, $timeout) {
return { return {
restrict: 'E', restrict: 'E',
template: require('./screen.jade'), template: require('./screen.jade'),
link: function (scope, element) { link: function (scope, element) {
var canvas = element.find('canvas')[0] var canvas = element.find('canvas')[0]
, imageRender = new FastImageRender(canvas, {render: 'canvas', timeout: 3000}) var imageRender = new FastImageRender(canvas, {
, guestDisplayDensity = setDisplayDensity(1.5) render: 'canvas',
, guestDisplayRotation = 0 timeout: 3000
, finger = element.find('span') })
, input = element.find('input') var guestDisplayDensity = setDisplayDensity(1.5)
, boundingWidth = 0 // TODO: cache inside FastImageRender? //var guestDisplayRotation = 0
, boundingHeight = 0 var finger = element.find('span')
, cachedBoundingWidth = 0 var input = element.find('input')
, cachedBoundingHeight = 0 var boundingWidth = 0 // TODO: cache inside FastImageRender?
, cachedImageWidth = 0 var boundingHeight = 0
, cachedImageHeight = 0 var cachedBoundingWidth = 0
, cachedRotation = 0 var cachedBoundingHeight = 0
, rotation = 0 var cachedImageWidth = 0
, loading = false var cachedImageHeight = 0
, scaler var cachedRotation = 0
, seq = 0 var rotation = 0
, cssTransform = VendorUtil.style(['transform', 'webkitTransform']) var loading = false
var scaler
var seq = 0
var cssTransform = VendorUtil.style(['transform', 'webkitTransform'])
// NOTE: instead of fa-pane-resize, a fa-child-pane-resize could be better // NOTE: instead of fa-pane-resize, a fa-child-pane-resize could be better
var onPanelResizeThrottled = _.throttle(updateBounds, 16) var onPanelResizeThrottled = _.throttle(updateBounds, 16)
@ -32,7 +36,10 @@ module.exports = function DeviceScreenDirective($document, ScalingService, Vendo
function setDisplayDensity(forRetina) { function setDisplayDensity(forRetina) {
// FORCE // FORCE
forRetina = 1.2 forRetina = 1.2
return guestDisplayDensity = BrowserInfo.mobile && BrowserInfo.retina ? forRetina : 1
guestDisplayDensity =
BrowserInfo.mobile && BrowserInfo.retina ? forRetina : 1
return guestDisplayDensity
} }
function sendTouch(type, e) { function sendTouch(type, e) {
@ -56,9 +63,7 @@ module.exports = function DeviceScreenDirective($document, ScalingService, Vendo
'translate3d(' + x + 'px,' + y + 'px,0)' 'translate3d(' + x + 'px,' + y + 'px,0)'
scope.control[type]( scope.control[type](
seq++ seq++, scaled.xP, scaled.yP
, scaled.xP
, scaled.yP
) )
} }
@ -216,8 +221,7 @@ module.exports = function DeviceScreenDirective($document, ScalingService, Vendo
function on() { function on() {
scaler = ScalingService.coordinator( scaler = ScalingService.coordinator(
scope.device.display.width scope.device.display.width, scope.device.display.height
, scope.device.display.height
) )
imageRender.onLoad = function (image) { imageRender.onLoad = function (image) {
@ -244,9 +248,7 @@ module.exports = function DeviceScreenDirective($document, ScalingService, Vendo
imageRender.canvasHeight = cachedImageHeight imageRender.canvasHeight = cachedImageHeight
var size = scaler.projectedSize( var size = scaler.projectedSize(
boundingWidth boundingWidth, boundingHeight, rotation
, boundingHeight
, rotation
) )
imageRender.canvasStyleWidth = size.width imageRender.canvasStyleWidth = size.width

View file

@ -1,9 +1,9 @@
module.exports = function SocketStateDirectiveFactory(socket, growl, gettext, $filter) { module.exports = function SocketStateDirectiveFactory(socket, growl, gettext,
$filter) {
return { return {
restrict: 'EA', restrict: 'EA',
template: require('./socket-state.jade'), template: require('./socket-state.jade'),
// scope: {
// }
link: function (scope) { link: function (scope) {
var hasFailedOnce = false var hasFailedOnce = false
@ -55,27 +55,33 @@ module.exports = function SocketStateDirectiveFactory(socket, growl, gettext, $f
hasFailedOnce = true hasFailedOnce = true
}) })
scope.$watch('socketState', function (newValue, oldValue) { scope.$watch('socketState', function (newValue) {
if (newValue) { if (newValue) {
if (newValue === 'connect') { if (newValue === 'connect') {
if (hasFailedOnce) { if (hasFailedOnce) {
growl.success('<h4>WebSocket</h4>' + $filter('translate')(gettext('Connected successfully.')) + '<refresh-page></refresh-page>', {ttl: 2000}) growl.success('<h4>WebSocket</h4>' + $filter('translate')(
gettext('Connected successfully.')) +
'<refresh-page></refresh-page>', {ttl: 2000})
} }
} else { } else {
switch (newValue) { switch (newValue) {
case 'disconnect': case 'disconnect':
growl.error('<h4>WebSocket</h4>' + $filter('translate')(gettext('Disconnected.<br />Socket connection was lost, try again reloading the page.')), {ttl: -1}) growl.error('<h4>WebSocket</h4>' + $filter('translate')(
gettext('Socket connection was lost, try again reloading the page.')),
{ttl: -1})
break; break;
case 'connect_error': case 'connect_error':
case 'connect_error':
case 'error': case 'error':
growl.error('<h4>WebSocket</h4>' + $filter('translate')(gettext('Error.'), {ttl: -1})) growl.error('<h4>WebSocket</h4>' + $filter('translate')(
gettext('Error.'), {ttl: -1}))
break; break;
case 'reconnect_failed': case 'reconnect_failed':
growl.error('<h4>WebSocket</h4>' + $filter('translate')(gettext('Error while reconnecting.')), {ttl: -1}) growl.error('<h4>WebSocket</h4>' + $filter('translate')(
gettext('Error while reconnecting.')), {ttl: -1})
break; break;
case 'reconnect': case 'reconnect':
growl.success('<h4>WebSocket</h4>' + $filter('translate')(gettext('Reconnected successfully.')), {ttl: -1}) growl.success('<h4>WebSocket</h4>' + $filter('translate')(
gettext('Reconnected successfully.')), {ttl: -1})
break; break;
} }
} }

View file

@ -1,6 +1,7 @@
var _ = require('lodash') var _ = require('lodash')
module.exports = function PortForwardingCtrl($scope, ngTableParams, SettingsService, gettext) { module.exports = function PortForwardingCtrl($scope, ngTableParams,
SettingsService, gettext) {
$scope.forwarding = false $scope.forwarding = false
@ -62,7 +63,8 @@ module.exports = function PortForwardingCtrl($scope, ngTableParams, SettingsServ
function portFieldsAreEmpty(ports) { function portFieldsAreEmpty(ports) {
return (_.isEmpty(ports.targetHost) && _.isEmpty(ports.targetPort) && _.isEmpty(ports.devicePort)) return (_.isEmpty(ports.targetHost) && _.isEmpty(ports.targetPort) &&
_.isEmpty(ports.devicePort))
} }
$scope.portSets = [ $scope.portSets = [
@ -96,7 +98,7 @@ module.exports = function PortForwardingCtrl($scope, ngTableParams, SettingsServ
} }
// Adds a new row whenever necessary // Adds a new row whenever necessary
$scope.$watch('portSets', function (newValue, oldValue) { $scope.$watch('portSets', function (newValue) {
if (newValue) { if (newValue) {
// Remove all empty sets from the middle // Remove all empty sets from the middle
_.remove(newValue, function (ports, index) { _.remove(newValue, function (ports, index) {
@ -108,12 +110,8 @@ module.exports = function PortForwardingCtrl($scope, ngTableParams, SettingsServ
if (!portFieldsAreEmpty(last)) { if (!portFieldsAreEmpty(last)) {
createEmptyField() createEmptyField()
} }
} else {
// createEmptyField()
} }
//SettingsService.setItem('PortForwarding.portSets', angular.copy($scope.portSets)) //SettingsService.setItem('PortForwarding.portSets', angular.copy($scope.portSets))
}, true) }, true)
$scope.portsTable = new ngTableParams({ $scope.portsTable = new ngTableParams({
@ -122,9 +120,7 @@ module.exports = function PortForwardingCtrl($scope, ngTableParams, SettingsServ
}, { }, {
counts: [], counts: [],
total: 1, total: 1,
getData: function ($defer, params) { getData: function ($defer) {
$defer.resolve($scope.portSets) $defer.resolve($scope.portSets)
} }
}) })

View file

@ -1,6 +1,6 @@
// See https://github.com/android/platform_packages_apps_settings/blob/master/AndroidManifest.xml // See https://github.com/android/platform_packages_apps_settings/blob/master/AndroidManifest.xml
module.exports = function ShellCtrl($scope, gettext) { module.exports = function ShellCtrl($scope) {
$scope.result = null $scope.result = null
var run = function (command) { var run = function (command) {
@ -13,7 +13,9 @@ module.exports = function ShellCtrl($scope, gettext) {
} }
function openSetting(activity) { function openSetting(activity) {
run('am start -a android.intent.action.MAIN -n com.android.settings/.Settings\$' + activity) // TODO: CHECK THIS
run('am start -a android.intent.action.MAIN -n com.android.settings/.Settings\\$' +
activity)
} }
$scope.openSettings = function () { $scope.openSettings = function () {

View file

@ -1,4 +1,4 @@
module.exports = function ClipboardCtrl($scope, gettext) { module.exports = function ClipboardCtrl() {
// $scope.clipboardContent = null // $scope.clipboardContent = null
// //
// $scope.getClipboardContent = function () { // $scope.getClipboardContent = function () {

View file

@ -14,6 +14,7 @@ module.exports = function NavigationCtrl($scope, $rootScope) {
$scope.urlFavicon = require('./default-favicon.png') $scope.urlFavicon = require('./default-favicon.png')
faviconIsSet = false faviconIsSet = false
} }
resetFavicon() resetFavicon()
$scope.textUrlChanged = function () { $scope.textUrlChanged = function () {
@ -31,7 +32,7 @@ module.exports = function NavigationCtrl($scope, $rootScope) {
$scope.blurUrl = false $scope.blurUrl = false
$scope.openURL = function ($event) { $scope.openURL = function () {
$scope.blurUrl = true $scope.blurUrl = true
$rootScope.screenFocus = true $rootScope.screenFocus = true