flaglib
Version:
Ignition event 15 added.
77 lines (58 loc) • 1.99 kB
JavaScript
var util = require('util');
var ActiveGroupUser = require('./groupuser.js');
var ActiveGroup = require('./activegroup.js');
//var map = require("collections/map");
module.exports = ActiveGroupList;
/*
* This function is a constructor.
* input: profile id and group id.
*/
function ActiveGroupList() {
this.groups = new map();
console.log("ActiveGroupList const called: ");
}
/*
* This function creates the active group and add to the list.
* input: number-> mobile number of driver
* flag: complete location data from the driver
*/
ActiveGroupList.prototype.addGroup = function(number, group) {
console.log("ActiveGroup:addGroup start: "+number);
this.groups.add(number,group);
console.log("ActiveGroup:addGroup end: "+this.groups.has(number));
};
/*
* This function deleted the active group from the list.
* input: number-> mobile number of driver
*/
ActiveGroupList.prototype.deleteGroup = function(number) {
console.log("ActiveGroup:deleteGroup start: ");
//1. parse flag, delete active group from the list
var activeGroup = this.groups.has(number);
if (activeGroup){
console.log("ActiveGroup:deleteGroup ele" +
"ment present: ");
this.groups.delete(number);
//groups.d
}else{
console.log("ActiveGroup:deleteGroup element not present: ");
}
console.log("ActiveGroup:deleteGroup end: ");
};
ActiveGroupList.prototype.getSize = function() {
return this.groups.length;
}
/*
* This function check the update for the active group.
* input: number-> mobile number of driver
* flag: complete location data from the driver
*/
ActiveGroupList.prototype.checkUpdateGroup = function(number, flag) {
console.log("ActiveGroup:checkUpdateGroup start: ");
//1. parse flag, get active group, and pass location details to active group for nearby check.
var activeGroup = this.groups.get(number);
if (activeGroup != null){
activeGroup.checkUpdate(flag,null);
}
console.log("ActiveGroup:checkUpdateGroup end: ");
};