-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcommon.js
executable file
·96 lines (75 loc) · 1.84 KB
/
common.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* common.js
2009-10-26 created by Tantek Çelik http://tantek.com
NOTES:
This uses code from CASSIS V0 by Tantek Celik http://tantek.com
http://tantek.pbworks.com/CassisProject
http://creativecommons.org/licenses/by-sa/3.0/
--------------------------------------------------------------------- */
/* cassis0.js */
function js() {
return ("00"==false);
}
function strcat($s1,$s2) {
if (js()) { return $s1 + $s2; }
else { return $s1 . $s2; }
}
/* end cassis0.js */
/* cassis0php.js - processed only by javascript */
// ?>
<!-- <? $js=<<<EJS
/* --> /**/
function strlen(s) {
return s.length;
}
function ord(s) {
return s.charCodeAt(0);
}
function substr(s,o,n) {
var m = strlen(s);
if (Math.abs(o)>=m) return false;
if (o<0) o=m+o;
if (n<0) n=m-o+n;
return s.substring(o,o+n);
}
function explode(d,s,n) {
return s.split(d,n);
}
function rawurlencode(s) {
return encodeURIComponent(s);
}
function htmlspecialchars(s) {
var c= [["&","&"],["<","<"],[">",">"],["'","'"],['"',"""]];
for (i=0;i<c.length;i++) {
s = s.replace(c[i][0],c[i][1]);
}
return s;
}
function str_ireplace(a,b,s) {
return s.replace(new RegExp(a,"gi"),b);
}
/* more javascript-only functions here */
/*
EJS;
/**/
/* end cassis0php.js */
/* functions written in CASSIS V0 */
function webaddresstouri($wa) {
if ((substr($wa,0,7) == "http://") || (substr($wa,0,8) == "https://")) {
return $wa;
}
if (substr($wa,0,1) == "@") {
return strcat("http://twitter.com/",substr($wa,1,strlen($wa)));
}
return strcat("http://",$wa);
}
function uriclean($uri) {
$uri = webaddresstouri($uri);
// prune the optional http:// for a neater param
if (substr($uri, 0,7) == "http://") {
$uri = explode("://",$uri,2);
$uri = $uri[1];
}
// URL encode
return str_ireplace("%2F","/",rawurlencode($uri));
}
/* end functions written in CASSIS V0 */