Przeglądaj źródła

Fixed invalid pages from redirecting to index.

Nathaniel van Diepen 10 lat temu
rodzic
commit
fc18b675b3
3 zmienionych plików z 18 dodań i 15 usunięć
  1. 3 0
      api.php
  2. 2 1
      data/pages/project.template
  3. 13 14
      js/index.js

+ 3 - 0
api.php

@@ -185,6 +185,9 @@
 						$ret['context'] = $context;
 					}else{
 						$ret['error'] = 'That page does not exist';
+						$ret['state'] = array(
+							'url'=>isset($_GET['back'])?$_GET['back']:'page-index'
+						);
 					}
 					retj($ret,$title);
 				break;

+ 2 - 1
data/pages/project.template

@@ -32,4 +32,5 @@
 		"type": "project",
 		"title": "Comment"
 	}
-</a>
+</a>
+<a href="#page-scrums">scrums</a>

+ 13 - 14
js/index.js

@@ -102,21 +102,20 @@
 				$.get(location.href,data,function(d){
 					if(exists(d['error'])){
 						error(d);
-					}else{
-						if(exists(d.state)){
-							d.state.title = (d.state.title+'').capitalize();
-							if(location.href.substr(location.href.lastIndexOf('/')+1) != d.state.url && d.state.url !== ''){
-								console.log('Forced redirection to '+d.state.url);
-								flag('handled',true);
-								d.state.data.back = State.data.back;
-								History.replaceState(d.state.data,d.state.title,d.state.url);
-								callback = function(){
-									location.reload();
-								};
-							}
-							document.title = d.state.title;
-							loading(false);
+					}
+					if(exists(d.state)){
+						d.state.title = (d.state.title+'').capitalize();
+						if(location.href.substr(location.href.lastIndexOf('/')+1) != d.state.url && d.state.url !== ''){
+							console.log('Forced redirection to '+d.state.url);
+							flag('handled',true);
+							d.state.data.back = State.data.back;
+							History.replaceState(d.state.data,d.state.title,d.state.url);
+							callback = function(){
+								location.reload();
+							};
 						}
+						document.title = d.state.title;
+						loading(false);
 					}
 					if(exists(callback)){
 						console.log('Running apiCall callback');