-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Start refactoring: use common object for all platforms * Implement Device backend for web platform * Implement device backend for android * Move location implementation to considered backend * Fix Location declaration * Fix build * Move 'location.js' to 'html' folder * fixed typo
- Loading branch information
Showing
12 changed files
with
147 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Object { | ||
signal propertyUpdated; | ||
property string macAddess; | ||
property string modelName; | ||
property string deviceId; | ||
property string firmware; | ||
property string sdk; | ||
property bool supportingUhd; | ||
property bool supporting3d; | ||
|
||
constructor: { | ||
var backend = _globals.core.__deviceBackend | ||
if (!backend) | ||
throw new Error('no backend found') | ||
backend().createDevice(this) | ||
} | ||
|
||
onSdkChanged, | ||
onDeviceIdChanged, | ||
onFirmwareChanged, | ||
onMacAddessChanged, | ||
onModelNameChanged, | ||
onSupporting3dChanged, | ||
onSupportingUhdChanged: { this.propertyUpdated() } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/// Window location object | ||
Object { | ||
property string hash; ///< contains current hash value (after '#' charachter) | ||
property string host; ///< current host with port number | ||
property string href; ///< whole current URL | ||
property string port; ///< current port number | ||
property string origin; ///< current protocol, hostname and port number of a URL | ||
property string hostname; ///< current host name | ||
property string pathname; ///< path name of the current URL | ||
property string protocol; ///< current protocol | ||
property string search; ///< query string of the URL | ||
property Object state; ///< current history state | ||
|
||
///@private | ||
constructor: { | ||
this.impl = null | ||
this._createLocation() | ||
} | ||
|
||
///@private | ||
function _getLocation() { | ||
if (this.impl === null) | ||
this._createPlayer() | ||
return this.impl | ||
} | ||
|
||
///@private | ||
function _createLocation() { | ||
if (this.impl) | ||
return this.impl | ||
|
||
var backend = _globals.core.__locationBackend | ||
if (!backend) | ||
throw new Error('no backend found') | ||
return this.impl = backend().createLocation(this) | ||
} | ||
|
||
pushState(state, title, url): { | ||
var location = this._getLocation() | ||
if (location) | ||
player.pushState(state, title, url) | ||
} | ||
|
||
changeHref(href): { | ||
var location = this._getLocation() | ||
if (location) | ||
player.changeHref(href) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var Device = function(ui) { | ||
ui.deviceId = "android_" + Math.random().toString(36).substr(2, 9) | ||
} | ||
|
||
exports.createDevice = function(ui) { | ||
return new Device(ui) | ||
} | ||
|
||
exports.Device = Device |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
var Location = function(ui) { | ||
this._ui = ui | ||
var location = window.location | ||
this.updateActualValues() | ||
var self = this | ||
var context = ui._context | ||
context.window.on("hashchange", function() { self._ui.hash = location.hash }.bind(this)) | ||
context.window.on("popstate", function() { self.updateActualValues() }.bind(this)) | ||
} | ||
|
||
Location.prototype.updateActualValues = function() { | ||
var ui = this._ui | ||
var windowContext = ui._context.window.dom | ||
ui.hash = windowContext.location.hash | ||
ui.href = windowContext.location.href | ||
ui.port = windowContext.location.port | ||
ui.host = windowContext.location.host | ||
ui.origin = windowContext.location.origin | ||
ui.hostname = windowContext.location.hostname | ||
ui.pathname = windowContext.location.pathname | ||
ui.protocol = windowContext.location.protocol | ||
ui.search = windowContext.location.search | ||
ui.state = windowContext.history.state | ||
} | ||
|
||
Location.prototype.changeHref = function(href) { | ||
this._ui._context.window.dom.location.href = href | ||
this.updateActualValues() | ||
} | ||
|
||
Location.prototype.pushState = function(state, title, url) { | ||
var ui = this._ui | ||
var windowContext = ui._context.window.dom | ||
if (windowContext.location.hostname) { | ||
windowContext.history.pushState(state, title, url) | ||
this.updateActualValues() | ||
} else { | ||
ui._context.document.title = title | ||
this.state = state | ||
} | ||
} | ||
|
||
exports.createLocation = function(ui) { | ||
return new Location(ui) | ||
} | ||
|
||
exports.Location = Location |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
var Device = function(ui) { | ||
var context = ui._context | ||
var deviceString = context.system.os + "_" + context.system.browser | ||
deviceString = deviceString.replace(/\s/g, '') | ||
ui.deviceId = deviceString + "_" + Math.random().toString(36).substr(2, 9) | ||
} | ||
|
||
exports.createDevice = function(ui) { | ||
return new Device(ui) | ||
} | ||
|
||
exports.Device = Device |