1/** 2 * Define Javascript function for refreshing attachments lists 3 * 4 * Copyright (C) 2010-2016 Jonathan M. Cameron, All Rights Reserved 5 * License: https://www.gnu.org/licenses/gpl-3.0.html GNU/GPL 6 * 7 * By Jonathan Cameron 8 * 9 * @param siteURL string the site base URL for the request 10 * @param ptype string parent_type for the attachments list parent 11 * @param pentity string parent_entity for the attachments list parent 12 * @param pid integer parent_id for the attachments list parent 13 * @param lang the current language ('' if not specified) 14 * @param from string the 'from' clause to pass in the request 15 */ 16 17function refreshAttachments(siteUrl, ptype, pentity, pid, lang, from) 18{ 19 // phpcs:disable 20 let id = "attachmentsList_" + ptype + "_" + pentity + "_" + pid, 21 alist = document.getElementById(id), 22 url = `${siteUrl}/index.php?option=com_attachments&task=attachmentsList`; 23 url += `&parent_id=${pid}`; 24 url += `&parent_type=${ptype}&parent_entity=${pentity}`; 25 url += `&lang=${lang}`; 26 url += `&from=${from}&tmpl=component&format=raw`; 27 // phpcs:enable 28 if (!alist) { 29 alist = window.parent.document.getElementById(id); 30 } 31 if (!alist) { 32 id = "attachmentsList_" + ptype + "_default_" + pid; 33 alist = window.parent.document.getElementById(id); 34 } 35 fetch(new Request(url, {method: "GET"})) 36 .then(function (response) { 37 if (response.status == 200) { 38 return response.text(); 39 } else { 40 return Promise.reject(response); 41 } 42 }) 43 .then(html => { 44 alist.innerHTML = html; 45 }) 46 .catch(reason => console.log(reason)); 47}; 48 49
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.