aboutsummaryrefslogtreecommitdiff
path: root/includes/js/dojox/storage/demos
diff options
context:
space:
mode:
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-13 09:49:11 +0000
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-13 09:49:11 +0000
commite44a7e37b6c7b5961adaffc62b9042b8d442938e (patch)
tree95b67c356e93163467db2451f2b8cce84ed5d582 /includes/js/dojox/storage/demos
parenta62b9742ee5e28bcec6872d88f50f25b820914f6 (diff)
downloadsemanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.gz
semanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.bz2
New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'includes/js/dojox/storage/demos')
-rw-r--r--includes/js/dojox/storage/demos/helloworld.html90
1 files changed, 90 insertions, 0 deletions
diff --git a/includes/js/dojox/storage/demos/helloworld.html b/includes/js/dojox/storage/demos/helloworld.html
new file mode 100644
index 0000000..44fd739
--- /dev/null
+++ b/includes/js/dojox/storage/demos/helloworld.html
@@ -0,0 +1,90 @@
+<html>
+ <head>
+ <script src="../../../dojo/dojo.js"></script>
+ <script src="../storage-browser.js"></script>
+
+ <script>
+ dojo.require("dojox.storage");
+
+ function runDemo(){
+ // setup event handlers
+ dojo.byId("saveButton").onclick = saveValue;
+
+ // write out what our storage provider is for debugging
+ dojo.byId("currentProvider").innerHTML =
+ dojox.storage.manager.currentProvider.declaredClass;
+
+ loadValues();
+ }
+
+ function loadValues(){
+ // get any values that were saved before and write them into the page
+ var results = dojox.storage.get("myValues");
+
+ if(results){
+ var printMe = "<ul>";
+ for(var i = 0; i < results.length; i++){
+ printMe += "<li>" + results[i] + "</li>";
+ }
+ printMe += "</ul>";
+ dojo.byId("allValues").innerHTML = printMe;
+ }
+ }
+
+ function saveValue(){
+ var value = dojo.byId("saveValue").value;
+ if(value == undefined || value === ""){
+ alert("Please enter a correct value");
+ return;
+ }
+
+ // get the old values first, since we are saving everything
+ // as one key
+ var results = dojox.storage.get("myValues");
+ if(!results){
+ results = new Array();
+ }
+
+ // add new value
+ results.push(value);
+
+ dojox.storage.put("myValues", results, function(status, keyName){
+ if(status == dojox.storage.FAILED){
+ alert("You do not have permission to store data for this web site.");
+ }else if(status == dojox.storage.SUCCESS){
+ loadValues();
+ }
+ });
+ }
+
+ // wait until the storage system is finished loading
+ if(!dojox.storage.manager.isInitialized()){
+ dojo.connect(dojox.storage.manager, "loaded", runDemo);
+ }else{
+ dojo.connect(dojo, "loaded", runDemo);
+ }
+ </script>
+ </head>
+
+ <body>
+ <h1>Dojo Storage Hello World</h1>
+
+ <p>Simple Dojo Storage example. Enter values below to have them
+ persisted in Dojo Storage; refresh browser page or close browser
+ and then return to this page to see the values again. Note that
+ Dojo Storage will not work from file:// URLs.</p>
+
+ <h2>Save Values:</h2>
+ <div>
+ <input id="saveValue" type="text"></input>
+ <button id="saveButton">Save Value</button>
+ </div>
+
+ <h2>All Saved Values:</h2>
+ <p id="allValues"></p>
+
+ <p>Using Dojo Storage Provider (autodetected):
+ <span id="currentProvider"></span>
+ <p>
+ </body>
+</html> \ No newline at end of file