I know this question has been asked many times, but I tried to find a solution, but did not get SO from the available questions.
I am very new to Javascript. I am trying to create an application for calculating examples in android using cordova. For this, I created the cordova plugin. But I constantly get two questions.
"Uncaught SyntaxError: Unexpected identifier", source: file:///android_asset/www/js/index.js (36)
here is the index.java code and targetCalculation () target.
var app = {
initialize: function() {
this.bindEvents();
},
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
document.getElementById("btnCalculate").addEventListener("click", performCalculation);
},
onDeviceReady: function() {
app.receivedEvent('deviceready');
},
receivedEvent: function(id) {
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
console.log('Received Event: ' + id);
}
performCalculation: function (){
console.log("in index.html");
var success = function() {
alert("Success");
};
var error = function(message) {
alert("Oopsie! " + message);
};
performAddition(20,10,success,error);
}
};
app.initialize();
Here is my second exception that I get.
"Uncaught SyntaxError: Unexpected token .", source: file:///android_asset/www/js/calculation.js (3)
and here is the .js calculation code
var calculationPlugin = {
console.log("calculation");
performAddition: function(first_number, second_number, successCallback, errorCallback) {
console.log("addition");
cordova.exec(
successCallback,
errorCallback,
'CalculationPlugin',
'addition',
[{
"firstNumber": first_number,
"secondNumber": second_number,
}]
);
}
}