Reformat dates. Surprisingly limited options for parsing and displaying dates.
[potlatch2.git] / resources / potlatch2.html
index 8cb1ad7d9cd0df0ad3ecdfc86932d06f72715350..f4533ca618f8ae9601f79c2fec74e34fb1fa7c96 100644 (file)
 </div>
 
 <script>
+       function getArgs() {
+               var args = new Object();
+               var query = location.search.substring(1);
+               var pairs = query.split("&");
+               for(var i = 0; i < pairs.length; i++) {
+                       var pos = pairs[i].indexOf('=');
+                       if (pos == -1) continue;
+                       var argname = pairs[i].substring(0,pos);
+                       var value = pairs[i].substring(pos+1);
+                       args[argname] = unescape(value);
+               }
+               return args;
+       }
+
+    var changesaved=true;
+  
+    window.onbeforeunload=function() {
+        if (!changesaved) {
+            return 'You have unsaved changes. You need to press the Save button to save them';
+        }
+    }
+
+    function markChanged(a) { changesaved=a; } /* called from flash */
+
+       var args = getArgs();
+       var lat;
+       var lon;
+       var zoom;
+       if (args.lat && args.lon) {
+               lat = parseFloat(args.lat);
+               lon = parseFloat(args.lon);
+       } else {
+               lat=51.875;
+               lon=-1.492;
+       }
+
+       if (args.zoom) {
+               zoom = parseInt(args.zoom);
+       } else {
+               zoom = 16;
+       }
+
        var fo = new SWFObject("potlatch2.swf?d="+Math.round(Math.random()*1000), "map", "100%", "100%", "9", "#FFFFFF");
-       fo.addVariable("lat",51.875);
-       fo.addVariable("lon",-1.492);
-       fo.addVariable("zoom",16);
+       fo.addVariable("lat",lat);
+       fo.addVariable("lon",lon);
+       fo.addVariable("zoom",zoom);
        fo.addVariable("api","http://api06.dev.openstreetmap.org/api/0.6/");
        fo.addVariable("policy","http://api06.dev.openstreetmap.org/api/crossdomain.xml");
        fo.addVariable("connection","XML");
        fo.addVariable("oauth_request_url", "http://api06.dev.openstreetmap.org/oauth/request_token");
        fo.addVariable("oauth_access_url", "http://api06.dev.openstreetmap.org/oauth/access_token");
        fo.addVariable("oauth_auth_url", "http://api06.dev.openstreetmap.org/oauth/authorize");
-        fo.addVariable("oauth_consumer_key", "fiM1IoqnKJk4JCfcl63DA");
-        fo.addVariable("oauth_consumer_secret", "7fYgJK9M4vB1CvBZ6jEsPGxYK9UD1hEnI6NqTxNGs");
-        fo.addVariable("serverName", "api06 Test On Dev");
-       fo.addVariable("style","potlatch.css?d="+Math.round(Math.random()*1000));
+       fo.addVariable("oauth_consumer_key", "fiM1IoqnKJk4JCfcl63DA");
+       fo.addVariable("oauth_consumer_secret", "7fYgJK9M4vB1CvBZ6jEsPGxYK9UD1hEnI6NqTxNGs");
+       fo.addVariable("serverName", "api06 Test On Dev");
        fo.write("map");