Nathaniel van Diepen преди 11 години
родител
ревизия
6ed8ec139a
променени са 2 файла, в които са добавени 50 реда и са изтрити 42 реда
  1. 24 20
      data/pages/login.template
  2. 26 22
      data/pages/register.template

+ 24 - 20
data/pages/login.template

@@ -12,27 +12,31 @@
 	<input type="button" value="cancel" class="cancel"/>
 </form>
 <script>
-	$('form#login').submit(function(){
-		var data = $(this).serializeObject(),
-			State = History.getState();
-		for(var i in State.data){
-			data[i] = State.data;
-		}
-		data.type = 'action';
-		data.id = 'login';
-		apiCall(data,function(d){
-			if(!d.error){
-				setKey(d.key);
-				History.go(-1);
-			}else{
-				setKey(null);
-				$('#loading').hide();
+	{{#if key}}
+		History.back();
+	{{else}}
+		$('form#login').submit(function(){
+			var data = $(this).serializeObject(),
+				State = History.getState();
+			for(var i in State.data){
+				data[i] = State.data;
 			}
+			data.type = 'action';
+			data.id = 'login';
+			apiCall(data,function(d){
+				if(!d.error){
+					setKey(d.key);
+					History.go(-1);
+				}else{
+					setKey(null);
+					$('#loading').hide();
+				}
+				return false;
+			});
+			return false;
+		}).children('.cancel').click(function(){
+			History.back();
 			return false;
 		});
-		return false;
-	}).children('.cancel').click(function(){
-		History.back();
-		return false;
-	});
+	{{/if}}
 </script>

+ 26 - 22
data/pages/register.template

@@ -23,27 +23,31 @@
 	<input type="button" value="cancel" class="cancel"/>
 </form>
 <script>
-	$('form#register').submit(function(){
-		var data = $(this).serializeObject(),
-				State = History.getState();
-			for(var i in State.data){
-				data[i] = State.data;
-			}
-			data.type = 'action';
-			data.id = 'register';
-			apiCall(data,function(d){
-				if(!d.error){
-					setKey(d.key);
-					loadState('page-index');
-				}else{
-					setKey(null);
-					$('#captcha').attr('src','index.php?get=captcha&timestamp='+new Date);
-					$('#loading').hide();
-				}
-			});
-		return false;
-	}).children('.cancel').click(function(){
+	{{#if key}}
 		History.back();
-		return false;
-	});
+	{{else}}
+		$('form#register').submit(function(){
+			var data = $(this).serializeObject(),
+					State = History.getState();
+				for(var i in State.data){
+					data[i] = State.data;
+				}
+				data.type = 'action';
+				data.id = 'register';
+				apiCall(data,function(d){
+					if(!d.error){
+						setKey(d.key);
+						loadState('page-index');
+					}else{
+						setKey(null);
+						$('#captcha').attr('src','index.php?get=captcha&timestamp='+new Date);
+						$('#loading').hide();
+					}
+				});
+			return false;
+		}).children('.cancel').click(function(){
+			History.back();
+			return false;
+		});
+	{{/if}}
 </script>