Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Localstorage

Localstorage databse.
  • Loading branch information...
commit f9f133165d52372176745c496fe0d23a2ab14b48 1 parent 30f7422
Lukasz Dzierzak ddluk authored
2  .gitignore
... ... @@ -0,0 +1,2 @@
  1 +
  2 +.DS_Store
BIN  BIN/Localstorage/device/SampleDatabaseApp.bar
Binary file not shown
BIN  BIN/Localstorage/simulator/SampleDatabaseApp.bar
Binary file not shown
18 Localstorage/config.xml
... ... @@ -0,0 +1,18 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<widget xmlns="http://www.w3.org/ns/widgets"
  3 + xmlns:rim="http://www.blackberry.com/ns/widgets"
  4 + version="1.0.0.0" id="sampleDatabaseApp">
  5 +
  6 + <author href="http://www.bbjam.pl/" rim:copyright="Copyright 2012 BB Jam Polska">BB Jam Polska</author>
  7 +
  8 + <name>Database application.</name>
  9 +
  10 + <description>
  11 + A sample application to demonstrate some of the local.storage database possibilities.
  12 + </description>
  13 +
  14 + <icon src="icon.png"/>
  15 +
  16 + <content src="index.html" />
  17 +
  18 +</widget>
BIN  Localstorage/icon.png
36 Localstorage/index.html
... ... @@ -0,0 +1,36 @@
  1 +<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
  2 +<!--
  3 +* Copyright 2010-2011 BB Jam Polska (bbjam.pl).
  4 +*
  5 +* Licensed under the Apache License, Version 2.0 (the "License");
  6 +* you may not use this file except in compliance with the License.
  7 +* You may obtain a copy of the License at
  8 +*
  9 +* http://www.apache.org/licenses/LICENSE-2.0
  10 +*
  11 +* Unless required by applicable law or agreed to in writing, software
  12 +* distributed under the License is distributed on an "AS IS" BASIS,
  13 +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14 +* See the License for the specific language governing permissions and
  15 +* limitations under the License.
  16 +-->
  17 +<html>
  18 + <head>
  19 + <meta name="viewport" content="initial-scale=1.0,width=device-width" />
  20 + <script type="text/javascript" src="js/main.js"></script>
  21 + </head>
  22 + <body onload="GetText();">
  23 + <!-- To load text when application starts we can use onload element
  24 + Aby załadować tekst podczas uruchomienia aplikacji możemy użyć elementu onload
  25 + -->
  26 + <div align="center">
  27 + <p style="font-weight: bold">Text:</p>
  28 + <input type="text" id="inputElement">
  29 + <br>
  30 + <input type="button" onclick="SaveText();" value="Save">
  31 + <br>
  32 + <input type="button" onclick="GetText();" value="Show">
  33 + <br>
  34 + <input type="button" onclick="ClearText();" value="Clear database">
  35 + </body>
  36 +</html>
67 Localstorage/js/main.js
... ... @@ -0,0 +1,67 @@
  1 +/*
  2 +* Copyright 2010-2011 BB Jam Polska (bbjam.pl).
  3 +*
  4 +* Licensed under the Apache License, Version 2.0 (the "License");
  5 +* you may not use this file except in compliance with the License.
  6 +* You may obtain a copy of the License at
  7 +*
  8 +* http://www.apache.org/licenses/LICENSE-2.0
  9 +*
  10 +* Unless required by applicable law or agreed to in writing, software
  11 +* distributed under the License is distributed on an "AS IS" BASIS,
  12 +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 +* See the License for the specific language governing permissions and
  14 +* limitations under the License.
  15 +*/
  16 +
  17 +function SaveText() {
  18 + // We are getting our input text from input element
  19 + // Pobieramy tekst z elementu input
  20 + var inputResult = document.getElementById("inputElement").value;
  21 +
  22 + // Next we need to create database element and save our text.
  23 + // Następinie tworzymy bazę danych i zapisujemy nasz tekst.
  24 + localStorage.setItem("databaseName", inputResult);
  25 +
  26 + alert("Element saved.");
  27 + clearInput();
  28 +
  29 +}
  30 +
  31 +function GetText() {
  32 + // Initiating our database
  33 + // Inicjowanie bazy danych
  34 + var databaseElement = localStorage.getItem("databaseName");
  35 +
  36 + // Checking if element exsist
  37 + // Sprawdzanie czy element istnieje
  38 + if (databaseElement) {
  39 +
  40 + //Set the text value to input element
  41 + //Ustaw tekst elementu input
  42 + document.getElementById("inputElement").value = databaseElement;
  43 + } else {
  44 + // Or display an error when element is not exsist
  45 + // Lub wyświetl błąd jeżeli element nie istnieje
  46 + alert("Database is empty.");
  47 + }
  48 +
  49 +}
  50 +
  51 +function ClearText() {
  52 + // To clear database
  53 + // Aby wyczyścić bazę danych
  54 + localStorage.removeItem("databaseName");
  55 +
  56 +
  57 + alert("Database clear.");
  58 + clearInput();
  59 +}
  60 +
  61 +// Sample function to clear input field after operation.
  62 +// Prost funcka czyszcząca pole input po wykonaniu danej operacji.
  63 +
  64 +function clearInput() {
  65 +
  66 + document.getElementById("inputElement").value = "";
  67 +}
23 README.md
Source Rendered
... ... @@ -1,4 +1,25 @@
1 1 Database-BB10
2 2 =============
3 3
4   -Simple database for BB10 / Prosta baza danych dla BB10
  4 +Simple database for BB10
  5 +
  6 +Tutorial is divided into two parts:
  7 +
  8 +Localstorage - HTML5 local.storage element
  9 +
  10 +SQL - HTML5 SQL database
  11 +
  12 +In BIN folder you can find executables which you can run using simulator or BB 10 Dev Alpha devices.
  13 +
  14 +==========================
  15 +
  16 +
  17 +Prosta baza danych dla BB10
  18 +
  19 +Tutorial został podzielony na dwie części:
  20 +
  21 +Localstorage - element local.storage HTML5
  22 +
  23 +SQL - baza SQL HTML5
  24 +
  25 +W folderze BIN znajdują się pliki wykonywalne, które możecie uruchomić na symulatorze lub urządzeniu BB 10 Dev Alpha.

0 comments on commit f9f1331

Please sign in to comment.
Something went wrong with that request. Please try again.