wall login in progress
This commit is contained in:
parent
687290a00d
commit
ca1e3d0579
10 changed files with 110 additions and 74 deletions
65
app/assets/javascripts/note.js
Normal file
65
app/assets/javascripts/note.js
Normal file
|
@ -0,0 +1,65 @@
|
|||
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();
|
||||
},
|
||||
|
||||
prepend:
|
||||
function(id, html) {
|
||||
this.last_id = id;
|
||||
$("#notes-list").prepend(html);
|
||||
},
|
||||
|
||||
getNew:
|
||||
function() {
|
||||
// refersh notes list
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: location.href,
|
||||
data: "last_id=" + this.last_id,
|
||||
dataType: "script"});
|
||||
},
|
||||
|
||||
initRefresh:
|
||||
function() {
|
||||
// init timer
|
||||
var int = setInterval("NoteList.getNew()", 20000);
|
||||
},
|
||||
|
||||
initLoadMore:
|
||||
function() {
|
||||
$(window).bind('scroll', function(){
|
||||
if($(window).scrollTop() == $(document).height() - $(window).height()){
|
||||
$(window).unbind('scroll');
|
||||
NoteList.getOld();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue