Creating a QrCode creator and decoder webapp - Web App Development

Hey guys, so I'm creating this webapp that creates a QrCode based on informations given by the user, decodes QrCodes and creates a log.
I would like some tips, like QrCodes, Image processing, Getting SubImages libraries and API's.
I'm using HTML5, CSS3 and JavaScript. This webapp will be able to Android, Firefox OS, Tizen OS, Windows Phone and iOS devices.
Thanks bros

devcorominas said:
Hey guys, so I'm creating this webapp that creates a QrCode based on informations given by the user, decodes QrCodes and creates a log.
I would like some tips, like QrCodes, Image processing, Getting SubImages libraries and API's.
I'm using HTML5, CSS3 and JavaScript. This webapp will be able to Android, Firefox OS, Tizen OS, Windows Phone and iOS devices.
Thanks bros
Click to expand...
Click to collapse
I suspect you may already be using this, but if not then have a look at using Cordova (or PhoneGap - same thing, at the moment)....
http://cordova.apache.org/
There's a barcode scanner available that is a doddle to use...
https://github.com/wildabeast/BarcodeScanner
Here's a basic page I threw together with just a button that scans all common types of barcode and alerts the result...
Code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<title>Barcode Scanner</title>
</head>
<body>
<h1>Barcode Scanner Demo</h1>
<p>Hit the button below to scan a barcode!</p>
<button id="scan">Scan Barcode</button>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript">
document.getElementById("scan").addEventListener("touchstart", function() {
cordova.plugins.barcodeScanner.scan(
function (result) {
alert("We got a barcode\n" +
"Result: " + result.text + "\n" +
"Format: " + result.format + "\n" +
"Cancelled: " + result.cancelled);
},
function (error) {
alert("Scanning failed: " + error);
});
});
</script>
</body>
</html>
Attached is a copy of the apk.
Seriously, that plugin is stupidly easy to use
As for creating QR codes, I can't help you with that. I've only ever used online generators when I've done it. Maybe one (or some) of them have a public API you could use?

Related

downloading bar color from stock orange to lite blue, any idea?

What do I need to do to change the downloading bar color from stock orange to lite blue?
thanks
Sent from my Mytouch3g cm6rc2 using XDA App
framework-res.apk
progress_horizontal.xml
thanks, im use to switching drawables .png using ninjamorph. now that i found horizontal progress.xml, how do i change the color? do i have to look for the xml file online? or do u have some that u can upload?
thanks
Sent from my HTC Magic using XDA App
Don't quote me on this, but I believe there's just a numerical value to change in the XML file. I haven't looked myself, but it shouldn't be too hard to find. Open it up in Notepad and take a look around.
...or I could be very wrong if so, sorry
this is the contents of progress_horizontal.xml
If you try to open the xml file from the rom it may not come up.
Grab the one from source and it will display something like this:
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2008 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<corners android:radius="5dip" />
<gradient
android:startColor="#ff9d9e9d"
android:centerColor="#ff5a5d5a"
android:centerY="0.75"
android:endColor="#ff747674"
android:angle="270"
/>
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<corners android:radius="5dip" />
<gradient
android:startColor="#80ffd300"
android:centerColor="#80ffb600"
android:centerY="0.75"
android:endColor="#a0ffcb00"
android:angle="270"
/>
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="5dip" />
<gradient
android:startColor="#ffffd300"
android:centerColor="#ffffb600"
android:centerY="0.75"
android:endColor="#ffffcb00"
android:angle="270"
/>
</shape>
</clip>
</item>
</layer-list>
Click to expand...
Click to collapse
Once you have made your adjustments then rebuild the rom from source and it should work just fine.
You can use this online tool (amongst the dozens of others) to find your appropriate color.
http://www.2createawebsite.com/build/hex-colors.html
thanks, i will keep these informations for future reference. as for now, i will hold back on this project, thanks again. guess we can close this thread
Sent from my HTC Magic using XDA App
kompheak said:
thanks, i will keep these informations for future reference. as for now, i will hold back on this project, thanks again. guess we can close this thread
Sent from my HTC Magic using XDA App
Click to expand...
Click to collapse
okie dokie

[Q] How to delete/add an item from a ListBox?

Hi there,
I have a ListBox bounded to a query (linq to xml)
Dim CASDAs XDocument = XDocument.Load("./Data/CASD.xml")
Dim CAS_Query As System.Collections.IEnumerable = From query In Cartridge_Doc.Descendants("Cartridges") Order By _
CStr(query.Element("AA")) Descending, CStr(query.Element("AA"))
Select New Cartridge_Data With {.AA1 = CStr(query.Element("AA")), _
.BB1= CStr(query.Element("BB")), _
.CC1 = CStr(query.Element("CC"))}
Me.ListBox_1.ItemsSource = CAS_Query
Now, what I need to do is to select an item and have the option to delete it.
So far, I always got a run-time exception when trying this
Me.ListBox_1.Items.Remove(Me.ListBox_1.SelectedItem)
System.InvalidOperationException was unhandled
Message=Operation not supported on read-only collection.
So far I have tried a lot of options without any luck.
Any help will be greatly appreciated!
Thanks in advance.
Stick your Linq result in an ObservableCollection, bind this to the Listbox and delete the item directly from the underlaying collection.
emigrating said:
Stick your Linq result in an ObservableCollection, bind this to the Listbox and delete the item directly from the underlaying collection.
Click to expand...
Click to collapse
Please, can you poost a little code to do that? I'm fairly new to this collections world.
On the other hand, once the item got deleted, how the Listbox gets refreshed?
Thanks!
You have to set up an NotifyPropertyChanged class to keep the listbox updated with your collection. The default phone list application template that comes with Visual Studio shows you how to do this. I think its's in c# though and it looks like you're coding in VB. I'm sure there's examples in VB you can find on the web with a little searching.
Ren13B said:
You have to set up an NotifyPropertyChanged class to keep the listbox updated with your collection. The default phone list application template that comes with Visual Studio shows you how to do this. I think its's in c# though and it looks like you're coding in VB. I'm sure there's examples in VB you can find on the web with a little searching.
Click to expand...
Click to collapse
My ListBox takes its data from an XML file via query.
Which strategy do you think is the best?
To first delete the Xelement then refresh the ListBox?
Or deleting from the item from the ListBox, then update the XML file?
Sorry but I have all the samples from MS and didn't find any phone list one.
Any code will be greatly appreciated!
Oops. It's called "Windows Phone Databound Application". Attached is a screenshot of the project if it makes it easier for you to find it.
It's hard to post code because I don't know what your xaml looks like and bindings have to be set there for it to work. The best thing you can do is load the above project and play around with it.
You never have to refresh the items in the listbox. A bound listbox updates itself when an item in the collection changes. Change the collection and your listbox will reflect those changes. The NotifyPropertyChanged class is what triggers the listbox to update itself.
I do C#, not VB but the following should give you some idea.
Code:
public class Model : INotifyPropertyChanged
{
public string Title { get; set; }
public string Blurb { get; set; }
public event PropertyChangedEventHandler PropChanged;
public void NotifyPropertyChanged(String _propName)
{
if (null!=PropChanged)
{ PropChanged(this, new PropertyChangedEventArgs(_propName)); }
}
}
The above is your model, create any properties you need there - i.e. one per item of data in your XML file.
Next, you need to create an ObservableCollection somewhere, for the sake of simplicity let's stick it in your MainPage.xaml.cs file for now, so;
Code:
public partial class MainPage : PhoneApplicationPage
{
public ObservableCollection<Model> Items { get; set; }
public MainPage()
{
InitializeComponent();
this.Items = new ObservableCollection<Model>();
MyListBox.ItemsSource = this.Items;
WebClient wc = new WebClient();
wc.OpenReadCompleted += wc_OpenReadCompleted;
wc.OpenReadAsync(new Uri("http://your.server.here/datafile.xml");
}
public void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
using (Stream s = e.Result)
{
XDocument xd = Xdocument.Load(s);
var XMLdata = (from q in doc.Descendants("Item") select new Model()
{
Title = (string)q.Element("Title"),
Blurb = (string)q.Element("Blurb")
}
foreach (Model m in XMLdata)
{
this.Items.Add(m);
}
}
}
public MyListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ListBox lb = (ListBox)sender;
if (lb.SelectedIndex == -1)
return;
this.Items.Remove(lb.SelectedItem)
}
}
This will create a collection named Items as well as tell your ListBox (named MyListBox) to get it's data from said collection. Then it will read (asynchroniously) the XML file from the web and copy each item of data into your collection.
When you select an item in your ListBox it will be deleted from the ObservableCollection which in turn will remove it from the view (ListBox). At this stage you want to include code to also remove this from your actual XML file and so on of course. But the idea is that you work on your Collection only and your View will update based on what is changed - automagically.
Please note, the above code may or may not work out of the box. Written directly here on the forums so it hasn't gone thru VS2010's excellent IntelliSense. Also, the above code is in no way the most efficient way of doing certain things, but it gives you an idea as to what code you need to write to handle your scenario.
While I wrote this I see you've got an answer above which directs you to the VS template - use that and everything should become clear. All you have to remember is that perform operations on the Collection - not directly on the ListBox and you'll be fine.
Emigrating and Ren13B,
Thanks to both of you for the help. Very appreciated!
Will take both advices to see what comes up.
Thanks!

[Q] Dynamic UI Creation XAML, C#

this is my first post. I am pretty desperate at the moment.
I would like to dynamically create the UI for the WP7 based on a CSV file in Isolated Storage. right now I would settle for just being able to write the UI in XAML from the code behind in C#.
steps that I would like to execute:
1. user clicks a muscle group button which passes a value to another page-done
2. users data is pulled from CSV file and placed in array for easy storage-done
3. for each data element create a XAML TextBlock with the data which is displayed in the UI <-- need some serious help
best I can do is show the XAML code with the <> tags as a string in the UI.
is what I am asking possible?
Thanks for helping.
Knudmt said:
this is my first post. I am pretty desperate at the moment.
I would like to dynamically create the UI for the WP7 based on a CSV file in Isolated Storage. right now I would settle for just being able to write the UI in XAML from the code behind in C#.
steps that I would like to execute:
1. user clicks a muscle group button which passes a value to another page-done
2. users data is pulled from CSV file and placed in array for easy storage-done
3. for each data element create a XAML TextBlock with the data which is displayed in the UI <-- need some serious help
best I can do is show the XAML code with the <> tags as a string in the UI.
is what I am asking possible?
Thanks for helping.
Click to expand...
Click to collapse
Sounds like what you really want to do is dynamically create controls in the code-behind. I would forget about generating "XAML".
Code:
private void AddTextboxesFromCSV(string[] CSVData) {
foreach(string str in CSVData) {
TextBlock tb = new TextBlock();
tb.Name = "txtUserSelectedValue" + CSVData.IndexOf(str);
tb.Text = str;
<YourObject>.Controls.Add(tb);
}
}
Where <YourObject> is the object you want to place the controls into, some sort of layout Panel.
Thanks for the response
I think that is the direction I will be going. Just out of curiosity do you know if what I wanted to do is even possible?
UN app for WP7 does something like this. Go to http://unitednations.codeplex.com/releases/view/57722 and grab the source. Open the source in Visual Studio and browse to the "Framework" folder and open up "BasePage.cs". At the bottom there's a method called AddNavigatingText() that does what I think you are looking to do.
Here's the method:
Code:
protected Grid AddNavigatingText()
{
var NavigatingText = (Grid) XamlReader.Load(
@" <Grid xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" Height=""30"" VerticalAlignment=""Top"" Background=""#CCFFFFFF"">
<TextBlock HorizontalAlignment=""Left"" TextWrapping=""Wrap"" Text=""Navigating..."" Width=""129"" FontSize=""{StaticResource PhoneFontSizeNormal}"" Margin=""24,0,0,0"" FontFamily=""{StaticResource PhoneFontFamilySemiBold}""/>
<ProgressBar Style=""{StaticResource PerformanceProgressBar}"" RenderTransformOrigin=""0.5,0.5"" Margin=""135,0,0,0"" UseLayoutRounding=""False"" Background=""White"" IsIndeterminate=""True"" LargeChange=""0"" />
</Grid>");
this.Content.As<Grid>().Children.Add(NavigatingText);
return NavigatingText;
}
Thanks for the reply. Looks pretty simple. I downloaded the source and signed up for codeplex. However I can not connect to the tfs.codeplex.com
It's not possible to use dynamically created XAML; code is the way to go and much easier IMHO.
When you open the project just hit cancel at the login screen and it will load.
sulphuricaciduk said:
It's not possible to use dynamically created XAML; code is the way to go and much easier IMHO.
Click to expand...
Click to collapse
Agreed, doing it via code with a very basic XAML based page is likely to be faster, and will actually work. It's also a lot easier to fix things than trying to work out what went wrong in XAML you can't see...
I would agree with the statement that creating the controls dynamically would be faster. And def a great deal easier to read It just bugs me when I know this can be accomplished, yet I cant get it to work
Blade0rz said:
Sounds like what you really want to do is dynamically create controls in the code-behind. I would forget about generating "XAML".
Code:
private void AddTextboxesFromCSV(string[] CSVData) {
foreach(string str in CSVData) {
TextBlock tb = new TextBlock();
tb.Name = "txtUserSelectedValue" + CSVData.IndexOf(str);
tb.Text = str;
<YourObject>.Controls.Add(tb);
}
}
Where <YourObject> is the object you want to place the controls into, some sort of layout Panel.
Click to expand...
Click to collapse
Well that worked very well, thanks! I am having a little formatting issue .. my textblocks show up right on top of each other. any ideas?
Thanks again
Knudmt said:
Well that worked very well, thanks! I am having a little formatting issue .. my textblocks show up right on top of each other. any ideas?
Thanks again
Click to expand...
Click to collapse
I solved this silly issue. just added a listbox control to the xaml front end and added my elements with an ugly cast
listbox1.items.add((TextBlock)myBlock);
Knudmt said:
I solved this silly issue. just added a listbox control to the xaml front end and added my elements with an ugly cast
listbox1.items.add((TextBlock)myBlock);
Click to expand...
Click to collapse
If you had a StackPanel as the parent control, you could have each new textblock stacked...

NookReader - Associate ePub files with the stock reader

I just got a NST and it looks like the app that I made way back for the Nook Color to load epubs with the stock reader app also works with the NST. Basically, this is an app that registers as an ePub receiver and forwards along the ePub activity to the B&N stock app.
It's very simple, attached is the apk and below is the code:
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="dev.nookreader">
<application android:label="@string/app_name">
<activity android:name=".NookReaderActivity"
android:label="@string/app_name" android:configChanges="keyboardHidden|orientation"
android:theme="@android:style/Theme.NoTitleBar"
android:launchMode="singleTask"
android:screenOrientation="sensor">
<meta-data android:name="noPickRestrictions" android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:host="" android:scheme="file" />
<data android:pathPattern=".*\\.epub"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:host="" android:scheme="file" />
<data android:mimeType="application/epub+zip"/>
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="3" />
</manifest>
Code:
package dev.nookreader;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.ComponentName;
public class NookReaderActivity
extends Activity
{
private Intent m_lastIntent = null;
@Override
protected void onStart()
{
super.onStart();
try
{
Intent i = getIntent();
if (m_lastIntent == i)
{
return;
}
m_lastIntent = i;
Intent newIntent = new Intent(i);
newIntent.setComponent(new ComponentName("com.bn.nook.reader.activities", "com.bn.nook.reader.activities.ReaderActivity"));
startActivity(newIntent);
}
catch(Exception e)
{
e.printStackTrace();
}
finish();
}
}
Code:
package dev.nookreader;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.ComponentName;
public class NookReaderReceiver
extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
try
{
Intent newIntent = new Intent(intent);
newIntent.setComponent(new ComponentName("com.bn.nook.reader.activities", "ReaderActivity"));
context.startActivity(newIntent);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
do you mind if I include your code in my Home replacement?
thread here
class file here
I thought that the stock reader is able to open e pubs?
What does this reader allow you to do?
Sent from my SAMSUNG-SGH-I777 using XDA App
aspellclark said:
do you mind if I include your code in my Home replacement?
Click to expand...
Click to collapse
Go ahead.
switters1 said:
I thought that the stock reader is able to open e pubs?
What does this reader allow you to do?
Click to expand...
Click to collapse
Despite the terrible name, this isn't a reader app. It just registers to receive epub intents and will redirect them in such a way so the stock reader opens the epub. This basically allows you to use a file explorer and click on an epub and have it open with the stock reader. If you try it without my app the stock reader won't open it.
JoshMiers said:
Despite the terrible name, this isn't a reader app.
Click to expand...
Click to collapse
Josh,
Looking for your advice here
I do remember you were working on Almost working: Stock 2.1 Nook Color Reader and Library, figured, you are the right guy to ask!
Thanks for posting this app. It was exactly what I was looking for.
But I noticed a limitation.
The "Last Book" button in the status bar takes me back to the last book which was opened through the Library, and ignores books opened through your app.
Please let me know if anyone has a workaround. Thanks!
once again, terrific work!
JoshMiers said:
I just got a NST and it looks like the app that I made way back for the Nook Color to load epubs with the stock reader app also works with the NST. Basically, this is an app that registers as an ePub receiver and forwards along the ePub activity to the B&N stock app.
...
Click to expand...
Click to collapse
This seems to be the solution to a problem I have on my Nook Tablet running CM7 ROM (off an SD card), which is not being able to use the stock B&N eReader to open epubs that are side-loaded. (However, I have not had this problem with my rooted NST).
Does this app make the B&N stock eReader the sole eReader (i.e., exclusive of other ereaders one might wish to try out) for epubs?
Exactly what I was looking for. Works very well, thanks a lot!
The stock reader already has entries in its AndroidManifest.xml for the mimetype epub.
Android does not really natively have a translator from file extension to mimetype.
Some file managers (like the Open Intents one) use their own internally.
That's why I have never seen this problem, for me, I click on an epub and it opens.
Yes, that application with a file filter can catch intents and relay them on to the stock reader.
Still, if I found that at all necessary, I'd rather just edit the stock reader's manifest for those intents.
Is there also a way to put a link to the default reader app onto the homescreen?
It does not show up in the application list when trying to create a shortcut.
rhhd said:
Is there also a way to put a link to the default reader app onto the homescreen?
It does not show up in the application list when trying to create a shortcut.
Click to expand...
Click to collapse
That's because the Reader has no android.intent.category.LAUNCHER in an intent filter.
Have you noticed that the Reader has no "Open File" option?
If you were to launch the Reader with no context, it would not display anything.
If you want last read book, it's already available on the upper left hand corner.
If you want Library, it's there in the app drawer already.
Renate NST said:
Have you noticed that the Reader has no "Open File" option?
If you were to launch the Reader with no context, it would not display anything.
Click to expand...
Click to collapse
Hmm interestingly that happens sometimes when I open an epub from my file manager (using the tool offered by the OP in this thread).
Renate NST said:
If you want last read book, it's already available on the upper left hand corner.
Click to expand...
Click to collapse
Yes, I do want the last book. (Well, really all I want would be a homescreen link that simply switches to the already running app.) But on the homescreen I have hidden the title bar, so I always have to swipe it down to click that.
Well, no big deal obviously.
hi OP
any chances of making similar apk for pdf's to be loaded with the stock NST reader?
This is not working for me. Running Nexus 7 Jellybean. Is there any reason it shouldn't?

[Q] PhoneGap and Ajax with database?

Hi all,
I recently finished learning how to create an APK using PhoneGap with code written using HTML5, CSS3 and Javascript.
Now, I would like to create a simple database app but I am not sure how to proceed. From what I learned about PhoneGap, everything can only be written in HTML5, CSS and Javascript coding. How do I get information from a database(flat-file or MySQL), display the data and edit it similar to how one would do using Ajax(I currently don't know how to code in ajax)? Is this possible with PhoneGap? How? Do I need a framework like JQuery Mobile to do this?
There would only be one page/view:
- displaying what is in the table
- and editing/adding new data to the table
Thank you.
using frameworks such as jquery mobile is a better option. u can use ajax calls to server to populate data. create a server side code that responds to ajax calls from app and fetch data from my sql and sends back the data either as json or xml
Falen said:
Hi all,
I recently finished learning how to create an APK using PhoneGap with code written using HTML5, CSS3 and Javascript.
Now, I would like to create a simple database app but I am not sure how to proceed. From what I learned about PhoneGap, everything can only be written in HTML5, CSS and Javascript coding. How do I get information from a database(flat-file or MySQL), display the data and edit it similar to how one would do using Ajax(I currently don't know how to code in ajax)? Is this possible with PhoneGap? How? Do I need a framework like JQuery Mobile to do this?
There would only be one page/view:
- displaying what is in the table
- and editing/adding new data to the table
Thank you.
Click to expand...
Click to collapse
If you just want your app to have a local database then HTML5 already does that for you. I've used this library in the past and had no problems with it at all...
http://html5sql.com/
I wrote an app that imported a CSV file into a database. It was a very basic app, written as proof of concept for a bigger project when I first started developing web apps for mobile. Here's a basic version of importing a CSV and using html5sql to create a table with it...
Code:
function createDatabase() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
}
function gotFS(fileSystem) {
fileSystem.root.getFile("/sdcard/external_sd/temp/PRODUCTS.CSV", null, gotFileEntry, fail);
}
function gotFileEntry(fileEntry) {
fileEntry.file(gotFile, fail);
}
function gotFile(file){
readAsText(file);
}
function readAsText(file) {
var reader = new FileReader();
reader.onloadend = function(evt) {
var csv = evt.target.result;
var lines = csv.split("\n");
var i = 1;
html5sql.openDatabase("com.archer.testapp.db", "Test DB", _dbSize);
html5sql.process("DROP TABLE IF EXISTS products; " +
"CREATE TABLE IF NOT EXISTS products (linecode int, description varchar(255), barcode varchar(25), price int, stock int); ", function() {
function addRow() {
var line = lines[i].split(",");
var sql = "INSERT INTO products (linecode, description, barcode, price, stock) values (" +
line[0] + ", " +
"'" + line[2] + "', " +
"'" + line[1] + "', " +
line[6] + "," +
line[13] + ")";
html5sql.process(sql);
var pd = i / lines.length * 100;
$(".progress-bar").css("width", pd + "%");
i++;
if (i < lines.length) {
setTimeout(addRow, 2);
}
}
addRow();
}, function(error, failingQuery) {
alert("Error : " + error.message + "\r\n" + failingQuery);
});
};
reader.readAsText(file);
}
There's obviously stuff in there that won't be relevant and you'll need to change. Also I had a global variable, _dbSize, that was the initial size (in bytes) of the database, and there's some stuff in there about a progress bar. Use it or delete it - it won't affect the database being created.
Also, note the use of the addRow() function that calls itself. This was to enable the function to run asynchronously, which is needed if you want to be UI friendly (nothing will update whilst doing the import if you just import everything in one go).
However, since you mention AJAX then that may not be relevant. In which case you're just looking at API calls for whatever service is holding your database.
Hi friend ! If you're new to hybrid development, I highly recommend you to take a look at Ionic. It would help you on so many levels ! http://ionicframework.com/
About your issue, you can always define a REST API using your favorite backend (I know it can be done very easily with Laravel framework in PHP using MySQL DB). I prefer using Firebase ! https://www.firebase.com/
Firebase and Ionic framework based on AngularJS are such perfect match that half your code is already done before you knows it.
Happy coding !

Categories

Resources