Help in Cordova

0

I am trying to carry out a research project that is based on alarms. The idea is that the user can enter the name of the medication, some special indication, the start date and the time it should be taken. But I'm not doing the save, nor the list ... or anything, just shows me the screens. Please help. This is all the code I have made in the index.html

<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<!--<link rel="stylesheet" type="text/css" href="css/index.css"> -->

<link rel="stylesheet" href="js/jquery.mobile-1.4.5.min.css">
<script src="js/jquery-2.1.4.min.js"></script>
<script src="js/jquery.mobile-1.4.5.min.js"></script>
 <script type="text/javascript" src="cordova.js"></script>

<title>Medicamentos</title>

    - >                           

Treatments

                              

                                     Add Medication                 

            <a target="_blank" id="pending_click" href="#pending" style="text-decoration: none">
                <button>Tratamientos Pendientes</button>
            </a>

            <a target="_blank" href="#all" style="text-decoration: none">
                <button>Todos los Tratamientos</button>
            </a>
        </p>
    </div>
</div>

<!-- <Página Agregar Medicamento>-->
<div data-role="page" id="add">
    <div data-role="header">
        <a target="_blank" href="#home" class="ui-btn ui-icon-home ui-btn-icon-left">Inicio</a>
        <h1>Agregar Medicamento</h1>
    </div>
    <div data-role="main" class="ui-content">
        <p>
            Ingrese los datos solicitados:
            <input type="text" id="title" placeholder="Nombre del Medicamento" />
            <input type="text" id="message" placeholder="Indicación especial" /> Ingrese fecha y hora de incio:
            <input type="date" id="date" />
            <input type="time" id="time" />
            <a target="_blank" href="javascript:agregar_medicamento()" style="text-decoration: none">
                <button>Agregar</button>
            </a>
        </p>
    </div>
</div>

<!-- <Página Todos los Medicamentos>-->
<div data-role="page" id="all">
    <div data-role="header">
        <a target="_blank" href="#home" class="ui-btn ui-icon-home ui-btn-icon-left">Inicio</a>
        <h1>Todos los medicamentos</h1>
    </div>

    <div data-role="main" class="ui-content">
        <table data-role="table" data-mode="column" id="allTable" class="ui-responsive table-stroke">
            <thead>
                <tr>
                    <th>Medicamento</th>
                    <th>Hora</th>
                </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
    </div>
</div>

<!-- <Página Medicamentos pendientes>-->
<div data-role="page" id="pending">
    <div data-role="header">
        <a target="_blank" href="#home" class="ui-btn ui-icon-home ui-btn-icon-left">Inicio</a>
        <h1>Medicamentos Pendientes</h1>
    </div>

    <div data-role="main" class="ui-content">
        <table data-role="table" data-mode="column" id="pendingTable" class="ui-responsive table-stroke">
            <thead>
                <tr>
                    <th>Medicamento</th>
                    <th>Hora</th>
                </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
    </div>
</div>

<script  type="text/javascript">
    var info = null;

    document.addEventListener("deviceready", function () {
        if (!localStorage.getItem("rp_data")) {
            var rp_data = { data: [] };
            localStorage.setItem("rp_data", JSON.stringify(rp_data));
        }

        info = JSON.parse(localStorage.getItem("rp_data"));
    }, false);
</script>


</body>

</html>

<script type="text/javascript">
  function agregar_medicamento() {
      var date = document.getElementById("date").value;
      var time = document.getElementById("time").value;
      var title = document.getElementById("title").value;
      var message = document.getElementById("message").value;

      if (date == "" || time == "" || title == "" || message == "") {
          navigator.notification.alert("Por favor, ingrese todos los datos");
          return;
      }

      var schedule_time = new Date((date + " " + time).replace(/-/g, "/")).getTime();
      schedule_time = new Date(schedule_time);

      var id = info.data.length;

  }

<!-- <Esta funcion programa una notificación local y almacena los datos del 
recordatorio en el almacenamiento local para futuras consultas.>-->
<script type="text/javascript">
    function schedule(id, title, message, schedule_time) {
      cordova.plugins.notification.local.schedule({
          id: id,
          title: title,
          message: message,
          at: schedule_time
      });

      var array = [id, title, message, schedule_time];
      info.data[info.data.length] = array;
      localStorage.setItem("rp_data", JSON.stringify(info));

      navigator.notification.alert("Medicamento agregado satisfactoriamente")
  }

<!-- Código JavaScript para rellenar la tabla con todos los medicamentos -->
<script  type="text/javascript">
      $(document).on("pagebeforeshow", "#all", function () {

        var html = '';

        for (var count = 0; count < info.data.length; count++) {
            html = html + "<tr><td>" + info.data[count][1] + "</td><td>" + 
info.data[count][3] + "</td></tr>";

      }

      $("table#allTable tbody").empty();
      $("table#allTable tbody").append(html).closest("table#allTable").table("refresh").trigger("create");
  });

<!-- Código JavaScript para rellenar la tabla con los medicamentos pendientes -->
<script src="js/jquery.mobile-1.4.5.min.js" type="text/javascript">
    $(document).on("pagebeforeshow", "#pending", function () {

      var html = '';

      for (var count = 0; count < info.data.length; count++) {
          var schedule_time = new Date(info.data[count][3]).getTime();
          var current_time = new Dater().getTime();

            if (current_time < schedule_time) {

               html = html + "<tr><td>" + info.data[count][1] + "</td> <td>"+info.data[count][3] + "</td></tr>";
            }
        }

      $("table#pendingTable tbody").empty();
      $("table#pendingTable tbody").append(html).closest("table#pendingTable").table("refresh").trigger("create");
  });

    
asked by Nestor Bogantes rdz 10.04.2018 в 04:53
source

0 answers