1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
var tabnouveau= new Array();
var db=[
{
"accNumber" : "123",
"eligible" : true,
"contacts" : ["0601234567","0600123456","0600012345"] ,
},
{
"accNumber" : "456",
"eligible" : true,
"contacts" : ["0611223344","0622334455"],
},
{
"accNumber" : "789",
"eligible" : true ,
"contacts" : ["0654321000"],
}
];
function isValid(accN){
var response = false;
for(var i=0; i<db.length;i++){
if(accN == db[i]["accNumber"]){
response = true;
}
}
return response;
}
function getIndex(accN){
for(var i=0; i<db.length;i++){
if(accN == db[i]["accNumber"]){
return i;
}
}
return -1;
}
function isELIG(accN){
return db[getIndex(accN)]["eligible"];
}
function nombreContacts(accN){
return db[getIndex(accN)]["contacts"].length;
}
function first(accN){
if(nombreContacts(accN)<=3)
return db[getIndex(accN)]["contacts"][0];
}
function second(accN){
if(nombreContacts(accN)<=3)
return db[getIndex(accN)]["contacts"][1];
}
function third(accN){
if(nombreContacts(accN)==3)
return db[getIndex(accN)]["contacts"][2];
}
function none(accN){
if(nombreContacts(accN)==0)
return 0;
}
function getnum(NEW) {
if( NEW.length == "12" && NEW.substring(0,4)== "2126" || NEW.length == "10" && NEW.substring(0,2) == "06" )
{
return true ;
}
else {
return false ;
}
}
function number(NEW){
if(NEW.length=="12"){
return NEW.substring(4,12);
}
else{
return NEW.substring(2,10);
}
}
function savenum(accN){
db[getIndex(accN)]["contacts"].concat(tabnouveau);
}
function addanother(nouveau){
tabnouveau.push(nouveau);
return tabnouveau.length;
}
function getIndex2(accN,nouveau){
for(var i=0 ; i<db.length ; i++) {
if( nouveau == (db[getIndex(accN)]["contacts"][i] )) {
return i;
}
}
return -1;
}
function inverser(accN,old,NEW) {
db[getIndex(accN)]["contacts"][getIndex2(accN,old)] = NEW ;
return true ;
}
function not_elig(accN){
if( db[getIndex(accN)]["eligible"] == true ) {
db[getIndex(accN)]["eligible"] == false;
return 0 ;
}
} |
Partager