mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-09-08 19:57:46 -04:00
Add params for source of CSS
Adds params in init.js for selecting source of CSS ("zimfile", "local" or "mobile"). User selection still to be implemented. Default is "zimfile". Former-commit-id: 311bac831c130592414cbb0df5ddba7eac61f5aa [formerly 903a65084c766f414c13115fd890017ca579814d] Former-commit-id: 96c6d751437772809e39a4a41785bcc71cd02cbb
This commit is contained in:
parent
3bb9bb65e8
commit
547a4d0cad
@ -26,15 +26,14 @@
|
||||
// This uses require.js to structure javascript:
|
||||
// http://requirejs.org/docs/api.html#define
|
||||
|
||||
define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies','abstractFilesystemAccess'],
|
||||
function($, zimArchiveLoader, util, uiUtil, cookies, abstractFilesystemAccess) {
|
||||
define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies','abstractFilesystemAccess', 'module'],
|
||||
function($, zimArchiveLoader, util, uiUtil, cookies, abstractFilesystemAccess, module) {
|
||||
|
||||
/**
|
||||
* Maximum number of articles to display in a search
|
||||
* @type Integer
|
||||
*/
|
||||
//var MAX_SEARCH_RESULT_SIZE = 50;
|
||||
var MAX_SEARCH_RESULT_SIZE = 20; //GK - speed up search
|
||||
var MAX_SEARCH_RESULT_SIZE = module.config().results; //This is set in init.js
|
||||
|
||||
/**
|
||||
* @type ZIMArchive
|
||||
@ -795,15 +794,17 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies','abstractFiles
|
||||
if (regexpMetadataUrl.test(linkArray[2])) { //It's a CSS file contained in ZIM
|
||||
var zimLink = decodeURIComponent(uiUtil.removeUrlParameters(linkArray[2]));
|
||||
//If this is a standard Wikipedia css stylesheet cached in the filesystem...
|
||||
if (zimLink.match(/-\/s\/style\.css/i) ||
|
||||
if ((module.config().cssSource != "zimfile") &&
|
||||
(zimLink.match(/-\/s\/style\.css/i) ||
|
||||
zimLink.match(/-\/s\/css_modules\/mediawiki\.toc\.css/i) ||
|
||||
zimLink.match(/-\/s\/css_modules\/ext\.cite\.styles\.css/i) ||
|
||||
zimLink.match(/-\/s\/css_modules\/ext\.cite\.a11y\.css/i)) {
|
||||
blobArray[i] = zimLink; //Store href as is
|
||||
injectCSS();
|
||||
zimLink.match(/-\/s\/css_modules\/ext\.cite\.a11y\.css/i))) {
|
||||
blobArray[i] = zimLink.match(/-\/s\/style\.css/i) && module.config().cssSource == "mobile" ? "../-/s/style-mobile.css" : zimLink;
|
||||
console.log("Matched #" + i + " [" + blobArray[i] + "] from local filesystem");
|
||||
injectCSS();
|
||||
} else { //Try to get the stylesheet from the ZIM file
|
||||
var linkURL = zimLink.match(regexpMetadataUrl)[1];
|
||||
console.log("Attempting to resolve CSS link #" + i + "...");
|
||||
console.log("Attempting to resolve CSS link #" + i + " [" + linkURL + "] from ZIM file...");
|
||||
resolveCSS(linkURL, i); //Pass link and index
|
||||
}
|
||||
} else {
|
||||
@ -838,9 +839,10 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies','abstractFiles
|
||||
htmlArticle = htmlArticle.replace(regexpSheetHref, ""); //Void existing stylesheets
|
||||
var cssArray$ = "\r\n" + cssArray.join("\r\n") + "\r\n";
|
||||
htmlArticle = htmlArticle.replace(/\s*(<\/head>)/i, cssArray$ + "$1");
|
||||
console.log("All CSS resolved");
|
||||
injectHTML(htmlArticle); //This passes the revised HTML to the image and JS subroutine...
|
||||
} else {
|
||||
console.log("Waiting for " + (cssArray.length - blobArray.length) + " out of " + cssArray.length + " to resolve...")
|
||||
//console.log("Waiting for " + (cssArray.length - blobArray.length) + " out of " + cssArray.length + " to resolve...")
|
||||
}
|
||||
}
|
||||
//End of preload stylesheets code
|
||||
|
@ -21,9 +21,13 @@
|
||||
* along with Kiwix (file LICENSE-GPLv3.txt). If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
'use strict';
|
||||
var params = {};
|
||||
var results = params['results'] || 10; //Number of search results to display
|
||||
var cssSource = params['cssSource'] || "zimfile"; //One of "zimfile", "local" or "mobile""
|
||||
|
||||
require.config({
|
||||
baseUrl: 'js/lib',
|
||||
config: { '../app': { results: results, cssSource: cssSource } },
|
||||
paths: {
|
||||
//'jquery': 'jquery-2.1.4',
|
||||
//'jquery': 'jquery-3.2.1',
|
||||
|
Loading…
x
Reference in New Issue
Block a user