/[jquery]/no_pager/no_pager.js
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /no_pager/no_pager.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10 - (show annotations)
Wed Aug 16 01:02:00 2006 UTC (17 years, 8 months ago) by dpavlin
File MIME type: application/javascript
File size: 3745 byte(s)
show time, simple query rewriter, status message tweaks
1 /*
2 no pager, as seen at
3 http://www.humanized.com/weblog/2006/04/28/reading_humanized/
4 */
5
6 function favorite( image, feedID ){
7 var makeFavorite;
8 if (image.src.indexOf("fav_off.gif") != -1){
9 image.src = "static/images/fav_on.gif";
10 makeFavorite = "True";
11 }
12 else if (image.src.indexOf("fav_on.gif") != -1){
13 image.src = "static/images/fav_off.gif";
14 makeFavorite = "False";
15 }
16 doSimpleXMLHttpRequest("favorite", {id: feedID, makeFavorite: makeFavorite})
17
18 }
19
20 function getMoreHistory(){
21 var indexVal = getElement("history_index").value;
22 var q = getElement('q').value;
23 getElement('status').innerHTML = 'Loading page '+ ( parseInt(indexVal) + 1 ) + '...';
24 var xmlDoc = doSimpleXMLHttpRequest("index.cgi/snippet", {index: indexVal, q: q});
25 xmlDoc.addCallbacks(addMoreHistory, failure);
26 }
27
28 function failure(){
29 var message = P( null, "" );
30 message.innerHTML = "<strong>Could not contact the Humanized server.</strong> <br />";
31 message.innerHTML += "Please wait awhile and try again. <br /><br />";
32 message.innerHTML += "We apologize for the inconvenience.";
33 var el = getElement("more_history");
34
35 }
36
37 function addMoreHistory( xmlDoc ){
38 var response = xmlDoc.responseText;
39
40 var index_el = getElement("history_index");
41 var indexVal = parseInt(index_el.value);
42
43 // minimum response length?
44 if (response.length < 500){
45
46 showElement("footer")
47 if( indexVal > 0 ){
48 var out = H2({'style':'text-align:center; font-style:italic; padding: 2em;'},
49 "No more results."
50 );
51 }else{
52 var out = H2({'style':'text-align:center; font-style:italic; padding: 2em;'},
53 "No results matched your search."
54 );
55 }
56 replaceChildNodes( "more_history", out )
57 getElement("status").innerHTML = '';
58 return;
59 }
60
61 response += "<div id='more_history'>";
62 response += " <strong>More posts are being loaded...</strong> <br />";
63 response += " If you are using the scroll bar, release the mouse to see more posts.";
64 response += "</div>"
65
66 index_el.value = indexVal + 1;
67
68 var new_history = DIV(null,"");
69 new_history.innerHTML = response;
70 swapDOM( "more_history", new_history );
71
72 isUpdating = false;
73
74 var status_update = getElement("status_update");
75 var status = getElement("status");
76 if (status_update && status) {
77 status.innerHTML = status_update.innerHTML;
78 log("status updated");
79 }
80
81 }
82
83 function updatePage(){
84 if ( isUpdating == false
85 && mouseState == "up"
86 && getPageHeight() - getScrollHeight() < preloadDistance){
87 log("Getting segment: ", $("history_index").value);
88 setCookie(id, $("history_index").value );
89 isUpdating = true;
90 getMoreHistory();
91 }
92 checker.cancel();
93 checker = callLater(checkInterval, updatePage);
94 }
95
96
97 function onMouseDown(e ){
98 mouseState = "down";
99 setCookie(id+"_height", getScrollHeight() );
100 setCookie(id+"_scroll", getScrollHeight() - _getWindowHeight() );
101 }
102
103 function onMouseUp(){
104 mouseState = "up";
105 }
106
107 var checker;
108 var checkInterval = .2;
109 var preloadDistance = 1000;
110 var isUpdating = false;
111 var mouseState = "up";
112 var id;
113
114 function init( ){
115 document.onmousedown = onMouseDown;
116 document.onmouseup = onMouseUp;
117
118 //createLoggingPane(true);
119 id = $("page_id").value;
120 logDebug("Page ID:", id);
121 logDebug("Page Cookie:", getCookie(id));
122
123 var fromBackButton = false;
124 if( getCookie(id) ){ fromBackButton = true; }
125 else{ setCookie(id, "1") }
126
127 logDebug("From Back Button?:", fromBackButton);
128 if( fromBackButton ){
129 logDebug( "Number of segments loaded: ", getCookie(id) );
130 logDebug( "Should scroll to: ", getCookie(id+"_scroll") );
131 $("spacer").style.height=getCookie(id+"_height")+"px";
132 scroll( 0, getCookie(id+"_scroll") );
133 }
134
135 getElement("history_index").value = 0;
136 checker = callLater(0, updatePage);
137 }
138
139 addLoadEvent(init);
140

  ViewVC Help
Powered by ViewVC 1.1.26