Phonegap (Android) - database changeVersion not functioning - javascript

If I take a database object (db) and open it with the command
var db = window.openDatabase("phr", "", "Cognovant PHR", 25000000);
// This should open whatever database is created, otherwise spawn one with a blank
// version number ("")
and then later do:
db.changeVersion(db.version, "2"); // Update database to version 2
console.log(db.version); //Should return "2", instead returns previous version of database
This code, line-for-line works flawlessly (almost better than I had hoped) on iOS, but constantly fails to change the database version on Android.
If there's some better way to do this, or some alternative way that needs done on Android, I would be greatly appreciative of the information.

This is actually pretty simple to solve.
Simply change the 2 argument version of db.changeVersion to the 3 argument version. Example:
db.changeVersion(db.version, "2", function () {console.log("foobar")});
And it will work.

This problem also occurs in Android 2.2.
09-28 07:15:14.954: E/Web Console(280): TYPE_MISMATCH_ERR: DOM Exception 17: The type of an object was incompatible with the expected type of the parameter associated to the object. at file:///android_asset/www/devbar/03%20db.js:158
The only solution I see is to workaround with my own version management.

Please go through below link, describes the way to implement the database Version control.
http://developer.apple.com/library/safari/#documentation/iphone/conceptual/safarijsdatabaseguide/UsingtheJavascriptDatabase/UsingtheJavascriptDatabase.html
i am able to do success operation with all 2.3.x devices, but with 4.x.x android device getting issue like 'unable to call method changeVersion' and saying method is undefined.
for time being i am using code as below,
if (db.changeVersion) {
db.changeVersion(oldVer, curVer, upgradeTableStructure, errorHandler, successDataHandler);
} else {
createTableStructure(db);//If Not exist for first time for 4.x.y devices
console.log('version changes not possible in this browser version.');
}
but this is not the right solution for the Current Problem, please suggest some solution.

Related

jQuery addClass does not work on Chrome running on Andriod

I have seen this question which is similar except it does not specify the browser and OS. I have also seen this question which describes the same issue for Chrome running on iPhone (I have tried the accepted answer, which suggests using JavaScript instead of jQuery, and it made no difference).
What I want to do is to show/hide pagination buttons depending on the number of documents in the search result. This is the code:
function showHidePagination(totalNoOfDocuments) {
var paginationContainer = document.getElementById('paginationContainer');
if (totalNoOfDocuments <= pageSize) {
paginationContainer.classList.add('d-none');
//$('#paginationContainer').addClass('d-none'); // <-- this did not work either
} else {
paginationContainer.classList.remove('d-none');
//$('#paginationContainer').removeClass('d-none'); // <-- this did not work either
}
}
When user clicks on Search button, an Ajax request is send to the server, the new results are fetched and then I call showHidePagination() and pass the total number of documents in the result. The function should hide the pagination if the total number of documents are less than pageSize (which is a constant variable).
The above code works in desktop and it does not work on Chrome running on Android. I have also seen this document which suggests removeClass works but addClass does not work... it suggests solving issue by negating the logic and using removeClass but I cannot see how to toggle d-none class this way...
I am not able to understand why is this issue happening? And how should I resolve this?

Javascript click or tts

i'm trying to make a web aplication than can read text automatically,i have this code:
function hablalo()
{
var palabra = new SpeechSynthesisUtterance('Casilla 6 turno E18');
palabra.lang = "es"
speechSynthesis.speak(palabra);
}
$('#perez').trigger($.Event( "click", { originalEvent: true } ));
and so i have a button with the event that call hablalo.
The problem is that when i try to make this, the result is:
(index):20 [Deprecation] speechSynthesis.speak() without user activation is no longer allowed since M71, around December 2018. See https://www.chromestatus.com/feature/5687444770914304 for more details
I would like a way to simulate a click in chrome or another way to make tts, thanks you. :)
--EDITED
If you know a library that i can use for autoplay tts at load of a webpage, is fine
So i solved my problem with this, summary i modify the laucher-flags of chrome in the client's pc adding --autoplay-policy=no-user-gesture-required at the end of route in propertiesof the launcher.
It seems like is imposible to make from code, but this solution is a resignation way.

Receive EntryChangedEvent on folder

Currently i'm experementing with the the chrome.fileSystem-Api and i was curious about the new EntryChangedEvent that was added in Version 38. But im writing because i do not really know how to receive this event in my app. I tried it like this, what obviously didn't worked :
chrome.fileSystem.chooseEntry({type: 'openDirectory'}, function(folder) {
if (!folder) {
output.textContent = 'No Folder selected.';
return;
}
folder.on("entrychangedevent",function(v){
console.log(v);
});
});
How do i have to change my code so that i really can use receive EntryChangedEvents?
Thanks!
Link to documentation:
https://developer.chrome.com/apps/fileSystem#type-EntryChangedEvent
I actually think that this feature is not implemented yet. I don't know why it is in the documentation, but if you look at the chromium source there is a function called chrome.fileSystem.observeDirectory (which has a callback that should get these events) but when looking at the implementation it just says:
bool FileSystemObserveDirectoryFunction::RunSync() {
NOTIMPLEMENTED();
error_ = kUnknownIdError;
return false;
}
I found this document which is a request for the API:
https://docs.google.com/document/d/1aW-37JOBZgoD2CIPvoBEgw6bog8gFSowpfqtDEKt5Vo/edit#heading=h.w8inspeo32bj
Anyways, great feature and will probably be available soon.
Three issues here:
It's not clear from the documentation what object this listener should be attached to. In your example, you have attached it to the DirectoryEntry representing a directory. While I don't know the answer, that sounds like it's probably wrong, as a DirectoryEntry is only a means for accessing a directory, and is not itself a directory.
The documentation says that this event is fired for only certain filesystems, and I guess neither of us knows whether it is even effective for whatever file systems we're testing with.
In your example, even if the code were right and the event were enabled, you don't have any changes to the directory, so the event wouldn't fire.

Specify a custom key in Chrome Extension manifest?

I've got a chrome extension that I update frequently, and so I wrote an update notification popup for it. It displays when the manifest.version changes so that the user doesn't miss that there was an update with new options that they'd need to enable/disable. Then I realized that for minor big fixes and the like, it doesn't make sense to bug the user. Because I have to update the manifest version everytime I update the script, I thought it would be nice to just have an 'new_options' : true field in the manifest that my script could key off of. Unfortunately when I tried it I get this:
Is there some way to add your own custom key/value entries in the chrome manifest?
I checked the documentation and it doesn't appear that there are any "free JSON" enabled keys, but I thought I'd ask before completely giving up on the idea. I could easily put a global flag in the script itself, but I know me, and I'm liable to forget to change it every update.
Although the "Unrecognised manifest key 'new_options'" warning can safely be ignored, I recommend to not abuse this method for toggling features. An extension cannot change its manifest file, so having a hypothetical "new_options": true field would not be very useful.
A better way to manage notifications for updates is to consistently stick to the following convention and use chrome.runtime.onInstalled:
Use the <major>.<minor> version numbering.
For minor changes, increase <minor>.
For major changes requiring (popup/changelog) notifications, increase <major>.
For example:
chrome.runtime.onInstalled.addListener(function(details) {
if (details.reason == 'install') {
// First-run code here.
// TODO: Thank the user for installing the extension
} else if (details.reason == 'update') {
// Check for update
var versionPartsOld = details.previousVersion.split('.');
var versionPartsNew = chrome.runtime.getManifest().version.split('.');
if (versionPartsOld[0] != versionPartsNew[0]) {
// Major version change!
// TODO: Show changelog for update?
}
}
});

Have you had problems with Dojo 1.7.1 in Internet Explorer 7/8?

I have been working on upgrading an application from dojo 1.4.3 to 1.7.1. Everything is working great in Firefox/Chrome/Safari, but IE7 and IE8 are both failing. The first failure appears to be coming from the code in dojo/ready around line 40.
try{
f();
}
// FIXME: signal the error via require.on
finally{
onLoadRecursiveGuard = 0;
}
Has anyone else noticed problems with this? Is there a work around? Dojo claims it should work in IE 6 - 9, but I have seen other comments that suggest the try/finally will break in IE without the catch. Is this true? Thanks for any insight into this problem ahead of time!
I had this problem and it was because safeMixin was called throughout my code without checking the arguments passed in. safeMixin is 'supposed' to have a valid object passed in as an argument.
This can happen up if you 'new' an object with an empty constructor and then pass the args directly into safeMixin. There are other cases as well.
Here is a bug report.
I had same problem when using JsonRest:
var jr = new JsonRest(); // cause exception
var jr = new JsonRest({}); // it works

Categories