I built a basic phone app using HTML5 and JavaScript (including JQTouch), and then used PhoneGap to turn it into an Android app (after many traumas - seems that PhoneGap and Windows computers don't get along too well).
The app works well in Chrome, but on an Android emulator the following error shows up in LogCat:
06-07 21:38:51.711: DEBUG/WebCore(204): Console: ReferenceError: Can't find variable: openDatabase line: 9 source: file:///android_asset/www/handicap.js
This refers to the following line in handicap.js:
db = openDatabase('Handicaps', '1.0', 'Handicaps', 65536);
The wider context of this piece of code is:
// initialise all important functions
$(document).ready(function(){
$('#newrace form').submit(saveRace);
$('#newrace form').submit(setTitle);
$('#enterhandicaps form').submit(savePrediction);
$('#enterhandicaps form').submit(refreshEntries);
$('#calcraces').click(raceList);
// create database to hold data on predicted and actual times
db = openDatabase('Handicaps', '1.0', 'Handicaps', 65536);
db.transaction(
function(transaction) {
transaction.executeSql(
'CREATE TABLE IF NOT EXISTS predictions (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,racename TEXT NOT NULL, runner TEXT NOT NULL, prediction INTEGER, start TEXT, finish TEXT, position TEXT);'
);
transaction.executeSql(
'CREATE TABLE IF NOT EXISTS races (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,racename TEXT NOT NULL, date TEXT, distance REAL);'
);
transaction.executeSql(
'CREATE TABLE IF NOT EXISTS autocompletion (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,runner TEXT NOT NULL, value TEXT,racename TEXT NOT NULL);'
);
}
);
}
);
On looking at other people having similar problems on stackoverflow, I've tried the suggestion of using only Android versions below 2.2 but that has not helped. Any other suggestions?
Could be something very obvious that I've missed, as I'm completely new to this.
The complete code for the app in web browser form is at https://github.com/fhr/Handicap-timer-app if that helps.
Can you share your app code in the app format with all the references to phonegap.js and so on ? Also I do not see your code using the window object. As per the phonegap apis the correct way to use the openDatabase() is var db = window.openDatabase(). Also, it would help if you could also mention the version of pg that you are using.
well i think its trying to open the file "file:///android_asset/www/handicap.js"
as opposed to where a db normally is //data/data//database/dbfile (normally no extension)
please post more code
i think its the opendatabase that your using.
Override onExceededDatabaseQuota method in your WebChromeClient Object.
#Override
public void onExceededDatabaseQuota(String url, String databaseIdentifier,
long currentQuota, long estimatedSize, long totalUsedQuota,
WebStorage.QuotaUpdater quotaUpdater) {
Log.d("test", "onExceededDatabaseQuota : " + " currentQuota=" + currentQuota
+ " estimatedSize=" + estimatedSize + " totalUsedQuota=" + totalUsedQuota);
quotaUpdater.updateQuota(estimatedSize * 2);
}
Related
I'm writing a simple Automator script in Javascript.
I want to send a key-code(or key-storke) to an OS X application that is not in front.
Basically, I want to run this code and do my things while the script opens a certain application, write text, and hit enter - all of this without bothering my other work.
I want something like this:
Application("System Events").processes['someApp'].windows[0].textFields[0].keyCode(76);
In Script Dictionary, there is keyCode method under Processes Suite.
The above code, however, throws an error that follows:
execution error: Error on line 16: Error: Named parameters must be passed as an object. (-2700)
I understand that the following code works fine, but it require the application to be running in front:
// KeyCode 76 => "Enter"
Application("System Events").keyCode(76);
UPDATE: I'm trying to search something on iTunes(Apple Music). Is this possible without bringing iTunes app upfront?
It's possible to write text in application that is not in front with the help of the GUI Scripting (accessibility), but :
You need to know what UI elements are in the window of your specific
application, and to know the attributes and properties of the
specific element.
You need to add your script in the System Preferences --> Security
& Privacy --> Accessibility.
Here's a sample script (tested on macOS Sierra) to write some text at the position of the cursor in the front document of the "TextEdit" application.
Application("System Events").processes['TextEdit'].windows[0].scrollAreas[0].textAreas[0].attributes["AXSelectedText"].value = "some text" + "\r" // r is the return KEY
Update
To send some key code to a background application, you can use the CGEventPostToPid() method of the Carbon framework.
Here's the script to search some text in iTunes (Works on my computer, macOS Sierra and iTunes Version 10.6.2).
ObjC.import('Carbon')
iPid = Application("System Events").processes['iTunes'].unixId()
searchField = Application("System Events").processes['iTunes'].windows[0].textFields[0]
searchField.buttons[0].actions['AXPress'].perform()
delay(0.1) // increase it, if no search
searchField.focused = true
delay(0.3) // increase it, if no search
searchField.value = "world" // the searching text
searchField.actions["AXConfirm"].perform()
delay(0.1) // increase it, if no search
// ** carbon methods to send the enter key to a background application ***
enterDown = $.CGEventCreateKeyboardEvent($(), 76, true);
enterUp = $.CGEventCreateKeyboardEvent($(), 76, false);
$.CGEventPostToPid(iPid, enterDown);
delay(0.1)
$.CGEventPostToPid(iPid, enterUp);
I am working on evernote javascript SDK [evernote#2.0.1-beta], things worked fine till I tried to make the following call ::
noteStore.getNoteWithResultSpec(guid, {includeContent:true, includeResourcesData: true})
The call to this function getNoteWithResultSpecfails when my notes on evernote contain binary data e.g. [img / pdf] etc. However if my notes only contain text data [ no img / pdf ] then this function works fine.
The console shows the following ::
evernote/node_modules/evernote/lib/thrift/transport/memBuffer.js:32
if (this.offset + len > this.buffer.length) throw Error('MemBuffer overrun');
^
Error: MemBuffer overrun
at Error (native)
at MemBuffer.read (/evernote/node_modules/evernote/lib/thrift/transport/memBuffer.js:32:55)
at BinaryProtocol.readBinary (/evernote/node_modules/evernote/lib/thrift/protocol/binaryProto
col.js:327:29)
at BinaryProtocol.readType (/evernote/node_modules/evernote/lib/thrift/protocol/binaryProtoco
l.js:355:25)
at Object.Thrift.Struct.readFields (/evernote/node_modules/evernote/lib/thrift/thrift.js:505:
49)
at Thrift.Struct.read (/evernote/node_modules/evernote/lib/thrift/thrift.js:485:19)
Not exactly the same issue but this looks similar. I would suggest that you create a new issue on Github so it'll be taken care of.
Please forgive my lack of knowledge!
I'm interested in creating a script/web application for my company and I've been diligently looking for the answer to my question.
Is it possible to detect iPhone or iPad models with useragent strings and then display a message to the effect of "You have an iPhone 5C"?...
If not, what are my other possible options?
I have seen quite a few posts about detecting if it were an iPad or and iPhone for browser formats.. and Also there is a SDK code that emulates the concept I'm trying to achieve.
I'm low on experience... but keen to learn!
The user-friendly name of the models are not available via API. Apps that I have been involved with that care use data compiled from several websites and build-up some kind of in-app list. You need both a list of models and their user-friendly name equivalents. Both are available via google searches. I don't know of a single, perfectly comprehensive, list, but a bit of searching will find several sites, whose data can be distilled into a single list.
To get the model number of the device to use as a key, the following code is used:
[UIDevice currentDevice].model
I assume you are trying to get the info from a visit to your website. You cannot know exact model of the device with web scripts, at least in my knowledge. But you can determine if the user is using an iPhone, iPad or iPod. Following are two options:
Javascript:
var Apple = {};
Apple.UA = navigator.userAgent;
Apple.Device = false;
Apple.Types = ["iPhone", "iPod", "iPad"];
for (var d = 0; d < Apple.Types.length; d++) {
var t = Apple.Types[d];
Apple[t] = !!Apple.UA.match(new RegExp(t, "i"));
Apple.Device = Apple.Device || Apple[t];
}
// is this an Apple device?
alert(
"Apple device? " + Apple.Device +
"niPhone? " + Apple.iPhone +
"niPod? " + Apple.iPod +
"niPad? " + Apple.iPad
);
PHP script:
// Apple detection array
$Apple = array();
$Apple['UA'] = $_SERVER['HTTP_USER_AGENT'];
$Apple['Device'] = false;
$Apple['Types'] = array('iPhone', 'iPod', 'iPad');
foreach ($Apple['Types'] as $d => $t) {
$Apple[$t] = (strpos($Apple['UA'], $t) !== false);
$Apple['Device'] |= $Apple[$t];
}
// is this an Apple device?
echo
"<p>Apple device? ", ($Apple['Device'] ? 'true' : 'false'),
"</p>n<p>iPhone? ", ($Apple['iPhone'] ? 'true' : 'false'),
"</p>n<p>iPod? ", ($Apple['iPod'] ? 'true' : 'false'),
"</p>n<p>iPad? ", ($Apple['iPad'] ? 'true' : 'false'),
'</p>';
For more information, read here.
Since your tags and statement is a bit confusing, just on the off-chance that If you are using iOS sdk and building an iOS app, you can simply get the model from one line like:
[[UIDevice currentDevice] platformString]
Our lab recently got an Agilent Bravo pipetting robot (it precisely dispenses tiny quantities of liquid for doing rapidly doing many biology or chemistry experiments). Apparently the glue language for extending the software that controls the robot is Javascript! I know, right?
Anyway, for the robot to be useful, we have to be able to retrieve information about the samples it's handling but every example I can find for sending queries in Javascript depends on PHP and usually the assumption that the script is running in a web-browser.
Is there some way to wrap a command-line mysql or is there already some library or utility that does this? The OS we're running is Windows 7.
Wow, thanks for the quick and useful answers.
In addition, I found a platform-specific answer: http://www.velocity11.com/techdocs/helpsystem/vworks_ug/usingjavascriptinvworks.html
Long story short, VWorks (control software for Agilent's equipment) has a run() global function that does exactly that. But, the above answers are probably more useful to this site than my own is, because they are relevant to a broader range of problems, so thanks again.
"sending queries in Javascript depends on PHP"
no it doesn't.
Just send retreive data(json) using ajax, I'd use http://api.jquery.com/jQuery.ajax/.
Yes, you can use ADO with Javascript on Windows to access various data sources. Search for "jscript ado" and you will get lots of information on this, e.g.:
// path to database
var DBpath="\\\\Server\\Path\\myDB.mdb"
// set up a few object constants
var adLockReadOnly=1
var adOpenForwardOnly=0
var adCmdText=1
// create and open a new connection (MSAccess)
var cnn=new ActiveXObject("ADODB.connection")
cnn.Provider = "Microsoft.Jet.OLEDB.4.0;Data Source=" + DBpath
try
{
cnn.open
}
catch(err)
{
// could not open connection
// view details in err.Description and err.Number
return 0
}
//open a read only recordset
var rs = new ActiveXObject("ADODB.Recordset")
try
{
rs.Open("Select * from myTable", cnn, adOpenForwardOnly, adLockReadOnly)
}
catch(err)
{
// could not open recordset
return 0
}
while(!rs.EOF)
{
// do something
rs.movenext
}
rs.close
Update:
According to info here, you can develop plugins using Visual Studio/C#. Maybe that is of some use? You could write a plugin to send the data somewhere...
I am new to gear, We are using gear in our web application were flow
is ...
When ever user assign with some task user will get message attached
with static html file, In that html we are showing work assign to user
in html form once user submit we are creating local database and
saving data to local database, But the problem is we are not
getting google.gears Object ...
function init() {
var success = false;
if (window.google && google.gears) {
try {
db = google.gears.factory.create('beta.database');
if (db) {
db.open('local');
db.execute('create table if not exists user (name varchar
(100), user_req_desc varchar(100), status varchar(100), timestamp
int)');
} catch (ex) {
setError('Could not create database: ' + ex.message);
}
}
if (!window.google || !google.gears) {
if(confirm("Gears is not installed. Do you want to install Gears
now ?")) {
location.href = "http://gears.google.com/?action=install";
}
}
google.gears object is coming null
gear is already installed in my system.
The above code is working in goole chrome, mean it's finding the google.gear object in chrome.
Any Help Appreciated ...
I am sorry the problem was I am not including gears_init.js, but than also it was working with google chrome ...
After including the gears_init.js file it's working fine ...