Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Case analise
index.js

var db = null;
var db2 = null;
var db3 = null;
var dbUser = null;
var dbName = "estudos.db";

var app = {
// Application Constructor
initialize: function() {
document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
},

// deviceready Event Handler
//
// Bind any cordova events here. Common events are:
// 'pause', 'resume', etc.
onDeviceReady: function() {
    this.receivedEvent('deviceready');
},

// Update DOM on a Received Event
receivedEvent: function(id) {
    var parentElement = document.getElementById(id);
_**// Line 43--->> var listeningElement = parentElement.querySelector('.listening');**_
    var receivedElement = parentElement.querySelector('.received');

    listeningElement.setAttribute('style', 'display:none;');
    receivedElement.setAttribute('style', 'display:block;');


    // OPERACOES BD - inicio

    //banco de dados local - aceite de termos e outras coisas
    dbUser = window.sqlitePlugin.openDatabase({name: 'user.db', location: 'default'});
    dbUser.transaction(function(tx) {
        tx.executeSql('CREATE TABLE IF NOT EXISTS Users (flg_aceite, flg_valid_bd)');
    }, function(error) {
        alert('Transaction ERROR: ' + error.message);
    }, function() {
        console.log('Database OK');
    });

    //copia do banco de dados de estudos
    window.plugins.sqlDB.copy(dbName, 0, copysuccess, copyerror);
    // OPERACOES BD - fim
}
};

app.initialize();

//---------------------------------------------------------------

function copysuccess()
{
//primeira versão deste banco de dados. o comando anterior.
//provavelmente realizou a cópia, abro o BD.
db = window.sqlitePlugin.openDatabase({name: dbName});
//preciso verificar se existem versões anteriores deste BD. Deleto por precaucao
dropTable();
fts_table();
}

function copyerror(e)
{
//esta versao do banco de dados ja existe.
//abro o BD
db = window.sqlitePlugin.openDatabase({name: dbName});
//db3 = window.sqlitePlugin.openDatabase({name: "vtestudos"});
//alert("copyerror" + JSON.stringify(e));
}

//---------------------------------------------------------------

function fts_table(){
db.transaction(function(tx) {
tx.executeSql('CREATE VIRTUAL TABLE vtestudos USING FTS3(titulo, texto, id_titulo)', [], function(tx,res){
//alert("nao deu erro");
//db = window.sqlitePlugin.openDatabase({name: "vtestudos"});
//alert("opened");

      db.transaction(function(tx) {
      tx.executeSql('INSERT INTO vtestudos(titulo, texto, id_titulo) SELECT titulo, texto, id_titulo FROM estudos', [], function(tx,res){
          //db3 = window.sqlitePlugin.openDatabase({name: "vtestudos"});
           console.log('insert ok');
      });
      }, function(err){
          alert(err.message);
      });

});
}, function(err){
    alert(err.message);
});


What I have tried:

I have tried to modify my database, altering my cordova.js and even my index.js replacing the index to call my otherPAGE.js
Posted
Updated 12-Apr-17 9:57am
v4
Comments
CHill60 12-Apr-17 13:05pm    
Word of advice: Get rid of the link and post the code that is giving the problem and state the error in your question. Your post ended up in the spam moderation queue (because of the link) and I nearly reported it as spam because it looked like site driving.
MarkNopfler 12-Apr-17 13:09pm    
Thanks for advice. I see. I will update question!
ZurdoDev 12-Apr-17 14:46pm    
I do not understand what you are asking.
MarkNopfler 12-Apr-17 14:53pm    
What didn´t you understand from my question?
MarkNopfler 12-Apr-17 15:39pm    
What didn´t you understand? I don´t have so time that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900