]> dev.renevier.net Git - syj.git/blobdiff - public/js/syj.js
redirection after path creation is decided by server (php), not guessed by client...
[syj.git] / public / js / syj.js
index f2ae9e19125230221488fe2c8eb6654a50550533..4b7f01d9a39dda1f010856080f130cc806577a0f 100644 (file)
@@ -225,7 +225,6 @@ var SYJView = {
     map: null,
     wkt: new OpenLayers.Format.WKT({ internalProjection: Mercator, externalProjection: WGS84 }),
     needsFormResubmit: false,
-    hasInitialGeom: false,
 
     init: function() {
         var externalGraphic, baseURL, baseLayer, layerOptions, extent, hidemessenger;
@@ -285,7 +284,6 @@ var SYJView = {
             // XXX: ie has not guessed height of map main div yet during map
             // initialisation. Now, it will read it correctly.
             this.map.updateSize();
-            this.hasInitialGeom = true;
         } else {
             extent = new OpenLayers.Bounds(gMaxExtent.minlon, gMaxExtent.minlat, gMaxExtent.maxlon, gMaxExtent.maxlat)
                                          .transform(WGS84, Mercator);
@@ -396,8 +394,8 @@ var SYJView = {
     },
 
     saveSuccess: function(transport) {
-      if (!this.hasInitialGeom) { // we have created a new path, change location
-          location = "idx/" + transport.responseText;
+      if (transport.responseJSON && (typeof transport.responseJSON.redirect === "string")) {
+          location = transport.responseJSON.redirect;
           return;
       }
 
@@ -419,7 +417,7 @@ var SYJView = {
             break;
             case 400:
             case 404:
-                message = SyjStrings.requestError; // default message
+                message = SyjStrings.requestError;
                 if (transport.responseJSON) {
                     switch (transport.responseJSON.message) {
                         case "uniquepath":
@@ -430,6 +428,12 @@ var SYJView = {
                     }
                 }
             break;
+            case 403:
+                message = "";
+                SYJLogin.messenger.setMessage(SyjStrings.loginNeeded, "warn");
+                SYJLogin.modalbox.show();
+                this.needsFormResubmit = true;
+            break;
             case 410:
                 message = SyjStrings.gonePathError;
             break;