Prepare separate classes for RPC calls and Marker management.
This commit is contained in:
14
assets/markermgr.coffee
Executable file
14
assets/markermgr.coffee
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
class window.MarkerMgr
|
||||||
|
constructor: (rpcclient) ->
|
||||||
|
console.log 'MarkerMgr::constructor(%o)', rpcclient
|
||||||
|
@rpcclient = rpcclient
|
||||||
|
|
||||||
|
getMarkers: (dateFromYMD, dateToYMD, accuracy) ->
|
||||||
|
console.log 'MarkerMgr::getMarkers(%o, %o, %o)', dateFromYMD, dateToYMD, accuracy
|
||||||
|
@rpcclient.getMarkers dateFromYMD, dateToYMD, accuracy
|
||||||
|
.done (data, status, xhr) =>
|
||||||
|
console.log 'Got: data=%o status=%o xhr=%o', data, status, xhr
|
||||||
|
if data.status? and data.status
|
||||||
|
@markers = data.markers
|
||||||
|
else
|
||||||
|
console.error 'Marker result not okay.'
|
@@ -1,6 +1,8 @@
|
|||||||
class window.OwnMap
|
class window.OwnMap
|
||||||
constructor: ->
|
constructor: (markermgr) ->
|
||||||
console.log 'OwnMap::constructor()'
|
console.log 'OwnMap::constructor(%o)', markermgr
|
||||||
|
|
||||||
|
@markermgr = markermgr
|
||||||
|
|
||||||
@my_markers = {}
|
@my_markers = {}
|
||||||
@trackerIDs = []
|
@trackerIDs = []
|
||||||
|
19
assets/rpcclient.coffee
Executable file
19
assets/rpcclient.coffee
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
class window.RpcClient
|
||||||
|
constructor: (url) ->
|
||||||
|
console.log 'RpcClient::constructor(%o)', url
|
||||||
|
@url = url
|
||||||
|
@markers = {}
|
||||||
|
|
||||||
|
getMarkers: (dateFromYMD, dateToYMD, accuracy) ->
|
||||||
|
console.log 'RpcClient::getMarkers(%o, %o, %o)', dateFromYMD, dateToYMD, accuracy
|
||||||
|
params =
|
||||||
|
'action': 'getMarkers'
|
||||||
|
'dateFrom': dateFromYMD
|
||||||
|
'dateTo': dateToYMD
|
||||||
|
'accuracy': accuracy
|
||||||
|
#'trackerID' : trackerID
|
||||||
|
#'epoc': time()
|
||||||
|
xhr = $.getJSON @url, params
|
||||||
|
xhr.fail (xhr, status, error) ->
|
||||||
|
console.error 'XHR error: xhr=%o status=%o error=%o', xhr, status, error
|
||||||
|
return xhr
|
@@ -8,8 +8,10 @@
|
|||||||
{{>index_assets}}
|
{{>index_assets}}
|
||||||
|
|
||||||
<!-- our scripts -->
|
<!-- our scripts -->
|
||||||
<script type="text/javascript" src="assets/main.js"></script>
|
<script type="text/javascript" src="assets/rpcclient.js"></script>
|
||||||
|
<script type="text/javascript" src="assets/markermgr.js"></script>
|
||||||
<script type="text/javascript" src="assets/ownmap.js"></script>
|
<script type="text/javascript" src="assets/ownmap.js"></script>
|
||||||
|
<script type="text/javascript" src="assets/main.js"></script>
|
||||||
<link rel="stylesheet" href="assets/style.css"/>
|
<link rel="stylesheet" href="assets/style.css"/>
|
||||||
<title>Your Own Tracks</title>
|
<title>Your Own Tracks</title>
|
||||||
</head>
|
</head>
|
||||||
@@ -102,8 +104,9 @@
|
|||||||
window.datepicker_language = '{{datepicker_language}}';
|
window.datepicker_language = '{{datepicker_language}}';
|
||||||
|
|
||||||
initUI();
|
initUI();
|
||||||
//initMap();
|
window.rpc = new RpcClient('rpc.php?callback=?');
|
||||||
window.mymap = new OwnMap();
|
window.markers = new MarkerMgr(window.rpc);
|
||||||
|
window.mymap = new OwnMap(window.markers);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
Reference in New Issue
Block a user