Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Localstorage

Localstorage databse.
  • Loading branch information...
commit f9f133165d52372176745c496fe0d23a2ab14b48 1 parent 30f7422
Lukasz Dzierzak ddluk authored
2  .gitignore
View
@@ -0,0 +1,2 @@
+
+.DS_Store
BIN  BIN/Localstorage/device/SampleDatabaseApp.bar
View
Binary file not shown
BIN  BIN/Localstorage/simulator/SampleDatabaseApp.bar
View
Binary file not shown
18 Localstorage/config.xml
View
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<widget xmlns="http://www.w3.org/ns/widgets"
+ xmlns:rim="http://www.blackberry.com/ns/widgets"
+ version="1.0.0.0" id="sampleDatabaseApp">
+
+ <author href="http://www.bbjam.pl/" rim:copyright="Copyright 2012 BB Jam Polska">BB Jam Polska</author>
+
+ <name>Database application.</name>
+
+ <description>
+ A sample application to demonstrate some of the local.storage database possibilities.
+ </description>
+
+ <icon src="icon.png"/>
+
+ <content src="index.html" />
+
+</widget>
BIN  Localstorage/icon.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 Localstorage/index.html
View
@@ -0,0 +1,36 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
+<!--
+* Copyright 2010-2011 BB Jam Polska (bbjam.pl).
+*
+* 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.
+-->
+<html>
+ <head>
+ <meta name="viewport" content="initial-scale=1.0,width=device-width" />
+ <script type="text/javascript" src="js/main.js"></script>
+ </head>
+ <body onload="GetText();">
+ <!-- To load text when application starts we can use onload element
+ Aby załadować tekst podczas uruchomienia aplikacji możemy użyć elementu onload
+ -->
+ <div align="center">
+ <p style="font-weight: bold">Text:</p>
+ <input type="text" id="inputElement">
+ <br>
+ <input type="button" onclick="SaveText();" value="Save">
+ <br>
+ <input type="button" onclick="GetText();" value="Show">
+ <br>
+ <input type="button" onclick="ClearText();" value="Clear database">
+ </body>
+</html>
67 Localstorage/js/main.js
View
@@ -0,0 +1,67 @@
+/*
+* Copyright 2010-2011 BB Jam Polska (bbjam.pl).
+*
+* 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.
+*/
+
+function SaveText() {
+ // We are getting our input text from input element
+ // Pobieramy tekst z elementu input
+ var inputResult = document.getElementById("inputElement").value;
+
+ // Next we need to create database element and save our text.
+ // Następinie tworzymy bazę danych i zapisujemy nasz tekst.
+ localStorage.setItem("databaseName", inputResult);
+
+ alert("Element saved.");
+ clearInput();
+
+}
+
+function GetText() {
+ // Initiating our database
+ // Inicjowanie bazy danych
+ var databaseElement = localStorage.getItem("databaseName");
+
+ // Checking if element exsist
+ // Sprawdzanie czy element istnieje
+ if (databaseElement) {
+
+ //Set the text value to input element
+ //Ustaw tekst elementu input
+ document.getElementById("inputElement").value = databaseElement;
+ } else {
+ // Or display an error when element is not exsist
+ // Lub wyświetl błąd jeżeli element nie istnieje
+ alert("Database is empty.");
+ }
+
+}
+
+function ClearText() {
+ // To clear database
+ // Aby wyczyścić bazę danych
+ localStorage.removeItem("databaseName");
+
+
+ alert("Database clear.");
+ clearInput();
+}
+
+// Sample function to clear input field after operation.
+// Prost funcka czyszcząca pole input po wykonaniu danej operacji.
+
+function clearInput() {
+
+ document.getElementById("inputElement").value = "";
+}
23 README.md
View
@@ -1,4 +1,25 @@
Database-BB10
=============
-Simple database for BB10 / Prosta baza danych dla BB10
+Simple database for BB10
+
+Tutorial is divided into two parts:
+
+Localstorage - HTML5 local.storage element
+
+SQL - HTML5 SQL database
+
+In BIN folder you can find executables which you can run using simulator or BB 10 Dev Alpha devices.
+
+==========================
+
+
+Prosta baza danych dla BB10
+
+Tutorial został podzielony na dwie części:
+
+Localstorage - element local.storage HTML5
+
+SQL - baza SQL HTML5
+
+W folderze BIN znajdują się pliki wykonywalne, które możecie uruchomić na symulatorze lub urządzeniu BB 10 Dev Alpha.
Please sign in to comment.
Something went wrong with that request. Please try again.