1/************************* 2 Coppermine Photo Gallery 3 ************************ 4 Copyright (c) 2003-2019 Coppermine Dev Team 5 v1.0 originally written by Gregory DEMAR 6 7 This program is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License version 3 9 as published by the Free Software Foundation. 10 11 ******************************************** 12 Coppermine version: 1.5.48 13 $HeadURL: https://svn.code.sf.net/p/coppermine/code/trunk/cpg1.5.x/js/scripts.js $ 14 $Revision: 8884 $ 15**********************************************/ 16 17// Object to hold javascript keyCodes for various keys 18var KEY_CODES = { 19 TAB : 9, 20 ENTER : 13 21}; 22 23var GB_ANIMATION = true; 24 25$(function() { 26 $(".cpg_zebra tr:even").addClass("tableb"); 27 $(".cpg_zebra tr:odd").addClass("tableb tableb_alternate"); 28}); 29 30function MM_openBrWindow(theURL,winName,features) { //v2.0 31 window.open(theURL,winName,features); 32} 33 34function writeCookie(name, data, noDays) { 35 if (js_vars.cookies_allowed == true) { 36 var cookieStr = name + "="+ data; 37 if (writeCookie.arguments.length > 2){ 38 cookieStr += "; expires=" + getCookieExpireDate(noDays); 39 } 40 document.cookie = cookieStr; 41 } 42} 43 44function readCookie(cookieName) { 45 var searchName = cookieName + "="; 46 var cookies = document.cookie; 47 var start = cookies.indexOf(cookieName); 48 if (start == -1){ // cookie not found 49 return ""; 50 } 51 start += searchName.length; //start of the cookie data 52 var end = cookies.indexOf(";", start); 53 if (end == -1){ 54 end = cookies.length; 55 } 56 return cookies.substring(start, end); 57} 58 59function blocking(nr, cookie, vis_state) { 60 display = ($("#" + nr).css('display') == 'none') ? vis_state : 'none'; 61 if (cookie != ''){ 62 writeCookie(nr, display); 63 } 64 $('#' + nr).css('display', display); 65} 66 67function show_section(e) { 68 $('#' + e).toggle(); 69} 70 71function expand() { 72 $("table[id^='section']").show(); 73} 74 75function hideall() { 76 $("table[id^='section']").hide(); 77} 78 79function selectAll(form_name) { 80 $('#' + form_name).data('boxes_checked', $('#' + form_name).data('boxes_checked') ? false : true); 81 $('#' + form_name + ' input:checkbox').each(function(){ 82 this.checked = $('#' + form_name).data('boxes_checked'); 83 }); 84} 85 86function redirect(url) { 87 window.location=url; 88} 89 90// Function used to not allow user to enter default username as username for comment 91function notDefaultUsername(f, defaultUsername, defaultUsernameMessage) { 92 // If username for comment is default username then display error message and return false 93 if (f.msg_author.value == defaultUsername || f.msg_author.value == '') { 94 alert(defaultUsernameMessage); 95 return false; 96 } 97 // By default return true 98 return true; 99} 100 101function HighlightAll(theField) { 102 var tempval=eval("document."+theField); 103 tempval.focus(); 104 tempval.select(); 105} 106 107var onloads = new Array(); 108 109function addonload(func){ 110 onloads.push(func); 111} 112 113/** 114 * sprintf() for JavaScript v.0.4 115 * 116 * Copyright (c) 2007 Alexandru Marasteanu <http://alexei.417.ro/> 117 * Thanks to David Baird (unit test and patch). 118 * 119 * This program is free software; you can redistribute it and/or modify it under 120 * the terms of the GNU General Public License as published by the Free Software 121 * Foundation; either version 2 of the License, or (at your option) any later 122 * version. 123 */ 124 125function str_repeat(i, m) { for (var o = []; m > 0; o[--m] = i); return(o.join('')); } 126 127function sprintf () { 128 var i = 0, a, f = arguments[i++], o = [], m, p, c, x; 129 while (f) { 130 if (m = /^[^\x25]+/.exec(f)) o.push(m[0]); 131 else if (m = /^\x25{2}/.exec(f)) o.push('%'); 132 else if (m = /^\x25(?:(\d+)\$)?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(f)) { 133 if (((a = arguments[m[1] || i++]) == null) || (a == undefined)) throw("Too few arguments."); 134 if (/[^s]/.test(m[7]) && (typeof(a) != 'number')) 135 throw("Expecting number but found " + typeof(a)); 136 switch (m[7]) { 137 case 'b': a = a.toString(2); break; 138 case 'c': a = String.fromCharCode(a); break; 139 case 'd': a = parseInt(a); break; 140 case 'e': a = m[6] ? a.toExponential(m[6]) : a.toExponential(); break; 141 case 'f': a = m[6] ? parseFloat(a).toFixed(m[6]) : parseFloat(a); break; 142 case 'o': a = a.toString(8); break; 143 case 's': a = ((a = String(a)) && m[6] ? a.substring(0, m[6]) : a); break; 144 case 'u': a = Math.abs(a); break; 145 case 'x': a = a.toString(16); break; 146 case 'X': a = a.toString(16).toUpperCase(); break; 147 } 148 a = (/[def]/.test(m[7]) && m[2] && a > 0 ? '+' + a : a);
149 c = m[3] ? m[3] == '0' ? '0' : m[3].charAt(1) : ' '; 150 x = m[5] - String(a).length; 151 p = m[5] ? str_repeat(c, x) : ''; 152 o.push(m[4] ? a + p : p + a); 153 } 154 else throw ("Huh ?!"); 155 f = f.substring(m[0].length); 156 } 157 return o.join(''); 158} 159// end function sprintf 160 161// PHP equivalent of stript_tags. 162// Source: http://phpjs.org 163function strip_tags (str, allowed_tags) { 164 // Strips HTML and PHP tags from a string 165 // 166 // version: 908.406 167 // discuss at: http://phpjs.org/functions/strip_tags 168 // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 169 // + improved by: Luke Godfrey 170 // + input by: Pul 171 // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 172 // + bugfixed by: Onno Marsman 173 // + input by: Alex 174 // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 175 // + input by: Marc Palau 176 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 177 // + input by: Brett Zamir (http://brett-zamir.me) 178 // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 179 // + bugfixed by: Eric Nagel 180 // + input by: Bobby Drake 181 // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 182 // + bugfixed by: Tomasz Wesolowski 183 // * example 1: strip_tags('<p>Kevin</p> <br /><b>van</b> <i>Zonneveld</i>', '<i><b>'); 184 // * returns 1: 'Kevin <b>van</b> <i>Zonneveld</i>' 185 // * example 2: strip_tags('<p>Kevin <img src="someimage.png" onmouseover="someFunction()">van <i>Zonneveld</i></p>', '<p>'); 186 // * returns 2: '<p>Kevin van Zonneveld</p>' 187 // * example 3: strip_tags("<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>", "<a>"); 188 // * returns 3: '<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>' 189 // * example 4: strip_tags('1 < 5 5 > 1'); 190 // * returns 4: '1 < 5 5 > 1' 191 var key = '', allowed = false; 192 var matches = []; 193 var allowed_array = []; 194 var allowed_tag = ''; 195 var i = 0; 196 var k = ''; 197 var html = ''; 198 var replacer = function (search, replace, str) { 199 return str.split(search).join(replace); 200 }; 201 // Build allowes tags associative array 202 if (allowed_tags) { 203 allowed_array = allowed_tags.match(/([a-zA-Z0-9]+)/gi); 204 } 205 str += ''; 206 // Match tags 207 matches = str.match(/(<\/?[\S][^>]*>)/gi); 208 // Go through all HTML tags 209 for (key in matches) { 210 if (isNaN(key)) { 211 // IE7 Hack 212 continue; 213 } 214 // Save HTML tag 215 html = matches[key].toString(); 216 // Is tag not in allowed list? Remove from str! 217 allowed = false; 218 // Go through all allowed tags 219 for (k in allowed_array) { 220 // Init 221 allowed_tag = allowed_array[k]; 222 i = -1; 223 if (i != 0) { i = html.toLowerCase().indexOf('<'+allowed_tag+'>');} 224 if (i != 0) { i = html.toLowerCase().indexOf('<'+allowed_tag+' ');} 225 if (i != 0) { i = html.toLowerCase().indexOf('</'+allowed_tag) ;} 226 227 // Determine 228 if (i == 0) { 229 allowed = true; 230 break; 231 } 232 } 233 if (!allowed) { 234 str = replacer(html, "", str); // Custom replace. No regexing 235 } 236 } 237 return str; 238} 239 240// Function to strip all html from given string. It replaces <br> with \n 241// This function is generally used to show error messages in js alert 242function strip_html(content) { 243 // We will first replace <br /> with \n 244 content = content.replace('<br>', '\n'); 245 content = content.replace('<br />', '\n'); 246 return strip_tags(content); 247} 248 249// 250function str_replace (search, replace, subject, count) { 251 // Replaces all occurrences of search in haystack with replace 252 // 253 // version: 908.406 254 // discuss at: http://phpjs.org/functions/str_replace 255 // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 256 // + improved by: Gabriel Paderni 257 // + improved by: Philip Peterson 258 // + improved by: Simon Willison (http://simonwillison.net) 259 // + revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com) 260 // + bugfixed by: Anton Ongson 261 // + input by: Onno Marsman 262 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 263 // + tweaked by: Onno Marsman 264 // + input by: Brett Zamir (http://brett-zamir.me) 265 // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 266 // + input by: Oleg Eremeev 267 // + improved by: Brett Zamir (http://brett-zamir.me) 268 // + bugfixed by: Oleg Eremeev 269 // % note 1: The count parameter must be passed as a string in order 270 // % note 1: to find a global variable in which the result will be given 271 // * example 1: str_replace(' ', '.', 'Kevin van Zonneveld'); 272 // * returns 1: 'Kevin.van.Zonneveld' 273 // * example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars'); 274 // * returns 2: 'hemmo, mars' 275 var i = 0, j = 0, temp = '', repl = '', sl = 0, fl = 0, 276 f = [].concat(search), 277 r = [].concat(replace), 278 s = subject, 279 ra = r instanceof Array, sa = s instanceof Array; 280 s = [].concat(s); 281 if (count) { 282 this.window[count] = 0; 283 } 284 285 for (i=0, sl=s.length; i < sl; i++) { 286 if (s[i] === '') { 287 continue; 288 } 289 for (j=0, fl=f.length; j < fl; j++) { 290 temp = s[i]+''; 291 repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0]; 292 s[i] = (temp).split(f[j]).join(repl); 293 if (count && s[i] !== temp) { 294 this.window[count] += (temp.length-s[i].length)/f[j].length;} 295 } 296 } 297 return sa ? s : s[0]; 298} 299 300// This prototype is from the public domain. 301// Source: http://www.hunlock.com/blogs/Mastering_Javascript_Arrays 302Array.prototype.find = function(searchStr) { 303 var returnArray = false; 304 for (i=0; i<this.length; i++) { 305 if (typeof(searchStr) == 'function') { 306 if (searchStr.test(this[i])) { 307 if (!returnArray) { returnArray = []; } 308 returnArray.push(i); 309 } 310 } else { 311 if (this[i]===searchStr) { 312 if (!returnArray) { returnArray = []; } 313 returnArray.push(i); 314 } 315 } 316 } 317 return returnArray; 318};
319// end function prototype array.find 320 321 322//This prototype is provided by the Mozilla foundation and 323//is distributed under the MIT license. 324//http://www.ibiblio.org/pub/Linux/LICENSES/mit.license 325 326if (!Array.prototype.indexOf) 327{ 328 Array.prototype.indexOf = function(elt /*, from*/) 329 { 330 var len = this.length; 331 332 var from = Number(arguments[1]) || 0; 333 from = (from < 0) 334 ? Math.ceil(from) 335 : Math.floor(from); 336 if (from < 0) 337 from += len; 338 339 for (; from < len; from++) 340 { 341 if (from in this && 342 this[from] === elt) 343 return from; 344 } 345 return -1; 346 }; 347} 348// end function prototype array.indexOf 349 350$(document).ready(function() { 351 for (func in onloads) { 352 eval(onloads[func]); 353 } 354 355 //hide all elements with class detail_body 356 $(".detail_body").hide(); 357 //toggle the component with class detail_body 358 $(".detail_head_collapsed").click(function() 359 { 360 $(this).toggleClass("detail_head_expanded").next(".detail_body").slideToggle(600); 361 }); 362 $(".detail_expand_all").click(function() 363 { 364 $(".detail_body").slideDown(1200); 365 $(".detail_head_collapsed").addClass("detail_head_expanded"); 366 $(".detail_expand_all").hide(); 367 $(".detail_collapse_all").show(); 368 369 }); 370 $(".detail_collapse_all").click(function() 371 { 372 $(".detail_body").slideUp(1200); 373 $(".detail_head_collapsed").removeClass("detail_head_expanded"); 374 $(".detail_expand_all").show(); 375 $(".detail_collapse_all").hide(); 376 377 }); 378 $(".detail_toggle_all").click(function() 379 { 380 $(".detail_body").slideToggle(600); 381 $(".detail_head_collapsed").toggleClass("detail_head_expanded"); 382 }); 383 384 // Greybox plugin initialization for the help system 385 $("a.greybox").click(function(){ 386 var t = this.title || $(this).text() || this.href; 387 GB_show(t,this.href,470,600); 388 return false; 389 }); 390 $("a.greyboxfull").click(function(){ 391 var t = this.title || $(this).text() || this.href; 392 GB_show(t,this.href,700,800); 393 return false; 394 }); 395 $('.elastic').elastic(); 396 397 //hide all elements with class noscript 398 $(".noscript").hide(); 399});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.