[ Index ] |
|
Code source de LifeType 1.2.4 |
1 function externalLinks() 2 { 3 if (!document.getElementsByTagName) return; 4 5 var anchors = document.getElementsByTagName("a"); 6 7 for (var i = 0; i < anchors.length; i++) 8 { 9 var anchor = anchors[i]; 10 11 if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") 12 { 13 anchor.target = "_blank"; 14 } 15 } 16 } 17 18 window.onload = externalLinks; 19 20 function verifyOneCheckMinimum(formName, msg, prefix) 21 { 22 n = "all"; 23 24 if (prefix) 25 { 26 n = prefix + n; 27 } 28 29 f = document.getElementById(formName); 30 i = 0; 31 j = 0; 32 33 while (e = f.elements[i]) 34 { 35 if (e.type == "checkbox" && e.id != n && e.checked) 36 { 37 if (!prefix || e.id.indexOf(prefix) != -1) 38 { 39 j++; 40 } 41 } 42 43 i++; 44 } 45 46 result = (j > 0); 47 48 if (!result && msg) 49 { 50 alert(msg); 51 } 52 53 return result; 54 } 55 56 function submitForm(formName, opValue, msg) 57 { 58 if (msg) 59 { 60 if (!verifyOneCheckMinimum(formName)) 61 { 62 alert(msg); 63 return false; 64 } 65 } 66 67 f = document.getElementById(formName); 68 f.op.value = opValue; 69 return true; 70 } 71 72 function toggleAllChecks(formName, prefix) 73 { 74 n = "all"; 75 76 if (prefix) 77 { 78 n = prefix + n; 79 } 80 81 i = 0; 82 e = document.getElementById(n); 83 s = e.checked; 84 f = document.getElementById(formName); 85 86 while (e = f.elements[i]) 87 { 88 if (e.type == "checkbox" && e.id != n) 89 { 90 if (!prefix || e.id.indexOf(prefix) != -1) 91 { 92 e.checked = s; 93 } 94 } 95 96 i++; 97 } 98 } 99 100 // In LifeType 1.2 imeplemtation, we don't have the Role object. 101 // So, I just defined two kind of permission group here, it can help user configure thier blog user permission easily. 102 var permissionSets = new Array(); 103 permissionSets["basic_blog_permission"] = new Array( 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 22, 23, 24, 25, 26, 36, 37 ); 104 permissionSets["full_blog_permission"] = new Array( 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 ); 105 106 function togglePermissionSets(formName, permissionSet) 107 { 108 if(permissionSet == "") 109 return; 110 111 f = document.getElementById(formName); 112 i = 0; 113 while (e = f.elements[i]) 114 { 115 if (e.type == "checkbox" && e.id != "sendNotification") 116 { 117 if( inArray(permissionSets[permissionSet], e.value) ) 118 e.checked = 1; 119 else 120 e.checked = 0; 121 } 122 i++; 123 } 124 } 125 126 // Returns true if the passed value is found in the 127 // array. Returns false if it is not. 128 function inArray(a, v, c) 129 { 130 var i; 131 for (i=0; i < a.length; i++) { 132 // use === to check for Matches. ie., identical (===), 133 if(c){ //performs match even the string is case sensitive 134 if (a[i].toLowerCase() == v.toLowerCase()) { 135 return true; 136 } 137 }else{ 138 if (a[i] == v) { 139 return true; 140 } 141 } 142 } 143 return false; 144 } 145 146 function confirmDlg(l, msg) 147 { 148 if (confirm(msg)) 149 { 150 if (typeof(l) == 'string') 151 { 152 document.location.href = l; 153 } 154 else 155 { 156 document.location.href = l.href; 157 } 158 } 159 160 return false; 161 } 162 163 function popUp(l, n, f) 164 { 165 if (!window.focus) 166 { 167 return true; 168 } 169 170 if (typeof(l) == 'string') 171 { 172 window.open(l, n, f); 173 } 174 else 175 { 176 window.open(l.href, n, f); 177 } 178 179 return false; 180 } 181 182 function goTo(l) 183 { 184 window.location.href = l; 185 } 186 187 function goToIf(l, msg) 188 { 189 if (confirm(msg)) 190 { 191 window.location.href = l; 192 } 193 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |