2011-11-04 14:37:38 +01:00
|
|
|
var NoteList = {
|
|
|
|
|
|
|
|
first_id: 0,
|
|
|
|
last_id: 0,
|
|
|
|
resource_name: null,
|
|
|
|
|
|
|
|
init:
|
|
|
|
function(resource_name, first_id, last_id) {
|
|
|
|
this.resource_name = resource_name;
|
|
|
|
this.first_id = first_id;
|
|
|
|
this.last_id = last_id;
|
|
|
|
this.initRefresh();
|
|
|
|
this.initLoadMore();
|
|
|
|
},
|
|
|
|
|
|
|
|
getOld:
|
|
|
|
function() {
|
|
|
|
$('.loading').show();
|
|
|
|
$.ajax({
|
|
|
|
type: "GET",
|
|
|
|
url: location.href,
|
|
|
|
data: "first_id=" + this.first_id,
|
|
|
|
complete: function(){ $('.loading').hide()},
|
|
|
|
dataType: "script"});
|
|
|
|
},
|
|
|
|
|
|
|
|
append:
|
|
|
|
function(id, html) {
|
|
|
|
this.first_id = id;
|
|
|
|
$("#notes-list").append(html);
|
|
|
|
this.initLoadMore();
|
|
|
|
},
|
|
|
|
|
2011-11-05 12:59:43 +01:00
|
|
|
replace:
|
|
|
|
function(fid, lid, html) {
|
|
|
|
this.first_id = fid;
|
|
|
|
this.last_id = lid;
|
|
|
|
$("#notes-list").html(html);
|
|
|
|
this.initLoadMore();
|
|
|
|
},
|
|
|
|
|
|
|
|
|
2011-11-04 14:37:38 +01:00
|
|
|
prepend:
|
|
|
|
function(id, html) {
|
2011-11-06 22:32:37 +01:00
|
|
|
if(id != this.last_id) {
|
|
|
|
this.last_id = id;
|
|
|
|
$("#notes-list").prepend(html);
|
|
|
|
}
|
2011-11-04 14:37:38 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
getNew:
|
|
|
|
function() {
|
|
|
|
// refersh notes list
|
|
|
|
$.ajax({
|
|
|
|
type: "GET",
|
|
|
|
url: location.href,
|
|
|
|
data: "last_id=" + this.last_id,
|
|
|
|
dataType: "script"});
|
|
|
|
},
|
|
|
|
|
2011-11-05 12:59:43 +01:00
|
|
|
refresh:
|
|
|
|
function() {
|
|
|
|
// refersh notes list
|
|
|
|
$.ajax({
|
|
|
|
type: "GET",
|
|
|
|
url: location.href,
|
|
|
|
data: "first_id=" + this.first_id + "&last_id=" + this.last_id,
|
|
|
|
dataType: "script"});
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-11-04 14:37:38 +01:00
|
|
|
initRefresh:
|
|
|
|
function() {
|
|
|
|
// init timer
|
2011-11-05 12:59:43 +01:00
|
|
|
var intNew = setInterval("NoteList.getNew()", 15000);
|
|
|
|
var intRefresh = setInterval("NoteList.refresh()", 90000);
|
2011-11-04 14:37:38 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
initLoadMore:
|
|
|
|
function() {
|
|
|
|
$(window).bind('scroll', function(){
|
|
|
|
if($(window).scrollTop() == $(document).height() - $(window).height()){
|
|
|
|
$(window).unbind('scroll');
|
|
|
|
NoteList.getOld();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|