/[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

Annotation of /no_pager/no_pager.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (hide annotations)
Tue Aug 15 15:43:31 2006 UTC (17 years, 8 months ago) by dpavlin
File MIME type: application/javascript
File size: 3423 byte(s)
import of first semi-working version of no pager

1 dpavlin 2 /*
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 xmlDoc = doSimpleXMLHttpRequest("index.cgi/snippet", {index: indexVal, q: document.getElementById('q').value });
23     xmlDoc.addCallbacks(addMoreHistory, failure);
24     }
25    
26     function failure(){
27     var message = P( null, "" );
28     message.innerHTML = "<strong>Could not contact the Humanized server.</strong> <br />";
29     message.innerHTML += "Please wait awhile and try again. <br /><br />";
30     message.innerHTML += "We apologize for the inconvenience.";
31     var el = getElement("more_history");
32    
33     }
34    
35     function addMoreHistory( xmlDoc ){
36     var response = xmlDoc.responseText;
37    
38     var index_el = getElement("history_index");
39     var indexVal = parseInt(index_el.value);
40    
41     // minimum response length?
42     if (response.length < 300){
43    
44     showElement("footer")
45     if( indexVal > 0 ){
46     var out = H2({'style':'text-align:center; font-style:italic; padding: 2em;'},
47     "No more results."
48     );
49     }else{
50     var out = H2({'style':'text-align:center; font-style:italic; padding: 2em;'},
51     "No posts matched your search."
52     );
53     }
54     replaceChildNodes( "more_history", out )
55     return;
56     }
57    
58     response += "<div id='more_history'>";
59     response += " <strong>More posts are being loaded...</strong> <br />";
60     response += " If you are using the scroll bar, release the mouse to see more posts.";
61     response += "</div>"
62    
63     index_el.value = indexVal + 1;
64    
65     var new_history = DIV(null,"");
66     new_history.innerHTML = response;
67     swapDOM( "more_history", new_history );
68    
69     isUpdating = false;
70     }
71    
72     function updatePage(){
73     if ( isUpdating == false
74     && mouseState == "up"
75     && getPageHeight() - getScrollHeight() < preloadDistance){
76     log("Getting segment: ", $("history_index").value);
77     setCookie(id, $("history_index").value );
78     isUpdating = true;
79     getMoreHistory();
80     }
81     checker.cancel();
82     checker = callLater(checkInterval, updatePage);
83     }
84    
85    
86     function onMouseDown(e ){
87     mouseState = "down";
88     setCookie(id+"_height", getScrollHeight() );
89     setCookie(id+"_scroll", getScrollHeight() - _getWindowHeight() );
90     }
91    
92     function onMouseUp(){
93     mouseState = "up";
94     }
95    
96     var checker;
97     var checkInterval = .2;
98     var preloadDistance = 1000;
99     var isUpdating = false;
100     var mouseState = "up";
101     var id;
102    
103     function init( ){
104     document.onmousedown = onMouseDown;
105     document.onmouseup = onMouseUp;
106    
107     //createLoggingPane(true);
108     id = $("page_id").value;
109     logDebug("Page ID:", id);
110     logDebug("Page Cookie:", getCookie(id));
111    
112     var fromBackButton = false;
113     if( getCookie(id) ){ fromBackButton = true; }
114     else{ setCookie(id, "1") }
115    
116     logDebug("From Back Button?:", fromBackButton);
117     if( fromBackButton ){
118     logDebug( "Number of segments loaded: ", getCookie(id) );
119     logDebug( "Should scroll to: ", getCookie(id+"_scroll") );
120     $("spacer").style.height=getCookie(id+"_height")+"px";
121     scroll( 0, getCookie(id+"_scroll") );
122     }
123    
124     getElement("history_index").value = 0;
125     checker = callLater(0, updatePage);
126     }
127    
128     addLoadEvent(init);
129    

  ViewVC Help
Powered by ViewVC 1.1.26