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