[ Index ] |
|
Code source de Plume CMS 1.2.2 |
1 /* ***** BEGIN LICENSE BLOCK ***** 2 * This file is part of Plume CMS, a website management application. 3 * Copyright (C) 2001-2005 Loic d'Anterroches and contributors. 4 * 5 * Plume CMS is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * Plume CMS is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 * 19 * ***** END LICENSE BLOCK ***** */ 20 21 function catChangePath(idArray) 22 { 23 if (document.formPost.c_path.value == '') { 24 document.formPost.c_path.value = idArray[document.formPost.c_parentid.value]; 25 } 26 } 27 28 function setUrl(titleField, urlField, param, param2) 29 { 30 url = document.getElementById(urlField); 31 title = document.getElementById(titleField); 32 if (param == 'cat') { 33 if (document.getElementById('quirk_category_path').value == 0) { 34 urlFromTitle = titleToUrl(title.value,'cat'); 35 url.value = param2[document.formPost.c_parentid.value] + urlFromTitle + '/'; 36 } 37 } else { 38 if (param2 == 0) { 39 url.value = titleToUrl(title.value,'art'); 40 } 41 } 42 } 43 44 function titleToUrl(string, type) 45 { 46 if (type == 'art') { 47 return string.replace(/([^a-z0-9 ])/ig, replaceFunc).replace(/[^a-z0-9 ]/ig, 48 '').replace(/ /g, '-').replace(/^([0-9]+)/ig, 49 '').replace(/([\-]+)$/ig, '').replace(/([\-]+)/ig, '-').replace(/([0-9\-]+)$/ig, '').replace(/([\-]+)$/ig, '').replace(/^([\-]+)/ig, ''); 50 } else { 51 return string.replace(/([^a-z0-9 ])/ig, replaceFunc).replace(/[^a-z0-9 ]/ig, 52 '').replace(/ /g, '-').replace(/([\-]+)/ig, '-').replace(/([\-]+)$/ig, '').replace(/^([\-]+)/ig, ''); 53 } 54 } 55 56 /** str: matched substring 57 p1: parenthetical match 58 offset: offset within the string 59 s: string itself 60 */ 61 function replaceFunc(str, p1, offset, s) 62 { 63 notclean = new String(unescape("%C0%C1%C2%C3%C4%C5%E0%E1%E2%E3%E4%E5%D2%D3%D4%D5%D6%D8%F2%F3%F4%F5%F6%F8%C8%C9%CA%CB%E8%E9%EA%EB%CC%CD%CE%CF%EC%ED%EE%EF%D9%DA%DB%DC%F9%FA%FB%FC%FF%D1%F1%E7%FD%DD%u0161%u0160%u011B%u011A%u010D%u010C%u0159%u0158%u017E%u017D%u016F%u016E%u0148%u0147%u010F%u010E%u0165%u0164%u013E%u013D%u013A%u0139%u0155%u0154")); 64 clean = new String("AAAAAAaaaaaaOOOOOOooooooEEEEeeeeIIIIiiiiUUUUuuuuyNncyYsSeEcCrRzZuUnNdDtTlLlLrR"); 65 idx = notclean.indexOf(str); 66 if (idx != -1) { 67 return clean.charAt(idx); 68 } else { 69 return ' '; 70 } 71 } 72 73 function openClose(id,mode) 74 { 75 if(document.getElementById) { 76 element = document.getElementById(id); 77 img = document.getElementById('img_' + id); 78 } else if(document.all) { 79 element = document.all[id]; 80 img = document.all['img_' + id]; 81 } else return; 82 83 if(element.style) { 84 if(mode == 0) { 85 if(element.style.display == 'block' ) { 86 element.style.display = 'none'; 87 img.src = 'themes/'+pxThemeid+'/images/plus.png'; 88 } else { 89 element.style.display = 'block'; 90 img.src = 'themes/'+pxThemeid+'/images/minus.png'; 91 } 92 } else if(mode == 1) { 93 element.style.display = 'block'; 94 img.src = 'themes/'+pxThemeid+'/images/minus.png'; 95 } else if(mode == -1) { 96 element.style.display = 'none'; 97 img.src = 'themes/'+pxThemeid+'/images/plus.png'; 98 } 99 } 100 } 101 102 function openCloseSpan(id,mode) 103 { 104 if(document.getElementById) { 105 element = document.getElementById(id); 106 } else if(document.all) { 107 element = document.all[id]; 108 } else return; 109 110 if(element.style) { 111 if(mode == 0) { 112 if(element.style.display == 'inline' ) { 113 element.style.display = 'none'; 114 } else { 115 element.style.display = 'inline'; 116 } 117 } else if(mode == 1) { 118 element.style.display = 'inline'; 119 } else if(mode == -1) { 120 element.style.display = 'none'; 121 } 122 } 123 } 124 125 function openCloseBlockIf(id, idsource, cond, mode, modeelse) 126 { 127 if(document.getElementById) { 128 element = document.getElementById(id); 129 sourceel = document.getElementById(idsource); 130 } else if(document.all) { 131 element = document.all[id]; 132 sourceel = document.all[idsource]; 133 } else return; 134 135 if (sourceel.value == cond) { 136 openCloseBlock(id,mode); 137 } else { 138 openCloseBlock(id,modeelse); 139 } 140 } 141 142 // function in_array(needle,haystack) 143 // craig heydenburg 4/8/02 144 // this function is similar to the PHP function of the same name 145 function in_array(value, array) 146 { 147 var bool = false; 148 for (var i=0; i<array.length; i++) { 149 if (array[i]== value) { bool=true; } 150 } 151 return bool; 152 } 153 154 function openCloseBlockIfArray(id, idsource, cond, mode, modeelse) 155 { 156 if(document.getElementById) { 157 element = document.getElementById(id); 158 sourceel = document.getElementById(idsource); 159 } else if(document.all) { 160 element = document.all[id]; 161 sourceel = document.all[idsource]; 162 } else return; 163 164 if (in_array(sourceel.value,cond)) { 165 openCloseBlock(id,mode); 166 } else { 167 openCloseBlock(id,modeelse); 168 } 169 170 } 171 172 function openCloseBlock(id,mode) 173 { 174 if(document.getElementById) { 175 element = document.getElementById(id); 176 } else if(document.all) { 177 element = document.all[id]; 178 } else return; 179 180 if(element.style) { 181 if(mode == 0) { 182 if(element.style.display == 'block' ) { 183 element.style.display = 'none'; 184 } else { 185 element.style.display = 'block'; 186 } 187 } else if(mode == 1) { 188 element.style.display = 'block'; 189 } else if(mode == -1) { 190 element.style.display = 'none'; 191 } 192 } 193 } 194 195 function mOpenClose(idArray,mode) 196 { 197 for(var i=0;i<idArray.length;i++) 198 { 199 openClose(idArray[i],mode); 200 } 201 } 202 203 function popup(url) 204 { 205 window.open(url,'dc_popup', 206 'alwaysRaised=yes,toolbar=no,height=450,width=480,menubar=no,resizable=yes,scrollbars=yes,status=no'); 207 } 208 209 function insertTextIn(formObj,text) 210 { 211 formObj.value += text; 212 } 213 214 function insertImage(origine,url,act,text) 215 { 216 form = origine.forms['formPost']; 217 if (form.n_content_format) format = form.n_content_format.value; 218 else if (form.a_description_format) format = form.a_description_format.value; 219 else if (form.a_page_content_format) format = form.a_page_content_format.value; 220 else if (form.c_format) format = form.c_format.value; 221 222 223 title = window.prompt(text); 224 225 if (act == 'img') { 226 if (format == 'wiki') 227 { 228 if (title != '') { 229 image = '(('+url+'|'+title+'))'; 230 } else { 231 image = '(('+url+'))'; 232 } 233 } 234 else 235 { 236 image = '<p><img src="'+url+'" alt="'+title+'" /></p>'; 237 } 238 } else { 239 if (format == 'wiki') 240 { 241 if (title != '') { 242 image = '['+title+'|'+url+']'; 243 } else { 244 image = '['+url+']'; 245 } 246 } 247 else 248 { 249 image = '<p><a href="'+url+'">'+title+'</a></p>'; 250 } 251 252 } 253 254 image = "\n\n"+image; 255 256 if (tb && format != 'wiki') { 257 tb.syncContents('iframe'); 258 } 259 260 if (form.n_content) form.n_content.value += image; 261 else if (form.a_description) form.a_description.value += image; 262 else if (form.a_page_content) form.a_page_content.value += image; 263 else if (form.c_description) form.c_description.value += image; 264 265 if (tb && format != 'wiki') { 266 tb.syncContents('textarea'); 267 } 268 269 270 } 271 272 function isFilled(elm) { 273 if (elm.value == "" || 274 elm.value == null) 275 return false; 276 else return true; 277 } 278 function isReady(name, text) { 279 arr = document.getElementsByName(name); 280 inpt = arr.item(0); 281 if (isFilled(inpt) == false) { 282 alert (text); 283 inpt.focus(); 284 return false; 285 } 286 return true; 287 } 288 289 290 /* Taken from: http://simon.incutio.com/archive/2004/05/26/addLoadEvent */ 291 function addLoadEvent(func) { 292 var oldonload = window.onload; 293 if (typeof window.onload != 'function') { 294 window.onload = func; 295 } else { 296 window.onload = function() { 297 if (oldonload) { 298 oldonload(); 299 } 300 func(); 301 } 302 } 303 } 304
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 11:57:01 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |