Browse Source

Fixed comment loading and template caching.

Nathaniel van Diepen 10 years ago
parent
commit
e004a22076
2 changed files with 7 additions and 9 deletions
  1. 2 1
      api.php
  2. 5 8
      js/index.js

+ 2 - 1
api.php

@@ -373,10 +373,11 @@
 								if(isset($_GET['of']) && isset($_GET['pid'])){
 									$ret = array();
 									$limit = array(
-										isset($_GET['start'])?$_GET['start']:0,
+										isset($_GET['at'])?$_GET['at']:0,
 										isset($_GET['amount'])?$_GET['amount']:10
 									);
 									$ret['messages'] = messages($_GET['pid'],$_GET['of'],$limit[0],$limit[1]);
+									$ret['params'] = array($_GET['pid'],$_GET['of'],$limit[0],$limit[1]);
 								}else{
 									$ret['error'] = 'Missing comment parameters';
 								}

+ 5 - 8
js/index.js

@@ -49,7 +49,7 @@
 			}
 			return false;
 		},
-		template = window.template = function(type,name,template){
+		template = window.template = function(type,name,template,hash){
 			var id = (function(type,name){
 					for(var i in templates){
 						if(templates[i].name == name && templates[i].type == type){
@@ -353,6 +353,7 @@
 					var t = $(this);
 					if(!$.hasData(t)){
 						t.data('type',t.text().trim());
+						t.data('at',t.prev().children().length);
 						t.text('Load More');
 					}
 				}).click(function(){
@@ -366,7 +367,7 @@
 							topbar: false,
 							no_state: true,
 							of: t.data('type'),
-							at: Number(t.children().length)+10
+							at: Number(t.data('at'))
 						};
 					data.start = t.data('at');
 					apiCall(data,function(d){
@@ -382,6 +383,7 @@
 							}
 							render.refresh(t.prev());
 						}
+						t.data('at',t.prev().children().length);
 					},true);
 				}).button();
 				render.comment.buttons(selector);
@@ -694,12 +696,7 @@
 									id: type,
 									name: d.manifest[i].name
 								},function(d){
-									templates.push({
-										name: d.name,
-										template: d.template,
-										type: d.type,
-										hash: d.hash
-									});
+									template(d.type,d.name,d.template,d.hash);
 									$.localStorage('templates',templates);
 									count--;
 									console.log('Loaded template('+count+' left): '+d.name);