/*
* Cepat Sembuh v1.0
* Copyright 2016 Cepat Sembuh
*/

document.addEventListener('deviceready', function () {
    Firebase.goOnline();
});

$('#not-available').on('click', function() {
	alert('Faskes is not available.')
})

function getNoAntri(tipe, username, name) {
  breanna = new Firebase('http://cepatsembuh.firebaseio.com/' + tipe + '/faskes/' + username),
  antri = new Firebase('http://cepatsembuh.firebaseio.com/' + tipe + '/faskes/' + username + '/antrian');
  pasien = breanna.child("pasien"),
  // Date
  date = new Date(),
  year = date.getFullYear(),
  month = date.getMonth() + 1,
  day = date.getDate(),
  right_now = year + '-' + month + '-' + day,
  today = breanna.child(right_now),

  if (navigator.online) {
    alert('Anda tidak online');
  } else {
    get = 'Getting data..';
    console.log(get);

    var nama = prompt("Nama: "),
        nik = prompt("NIK: ");

    if (nama === '' || nik.length != 16 || typeof Number(nik) !== 'number' || Number(nik) == 'NaN') {
      alert('Input tidak valid');
    } else {
      antri.transaction(function(currentRank) {
          currentData = currentRank + 1;

          return currentData;
      }, function(error, committed, snapshot) {
          if (error) {
              alert('Koneksi anda tidak stabil' + error);
          } else {
              alert('Nomor Antrian: ' + snapshot.val());
              today.push().set({
                nama: nama,
                nik: nik,
                no_antri: snapshot.val()
              })
          }
      });
    }
    console.log('Data is ready');
  }
}

function tempatTidur(tipe, username) {
  brea = new Firebase('http://cepatsembuh.firebaseio.com/' + tipe + '/faskes/' + username + '/tempat_tidur');

  wait = 'Getting data..';
  console.log(wait);
  alert(wait);

  brea.on('value', function(snapshot) {
    satu = snapshot.val().satu;
    dua = snapshot.val().dua;
    tiga = snapshot.val().tiga;

    alert('Kelas I: ' + satu + '\n' + 'Kelas II: ' + dua + '\n' + 'Kelas III: ' + tiga); // Show user the data's
  })
}

function doctorProfile(nama, lulusan, tahun) {
  giant = 'Lulusan: ' + lulusan + '\n' + 'Tahun: ' + tahun;
  name = 'dr. ' + nama;

  alert(name + '\n' + giant); // Pop-up
}

@@ -702,79 +702,8 @@
 ),%0A%0A
-  if (navigator.online) %7B%0A    alert('Anda tidak online');%0A  %7D else %7B%0A  
   ge
@@ -724,18 +724,16 @@
 ata..';%0A
-  
   consol
@@ -745,18 +745,16 @@
 (get);%0A%0A
-  
   var na
@@ -782,18 +782,16 @@
 ,%0A      
- 
- 
 nik = pr
@@ -806,18 +806,16 @@
 K: %22);%0A%0A
-  
   if (na
@@ -906,26 +906,24 @@
 NaN') %7B%0A    
-  
 alert('Input
@@ -938,18 +938,16 @@
 alid');%0A
-  
   %7D else
@@ -953,18 +953,16 @@
 e %7B%0A    
- 
- 
 antri.tr
@@ -1003,18 +1003,16 @@
         
-  
 currentD
@@ -1043,18 +1043,16 @@
         
- 
- 
 return c
@@ -1063,18 +1063,16 @@
 ntData;%0A
-  
     %7D, f
@@ -1117,18 +1117,16 @@
         
-  
 if (erro
@@ -1126,26 +1126,24 @@
 f (error) %7B%0A
-  
             
@@ -1194,18 +1194,16 @@
         
-  
 %7D else %7B
@@ -1203,18 +1203,16 @@
  else %7B%0A
-  
         
@@ -1270,18 +1270,16 @@
         
-  
 today.pu
@@ -1289,18 +1289,16 @@
 ).set(%7B%0A
-  
         
@@ -1329,18 +1329,16 @@
         
-  
 nik: nik
@@ -1353,18 +1353,16 @@
         
- 
- 
 no_antri
@@ -1394,15 +1394,11 @@
     
-  
 %7D)%0A
-  
     
@@ -1411,22 +1411,16 @@
     
-  
 %7D);%0A  
- 
- 
 %7D%0A
-  
   co
@@ -1447,20 +1447,16 @@
 eady');%0A
-  %7D%0A
 %7D%0A%0Afunct

Remove navigator if condition