diff --git a/KiwixWebApp.jsproj b/KiwixWebApp.jsproj index 6f85c02e..8e76d2c7 100644 --- a/KiwixWebApp.jsproj +++ b/KiwixWebApp.jsproj @@ -178,6 +178,7 @@ + diff --git a/bin/Release/AppX/resources.pri b/bin/Release/AppX/resources.pri index 38c07962..1cb94da7 100644 Binary files a/bin/Release/AppX/resources.pri and b/bin/Release/AppX/resources.pri differ diff --git a/bin/Release/AppX/vs.appxrecipe b/bin/Release/AppX/vs.appxrecipe index 8f852811..57af36c7 100644 --- a/bin/Release/AppX/vs.appxrecipe +++ b/bin/Release/AppX/vs.appxrecipe @@ -32,7 +32,7 @@ AppxManifest.xml true - 2017-08-31T09:18:37.777 + 2017-09-01T12:03:24.182 @@ -475,7 +475,7 @@ www\index.html - 2017-08-31T09:18:23.126 + 2017-08-31T17:39:13.678 www\favicon.ico @@ -603,7 +603,7 @@ www\js\app.js - 2017-08-30T21:02:22.332 + 2017-09-01T12:02:28.680 www\js\init.js @@ -625,6 +625,10 @@ www\js\lib\jquery-3.2.1.slim.js 2017-07-10T18:00:56.198 + + www\js\lib\kiwixServe.js + 2017-09-01T12:03:14.501 + www\js\lib\q.js 2017-07-19T09:47:27.642 @@ -635,7 +639,7 @@ www\js\lib\transformStyles.js - 2017-08-29T20:22:39.602 + 2017-09-01T11:35:16.002 www\js\lib\uiUtil.js @@ -647,7 +651,7 @@ www\js\lib\util.js - 2017-08-31T09:11:08.245 + 2017-09-01T11:56:11.733 www\js\lib\xzdec.js @@ -1528,7 +1532,7 @@ resources.pri true - 2017-08-31T07:00:06.005 + 2017-09-01T12:02:47.117 diff --git a/bin/Release/AppX/www/index.html b/bin/Release/AppX/www/index.html index fa26a196..ea9ab6ff 100644 --- a/bin/Release/AppX/www/index.html +++ b/bin/Release/AppX/www/index.html @@ -297,10 +297,11 @@

Download links

-
Files can be very large, do not attempt to download over a mobile connection! + Files can be very large, do not attempt to download over a mobile connection!
Open full list of download links : Warning: requires active Internet connection and will use data

+
diff --git a/bin/Release/AppX/www/js/app.js b/bin/Release/AppX/www/js/app.js index 2acfdc2b..7ce176ee 100644 --- a/bin/Release/AppX/www/js/app.js +++ b/bin/Release/AppX/www/js/app.js @@ -26,8 +26,8 @@ // This uses require.js to structure javascript: // http://requirejs.org/docs/api.html#define -define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'abstractFilesystemAccess', 'q', 'module', 'transformStyles'], - function ($, zimArchiveLoader, util, uiUtil, cookies, abstractFilesystemAccess, q, module, transformStyles) { +define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'abstractFilesystemAccess', 'q', 'module', 'transformStyles', 'kiwixServe'], + function ($, zimArchiveLoader, util, uiUtil, cookies, abstractFilesystemAccess, q, module, transformStyles, kiwixServe) { /** * Maximum number of articles to display in a search @@ -328,6 +328,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'abstractFile $('#articleContent').hide(); $('#searchingForArticles').hide(); $('#downloadLinks').hide(); + $('#serverResponse').hide(); refreshAPIStatus(); //If user hadn't previously picked a folder or a file, resort to the local storage folder (UWP functionality) if (params.localStorage && !params.pickedFolder && !params.pickedFile) { @@ -399,7 +400,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'abstractFile } }); document.getElementById('downloadTrigger').addEventListener('click', function () { - util.requestDownloadLinks(params.kiwixDownloadLink); + kiwixServe.requestDownloadLinks(params.kiwixDownloadLink); }); $('input:radio[name=contentInjectionMode]').on('change', function (e) { diff --git a/bin/Release/AppX/www/js/lib/kiwixServe.js b/bin/Release/AppX/www/js/lib/kiwixServe.js new file mode 100644 index 00000000..7382874a --- /dev/null +++ b/bin/Release/AppX/www/js/lib/kiwixServe.js @@ -0,0 +1,373 @@ +/** + * languageCodes.js: Provides an object literal for looking up the English-language names of language codes + * as defined in ISO 639-1, augmented with some ISO 639-3 codes as used by Wikipedia + * + * This file is part of Kiwix. + * + * Kiwix is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + */ +'use strict'; + +define([], function () { + + var langCodes = { + ab: 'Abkhazian', + aa: 'Afar', + af: 'Afrikaans', + ak: 'Akan', + sq: 'Albanian', + am: 'Amharic', + ar: 'Arabic', + an: 'Aragonese', + hy: 'Armenian', + as: 'Assamese', + av: 'Avaric', + ae: 'Avestan', + ay: 'Aymara', + az: 'Azerbaijani', + bm: 'Bambara', + ba: 'Bashkir', + eu: 'Basque', + be: 'Belarusian', + bn: 'Bengali (Bangla)', + bh: 'Bihari', + bi: 'Bislama', + bs: 'Bosnian', + br: 'Breton', + bg: 'Bulgarian', + my: 'Burmese', + ca: 'Catalan', + ch: 'Chamorro', + ce: 'Chechen', + ny: 'Chichewa-Chewa-Nyanja', + zh: 'Chinese', + zh: 'Chinese', + cv: 'Chuvash', + kw: 'Cornish', + co: 'Corsican', + cr: 'Cree', + hr: 'Croatian', + cs: 'Czech', + da: 'Danish', + dv: 'Divehi-Dhivehi-Maldivian', + nl: 'Dutch', + dz: 'Dzongkha', + en: 'English', + eo: 'Esperanto', + et: 'Estonian', + ee: 'Ewe', + fo: 'Faroese', + fj: 'Fijian', + fi: 'Finnish', + fr: 'French', + ff: 'Fula-Fulah-Pulaar-Pular', + gl: 'Galician', + gd: 'Gaelic (Scottish)', + gv: 'Gaelic (Manx)', + ka: 'Georgian', + de: 'German', + el: 'Greek', + kl: 'Greenlandic-Kalaallisut', + gn: 'Guarani', + gu: 'Gujarati', + ht: 'Haitian Creole', + ha: 'Hausa', + he: 'Hebrew', + hz: 'Herero', + hi: 'Hindi', + ho: 'Hiri Motu', + hu: 'Hungarian', + is: 'Icelandic', + io: 'Ido', + ig: 'Igbo', + id: 'Indonesian', + in: 'Indonesian', + ia: 'Interlingua', + ie: 'Interlingue', + iu: 'Inuktitut', + ik: 'Inupiak', + ga: 'Irish', + it: 'Italian', + ja: 'Japanese', + jv: 'Javanese', + kn: 'Kannada', + kr: 'Kanuri', + ks: 'Kashmiri', + kk: 'Kazakh', + km: 'Khmer', + ki: 'Kikuyu', + rw: 'Kinyarwanda (Rwanda)', + rn: 'Kirundi', + ky: 'Kyrgyz', + kv: 'Komi', + kg: 'Kongo', + ko: 'Korean', + ku: 'Kurdish', + kj: 'Kwanyama', + lo: 'Lao', + la: 'Latin', + lv: 'Latvian (Lettish)', + li: 'Limburgish ( Limburger)', + ln: 'Lingala', + lt: 'Lithuanian', + lu: 'Luga-Katanga', + lg: 'Luganda-Ganda', + lb: 'Luxembourgish', + mk: 'Macedonian', + mg: 'Malagasy', + ms: 'Malay', + ml: 'Malayalam', + mt: 'Maltese', + mi: 'Maori', + mr: 'Marathi', + mh: 'Marshallese', + mo: 'Moldavian', + mn: 'Mongolian', + na: 'Nauru', + nv: 'Navajo', + ng: 'Ndonga', + nd: 'Northern Ndebele', + ne: 'Nepali', + no: 'Norwegian', + nb: 'Norwegian bokmål', + nn: 'Norwegian nynorsk', + ii: 'Nuosu (Sichuan Yi)', + oc: 'Occitan', + oj: 'Ojibwe', + cu: 'Old Church Slavonic-Old Bulgarian', + or: 'Oriya', + om: 'Oromo (Afaan Oromo)', + os: 'Ossetian', + pi: 'Pāli', + ps: 'Pashto-Pushto', + fa: 'Persian (Farsi)', + pl: 'Polish', + pt: 'Portuguese', + pa: 'Punjabi (Eastern)', + qu: 'Quechua', + rm: 'Romansh', + ro: 'Romanian', + ru: 'Russian', + se: 'Sami', + sm: 'Samoan', + sg: 'Sango', + sa: 'Sanskrit', + sr: 'Serbian', + sh: 'Serbo-Croatian', + st: 'Sesotho', + tn: 'Setswana', + sn: 'Shona', + sd: 'Sindhi', + si: 'Sinhalese', + ss: 'Siswati', + sk: 'Slovak', + sl: 'Slovenian', + so: 'Somali', + nr: 'Southern Ndebele', + es: 'Spanish', + su: 'Sundanese', + sw: 'Swahili (Kiswahili)', + sv: 'Swedish', + tl: 'Tagalog', + ty: 'Tahitian', + tg: 'Tajik', + ta: 'Tamil', + tt: 'Tatar', + te: 'Telugu', + th: 'Thai', + bo: 'Tibetan', + ti: 'Tigrinya', + to: 'Tonga', + ts: 'Tsonga', + tr: 'Turkish', + tk: 'Turkmen', + tum: 'Tumbuka', + tw: 'Twi', + ug: 'Uyghur', + uk: 'Ukrainian', + ur: 'Urdu', + uz: 'Uzbek', + ve: 'Venda', + vi: 'Vietnamese', + vo: 'Volapük', + wa: 'Wallon', + cy: 'Welsh', + wo: 'Wolof', + fy: 'Western Frisian', + xh: 'Xhosa', + yi: 'Yiddish', + ji: 'Yiddish', + yo: 'Yoruba', + za: 'Zhuang-Chuang', + zu: 'Zulu' + }; + + function requestDownloadLinks(URL, lang) { + var xhttp = new XMLHttpRequest(); + xhttp.onreadystatechange = function () { + var downloadLinks = document.getElementById('downloadLinks'); + var serverResponse = document.getElementById('serverResponse'); + serverResponse.innerHTML = "Server response: Waiting..."; + serverResponse.style.display = "inline"; + if (this.readyState == 4 && this.status == 200) { + serverResponse.innerHTML = "Server response: 200 OK (data received)"; + var doc = this.responseText; + if (/\.meta4$/i.test(URL)) { + //It's the metalink with download links + var linkArray = doc.match(/]*>[^<]*<\/url>/ig); + var size = doc.match(/(\d+)<\/size>/i); + //Filter value (add commas if required) + size = size.length ? size[1] : ""; + var megabytes = size ? Math.round(size * 10 / (1024 * 1024)) / 10 : size; + //Use the lookbehind reversal trick to add commas.... + size = size.toString().split('').reverse().join('').replace(/(\d{3}(?!.*\.|$))/g, '$1,').split('').reverse().join(''); + var megabytes$ = megabytes.toString().split('').reverse().join('').replace(/(\d{3}(?!.*\.|$))/g, '$1,').split('').reverse().join(''); + doc = ""; + //NB we'ere intentionally discarding first link to kiwix.org (not to zim) + var mirrorservice = false; + for (var i = 1; i < linkArray.length; i++) { + if (/mirrorservice\.org/i.test(linkArray[i])) { + mirrorservice = true; + doc += linkArray[i].replace(/]*>([^<]*)<\/url>/i, '
  • *** Server has download bug, see note ***
    $1
  • \r\n'); + } else { + doc += linkArray[i].replace(/]*>([^<]*)<\/url>/i, '
  • $1
  • \r\n'); + } + } + var headerDoc = 'We found the following links to your file:'; + var bodyDoc = " 200 ? ' style="color:red;"> WARNING: ' : '>'; + bodyDoc += 'File size is ' + (megabytes ? megabytes$ + 'MB' : 'unnown') + '' + (size ? ' (' + size + ' bytes)' : '') + '\r\n'; + if (megabytes > 4000) bodyDoc += '

    This file is larger than the maximum file size permitted on an SD card formatted as FAT32 (max size is approx. 4GB). If your card or other storage area is formatted in this way, you will need to download a split version of this file: see Frequently Asked Questions.

    \r\n'; + if (megabytes > 200) bodyDoc += '

    Consider using a torrent download method: see About section

    \r\n'; + bodyDoc += '

    Links will open in a new browser window

      \r\n' + doc + '
    \r\n'; + if (mirrorservice) bodyDoc += '*** Note: mirrorservice.org currently has a download bug with ZIM archives: on some browsers it will download the ZIM file as plain text in browser window

    '; + bodyDoc += '<< Back to list of files

    '; + var header = document.getElementById('dl-panel-heading'); + header.outerHTML = header.outerHTML.replace(/]*)>[\s\S]*?<\/pre>/i, '' + headerDoc + ''); + var body = document.getElementById('dl-panel-body'); + body.outerHTML = body.outerHTML.replace(/]*)>[\s\S]*?<\/pre>/i, '' + bodyDoc + ''); + downloadLinks.innerHTML = downloadLinks.innerHTML.replace(/Index\s+of/ig, "File in"); + if (megabytes > 4000) downloadLinks.innerHTML = downloadLinks.innerHTML.replace(/panel-success/i, "panel-danger"); + if (megabytes > 200) downloadLinks.innerHTML = downloadLinks.innerHTML.replace(/panel-success/i, "panel-warning"); + var langSel = document.getElementById("langs"); + //Set chosen value in language selector (really this is for return) + if (langSel) { + langs.value = lang; + } + //Add event listener for click on return link, to go back to list of archives + document.getElementById('returnLink').addEventListener('click', function (e) { + var langSel = document.getElementById("langs"); + //var langID = langSel ? langSel.options[langSel.selectedIndex].value : ""; + var langID = langSel ? langs.value : ""; + langID = langID == "All" ? "" : langID; + requestDownloadLinks(this.dataset.kiwixDl, langID); + }); + return; + } + //Remove images + var doc = doc.replace(/]*>\s*/ig, ""); + //Reduce size of header + doc = doc.replace(/]*>[^<]*<\/)h1>/ig, ""); + //Limit height of pre box and prevent word wrapping + doc = doc.replace(/
    /i, '
    \r\n' + + '
    $#$#
    \r\n' + + '
    ');
    +                //Remove hr at end of page and add extra 
    + doc = doc.replace(/]*>(\s*<\/pre>)/i, "$1"); + //Move header into panel-header (NB regex is deliberately redundant to increase specificity of search) + doc = doc.replace(/\$\#\$\#([\s\S]+?)(]+>name<[\s\S]+?last\s+modified<[\s\S]+?)
    \s*/i, "$2$1"); + if (/\dK|\dM|\dG/.test(doc)) { + //Swap size and date fields to make file size more prominent on narrow screens + doc = doc.replace(/(]*>last\s+modified<\/a>\s*)(]*>size<\/a>\s*)/ig, "$2$1"); + doc = doc.replace(/(\d\d-\w{3}-\d{4}\s\d\d\:\d\d\s+)(\d[\d.\w]+\s+)$/img, "$2$1"); + } + if (/^[^_\n\r]+_([^_]+)_.+\.zim.+$/m.test(doc)) { + //Delete all lines without a wiki pattern from language list + var langList = doc.replace(/^(?![^_\n\r]+_(\w+)_.+$).*[\r\n]*/mg, ""); + //Get list of all languages + langList = langList.replace(/^[^_]+_([^_]+)_.+$/mg, "$1"); + //Delete recurrences + langList = langList.replace(/\b(\w+)\n(?=.*\b\1\n?)/mg, ""); + langList = "All\n" + langList; + var langArray = langList.match(/^\w+$/mg); + if (langArray) { + var dropdown = '\r\n'; + doc = doc.replace(/<\/h3>/i, '

    Filter list by language code: ' + dropdown + '

    '); + } + //Add language spans to doc + doc = doc.replace(/^([^_\n\r]+_([^_]+)_.+\.zim.+)$[\n\r]*/img, '$1
    '); + } + downloadLinks.innerHTML = doc; + if (lang) { + var langEntries = document.querySelectorAll(".wikiLang"); + //Hide all entries except specified language + for (i = 0; i < langEntries.length; i++) { + if (langEntries[i].lang != lang) langEntries[i].style.display = "none"; + } + var langSel = document.getElementById("langs"); + if (langSel) { + //var match = false; + //for (var i = 0; i = langSel.options.length; i++) { + // if (langSel.options[i].value == lang) { match = true; break; } + //} + //if (match) langSel.options[i] + langs.value = lang; + } + } + if (typeof langArray !== "undefined") { + //Set up event listener for language selector + document.getElementById("langs").addEventListener("change", function () { + var langSel = document.getElementById("langs"); + var langID = langSel ? langSel.options[langSel.selectedIndex].value : ""; + var langEntries = document.querySelectorAll(".wikiLang"); + //Hide all entries except specified language + for (i = 0; i < langEntries.length; i++) { + if (langEntries[i].lang == langID || langID == "All") langEntries[i].style.display = "inline"; + if (langEntries[i].lang != langID && langID != "All") langEntries[i].style.display = "none"; + } + }); + } + var links = downloadLinks.getElementsByTagName("a"); + for (var i = 0; i < links.length; i++) { + //Store the href - seems it's not useful? + //links[i].setAttribute("data-kiwix-dl", links[i].href); + links[i].href = "#"; + links[i].addEventListener('click', function () { + var langSel = document.getElementById("langs"); + //var langID = langSel ? langSel.options[langSel.selectedIndex].value : ""; + var langID = langSel ? langs.value : ""; + var replaceURL = URL + this.text; + if (/\.zim$/i.test(this.text)) + replaceURL = replaceURL + ".meta4"; + if (/parent\s*directory/i.test(this.text)) + replaceURL = URL.replace(/\/[^\/]*\/$/i, "\/"); + requestDownloadLinks(replaceURL, langID); + }); + } + //Toggle display of download panel -- bug: causes whole div to close if clicking on a link... + //downloadLinks.style.display = downloadLinks.style.display == "none" ? "inline" : "none"; + downloadLinks.style.display = "inline"; + } else { + serverResponse.innerHTML += "."; + } + }; + xhttp.open("GET", URL, true); + xhttp.send(); + } + + + /** + * Functions and classes exposed by this module + */ + return { + langCodes: langCodes, + requestDownloadLinks: requestDownloadLinks + }; +}); \ No newline at end of file diff --git a/bin/Release/AppX/www/js/lib/transformStyles.js b/bin/Release/AppX/www/js/lib/transformStyles.js index 2c073186..bd7c65aa 100644 --- a/bin/Release/AppX/www/js/lib/transformStyles.js +++ b/bin/Release/AppX/www/js/lib/transformStyles.js @@ -1,5 +1,5 @@ /** - * transformCSS.js: Provides transformations in CSS of Wikipedia articles contained in the ZIM file + * transformStyles.js: Provides transformations in CSS of Wikipedia articles contained in the ZIM file * This allows the user to choose the presentation style for the page to be viewed. * Currently available are "mobile" and "desktop" display modes. * @@ -122,7 +122,7 @@ define(['util', 'uiUtil'], function (util, uiUtil) { if (paras.length) { for (var g = 0; g < 3; g++) { //Check if the paragraph is a proper sentence, i.e. contains at least 50 non-HTML-delimetered non-full-stop characters, followed by a punctuation character - if (/[^.]{50,}[^.]*[.,;:?!-]/.test(paras[g].replace(/<[^>]*>/g, ""))) { matched = true; break; } + if (paras[g] && /[^.]{50,}[^.]*[.,;:?!-]/.test(paras[g].replace(/<[^>]*>/g, ""))) { matched = true; break; } } if (matched) { //Swap table and first matched paragraph, but mark lead paragraph first diff --git a/bin/Release/AppX/www/js/lib/util.js b/bin/Release/AppX/www/js/lib/util.js index e1d096d6..a03cf673 100644 --- a/bin/Release/AppX/www/js/lib/util.js +++ b/bin/Release/AppX/www/js/lib/util.js @@ -694,84 +694,6 @@ define(['q'], function(q) { } - function requestDownloadLinks(URL) { - var xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function () { - if (this.readyState == 4 && this.status == 200) { - var doc = this.responseText; - var downloadLinks = document.getElementById('downloadLinks'); - if (/\.meta4$/i.test(URL)) { - //It's the metalink with download links - var linkArray = doc.match(/]*>[^<]*<\/url>/ig); - var size = doc.match(/(\d+)<\/size>/i); - //Filter value (add commas if required) - size = size.length ? size[1] : ""; - var megabytes = size ? Math.round(size * 10 / (1024 * 1024)) / 10 : size; - //Use the lookbehind reversal trick to add commas.... - size = size.toString().split('').reverse().join('').replace(/(\d{3}(?!.*\.|$))/g, '$1,').split('').reverse().join(''); - doc = ""; - //NB we'ere intentionally discarding first link to kiwix.org (not to zim) - var mirrorservice = false; - for (var i = 1; i < linkArray.length; i++) { - if (/mirrorservice\.org/i.test(linkArray[i])) { - mirrorservice = true; - doc += linkArray[i].replace(/]*>([^<]*)<\/url>/i, '
  • *** Server has download bug, see note ***
    $1
  • \r\n'); - } else { - doc += linkArray[i].replace(/]*>([^<]*)<\/url>/i, '
  • $1
  • \r\n'); - } - } - var fullDoc = '
    \r\n

    We found the following links to your file

    \r\n 200) fullDoc += ' style="color:red;"'; - fullDoc += '>WARNING: file size is ' + (megabytes ? megabytes + 'Mb' : 'unnown') + '' + (size ? ' (' + size + ' bytes)' : '') + '\r\n'; - if (megabytes > 200) fullDoc += 'Consider using a torrent download method: see About section\r\n'; - fullDoc += '

    Links will open in a new browser window

      \r\n' + doc + '
    \r\n'; - if (mirrorservice) fullDoc += '*** Note: mirrorservice.org currently has a download bug with ZIM archives: on some browsers it will download the ZIM file as plain text in browser window

    '; - fullDoc += '<< Back to list of files
    '; - downloadLinks.innerHTML = fullDoc; - document.getElementById('returnLink').addEventListener('click', function (e) { - requestDownloadLinks(this.dataset.kiwixDl); - }); - return; - } - //Remove images - var doc = doc.replace(/]*>\s*/ig, ""); - //Reduce size of header - doc = doc.replace(/]*>[^<]*<\/)h1>/ig, ""); - //Limit height of pre box and prevent word wrapping - doc = doc.replace(/
    /i, '
    $#$#
    \r\n
    ');
    -            //Remove hr at end of page and add extra 
    - doc = doc.replace(/]*>(\s*<\/pre>)/i, "$1"); - //Move header into panel-header (NB regex is deliberately redundant to increase specificity of search) - doc = doc.replace(/\$\#\$\#([\s\S]+?)(]+>name<[\s\S]+?last\s+modified<[\s\S]+?)
    \s*/i, "$2$1"); - if (/\dK|\dM|\dG/.test(doc)) { - //Swap size and date fields to make file size more prominent on narrow screens - doc = doc.replace(/(]*>last\s+modified<\/a>)(\s+)(]*>size<\/a>)/ig, "$3$2$1"); - doc = doc.replace(/(\d\d-\w{3}-\d{4}\s\d\d\:\d\d)(\s+)(\d[\d.\w]+)\s+$/img, "$3$2$1"); - } - downloadLinks.innerHTML = doc; - var links = downloadLinks.getElementsByTagName("a"); - for (var i = 0; i < links.length; i++) { - //Store the href - seems it's not useful? - //links[i].setAttribute("data-kiwix-dl", links[i].href); - links[i].href = "#"; - links[i].addEventListener('click', function (e) { - var replaceURL = URL + this.text; - if (/\.zim$/i.test(this.text)) - replaceURL = replaceURL + ".meta4"; - if (/parent\s*directory/i.test(this.text)) - replaceURL = URL.replace(/\/[^\/]*\/$/i, "\/"); - requestDownloadLinks(replaceURL); - }); - } - //Toggle display of download panel -- bug: causes whole div to close if clicking on a link... - //downloadLinks.style.display = downloadLinks.style.display == "none" ? "inline" : "none"; - downloadLinks.style.display = "inline"; - } - }; - xhttp.open("GET", URL, true); - xhttp.send(); - } - /** * Functions and classes exposed by this module @@ -795,7 +717,6 @@ define(['q'], function(q) { leftShift: leftShift, matchOuter: matchOuter, matchInner: matchInner, - Hilitor: Hilitor, - requestDownloadLinks: requestDownloadLinks + Hilitor: Hilitor }; }); diff --git a/bin/Release/KiwixWebApp.build.appxrecipe b/bin/Release/KiwixWebApp.build.appxrecipe index 957cfd20..5f522cf2 100644 --- a/bin/Release/KiwixWebApp.build.appxrecipe +++ b/bin/Release/KiwixWebApp.build.appxrecipe @@ -478,6 +478,9 @@ www\js\lib\jquery-3.2.1.slim.js + + www\js\lib\kiwixServe.js + www\js\lib\q.js diff --git a/bin/Release/ReverseMap/resources.pri b/bin/Release/ReverseMap/resources.pri index 38c07962..1cb94da7 100644 Binary files a/bin/Release/ReverseMap/resources.pri and b/bin/Release/ReverseMap/resources.pri differ diff --git a/bld/Release/layout.resfiles b/bld/Release/layout.resfiles index 5ef3eb84..bcf93bdd 100644 --- a/bld/Release/layout.resfiles +++ b/bld/Release/layout.resfiles @@ -112,6 +112,7 @@ www\js\lib\abstractFilesystemAccess.js www\js\lib\bootstrap.min.js www\js\lib\cookies.js www\js\lib\jquery-3.2.1.slim.js +www\js\lib\kiwixServe.js www\js\lib\q.js www\js\lib\require.js www\js\lib\transformStyles.js diff --git a/bld/Release/layout.resfiles.intermediate b/bld/Release/layout.resfiles.intermediate index 5ef3eb84..bcf93bdd 100644 --- a/bld/Release/layout.resfiles.intermediate +++ b/bld/Release/layout.resfiles.intermediate @@ -112,6 +112,7 @@ www\js\lib\abstractFilesystemAccess.js www\js\lib\bootstrap.min.js www\js\lib\cookies.js www\js\lib\jquery-3.2.1.slim.js +www\js\lib\kiwixServe.js www\js\lib\q.js www\js\lib\require.js www\js\lib\transformStyles.js diff --git a/www/index.html b/www/index.html index 71e04d0f..ea9ab6ff 100644 --- a/www/index.html +++ b/www/index.html @@ -301,6 +301,7 @@
    Open full list of download links : Warning: requires active Internet connection and will use data

    + diff --git a/www/js/app.js b/www/js/app.js index 2acfdc2b..7ce176ee 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -26,8 +26,8 @@ // This uses require.js to structure javascript: // http://requirejs.org/docs/api.html#define -define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'abstractFilesystemAccess', 'q', 'module', 'transformStyles'], - function ($, zimArchiveLoader, util, uiUtil, cookies, abstractFilesystemAccess, q, module, transformStyles) { +define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'abstractFilesystemAccess', 'q', 'module', 'transformStyles', 'kiwixServe'], + function ($, zimArchiveLoader, util, uiUtil, cookies, abstractFilesystemAccess, q, module, transformStyles, kiwixServe) { /** * Maximum number of articles to display in a search @@ -328,6 +328,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'abstractFile $('#articleContent').hide(); $('#searchingForArticles').hide(); $('#downloadLinks').hide(); + $('#serverResponse').hide(); refreshAPIStatus(); //If user hadn't previously picked a folder or a file, resort to the local storage folder (UWP functionality) if (params.localStorage && !params.pickedFolder && !params.pickedFile) { @@ -399,7 +400,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'abstractFile } }); document.getElementById('downloadTrigger').addEventListener('click', function () { - util.requestDownloadLinks(params.kiwixDownloadLink); + kiwixServe.requestDownloadLinks(params.kiwixDownloadLink); }); $('input:radio[name=contentInjectionMode]').on('change', function (e) { diff --git a/www/js/lib/kiwixServe.js b/www/js/lib/kiwixServe.js new file mode 100644 index 00000000..744476f9 --- /dev/null +++ b/www/js/lib/kiwixServe.js @@ -0,0 +1,379 @@ +/** + * kiwixServe.js: Provides an AJAX request process for contacting the Kiwix Download Server + * and manipulating the returned data for display in-app + * Also provides an object literal (langCodes) for looking up the English-language names of + * language codesas defined in ISO 639-1, augmented with some ISO 639-3 codes as used by the + * Kiwix server + * + * Copyright 2018 Jaifroid and contributors + * License GPL v3: + * + * This file is part of Kiwix. + * + * Kiwix is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + */ +'use strict'; + +define([], function () { + + var langCodes = { + ab: 'Abkhazian', + aa: 'Afar', + af: 'Afrikaans', + ak: 'Akan', + sq: 'Albanian', + am: 'Amharic', + ar: 'Arabic', + an: 'Aragonese', + hy: 'Armenian', + as: 'Assamese', + av: 'Avaric', + ae: 'Avestan', + ay: 'Aymara', + az: 'Azerbaijani', + bm: 'Bambara', + ba: 'Bashkir', + eu: 'Basque', + be: 'Belarusian', + bn: 'Bengali (Bangla)', + bh: 'Bihari', + bi: 'Bislama', + bs: 'Bosnian', + br: 'Breton', + bg: 'Bulgarian', + my: 'Burmese', + ca: 'Catalan', + ch: 'Chamorro', + ce: 'Chechen', + ny: 'Chichewa-Chewa-Nyanja', + zh: 'Chinese', + zh: 'Chinese', + cv: 'Chuvash', + kw: 'Cornish', + co: 'Corsican', + cr: 'Cree', + hr: 'Croatian', + cs: 'Czech', + da: 'Danish', + dv: 'Divehi-Dhivehi-Maldivian', + nl: 'Dutch', + dz: 'Dzongkha', + en: 'English', + eo: 'Esperanto', + et: 'Estonian', + ee: 'Ewe', + fo: 'Faroese', + fj: 'Fijian', + fi: 'Finnish', + fr: 'French', + ff: 'Fula-Fulah-Pulaar-Pular', + gl: 'Galician', + gd: 'Gaelic (Scottish)', + gv: 'Gaelic (Manx)', + ka: 'Georgian', + de: 'German', + el: 'Greek', + kl: 'Greenlandic-Kalaallisut', + gn: 'Guarani', + gu: 'Gujarati', + ht: 'Haitian Creole', + ha: 'Hausa', + he: 'Hebrew', + hz: 'Herero', + hi: 'Hindi', + ho: 'Hiri Motu', + hu: 'Hungarian', + is: 'Icelandic', + io: 'Ido', + ig: 'Igbo', + id: 'Indonesian', + in: 'Indonesian', + ia: 'Interlingua', + ie: 'Interlingue', + iu: 'Inuktitut', + ik: 'Inupiak', + ga: 'Irish', + it: 'Italian', + ja: 'Japanese', + jv: 'Javanese', + kn: 'Kannada', + kr: 'Kanuri', + ks: 'Kashmiri', + kk: 'Kazakh', + km: 'Khmer', + ki: 'Kikuyu', + rw: 'Kinyarwanda (Rwanda)', + rn: 'Kirundi', + ky: 'Kyrgyz', + kv: 'Komi', + kg: 'Kongo', + ko: 'Korean', + ku: 'Kurdish', + kj: 'Kwanyama', + lo: 'Lao', + la: 'Latin', + lv: 'Latvian (Lettish)', + li: 'Limburgish ( Limburger)', + ln: 'Lingala', + lt: 'Lithuanian', + lu: 'Luga-Katanga', + lg: 'Luganda-Ganda', + lb: 'Luxembourgish', + mk: 'Macedonian', + mg: 'Malagasy', + ms: 'Malay', + ml: 'Malayalam', + mt: 'Maltese', + mi: 'Maori', + mr: 'Marathi', + mh: 'Marshallese', + mo: 'Moldavian', + mn: 'Mongolian', + na: 'Nauru', + nv: 'Navajo', + ng: 'Ndonga', + nd: 'Northern Ndebele', + ne: 'Nepali', + no: 'Norwegian', + nb: 'Norwegian bokmål', + nn: 'Norwegian nynorsk', + ii: 'Nuosu (Sichuan Yi)', + oc: 'Occitan', + oj: 'Ojibwe', + cu: 'Old Church Slavonic-Old Bulgarian', + or: 'Oriya', + om: 'Oromo (Afaan Oromo)', + os: 'Ossetian', + pi: 'Pāli', + ps: 'Pashto-Pushto', + fa: 'Persian (Farsi)', + pl: 'Polish', + pt: 'Portuguese', + pa: 'Punjabi (Eastern)', + qu: 'Quechua', + rm: 'Romansh', + ro: 'Romanian', + ru: 'Russian', + se: 'Sami', + sm: 'Samoan', + sg: 'Sango', + sa: 'Sanskrit', + sr: 'Serbian', + sh: 'Serbo-Croatian', + st: 'Sesotho', + tn: 'Setswana', + sn: 'Shona', + sd: 'Sindhi', + si: 'Sinhalese', + ss: 'Siswati', + sk: 'Slovak', + sl: 'Slovenian', + so: 'Somali', + nr: 'Southern Ndebele', + es: 'Spanish', + su: 'Sundanese', + sw: 'Swahili (Kiswahili)', + sv: 'Swedish', + tl: 'Tagalog', + ty: 'Tahitian', + tg: 'Tajik', + ta: 'Tamil', + tt: 'Tatar', + te: 'Telugu', + th: 'Thai', + bo: 'Tibetan', + ti: 'Tigrinya', + to: 'Tonga', + ts: 'Tsonga', + tr: 'Turkish', + tk: 'Turkmen', + tum: 'Tumbuka', + tw: 'Twi', + ug: 'Uyghur', + uk: 'Ukrainian', + ur: 'Urdu', + uz: 'Uzbek', + ve: 'Venda', + vi: 'Vietnamese', + vo: 'Volapük', + wa: 'Wallon', + cy: 'Welsh', + wo: 'Wolof', + fy: 'Western Frisian', + xh: 'Xhosa', + yi: 'Yiddish', + ji: 'Yiddish', + yo: 'Yoruba', + za: 'Zhuang-Chuang', + zu: 'Zulu' + }; + + function requestDownloadLinks(URL, lang) { + var xhttp = new XMLHttpRequest(); + xhttp.onreadystatechange = function () { + var downloadLinks = document.getElementById('downloadLinks'); + var serverResponse = document.getElementById('serverResponse'); + serverResponse.innerHTML = "Server response: Waiting..."; + serverResponse.style.display = "inline"; + if (this.readyState == 4 && this.status == 200) { + serverResponse.innerHTML = "Server response: 200 OK (data received)"; + var doc = this.responseText; + if (/\.meta4$/i.test(URL)) { + //It's the metalink with download links + var linkArray = doc.match(/]*>[^<]*<\/url>/ig); + var size = doc.match(/(\d+)<\/size>/i); + //Filter value (add commas if required) + size = size.length ? size[1] : ""; + var megabytes = size ? Math.round(size * 10 / (1024 * 1024)) / 10 : size; + //Use the lookbehind reversal trick to add commas.... + size = size.toString().split('').reverse().join('').replace(/(\d{3}(?!.*\.|$))/g, '$1,').split('').reverse().join(''); + var megabytes$ = megabytes.toString().split('').reverse().join('').replace(/(\d{3}(?!.*\.|$))/g, '$1,').split('').reverse().join(''); + doc = ""; + //NB we'ere intentionally discarding first link to kiwix.org (not to zim) + var mirrorservice = false; + for (var i = 1; i < linkArray.length; i++) { + if (/mirrorservice\.org/i.test(linkArray[i])) { + mirrorservice = true; + doc += linkArray[i].replace(/]*>([^<]*)<\/url>/i, '
  • *** Server has download bug, see note ***
    $1
  • \r\n'); + } else { + doc += linkArray[i].replace(/]*>([^<]*)<\/url>/i, '
  • $1
  • \r\n'); + } + } + var headerDoc = 'We found the following links to your file:'; + var bodyDoc = " 200 ? ' style="color:red;"> WARNING: ' : '>'; + bodyDoc += 'File size is ' + (megabytes ? megabytes$ + 'MB' : 'unnown') + '' + (size ? ' (' + size + ' bytes)' : '') + '\r\n'; + if (megabytes > 4000) bodyDoc += '

    This file is larger than the maximum file size permitted on an SD card formatted as FAT32 (max size is approx. 4GB). If your card or other storage area is formatted in this way, you will need to download a split version of this file: see Frequently Asked Questions.

    \r\n'; + if (megabytes > 200) bodyDoc += '

    Consider using a torrent download method: see About section

    \r\n'; + bodyDoc += '

    Links will open in a new browser window

      \r\n' + doc + '
    \r\n'; + if (mirrorservice) bodyDoc += '*** Note: mirrorservice.org currently has a download bug with ZIM archives: on some browsers it will download the ZIM file as plain text in browser window

    '; + bodyDoc += '<< Back to list of files

    '; + var header = document.getElementById('dl-panel-heading'); + header.outerHTML = header.outerHTML.replace(/]*)>[\s\S]*?<\/pre>/i, '' + headerDoc + ''); + var body = document.getElementById('dl-panel-body'); + body.outerHTML = body.outerHTML.replace(/]*)>[\s\S]*?<\/pre>/i, '' + bodyDoc + ''); + downloadLinks.innerHTML = downloadLinks.innerHTML.replace(/Index\s+of/ig, "File in"); + if (megabytes > 4000) downloadLinks.innerHTML = downloadLinks.innerHTML.replace(/panel-success/i, "panel-danger"); + if (megabytes > 200) downloadLinks.innerHTML = downloadLinks.innerHTML.replace(/panel-success/i, "panel-warning"); + var langSel = document.getElementById("langs"); + //Set chosen value in language selector (really this is for return) + if (langSel) { + langs.value = lang; + } + //Add event listener for click on return link, to go back to list of archives + document.getElementById('returnLink').addEventListener('click', function (e) { + var langSel = document.getElementById("langs"); + //var langID = langSel ? langSel.options[langSel.selectedIndex].value : ""; + var langID = langSel ? langs.value : ""; + langID = langID == "All" ? "" : langID; + requestDownloadLinks(this.dataset.kiwixDl, langID); + }); + return; + } + //Remove images + var doc = doc.replace(/]*>\s*/ig, ""); + //Reduce size of header + doc = doc.replace(/]*>[^<]*<\/)h1>/ig, ""); + //Limit height of pre box and prevent word wrapping + doc = doc.replace(/
    /i, '
    \r\n' + + '
    $#$#
    \r\n' + + '
    ');
    +                //Remove hr at end of page and add extra 
    + doc = doc.replace(/]*>(\s*<\/pre>)/i, "$1"); + //Move header into panel-header (NB regex is deliberately redundant to increase specificity of search) + doc = doc.replace(/\$\#\$\#([\s\S]+?)(]+>name<[\s\S]+?last\s+modified<[\s\S]+?)
    \s*/i, "$2$1"); + if (/\dK|\dM|\dG/.test(doc)) { + //Swap size and date fields to make file size more prominent on narrow screens + doc = doc.replace(/(]*>last\s+modified<\/a>\s*)(]*>size<\/a>\s*)/ig, "$2$1"); + doc = doc.replace(/(\d\d-\w{3}-\d{4}\s\d\d\:\d\d\s+)(\d[\d.\w]+\s+)$/img, "$2$1"); + } + if (/^[^_\n\r]+_([^_]+)_.+\.zim.+$/m.test(doc)) { + //Delete all lines without a wiki pattern from language list + var langList = doc.replace(/^(?![^_\n\r]+_(\w+)_.+$).*[\r\n]*/mg, ""); + //Get list of all languages + langList = langList.replace(/^[^_]+_([^_]+)_.+$/mg, "$1"); + //Delete recurrences + langList = langList.replace(/\b(\w+)\n(?=.*\b\1\n?)/mg, ""); + langList = "All\n" + langList; + var langArray = langList.match(/^\w+$/mg); + if (langArray) { + var dropdown = '\r\n'; + doc = doc.replace(/<\/h3>/i, '

    Filter list by language code: ' + dropdown + '

    '); + } + //Add language spans to doc + doc = doc.replace(/^([^_\n\r]+_([^_]+)_.+\.zim.+)$[\n\r]*/img, '$1
    '); + } + downloadLinks.innerHTML = doc; + if (lang) { + var langEntries = document.querySelectorAll(".wikiLang"); + //Hide all entries except specified language + for (i = 0; i < langEntries.length; i++) { + if (langEntries[i].lang != lang) langEntries[i].style.display = "none"; + } + var langSel = document.getElementById("langs"); + if (langSel) { + //var match = false; + //for (var i = 0; i = langSel.options.length; i++) { + // if (langSel.options[i].value == lang) { match = true; break; } + //} + //if (match) langSel.options[i] + langs.value = lang; + } + } + if (typeof langArray !== "undefined") { + //Set up event listener for language selector + document.getElementById("langs").addEventListener("change", function () { + var langSel = document.getElementById("langs"); + var langID = langSel ? langSel.options[langSel.selectedIndex].value : ""; + var langEntries = document.querySelectorAll(".wikiLang"); + //Hide all entries except specified language + for (i = 0; i < langEntries.length; i++) { + if (langEntries[i].lang == langID || langID == "All") langEntries[i].style.display = "inline"; + if (langEntries[i].lang != langID && langID != "All") langEntries[i].style.display = "none"; + } + }); + } + var links = downloadLinks.getElementsByTagName("a"); + for (var i = 0; i < links.length; i++) { + //Store the href - seems it's not useful? + //links[i].setAttribute("data-kiwix-dl", links[i].href); + links[i].href = "#"; + links[i].addEventListener('click', function () { + var langSel = document.getElementById("langs"); + //var langID = langSel ? langSel.options[langSel.selectedIndex].value : ""; + var langID = langSel ? langs.value : ""; + var replaceURL = URL + this.text; + if (/\.zim$/i.test(this.text)) + replaceURL = replaceURL + ".meta4"; + if (/parent\s*directory/i.test(this.text)) + replaceURL = URL.replace(/\/[^\/]*\/$/i, "\/"); + requestDownloadLinks(replaceURL, langID); + }); + } + //Toggle display of download panel -- bug: causes whole div to close if clicking on a link... + //downloadLinks.style.display = downloadLinks.style.display == "none" ? "inline" : "none"; + downloadLinks.style.display = "inline"; + } else { + serverResponse.innerHTML += "."; + } + }; + xhttp.open("GET", URL, true); + xhttp.send(); + } + + + /** + * Functions and classes exposed by this module + */ + return { + langCodes: langCodes, + requestDownloadLinks: requestDownloadLinks + }; +}); \ No newline at end of file diff --git a/www/js/lib/transformStyles.js b/www/js/lib/transformStyles.js index 2c073186..bd7c65aa 100644 --- a/www/js/lib/transformStyles.js +++ b/www/js/lib/transformStyles.js @@ -1,5 +1,5 @@ /** - * transformCSS.js: Provides transformations in CSS of Wikipedia articles contained in the ZIM file + * transformStyles.js: Provides transformations in CSS of Wikipedia articles contained in the ZIM file * This allows the user to choose the presentation style for the page to be viewed. * Currently available are "mobile" and "desktop" display modes. * @@ -122,7 +122,7 @@ define(['util', 'uiUtil'], function (util, uiUtil) { if (paras.length) { for (var g = 0; g < 3; g++) { //Check if the paragraph is a proper sentence, i.e. contains at least 50 non-HTML-delimetered non-full-stop characters, followed by a punctuation character - if (/[^.]{50,}[^.]*[.,;:?!-]/.test(paras[g].replace(/<[^>]*>/g, ""))) { matched = true; break; } + if (paras[g] && /[^.]{50,}[^.]*[.,;:?!-]/.test(paras[g].replace(/<[^>]*>/g, ""))) { matched = true; break; } } if (matched) { //Swap table and first matched paragraph, but mark lead paragraph first diff --git a/www/js/lib/util.js b/www/js/lib/util.js index e1d096d6..a03cf673 100644 --- a/www/js/lib/util.js +++ b/www/js/lib/util.js @@ -694,84 +694,6 @@ define(['q'], function(q) { } - function requestDownloadLinks(URL) { - var xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function () { - if (this.readyState == 4 && this.status == 200) { - var doc = this.responseText; - var downloadLinks = document.getElementById('downloadLinks'); - if (/\.meta4$/i.test(URL)) { - //It's the metalink with download links - var linkArray = doc.match(/]*>[^<]*<\/url>/ig); - var size = doc.match(/(\d+)<\/size>/i); - //Filter value (add commas if required) - size = size.length ? size[1] : ""; - var megabytes = size ? Math.round(size * 10 / (1024 * 1024)) / 10 : size; - //Use the lookbehind reversal trick to add commas.... - size = size.toString().split('').reverse().join('').replace(/(\d{3}(?!.*\.|$))/g, '$1,').split('').reverse().join(''); - doc = ""; - //NB we'ere intentionally discarding first link to kiwix.org (not to zim) - var mirrorservice = false; - for (var i = 1; i < linkArray.length; i++) { - if (/mirrorservice\.org/i.test(linkArray[i])) { - mirrorservice = true; - doc += linkArray[i].replace(/]*>([^<]*)<\/url>/i, '
  • *** Server has download bug, see note ***
    $1
  • \r\n'); - } else { - doc += linkArray[i].replace(/]*>([^<]*)<\/url>/i, '
  • $1
  • \r\n'); - } - } - var fullDoc = '
    \r\n

    We found the following links to your file

    \r\n 200) fullDoc += ' style="color:red;"'; - fullDoc += '>WARNING: file size is ' + (megabytes ? megabytes + 'Mb' : 'unnown') + '' + (size ? ' (' + size + ' bytes)' : '') + '\r\n'; - if (megabytes > 200) fullDoc += 'Consider using a torrent download method: see About section\r\n'; - fullDoc += '

    Links will open in a new browser window

      \r\n' + doc + '
    \r\n'; - if (mirrorservice) fullDoc += '*** Note: mirrorservice.org currently has a download bug with ZIM archives: on some browsers it will download the ZIM file as plain text in browser window

    '; - fullDoc += '<< Back to list of files
    '; - downloadLinks.innerHTML = fullDoc; - document.getElementById('returnLink').addEventListener('click', function (e) { - requestDownloadLinks(this.dataset.kiwixDl); - }); - return; - } - //Remove images - var doc = doc.replace(/]*>\s*/ig, ""); - //Reduce size of header - doc = doc.replace(/]*>[^<]*<\/)h1>/ig, ""); - //Limit height of pre box and prevent word wrapping - doc = doc.replace(/
    /i, '
    $#$#
    \r\n
    ');
    -            //Remove hr at end of page and add extra 
    - doc = doc.replace(/]*>(\s*<\/pre>)/i, "$1"); - //Move header into panel-header (NB regex is deliberately redundant to increase specificity of search) - doc = doc.replace(/\$\#\$\#([\s\S]+?)(]+>name<[\s\S]+?last\s+modified<[\s\S]+?)
    \s*/i, "$2$1"); - if (/\dK|\dM|\dG/.test(doc)) { - //Swap size and date fields to make file size more prominent on narrow screens - doc = doc.replace(/(]*>last\s+modified<\/a>)(\s+)(]*>size<\/a>)/ig, "$3$2$1"); - doc = doc.replace(/(\d\d-\w{3}-\d{4}\s\d\d\:\d\d)(\s+)(\d[\d.\w]+)\s+$/img, "$3$2$1"); - } - downloadLinks.innerHTML = doc; - var links = downloadLinks.getElementsByTagName("a"); - for (var i = 0; i < links.length; i++) { - //Store the href - seems it's not useful? - //links[i].setAttribute("data-kiwix-dl", links[i].href); - links[i].href = "#"; - links[i].addEventListener('click', function (e) { - var replaceURL = URL + this.text; - if (/\.zim$/i.test(this.text)) - replaceURL = replaceURL + ".meta4"; - if (/parent\s*directory/i.test(this.text)) - replaceURL = URL.replace(/\/[^\/]*\/$/i, "\/"); - requestDownloadLinks(replaceURL); - }); - } - //Toggle display of download panel -- bug: causes whole div to close if clicking on a link... - //downloadLinks.style.display = downloadLinks.style.display == "none" ? "inline" : "none"; - downloadLinks.style.display = "inline"; - } - }; - xhttp.open("GET", URL, true); - xhttp.send(); - } - /** * Functions and classes exposed by this module @@ -795,7 +717,6 @@ define(['q'], function(q) { leftShift: leftShift, matchOuter: matchOuter, matchInner: matchInner, - Hilitor: Hilitor, - requestDownloadLinks: requestDownloadLinks + Hilitor: Hilitor }; });