/[jquery]/no_pager/utils.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/utils.js

Parent Directory Parent Directory | Revision Log Revision Log


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

1 // These three functions are taken from code displayed on
2 // http://www.netspade.com/articles/2005/11/16/javascript-cookies/
3
4 /**
5 * Sets a Cookie with the given name and value.
6 *
7 * name Name of the cookie
8 * value Value of the cookie
9 * [expires] Expiration date of the cookie (default: end of current session)
10 * [path] Path where the cookie is valid (default: path of calling document)
11 * [domain] Domain where the cookie is valid
12 * (default: domain of calling document)
13 * [secure] Boolean value indicating if the cookie transmission requires a
14 * secure transmission
15 */
16 function setCookie(name, value, expires, path, domain, secure) {
17 document.cookie= name + "=" + escape(value) +
18 ((expires) ? "; expires=" + expires.toGMTString() : "") +
19 ((path) ? "; path=" + path : "") +
20 ((domain) ? "; domain=" + domain : "") +
21 ((secure) ? "; secure" : "");
22 }
23
24 /**
25 * Gets the value of the specified cookie.
26 *
27 * name Name of the desired cookie.
28 *
29 * Returns a string containing value of specified cookie,
30 * or null if cookie does not exist.
31 */
32 function getCookie(name) {
33 var dc = document.cookie;
34 var prefix = name + "=";
35 var begin = dc.indexOf("; " + prefix);
36 if (begin == -1) {
37 begin = dc.indexOf(prefix);
38 if (begin != 0) return null;
39 } else {
40 begin += 2;
41 }
42 var end = document.cookie.indexOf(";", begin);
43 if (end == -1) {
44 end = dc.length;
45 }
46 return unescape(dc.substring(begin + prefix.length, end));
47 }
48
49 /**
50 * Deletes the specified cookie.
51 *
52 * name name of the cookie
53 * [path] path of the cookie (must be same as path used to create cookie)
54 * [domain] domain of the cookie (must be same as domain used to create cookie)
55 */
56 function deleteCookie(name, path, domain) {
57 if (getCookie(name)) {
58 document.cookie = name + "=" +
59 ((path) ? "; path=" + path : "") +
60 ((domain) ? "; domain=" + domain : "") +
61 "; expires=Thu, 01-Jan-70 00:00:01 GMT";
62 }
63 }
64
65 // These two functions are based on code from
66 // http://www.quirksmode.org/viewport/compatibility.html
67
68 function getPageHeight(){
69 var y;
70 var test1 = document.body.scrollHeight;
71 var test2 = document.body.offsetHeight
72 if (test1 > test2) // all but Explorer Mac
73 {
74 y = document.body.scrollHeight;
75 }
76 else // Explorer Mac;
77 //would also work in Explorer 6 Strict, Mozilla and Safari
78 {
79 y = document.body.offsetHeight;
80 }
81 return parseInt(y);
82 }
83
84 function _getWindowHeight(){
85 if (self.innerWidth)
86 {
87 frameWidth = self.innerWidth;
88 frameHeight = self.innerHeight;
89 }
90 else if (document.documentElement && document.documentElement.clientWidth)
91 {
92 frameWidth = document.documentElement.clientWidth;
93 frameHeight = document.documentElement.clientHeight;
94 }
95 else if (document.body)
96 {
97 frameWidth = document.body.clientWidth;
98 frameHeight = document.body.clientHeight;
99 }
100 return parseInt(frameHeight);
101 }
102
103
104 function getScrollHeight(){
105 var y;
106 // all except Explorer
107 if (self.pageYOffset)
108 {
109 y = self.pageYOffset;
110 }
111 else if (document.documentElement && document.documentElement.scrollTop)
112 {
113 y = document.documentElement.scrollTop;
114 }
115 else if (document.body) // all other Explorers
116 {
117 y = document.body.scrollTop;
118 }
119 return parseInt(y)+_getWindowHeight();
120 }
121

  ViewVC Help
Powered by ViewVC 1.1.26