1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-05 02:29:26 +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,16 +1,18 @@
module.exports = function angularDraggabillyDirective(DraggabillyService) {
return {
restrict: 'AE',
link: function (scope, element, attrs) {
var parsedAttrs = $parse(attrs.angularDraggabilly)()
if (typeof parsedAttrs !== 'object') {
parsedAttrs = {}
module.exports =
function angularDraggabillyDirective(DraggabillyService, $parse) {
return {
restrict: 'AE',
link: function (scope, element, attrs) {
var parsedAttrs = $parse(attrs.angularDraggabilly)()
if (typeof parsedAttrs !== 'object') {
parsedAttrs = {}
}
var options = angular.extend({
}, parsedAttrs)
/* jshint unused: false */
var draggie = new DraggabillyService(element[0], options)
}
var options = angular.extend({
}, parsedAttrs)
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() {
var service = {}
var domPrefixes = 'Webkit Moz O ms'.toLowerCase().split(' ')
function createElement() {
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) {
service[key] = (typeof test == 'function') ? test() : test
}
addTest('touch', function () {
return ('ontouchstart' in window) || window.DocumentTouch &&
document instanceof DocumentTouch
document instanceof window.DocumentTouch
})
addTest('retina', function () {
@ -73,13 +52,33 @@ module.exports = function BrowserInfoServiceFactory() {
var canvas = createElement('canvas')
if ('supportsContext' in canvas) {
return canvas.supportsContext('webgl') ||
canvas.supportsContext('experimental-webgl')
canvas.supportsContext('experimental-webgl')
}
return !!window.WebGLRenderingContext
})
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 () {
// var bool = false
// var i = domPrefixes.length

View file

@ -3,11 +3,9 @@ module.exports = function badgeIconDirective() {
restrict: 'EA',
replace: true,
scope: {
},
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 {
replace: false,
scope: true,
@ -52,7 +52,7 @@ module.exports = function counterDirective($timeout, $$rAF) {
}
})
attrs.$observe('countFrom', function (val) {
attrs.$observe('countFrom', function (/*val*/) {
start()
})

View file

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

View file

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

View file

@ -4,14 +4,14 @@ module.exports = function niceTabsDirective() {
replace: true,
template: require('./nice-tabs.jade'),
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
scope.$watch(attrs.tabs, function (newValue, oldValue) {
scope.$watch(attrs.tabs, function (newValue) {
scope.tabs = newValue
})
scope.$watch(attrs.filter, function (newValue, oldValue) {
scope.$watch(attrs.filter, function (newValue) {
scope.filter = newValue
})

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,49 +1,50 @@
module.exports = function landscapeDirective(BrowserInfo, $document, $window, $rootScope) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
var body = angular.element($document[0].body)
module.exports =
function landscapeDirective(BrowserInfo, $document, $window) {
return {
restrict: 'A',
link: function (scope) {
var body = angular.element($document[0].body)
if (typeof $window.orientation !== 'undefined') {
if ($window.orientation === 0) {
//rotateGuest(true)
} else {
rotateGuest(false)
if (typeof $window.orientation !== 'undefined') {
if ($window.orientation !== 0) {
rotateGuest(false)
}
}
}
function rotateGuest(portrait) {
if (portrait) {
body.addClass('guest-portrait')
body.removeClass('guest-landscape')
function rotateGuest(portrait) {
if (portrait) {
body.addClass('guest-portrait')
body.removeClass('guest-landscape')
scope.$broadcast('guest-portrait')
} else {
body.addClass('guest-landscape')
body.removeClass('guest-portrait')
scope.$broadcast('guest-portrait')
} else {
body.addClass('guest-landscape')
body.removeClass('guest-portrait')
scope.$broadcast('guest-landscape')
scope.$broadcast('guest-landscape')
$window.scrollTo(0,0)
$window.scrollTo(0, 0)
}
}
}
function guestDisplayRotatated(eventData) {
var isPortrait = (window.innerHeight > window.innerWidth)
rotateGuest(isPortrait)
}
function guestDisplayRotated() {
var isPortrait = (window.innerHeight > window.innerWidth)
rotateGuest(isPortrait)
}
if (BrowserInfo.deviceorientation) {
window.addEventListener('orientationchange', guestDisplayRotatated, true)
}
function off() {
if (BrowserInfo.deviceorientation) {
window.removeEventListener('orientationchange', guestDisplayRotatated)
window.addEventListener('orientationchange', guestDisplayRotated,
true)
}
}
scope.$on('$destroy', off)
function off() {
if (BrowserInfo.deviceorientation) {
window.removeEventListener('orientationchange',
guestDisplayRotated)
}
}
scope.$on('$destroy', off)
}
}
}
}

View file

@ -1,112 +1,113 @@
var _ = require('lodash')
module.exports = function logcatTableDirective($rootScope, $timeout, LogcatService) {
return {
restrict: 'E',
replace: true,
template: require('./logcat-table.jade'),
link: function (scope, element, attrs) {
var autoScroll = true
var autoScrollDependingOnScrollPosition = true
var scrollPosition = 0
var scrollHeight = 0
var parent = element[0]
var body = element.find('tbody')[0]
var maxEntriesBuffer = 3000
var numberOfEntries = 0
module.exports =
function logcatTableDirective($rootScope, $timeout, LogcatService) {
return {
restrict: 'E',
replace: true,
template: require('./logcat-table.jade'),
link: function (scope, element) {
var autoScroll = true
var autoScrollDependingOnScrollPosition = true
var scrollPosition = 0
var scrollHeight = 0
var parent = element[0]
var body = element.find('tbody')[0]
var maxEntriesBuffer = 3000
var numberOfEntries = 0
function incrementNumberEntry() {
numberOfEntries++
if (numberOfEntries > maxEntriesBuffer) {
scope.clearTable()
function incrementNumberEntry() {
numberOfEntries++
if (numberOfEntries > maxEntriesBuffer) {
scope.clearTable()
}
}
}
LogcatService.addEntryListener = function (entry) {
incrementNumberEntry()
addRow(body, entry)
}
LogcatService.addFilteredEntriesListener = function (entries) {
clearTable()
//var fragment = document.createDocumentFragment()
_.each(entries, function (entry) {
// TODO: This is not adding all the entries after first scope creation
LogcatService.addEntryListener = function (entry) {
incrementNumberEntry()
addRow(body, entry, true)
addRow(body, entry)
}
LogcatService.addFilteredEntriesListener = function (entries) {
clearTable()
//var fragment = document.createDocumentFragment()
_.each(entries, function (entry) {
// TODO: This is not adding all the entries after first scope creation
incrementNumberEntry()
addRow(body, entry, true)
})
}
function shouldAutoScroll() {
if (autoScrollDependingOnScrollPosition) {
return scrollPosition === scrollHeight
} else {
return true
}
}
function scrollListener(event) {
scrollPosition = event.target.scrollTop + event.target.clientHeight
scrollHeight = event.target.scrollHeight
}
var throttledScrollListener = _.throttle(scrollListener, 100)
parent.addEventListener('scroll', throttledScrollListener, false)
function scrollToBottom() {
parent.scrollTop = parent.scrollHeight + 20
$timeout(function () {
parent.scrollTop = parent.scrollHeight
}, 10)
}
function addRow(rowParent, data, batchRequest) {
var newRow = rowParent.insertRow(-1)
newRow.classList.add('log-' + data.priorityLabel)
//newRow.insertCell(-1)
// .appendChild(document.createTextNode(LogcatService.numberOfEntries))
//newRow.insertCell(-1)
// .appendChild(document.createTextNode(data.deviceLabel))
newRow.insertCell(-1)
.appendChild(document.createTextNode(data.priorityLabel))
newRow.insertCell(-1)
.appendChild(document.createTextNode(data.dateLabel))
if ($rootScope.platform === 'native') {
newRow.insertCell(-1)
.appendChild(document.createTextNode(data.pid))
newRow.insertCell(-1)
.appendChild(document.createTextNode(data.tid))
//newRow.insertCell(-1)
// .appendChild(document.createTextNode(data.app))
newRow.insertCell(-1)
.appendChild(document.createTextNode(data.tag))
}
newRow.insertCell(-1)
.appendChild(document.createTextNode(data.message))
if (autoScroll && shouldAutoScroll() && !batchRequest) {
_.throttle(scrollToBottom, 30)()
}
}
function clearTable() {
var oldBody = body
var newBody = document.createElement('tbody')
oldBody.parentNode.replaceChild(newBody, oldBody)
body = newBody
}
scope.clearTable = function () {
LogcatService.clear()
numberOfEntries = 0
clearTable()
}
scope.$on('$destroy', function () {
parent.removeEventListener('scroll', throttledScrollListener)
})
}
function shouldAutoScroll() {
if (autoScrollDependingOnScrollPosition) {
return scrollPosition === scrollHeight
} else {
return true
}
}
function scrollListener(event) {
scrollPosition = event.target.scrollTop + event.target.clientHeight
scrollHeight = event.target.scrollHeight
}
var throttledScrollListener = _.throttle(scrollListener, 100)
parent.addEventListener('scroll', throttledScrollListener, false)
function scrollToBottom() {
parent.scrollTop = parent.scrollHeight + 20
$timeout(function () {
parent.scrollTop = parent.scrollHeight
}, 10)
}
function addRow(rowParent, data, batchRequest) {
var newRow = rowParent.insertRow(-1)
newRow.classList.add('log-' + data.priorityLabel)
//newRow.insertCell(-1)
// .appendChild(document.createTextNode(LogcatService.numberOfEntries))
//newRow.insertCell(-1)
// .appendChild(document.createTextNode(data.deviceLabel))
newRow.insertCell(-1)
.appendChild(document.createTextNode(data.priorityLabel))
newRow.insertCell(-1)
.appendChild(document.createTextNode(data.dateLabel))
if ($rootScope.platform === 'native') {
newRow.insertCell(-1)
.appendChild(document.createTextNode(data.pid))
newRow.insertCell(-1)
.appendChild(document.createTextNode(data.tid))
//newRow.insertCell(-1)
// .appendChild(document.createTextNode(data.app))
newRow.insertCell(-1)
.appendChild(document.createTextNode(data.tag))
}
newRow.insertCell(-1)
.appendChild(document.createTextNode(data.message))
if (autoScroll && shouldAutoScroll() && !batchRequest) {
_.throttle(scrollToBottom, 30)()
}
}
function clearTable() {
var oldBody = body
var newBody = document.createElement('tbody')
oldBody.parentNode.replaceChild(newBody, oldBody)
body = newBody
}
scope.clearTable = function () {
LogcatService.clear()
numberOfEntries = 0
clearTable()
}
scope.$on('$destroy', function () {
parent.removeEventListener('scroll', throttledScrollListener)
})
}
}
}

View file

@ -16,15 +16,16 @@ CanvasRender.prototype.draw = function (image) {
}
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)
}
// -------------------------------------------------------------------------------------------------
/*
Based on http://www-cs-students.stanford.edu/~eparker/files/crunch/renderer.js
*/
Based on http://www-cs-students.stanford.edu/~eparker/files/crunch/renderer.js
*/
/**
* Constructs a renderer object.
@ -37,121 +38,117 @@ var Renderer = function (gl) {
* @type {WebGLRenderingContext}
* @private
*/
this.gl_ = gl;
this.gl_ = gl
/**
* The WebGLProgram.
* @type {WebGLProgram}
* @private
*/
this.program_ = gl.createProgram();
this.program_ = gl.createProgram()
/**
* @type {WebGLShader}
* @private
*/
this.vertexShader_ = this.compileShader_(
Renderer.vertexShaderSource_, gl.VERTEX_SHADER);
Renderer.vertexShaderSource_, gl.VERTEX_SHADER)
/**
* @type {WebGLShader}
* @private
*/
this.fragmentShader_ = this.compileShader_(
Renderer.fragmentShaderSource_, gl.FRAGMENT_SHADER);
Renderer.fragmentShaderSource_, gl.FRAGMENT_SHADER)
/**
* Cached uniform locations.
* @type {Object.<string, WebGLUniformLocation>}
* @private
*/
this.uniformLocations_ = {};
this.uniformLocations_ = {}
/**
* Cached attribute locations.
* @type {Object.<string, WebGLActiveInfo>}
* @private
*/
this.attribLocations_ = {};
this.attribLocations_ = {}
/**
* 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].
* @private
*/
this.quadVertexBuffer_ = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, this.quadVertexBuffer_);
this.quadVertexBuffer_ = gl.createBuffer()
gl.bindBuffer(gl.ARRAY_BUFFER, this.quadVertexBuffer_)
var vertices = new Float32Array(
[-1.0, -1.0, 0.0, 1.0,
+1.0, -1.0, 1.0, 1.0,
-1.0, +1.0, 0.0, 0.0,
1.0, +1.0, 1.0, 0.0]);
gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW);
1.0, +1.0, 1.0, 0.0])
gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW)
// Init shaders
gl.attachShader(this.program_, this.vertexShader_);
gl.attachShader(this.program_, this.fragmentShader_);
gl.bindAttribLocation(this.program_, 0, 'vert');
gl.linkProgram(this.program_);
gl.useProgram(this.program_);
gl.enableVertexAttribArray(0);
gl.attachShader(this.program_, this.vertexShader_)
gl.attachShader(this.program_, this.fragmentShader_)
gl.bindAttribLocation(this.program_, 0, 'vert')
gl.linkProgram(this.program_)
gl.useProgram(this.program_)
gl.enableVertexAttribArray(0)
gl.enable(gl.DEPTH_TEST);
gl.disable(gl.CULL_FACE);
gl.enable(gl.DEPTH_TEST)
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++) {
var infoU = gl.getActiveUniform(this.program_, i);
var infoU = gl.getActiveUniform(this.program_, i)
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++) {
var infoA = gl.getActiveAttrib(this.program_, j);
var infoA = gl.getActiveAttrib(this.program_, j)
this.attribLocations_[infoA.name] =
gl.getAttribLocation(this.program_, infoA.name);
gl.getAttribLocation(this.program_, infoA.name)
}
};
}
Renderer.prototype.finishInit = function () {
this.draw();
};
this.draw()
}
Renderer.prototype.createDxtTexture = function (
dxtData
, width
, height
, format
) {
var gl = this.gl_;
var tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
gl.compressedTexImage2D(
gl.TEXTURE_2D,
0,
format,
width,
height,
0,
dxtData);
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_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
//gl.generateMipmap(gl.TEXTURE_2D)
gl.bindTexture(gl.TEXTURE_2D, null);
return tex;
};
Renderer.prototype.createDxtTexture =
function (dxtData, width, height, format) {
var gl = this.gl_
var tex = gl.createTexture()
gl.bindTexture(gl.TEXTURE_2D, tex)
gl.compressedTexImage2D(
gl.TEXTURE_2D,
0,
format,
width,
height,
0,
dxtData)
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_WRAP_S, gl.CLAMP_TO_EDGE)
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE)
//gl.generateMipmap(gl.TEXTURE_2D)
gl.bindTexture(gl.TEXTURE_2D, null)
return tex
}
Renderer.prototype.createRgb565Texture = function (rgb565Data, width, height) {
var gl = this.gl_;
var tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
var gl = this.gl_
var tex = gl.createTexture()
gl.bindTexture(gl.TEXTURE_2D, tex)
gl.texImage2D(
gl.TEXTURE_2D,
0,
@ -161,35 +158,35 @@ Renderer.prototype.createRgb565Texture = function (rgb565Data, width, height) {
0,
gl.RGB,
gl.UNSIGNED_SHORT_5_6_5,
rgb565Data);
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_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
rgb565Data)
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_WRAP_S, gl.CLAMP_TO_EDGE)
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE)
//gl.generateMipmap(gl.TEXTURE_2D)
gl.bindTexture(gl.TEXTURE_2D, null);
return tex;
};
gl.bindTexture(gl.TEXTURE_2D, null)
return tex
}
Renderer.prototype.drawTexture = function (texture, width, height) {
var gl = this.gl_;
var gl = this.gl_
// draw scene
gl.clearColor(0, 0, 0, 1);
gl.clearDepth(1.0);
gl.viewport(0, 0, width, height);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);
gl.clearColor(0, 0, 0, 1)
gl.clearDepth(1.0)
gl.viewport(0, 0, width, height)
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT)
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.uniform1i(this.uniformLocations_.texSampler, 0);
gl.activeTexture(gl.TEXTURE0)
gl.bindTexture(gl.TEXTURE_2D, texture)
gl.uniform1i(this.uniformLocations_.texSampler, 0)
gl.enableVertexAttribArray(this.attribLocations_.vert);
gl.bindBuffer(gl.ARRAY_BUFFER, this.quadVertexBuffer_);
gl.enableVertexAttribArray(this.attribLocations_.vert)
gl.bindBuffer(gl.ARRAY_BUFFER, this.quadVertexBuffer_)
gl.vertexAttribPointer(this.attribLocations_.vert, 4, gl.FLOAT,
false, 0, 0);
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
};
false, 0, 0)
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4)
}
/**
@ -200,12 +197,12 @@ Renderer.prototype.drawTexture = function (texture, width, height) {
* @private
*/
Renderer.prototype.compileShader_ = function (shaderSource, type) {
var gl = this.gl_;
var shader = gl.createShader(type);
gl.shaderSource(shader, shaderSource);
gl.compileShader(shader);
return shader;
};
var gl = this.gl_
var shader = gl.createShader(type)
gl.shaderSource(shader, shaderSource)
gl.compileShader(shader)
return shader
}
/**
@ -219,7 +216,7 @@ Renderer.vertexShaderSource_ = [
' gl_Position = vec4(vert.xy, 0.0, 1.0);',
' v_texCoord = vert.zw;',
'}'
].join('\n');
].join('\n')
/**
@ -233,7 +230,7 @@ Renderer.fragmentShaderSource_ = [
'void main() {',
' gl_FragColor = texture2D(texSampler, v_texCoord);',
'}'
].join('\n');
].join('\n')
// -------------------------------------------------------------------------------------------------
@ -254,7 +251,7 @@ function WebGLRender(canvasElement) {
} catch (e2) {
// fail, not able to get a context
throw new Error('This browser does not support webGL. Try using the' +
'canvas renderer' + this)
'canvas renderer' + this)
}
}
@ -284,7 +281,7 @@ WebGLRender.prototype.setup = function () {
'void main(void) {' +
' gl_Position = vec4(aVertex, 0.0, 1.0);' +
' vTex = aUV;' +
'}';
'}'
var fragmentShaderSrc =
'precision highp float;' +
@ -292,7 +289,7 @@ WebGLRender.prototype.setup = function () {
'uniform sampler2D sampler0;' +
'void main(void){' +
' gl_FragColor = texture2D(sampler0, vTex);' +
'}';
'}'
var vertShaderObj = this.ctx.createShader(this.ctx.VERTEX_SHADER)
var fragShaderObj = this.ctx.createShader(this.ctx.FRAGMENT_SHADER)
@ -316,18 +313,9 @@ WebGLRender.prototype.setup = function () {
this.vertexBuff = this.ctx.createBuffer()
this.ctx.bindBuffer(this.ctx.ARRAY_BUFFER, this.vertexBuff)
this.ctx.bufferData(
this.ctx.ARRAY_BUFFER
, new Float32Array([
-1 / 8
, 1 / 6
, -1 / 8
, -1 / 6
, 1 / 8
, -1 / 6
, 1 / 8
, 1 / 6
])
, this.ctx.STATIC_DRAW
this.ctx.ARRAY_BUFFER, new Float32Array([
-1 / 8, 1 / 6, -1 / 8, -1 / 6, 1 / 8, -1 / 6, 1 / 8, 1 / 6
]), this.ctx.STATIC_DRAW
)
this.texBuff = this.ctx.createBuffer()
@ -345,7 +333,6 @@ WebGLRender.prototype.setup = function () {
WebGLRender.prototype.draw = function (image) {
// this.renderer.drawTexture(image, image.width, image.height)
this.renderer.drawTexture(image, 643, 1149)
}
@ -353,41 +340,33 @@ WebGLRender.prototype.drawOld = function (image) {
var tex = this.ctx.createTexture()
this.ctx.bindTexture(this.ctx.TEXTURE_2D, tex)
this.ctx.texParameteri(
this.ctx.TEXTURE_2D
, this.ctx.TEXTURE_MIN_FILTER
, this.ctx.NEAREST
this.ctx.TEXTURE_2D, this.ctx.TEXTURE_MIN_FILTER, this.ctx.NEAREST
)
this.ctx.texParameteri(
this.ctx.TEXTURE_2D
, this.ctx.TEXTURE_MAG_FILTER
, this.ctx.NEAREST
)
/*
this.ctx.texParameteri(
this.ctx.TEXTURE_2D
, this.ctx.TEXTURE_MIN_FILTER
, this.ctx.LINEAR
this.ctx.TEXTURE_2D, this.ctx.TEXTURE_MAG_FILTER, this.ctx.NEAREST
)
/*
this.ctx.texParameteri(
this.ctx.TEXTURE_2D
, this.ctx.TEXTURE_MIN_FILTER
, this.ctx.LINEAR
)
this.ctx.texParameteri(
this.ctx.TEXTURE_2D
, this.ctx.TEXTURE_WRAP_S
, this.ctx.CLAMP_TO_EDGE
)
this.ctx.texParameteri(
this.ctx.TEXTURE_2D
, this.ctx.TEXTURE_WRAP_T
, this.ctx.CLAMP_TO_EDGE
)
*/
this.ctx.texParameteri(
this.ctx.TEXTURE_2D
, this.ctx.TEXTURE_WRAP_S
, this.ctx.CLAMP_TO_EDGE
)
this.ctx.texParameteri(
this.ctx.TEXTURE_2D
, this.ctx.TEXTURE_WRAP_T
, this.ctx.CLAMP_TO_EDGE
)
*/
this.ctx.generateMipmap(this.ctx.TEXTURE_2D)
this.ctx.texImage2D(
this.ctx.TEXTURE_2D
, 0
, this.ctx.RGBA
, this.ctx.RGBA
, this.ctx.UNSIGNED_BYTE
, image
this.ctx.TEXTURE_2D, 0, this.ctx.RGBA, this.ctx.RGBA,
this.ctx.UNSIGNED_BYTE, image
)
this.ctx.enableVertexAttribArray(this.vloc)
@ -415,31 +394,30 @@ function FastImageRender(canvasElement, options) {
this.timeoutId = null
if (that.options.raf) {
that.animLoop = function() {
that.raf = requireAnimationFrame(that.animLoop)
that.animLoop = function () {
that.raf = window.requireAnimationFrame(that.animLoop)
// separate render from drawing
// render
}
}
if (true) {
this.loader = new Image()
this.loader.onload = function () {
if (that.options.timeout) {
clearTimeout(that.timeoutId)
}
if (typeof(that.onLoad) === 'function') {
that.onLoad(this)
}
// Loader
this.loader = new Image()
this.loader.onload = function () {
if (that.options.timeout) {
clearTimeout(that.timeoutId)
}
this.loader.onerror = function () {
if (that.options.timeout) {
clearTimeout(that.timeoutId)
}
if (typeof(that.onError) === 'function') {
that.onError(this)
}
if (typeof(that.onLoad) === 'function') {
that.onLoad(this)
}
}
this.loader.onerror = function () {
if (that.options.timeout) {
clearTimeout(that.timeoutId)
}
if (typeof(that.onError) === 'function') {
that.onError(this)
}
}
@ -454,7 +432,7 @@ function FastImageRender(canvasElement, options) {
FastImageRender.prototype.destroy = function () {
cancelAnimationFrame(this.raf)
window.cancelAnimationFrame(this.raf)
// delete onLoad & onError
}
@ -472,11 +450,11 @@ FastImageRender.prototype.load = function (url, type) {
if (this.options.textureLoader) {
if (!this.textureLoader) {
this.textureLoader = new TextureUtil.TextureLoader(this.render.ctx)
this.textureLoader = new window.TextureUtil.TextureLoader(this.render.ctx)
}
var texture = null
if (type) {
texture = this.render.ctx.createTexture();
texture = this.render.ctx.createTexture()
this.textureLoader.loadEx(url, texture, true, function () {
if (typeof(that.onLoad) === 'function') {
that.onLoad(texture)
@ -511,7 +489,7 @@ Object.defineProperty(FastImageRender.prototype, 'canvasWidth', {
set: function (width) {
if (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) {
if (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) {
if (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) {
if (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) {
var styleWidth = width + 'px'
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) {
var styleHeight = height + 'px'
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 _ = require('lodash')
module.exports = function DeviceScreenDirective($document, ScalingService, VendorUtil, PageVisibilityService, BrowserInfo, $timeout) {
module.exports = function DeviceScreenDirective($document, ScalingService,
VendorUtil, PageVisibilityService, BrowserInfo, $timeout) {
return {
restrict: 'E',
template: require('./screen.jade'),
link: function (scope, element) {
var canvas = element.find('canvas')[0]
, imageRender = new FastImageRender(canvas, {render: 'canvas', timeout: 3000})
, guestDisplayDensity = setDisplayDensity(1.5)
, guestDisplayRotation = 0
, finger = element.find('span')
, input = element.find('input')
, boundingWidth = 0 // TODO: cache inside FastImageRender?
, boundingHeight = 0
, cachedBoundingWidth = 0
, cachedBoundingHeight = 0
, cachedImageWidth = 0
, cachedImageHeight = 0
, cachedRotation = 0
, rotation = 0
, loading = false
, scaler
, seq = 0
, cssTransform = VendorUtil.style(['transform', 'webkitTransform'])
var imageRender = new FastImageRender(canvas, {
render: 'canvas',
timeout: 3000
})
var guestDisplayDensity = setDisplayDensity(1.5)
//var guestDisplayRotation = 0
var finger = element.find('span')
var input = element.find('input')
var boundingWidth = 0 // TODO: cache inside FastImageRender?
var boundingHeight = 0
var cachedBoundingWidth = 0
var cachedBoundingHeight = 0
var cachedImageWidth = 0
var cachedImageHeight = 0
var cachedRotation = 0
var rotation = 0
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
var onPanelResizeThrottled = _.throttle(updateBounds, 16)
@ -32,7 +36,10 @@ module.exports = function DeviceScreenDirective($document, ScalingService, Vendo
function setDisplayDensity(forRetina) {
// FORCE
forRetina = 1.2
return guestDisplayDensity = BrowserInfo.mobile && BrowserInfo.retina ? forRetina : 1
guestDisplayDensity =
BrowserInfo.mobile && BrowserInfo.retina ? forRetina : 1
return guestDisplayDensity
}
function sendTouch(type, e) {
@ -56,9 +63,7 @@ module.exports = function DeviceScreenDirective($document, ScalingService, Vendo
'translate3d(' + x + 'px,' + y + 'px,0)'
scope.control[type](
seq++
, scaled.xP
, scaled.yP
seq++, scaled.xP, scaled.yP
)
}
@ -126,22 +131,22 @@ module.exports = function DeviceScreenDirective($document, ScalingService, Vendo
// Chrome/Safari/Opera
if (
// Mac | Kinesis keyboard | Karabiner | Latin key, Kana key
e.keyCode === 0 && e.keyIdentifier === 'U+0010' ||
e.keyCode === 0 && e.keyIdentifier === 'U+0010' ||
// Mac | MacBook Pro keyboard | Latin key, Kana key
e.keyCode === 0 && e.keyIdentifier === 'U+0020' ||
e.keyCode === 0 && e.keyIdentifier === 'U+0020' ||
// Win | Lenovo X230 keyboard | Alt+Latin key
e.keyCode === 246 && e.keyIdentifier === 'U+00F6' ||
e.keyCode === 246 && e.keyIdentifier === 'U+00F6' ||
// Win | Lenovo X230 keyboard | Convert key
e.keyCode === 28 && e.keyIdentifier === 'U+001C'
) {
e.keyCode === 28 && e.keyIdentifier === 'U+001C'
) {
return true
}
// Firefox
switch(e.key) {
switch (e.key) {
case 'Convert': // Windows | Convert key
case 'Alphanumeric': // Mac | Latin key
case 'RomanCharacters': // Windows/Mac | Latin key
@ -207,17 +212,16 @@ module.exports = function DeviceScreenDirective($document, ScalingService, Vendo
if (!loading && scope.$parent.showScreen && scope.device) {
loading = true
imageRender.load(scope.device.display.url +
'?width=' + Math.ceil(boundingWidth * guestDisplayDensity) +
'&height=' + Math.ceil(boundingHeight * guestDisplayDensity) +
'&time=' + Date.now()
'?width=' + Math.ceil(boundingWidth * guestDisplayDensity) +
'&height=' + Math.ceil(boundingHeight * guestDisplayDensity) +
'&time=' + Date.now()
)
}
}
function on() {
scaler = ScalingService.coordinator(
scope.device.display.width
, scope.device.display.height
scope.device.display.width, scope.device.display.height
)
imageRender.onLoad = function (image) {
@ -244,9 +248,7 @@ module.exports = function DeviceScreenDirective($document, ScalingService, Vendo
imageRender.canvasHeight = cachedImageHeight
var size = scaler.projectedSize(
boundingWidth
, boundingHeight
, rotation
boundingWidth, boundingHeight, rotation
)
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 {
restrict: 'EA',
template: require('./socket-state.jade'),
// scope: {
// }
link: function (scope) {
var hasFailedOnce = false
@ -55,27 +55,33 @@ module.exports = function SocketStateDirectiveFactory(socket, growl, gettext, $f
hasFailedOnce = true
})
scope.$watch('socketState', function (newValue, oldValue) {
scope.$watch('socketState', function (newValue) {
if (newValue) {
if (newValue === 'connect') {
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 {
switch (newValue) {
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;
case 'connect_error':
case 'connect_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;
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;
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;
}
}

View file

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

View file

@ -1,6 +1,6 @@
// 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
var run = function (command) {
@ -13,7 +13,9 @@ module.exports = function ShellCtrl($scope, gettext) {
}
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 () {

View file

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

View file

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