You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2013/06/21 10:02:50 UTC

[3/5] git commit: Windows Phone 8 does not need the WebStorage polyfil

Windows Phone 8 does not need the WebStorage polyfil


Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/135ffb9d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/135ffb9d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/135ffb9d

Branch: refs/heads/master
Commit: 135ffb9d0b01ff768c4f6e008728658136b91748
Parents: 02544e7
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Fri Jun 21 00:51:53 2013 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Fri Jun 21 00:51:53 2013 -0700

----------------------------------------------------------------------
 wp8/template/CordovaWP8AppProj.csproj       |   1 -
 wp8/template/cordovalib/CordovaView.xaml.cs |  45 +++----
 wp8/template/cordovalib/DOMStorageHelper.cs | 145 -----------------------
 3 files changed, 18 insertions(+), 173 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/135ffb9d/wp8/template/CordovaWP8AppProj.csproj
----------------------------------------------------------------------
diff --git a/wp8/template/CordovaWP8AppProj.csproj b/wp8/template/CordovaWP8AppProj.csproj
index 18f5bf8..8039209 100644
--- a/wp8/template/CordovaWP8AppProj.csproj
+++ b/wp8/template/CordovaWP8AppProj.csproj
@@ -131,7 +131,6 @@
     <Compile Include="cordovalib\CordovaView.xaml.cs">
       <DependentUpon>CordovaView.xaml</DependentUpon>
     </Compile>
-    <Compile Include="cordovalib\DOMStorageHelper.cs" />
     <Compile Include="cordovalib\JSON\JsonHelper.cs" />
     <Compile Include="cordovalib\NativeExecution.cs" />
     <Compile Include="cordovalib\OrientationHelper.cs" />

http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/135ffb9d/wp8/template/cordovalib/CordovaView.xaml.cs
----------------------------------------------------------------------
diff --git a/wp8/template/cordovalib/CordovaView.xaml.cs b/wp8/template/cordovalib/CordovaView.xaml.cs
index e1ad8da..bf70d42 100644
--- a/wp8/template/cordovalib/CordovaView.xaml.cs
+++ b/wp8/template/cordovalib/CordovaView.xaml.cs
@@ -1,15 +1,15 @@
 /*  
-	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.
+    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.
 */
 
 using System;
@@ -74,7 +74,6 @@ namespace WPCordovaClassLib
         private NativeExecution nativeExecution;
 
         protected BrowserMouseHelper bmHelper;
-        protected DOMStorageHelper domStorageHelper;
         protected OrientationHelper orientationHelper;
 
         private ConfigHandler configHandler;
@@ -122,7 +121,7 @@ namespace WPCordovaClassLib
                 }
             }
         }
-       
+
         /// <summary>
         /// Gets or sets whether to suppress bouncy scrolling of
         /// the WebBrowser control;
@@ -172,8 +171,8 @@ namespace WPCordovaClassLib
                 else
                 {
                     this.StartPageUri = new Uri(AppRoot + "www/" + configHandler.ContentSrc, UriKind.Relative);
-                } 
-            }         
+                }
+            }
 
             nativeExecution = new NativeExecution(ref this.CordovaBrowser);
             bmHelper = new BrowserMouseHelper(ref this.CordovaBrowser);
@@ -231,9 +230,6 @@ namespace WPCordovaClassLib
             if (this.IsBrowserInitialized) return;
 
 
-
-            this.domStorageHelper = new DOMStorageHelper(this.CordovaBrowser);
-
             try
             {
 
@@ -395,7 +391,7 @@ namespace WPCordovaClassLib
             string[] autoloadPlugs = this.configHandler.AutoloadPlugins;
             foreach (string plugName in autoloadPlugs)
             {
-               //nativeExecution.ProcessCommand(commandCallParams); 
+                //nativeExecution.ProcessCommand(commandCallParams); 
             }
 
             string nativeReady = "(function(){ cordova.require('cordova/channel').onNativeReady.fire()})();";
@@ -442,12 +438,7 @@ namespace WPCordovaClassLib
         {
             string commandStr = e.Value;
 
-            if (commandStr.IndexOf("DOMStorage") == 0)
-            {
-                this.domStorageHelper.HandleStorageCommand(commandStr);
-                return;
-            }
-            else if (commandStr.IndexOf("Orientation") == 0)
+            if (commandStr.IndexOf("Orientation") == 0)
             {
                 this.orientationHelper.HandleCommand(commandStr);
                 return;
@@ -466,7 +457,7 @@ namespace WPCordovaClassLib
                 {
                     case "overridebackbutton":
                         string arg0 = JsonHelper.Deserialize<string[]>(commandCallParams.Args)[0];
-                        this.OverrideBackButton = (arg0 != null && arg0.Length > 0 && arg0.ToLower() == "true"); 
+                        this.OverrideBackButton = (arg0 != null && arg0.Length > 0 && arg0.ToLower() == "true");
                         break;
                 }
             }
@@ -478,7 +469,7 @@ namespace WPCordovaClassLib
                 }
                 else
                 {
-                    Debug.WriteLine("Error::Plugin not allowed in config.xml. " + commandCallParams.Service); 
+                    Debug.WriteLine("Error::Plugin not allowed in config.xml. " + commandCallParams.Service);
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/135ffb9d/wp8/template/cordovalib/DOMStorageHelper.cs
----------------------------------------------------------------------
diff --git a/wp8/template/cordovalib/DOMStorageHelper.cs b/wp8/template/cordovalib/DOMStorageHelper.cs
deleted file mode 100644
index 01b6273..0000000
--- a/wp8/template/cordovalib/DOMStorageHelper.cs
+++ /dev/null
@@ -1,145 +0,0 @@
-/*  
-	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.
-*/
-
-using System;
-using System.Net;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Documents;
-using System.Windows.Ink;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Animation;
-using System.Windows.Shapes;
-using System.IO.IsolatedStorage;
-using System.Collections.Generic;
-using Microsoft.Phone.Controls;
-using System.Linq;
-using WPCordovaClassLib.Cordova.JSON;
-
-/*
- * Translates DOMStorage API between JS and Isolated Storage
- * Missing pieces : QUOTA_EXCEEDED_ERR  + StorageEvent  
- * */
-
-namespace WPCordovaClassLib
-{
-    public class DOMStorageHelper
-    {
-        protected WebBrowser webBrowser1;
-
-        public DOMStorageHelper(WebBrowser aBrowser)
-        {
-            this.webBrowser1 = aBrowser;
-            // always clear session at creation
-            UserSettings["sessionStorage"] = new Dictionary<string, string>();
-
-            if (!UserSettings.Contains("localStorage"))
-            {
-                UserSettings["localStorage"] = new Dictionary<string, string>();
-                UserSettings.Save();
-            }
-            Application.Current.Exit += new EventHandler(OnAppExit);
-        }
-
-        void OnAppExit(object sender, EventArgs e)
-        {
-            UserSettings.Remove("sessionStorage");
-            UserSettings.Save();
-        }
-
-        protected IsolatedStorageSettings UserSettings
-        {
-            get
-            {
-                return IsolatedStorageSettings.ApplicationSettings;
-            }
-        }
-
-        protected Dictionary<string, string> getStorageByType(string type)
-        {
-            if (!UserSettings.Contains(type))
-            {
-                UserSettings[type] = new Dictionary<string, string>();
-                UserSettings.Save();
-            }
-            return UserSettings[type] as Dictionary<string, string>;
-        }
-
-
-        public void HandleStorageCommand(string commandStr)
-        {
-
-            string[] split = commandStr.Split('/');
-            if (split.Length > 3)
-            {
-                string api = split[0];
-                string type = split[1]; // localStorage || sessionStorage
-                string command = split[2];
-                string param = split[3];
-
-                Dictionary<string, string> currentStorage = getStorageByType(type);
-
-                switch (command)
-                {
-                    case "get":
-                        {
-
-                            if (currentStorage.Keys.Contains(param))
-                            {
-                                string value = currentStorage[param];
-                                webBrowser1.InvokeScript("execScript", "window." + type + ".onResult('" + param + "','" + value + "');");
-                            }
-                            else
-                            {
-                                webBrowser1.InvokeScript("execScript", "window." + type + ".onResult('" + param + "');");
-                            }
-
-                        }
-                        break;
-                    case "load":
-                        {
-                            string[] keys = currentStorage.Keys.ToArray();
-                            string jsonString = JsonHelper.Serialize(keys);
-                            string callbackJS = "window." + type + ".onKeysChanged('" + jsonString + "');";
-                            webBrowser1.InvokeScript("execScript", callbackJS);
-                        }
-                        break;
-                    case "set":
-                        {
-                            // TODO: check that length is not out of bounds
-                            currentStorage[param] = split[4];
-                            UserSettings.Save();
-                            string[] keys = currentStorage.Keys.ToArray();
-                            string jsonString = JsonHelper.Serialize(keys);
-                            string callbackJS = "window." + type + ".onKeysChanged('" + jsonString + "');";
-                            webBrowser1.InvokeScript("execScript", callbackJS);
-                        }
-                        break;
-                    case "remove":
-                        currentStorage.Remove(param);
-                        UserSettings.Save();
-                        break;
-                    case "clear":
-                        currentStorage = new Dictionary<string, string>();
-                        UserSettings[type] = currentStorage;
-                        UserSettings.Save();
-                        break;
-                }
-
-            }
-
-        }
-    }
-}