mirror of
https://github.com/Dansen999/migor.git
synced 2026-01-11 05:24:16 +00:00
Initial import (partially)
This commit is contained in:
@@ -12,8 +12,6 @@
|
||||
<link href="css/jquery.mobile-1.3.2.min.css?_=<%=buildDate%>" rel="stylesheet" type="text/css"/>
|
||||
|
||||
|
||||
|
||||
|
||||
<%-- Plugins --%>
|
||||
<script type="text/javascript" src="js/plugin/jquery-1.10.2.js?_=<%=buildDate%>"></script>
|
||||
<script type="text/javascript" src="js/plugin/jquery.mobile-1.3.2.js?_=<%=buildDate%>"></script>
|
||||
@@ -22,15 +20,11 @@
|
||||
<script type="text/javascript" src="js/widget/widget-chat.js?_=<%=buildDate%>"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- EXECUTE INIT SCRIPT -->
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$(document).ready(function () {
|
||||
$('#chat-content').chat();
|
||||
$('#send').on('click', function() {
|
||||
$('#send').on('click', function () {
|
||||
var message = $('#message').val();
|
||||
if (message.length > 0) {
|
||||
$('#chat-content').chat('send', message);
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,9 +1,9 @@
|
||||
#login-content {
|
||||
background: #FFFFFF url(../image/gps.gif) no-repeat fixed top;
|
||||
background-size: 200px;
|
||||
position:absolute;
|
||||
top:40px;
|
||||
right:0;
|
||||
bottom:0;
|
||||
left:0;
|
||||
position: absolute;
|
||||
top: 40px;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
<meta http-equiv="refresh" content="0;url=./index.jsp" />
|
||||
<meta http-equiv="refresh" content="0;url=./index.jsp"/>
|
||||
@@ -16,14 +16,13 @@
|
||||
<script type="text/javascript" src="js/plugin/jquery.mobile-1.3.2.js?_=<%=buildDate%>"></script>
|
||||
|
||||
|
||||
|
||||
<!-- EXECUTE INIT SCRIPT -->
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$(document).ready(function () {
|
||||
$('#startButton')
|
||||
.button('disable')
|
||||
.on('click', function() {
|
||||
$.mobile.changePage( "chat.jsp", {
|
||||
.on('click', function () {
|
||||
$.mobile.changePage("chat.jsp", {
|
||||
transition: 'fade'
|
||||
}
|
||||
);
|
||||
@@ -31,7 +30,7 @@
|
||||
);
|
||||
|
||||
|
||||
$('#username').on('change', function(event) {
|
||||
$('#username').on('change', function (event) {
|
||||
if ($('#username').val().length > 2) {
|
||||
$('#startButton').button('enable');
|
||||
} else {
|
||||
@@ -62,12 +61,13 @@
|
||||
</div>
|
||||
|
||||
<div id="login-content" data-role="content" style="padding-top: 120px;">
|
||||
<p>
|
||||
<input id="username" type="text" value="" placeholder="Username" />
|
||||
</p>
|
||||
<p>
|
||||
<button id="startButton" data-role="button">Start</button>
|
||||
</p>
|
||||
<p>
|
||||
<input id="username" type="text" value="" placeholder="Username"/>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<button id="startButton" data-role="button">Start</button>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -14,39 +14,35 @@
|
||||
var bb = {
|
||||
success: 0,
|
||||
error: 0,
|
||||
blackberryTimeoutId : -1
|
||||
blackberryTimeoutId: -1
|
||||
};
|
||||
|
||||
function handleBlackBerryLocationTimeout()
|
||||
{
|
||||
if(bb.blackberryTimeoutId!=-1) {
|
||||
bb.error({ message: "Timeout error",
|
||||
code: 3
|
||||
function handleBlackBerryLocationTimeout() {
|
||||
if (bb.blackberryTimeoutId != -1) {
|
||||
bb.error({ message: "Timeout error",
|
||||
code: 3
|
||||
});
|
||||
}
|
||||
}
|
||||
function handleBlackBerryLocation()
|
||||
{
|
||||
function handleBlackBerryLocation() {
|
||||
clearTimeout(bb.blackberryTimeoutId);
|
||||
bb.blackberryTimeoutId=-1;
|
||||
bb.blackberryTimeoutId = -1;
|
||||
if (bb.success && bb.error) {
|
||||
if(blackberry.location.latitude==0 && blackberry.location.longitude==0) {
|
||||
if (blackberry.location.latitude == 0 && blackberry.location.longitude == 0) {
|
||||
//http://dev.w3.org/geo/api/spec-source.html#position_unavailable_error
|
||||
//POSITION_UNAVAILABLE (numeric value 2)
|
||||
bb.error({message:"Position unavailable", code:2});
|
||||
bb.error({message: "Position unavailable", code: 2});
|
||||
}
|
||||
else
|
||||
{
|
||||
var timestamp=null;
|
||||
else {
|
||||
var timestamp = null;
|
||||
//only available with 4.6 and later
|
||||
//http://na.blackberry.com/eng/deliverables/8861/blackberry_location_568404_11.jsp
|
||||
if (blackberry.location.timestamp)
|
||||
{
|
||||
timestamp = new Date( blackberry.location.timestamp );
|
||||
if (blackberry.location.timestamp) {
|
||||
timestamp = new Date(blackberry.location.timestamp);
|
||||
}
|
||||
bb.success( { timestamp: timestamp ,
|
||||
bb.success({ timestamp: timestamp,
|
||||
coords: {
|
||||
latitude: blackberry.location.latitude,
|
||||
latitude: blackberry.location.latitude,
|
||||
longitude: blackberry.location.longitude
|
||||
}
|
||||
});
|
||||
@@ -60,22 +56,21 @@ function handleBlackBerryLocation()
|
||||
}
|
||||
}
|
||||
|
||||
var geoPosition=function() {
|
||||
var geoPosition = function () {
|
||||
|
||||
var pub = {};
|
||||
var provider=null;
|
||||
var u="undefined";
|
||||
var provider = null;
|
||||
var u = "undefined";
|
||||
var ipGeolocationSrv = 'http://freegeoip.net/json/?callback=JSONPCallback';
|
||||
|
||||
pub.getCurrentPosition = function(success,error,opts)
|
||||
{
|
||||
provider.getCurrentPosition(success, error,opts);
|
||||
pub.getCurrentPosition = function (success, error, opts) {
|
||||
provider.getCurrentPosition(success, error, opts);
|
||||
}
|
||||
|
||||
pub.jsonp = {
|
||||
callbackCounter: 0,
|
||||
|
||||
fetch: function(url, callback) {
|
||||
fetch: function (url, callback) {
|
||||
var fn = 'JSONPCallback_' + this.callbackCounter++;
|
||||
window[fn] = this.evalJSONP(callback);
|
||||
url = url.replace('=JSONPCallback', '=' + fn);
|
||||
@@ -85,96 +80,93 @@ var geoPosition=function() {
|
||||
document.getElementsByTagName('HEAD')[0].appendChild(scriptTag);
|
||||
},
|
||||
|
||||
evalJSONP: function(callback) {
|
||||
return function(data) {
|
||||
evalJSONP: function (callback) {
|
||||
return function (data) {
|
||||
callback(data);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
pub.confirmation = function()
|
||||
{
|
||||
pub.confirmation = function () {
|
||||
return confirm('This Webpage wants to track your physical location.\nDo you allow it?');
|
||||
};
|
||||
|
||||
pub.init = function()
|
||||
{
|
||||
try
|
||||
{
|
||||
var hasGeolocation = typeof(navigator.geolocation)!=u;
|
||||
if( !hasGeolocation ){
|
||||
if( !pub.confirmation() ){
|
||||
pub.init = function () {
|
||||
try {
|
||||
var hasGeolocation = typeof(navigator.geolocation) != u;
|
||||
if (!hasGeolocation) {
|
||||
if (!pub.confirmation()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( typeof(geoPositionSimulator)!=u ) && (geoPositionSimulator.length > 0 ) ){
|
||||
provider=geoPositionSimulator;
|
||||
} else if (typeof(bondi)!=u && typeof(bondi.geolocation)!=u ) {
|
||||
provider=bondi.geolocation;
|
||||
} else if ( hasGeolocation ) {
|
||||
provider=navigator.geolocation;
|
||||
pub.getCurrentPosition = function(success, error, opts) {
|
||||
if (( typeof(geoPositionSimulator) != u ) && (geoPositionSimulator.length > 0 )) {
|
||||
provider = geoPositionSimulator;
|
||||
} else if (typeof(bondi) != u && typeof(bondi.geolocation) != u) {
|
||||
provider = bondi.geolocation;
|
||||
} else if (hasGeolocation) {
|
||||
provider = navigator.geolocation;
|
||||
pub.getCurrentPosition = function (success, error, opts) {
|
||||
function _success(p) {
|
||||
//for mozilla geode,it returns the coordinates slightly differently
|
||||
var params;
|
||||
if(typeof(p.latitude)!=u) {
|
||||
if (typeof(p.latitude) != u) {
|
||||
params = {
|
||||
timestamp: p.timestamp,
|
||||
coords: {
|
||||
latitude: p.latitude,
|
||||
latitude: p.latitude,
|
||||
longitude: p.longitude
|
||||
}
|
||||
};
|
||||
} else {
|
||||
params = p;
|
||||
}
|
||||
success( params );
|
||||
success(params);
|
||||
}
|
||||
provider.getCurrentPosition(_success,error,opts);
|
||||
|
||||
provider.getCurrentPosition(_success, error, opts);
|
||||
}
|
||||
} else if(typeof(window.blackberry)!=u && blackberry.location.GPSSupported) {
|
||||
} else if (typeof(window.blackberry) != u && blackberry.location.GPSSupported) {
|
||||
// set to autonomous mode
|
||||
if(typeof(blackberry.location.setAidMode)==u) {
|
||||
if (typeof(blackberry.location.setAidMode) == u) {
|
||||
return false;
|
||||
}
|
||||
blackberry.location.setAidMode(2);
|
||||
//override default method implementation
|
||||
pub.getCurrentPosition = function(success,error,opts)
|
||||
{
|
||||
pub.getCurrentPosition = function (success, error, opts) {
|
||||
//passing over callbacks as parameter didn't work consistently
|
||||
//In the onLocationUpdate method, thats why they have to be set outside
|
||||
bb.success = success;
|
||||
bb.error = error;
|
||||
//function needs to be a string according to
|
||||
//http://www.tonybunce.com/2008/05/08/Blackberry-Browser-Amp-GPS.aspx
|
||||
if(opts['timeout']) {
|
||||
bb.blackberryTimeoutId = setTimeout("handleBlackBerryLocationTimeout()",opts['timeout']);
|
||||
if (opts['timeout']) {
|
||||
bb.blackberryTimeoutId = setTimeout("handleBlackBerryLocationTimeout()", opts['timeout']);
|
||||
} else {
|
||||
//default timeout when none is given to prevent a hanging script
|
||||
bb.blackberryTimeoutId = setTimeout("handleBlackBerryLocationTimeout()",60000);
|
||||
bb.blackberryTimeoutId = setTimeout("handleBlackBerryLocationTimeout()", 60000);
|
||||
}
|
||||
blackberry.location.onLocationUpdate("handleBlackBerryLocation()");
|
||||
blackberry.location.refreshLocation();
|
||||
}
|
||||
provider = blackberry.location;
|
||||
|
||||
} else if ( typeof(Mojo) !=u && typeof(Mojo.Service.Request)!="Mojo.Service.Request") {
|
||||
} else if (typeof(Mojo) != u && typeof(Mojo.Service.Request) != "Mojo.Service.Request") {
|
||||
provider = true;
|
||||
pub.getCurrentPosition = function(success, error, opts) {
|
||||
pub.getCurrentPosition = function (success, error, opts) {
|
||||
parameters = {};
|
||||
if( opts ) {
|
||||
if (opts) {
|
||||
//http://developer.palm.com/index.php?option=com_content&view=article&id=1673#GPS-getCurrentPosition
|
||||
if (opts.enableHighAccuracy && opts.enableHighAccuracy == true ){
|
||||
if (opts.enableHighAccuracy && opts.enableHighAccuracy == true) {
|
||||
parameters.accuracy = 1;
|
||||
}
|
||||
if ( opts.maximumAge ) {
|
||||
if (opts.maximumAge) {
|
||||
parameters.maximumAge = opts.maximumAge;
|
||||
}
|
||||
if (opts.responseTime) {
|
||||
if( opts.responseTime < 5 ) {
|
||||
if (opts.responseTime < 5) {
|
||||
parameters.responseTime = 1;
|
||||
} else if ( opts.responseTime < 20 ) {
|
||||
} else if (opts.responseTime < 20) {
|
||||
parameters.responseTime = 2;
|
||||
} else {
|
||||
parameters.timeout = 3;
|
||||
@@ -182,30 +174,30 @@ var geoPosition=function() {
|
||||
}
|
||||
}
|
||||
|
||||
r = new Mojo.Service.Request( 'palm://com.palm.location' , {
|
||||
method:"getCurrentPosition",
|
||||
parameters:parameters,
|
||||
onSuccess: function( p ){
|
||||
success( { timestamp: p.timestamp,
|
||||
r = new Mojo.Service.Request('palm://com.palm.location', {
|
||||
method: "getCurrentPosition",
|
||||
parameters: parameters,
|
||||
onSuccess: function (p) {
|
||||
success({ timestamp: p.timestamp,
|
||||
coords: {
|
||||
latitude: p.latitude,
|
||||
latitude: p.latitude,
|
||||
longitude: p.longitude,
|
||||
heading: p.heading
|
||||
heading: p.heading
|
||||
}
|
||||
});
|
||||
},
|
||||
onFailure: function( e ){
|
||||
if (e.errorCode==1) {
|
||||
error({ code: 3,
|
||||
message: "Timeout"
|
||||
onFailure: function (e) {
|
||||
if (e.errorCode == 1) {
|
||||
error({ code: 3,
|
||||
message: "Timeout"
|
||||
});
|
||||
} else if (e.errorCode==2){
|
||||
error({ code: 2,
|
||||
message: "Position unavailable"
|
||||
} else if (e.errorCode == 2) {
|
||||
error({ code: 2,
|
||||
message: "Position unavailable"
|
||||
});
|
||||
} else {
|
||||
error({ code: 0,
|
||||
message: "Unknown Error: webOS-code" + errorCode
|
||||
error({ code: 0,
|
||||
message: "Unknown Error: webOS-code" + errorCode
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -213,51 +205,54 @@ var geoPosition=function() {
|
||||
}
|
||||
|
||||
}
|
||||
else if (typeof(device)!=u && typeof(device.getServiceObject)!=u) {
|
||||
provider=device.getServiceObject("Service.Location", "ILocation");
|
||||
else if (typeof(device) != u && typeof(device.getServiceObject) != u) {
|
||||
provider = device.getServiceObject("Service.Location", "ILocation");
|
||||
|
||||
//override default method implementation
|
||||
pub.getCurrentPosition = function(success, error, opts){
|
||||
pub.getCurrentPosition = function (success, error, opts) {
|
||||
function callback(transId, eventCode, result) {
|
||||
if (eventCode == 4) {
|
||||
error({message:"Position unavailable", code:2});
|
||||
error({message: "Position unavailable", code: 2});
|
||||
} else {
|
||||
//no timestamp of location given?
|
||||
success( { timestamp:null,
|
||||
success({ timestamp: null,
|
||||
coords: {
|
||||
latitude: result.ReturnValue.Latitude,
|
||||
longitude: result.ReturnValue.Longitude,
|
||||
altitude: result.ReturnValue.Altitude,
|
||||
heading: result.ReturnValue.Heading }
|
||||
latitude: result.ReturnValue.Latitude,
|
||||
longitude: result.ReturnValue.Longitude,
|
||||
altitude: result.ReturnValue.Altitude,
|
||||
heading: result.ReturnValue.Heading }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//location criteria
|
||||
|
||||
var criteria = new Object();
|
||||
criteria.LocationInformationClass = "BasicLocationInformation";
|
||||
//make the call
|
||||
provider.ILocation.GetLocation(criteria,callback);
|
||||
provider.ILocation.GetLocation(criteria, callback);
|
||||
}
|
||||
} else {
|
||||
pub.getCurrentPosition = function(success, error, opts) {
|
||||
} else {
|
||||
pub.getCurrentPosition = function (success, error, opts) {
|
||||
pub.jsonp.fetch(ipGeolocationSrv,
|
||||
function( p ){ success( { timestamp: p.timestamp,
|
||||
coords: {
|
||||
latitude: p.latitude,
|
||||
longitude: p.longitude,
|
||||
heading: p.heading
|
||||
}
|
||||
});});
|
||||
function (p) {
|
||||
success({ timestamp: p.timestamp,
|
||||
coords: {
|
||||
latitude: p.latitude,
|
||||
longitude: p.longitude,
|
||||
heading: p.heading
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
provider = true;
|
||||
}
|
||||
}
|
||||
catch (e){
|
||||
if( typeof(console) != u ) console.log(e);
|
||||
catch (e) {
|
||||
if (typeof(console) != u) console.log(e);
|
||||
return false;
|
||||
}
|
||||
return provider!=null;
|
||||
return provider != null;
|
||||
}
|
||||
return pub;
|
||||
}();
|
||||
@@ -5,7 +5,7 @@ $.widget("migor.chat", {
|
||||
options: {
|
||||
endpoint: '/migor/services/client/socket/chat'
|
||||
},
|
||||
_create:function () {
|
||||
_create: function () {
|
||||
var self = this;
|
||||
|
||||
|
||||
@@ -13,10 +13,10 @@ $.widget("migor.chat", {
|
||||
var endpoint = 'ws://192.168.0.18:8080' + self.options.endpoint;
|
||||
|
||||
self.socket = new WebSocket(endpoint);
|
||||
self.socket.onmessage = function(event) {
|
||||
self.socket.onmessage = function (event) {
|
||||
self._onMessage(event.data);
|
||||
};
|
||||
self.socket.onerror = function(event) {
|
||||
self.socket.onerror = function (event) {
|
||||
self.element.prepend('<p class="message error">Cannot connect to web socket!!</p>');
|
||||
};
|
||||
} else {
|
||||
@@ -24,7 +24,7 @@ $.widget("migor.chat", {
|
||||
}
|
||||
|
||||
},
|
||||
_destroy: function() {
|
||||
_destroy: function () {
|
||||
var self = this;
|
||||
|
||||
if (self.socket) {
|
||||
@@ -32,15 +32,15 @@ $.widget("migor.chat", {
|
||||
self.socket = null;
|
||||
}
|
||||
},
|
||||
_setOptions: function() {
|
||||
this._superApply( arguments );
|
||||
_setOptions: function () {
|
||||
this._superApply(arguments);
|
||||
},
|
||||
_onMessage: function(message) {
|
||||
_onMessage: function (message) {
|
||||
var self = this;
|
||||
|
||||
self.element.prepend('<p class="message received">'+message+'</p>');
|
||||
self.element.prepend('<p class="message received">' + message + '</p>');
|
||||
},
|
||||
send: function(message) {
|
||||
send: function (message) {
|
||||
var self = this;
|
||||
|
||||
if (self.socket) {
|
||||
|
||||
@@ -5,7 +5,7 @@ $.widget("migor.mobile", {
|
||||
options: {
|
||||
|
||||
},
|
||||
_create:function () {
|
||||
_create: function () {
|
||||
var self = this;
|
||||
|
||||
if (!self.user) {
|
||||
@@ -20,8 +20,8 @@ $.widget("migor.mobile", {
|
||||
}
|
||||
|
||||
},
|
||||
_setOptions: function() {
|
||||
this._superApply( arguments );
|
||||
_setOptions: function () {
|
||||
this._superApply(arguments);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user