Prepare separate classes for RPC calls and Marker management.
This commit is contained in:
parent
fd2c287799
commit
55b629b8e0
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
|
||||
constructor: ->
|
||||
console.log 'OwnMap::constructor()'
|
||||
constructor: (markermgr) ->
|
||||
console.log 'OwnMap::constructor(%o)', markermgr
|
||||
|
||||
@markermgr = markermgr
|
||||
|
||||
@my_markers = {}
|
||||
@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}}
|
||||
|
||||
<!-- 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/main.js"></script>
|
||||
<link rel="stylesheet" href="assets/style.css"/>
|
||||
<title>Your Own Tracks</title>
|
||||
</head>
|
||||
@ -102,8 +104,9 @@
|
||||
window.datepicker_language = '{{datepicker_language}}';
|
||||
|
||||
initUI();
|
||||
//initMap();
|
||||
window.mymap = new OwnMap();
|
||||
window.rpc = new RpcClient('rpc.php?callback=?');
|
||||
window.markers = new MarkerMgr(window.rpc);
|
||||
window.mymap = new OwnMap(window.markers);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
Reference in New Issue
Block a user