Implement list of start pages

Former-commit-id: 7c9a26a458cc7551cad461bf129976d163ad27a0 [formerly d5d432bf16f0eb0ccdff04d2baacd72dea17def0 [formerly 5dce5628299d48a29b0e5b74eeee714fba6477cc]]
Former-commit-id: 70d87db47955a0c23d8873e6744d82cb4099c5dd
Former-commit-id: dba37454def0f32c4b1f3c2dd6cdbefc27ef8f38
This commit is contained in:
Jaifroid 2021-02-13 18:28:23 +00:00
parent ca2e91e58b
commit 973be6f98e
4 changed files with 1126 additions and 444 deletions

View File

@ -1,22 +1,22 @@
## If you are viewing this folder on GitHub or a cloned repository…
Due to GitHub filesize restrictions, it is not possible to upload ZIMs that are larger than 100Mb to this directory. If you wish to build the source code yourself, you will need to add the appropriate packaged ZIM file to your local repository before building. See below.
## How to change the packaged archive
If you have a distribution of this app and want to delete the packaged archive to save space, or change the default archive, simply delete the ZIM file here or add your own file and change some values in the `www/js/init.js`. The values to change are these:
```
params['packagedFile'] = "name_of_your_file.zim";
params['fileVersion'] = "descriptive_name_of_your_file (Jan-2020)"; // These values will show in the app
params['cachedStartPage'] = false;
params['kiwixDownloadLink'] = "https://download.kiwix.org/zim/"; //Include final slash
```
You can have more than one ZIM archive in `archives`, but only one weill launch on app startup as the packaged file. If you do have more than one, then be sure to set `params['showFileSelectors'] = true;` to aid in discoverability of the other archive, otherwise your users will not eaeily realize it is there. Keeping that parameter as `false` dedicates the app to the packaged archive, but users can still override and pick a different ZIM by changing the value in Expert Settings (Config).
## Building the app
If you are building a custom packaged version of the app, then remember that ZIMs will not appear in your online GitHub repo, so add a text file to `archives` to show the intended filename, like the `*.zim.txt` file in this directory, e.g. `wikivoyage_en_all_novid_2019-07.zim.txt`. The text file can be empty (0 bytes). You should also set the fields listed above in `www/js/init.js` to match, and additionally decide whether to set `params['showFileSelectors'] = false;` (if you want to simplify the interface in Config).
Advanced: If you wish to restrict the files that users can search for on the server, e.g. to ensure your app remains dedicated to WikiMed archives, and to aid discoverability of only those archives, then look in `kiwixServe.js` and search for `DEV:` (first comment labelled `DEV:`) for more info. Also, ensure `params['kiwixDownloadLink'] = "https://download.kiwix.org/zim/";` is set appropriately so that the download library opens in the directory where multilingual or updated versions of your packaged ZIM can be found.
## If you are viewing this folder on GitHub or a cloned repository…
Due to GitHub filesize restrictions, it is not possible to upload ZIMs that are larger than 100Mb to this directory. If you wish to build the source code yourself, you will need to add the appropriate packaged ZIM file to your local repository before building. See below.
## How to change the packaged archive
If you have a distribution of this app and want to delete the packaged archive to save space, or change the default archive, simply delete the ZIM file here or add your own file and change some values in the `www/js/init.js`. The values to change are these:
```
params['packagedFile'] = "name_of_your_file.zim";
params['fileVersion'] = "descriptive_name_of_your_file (Jan-2020)"; // These values will show in the app
params['cachedStartPages'] = false;
params['kiwixDownloadLink'] = "https://download.kiwix.org/zim/"; //Include final slash
```
You can have more than one ZIM archive in `archives`, but only one weill launch on app startup as the packaged file. If you do have more than one, then be sure to set `params['showFileSelectors'] = true;` to aid in discoverability of the other archive, otherwise your users will not eaeily realize it is there. Keeping that parameter as `false` dedicates the app to the packaged archive, but users can still override and pick a different ZIM by changing the value in Expert Settings (Config).
## Building the app
If you are building a custom packaged version of the app, then remember that ZIMs will not appear in your online GitHub repo, so add a text file to `archives` to show the intended filename, like the `*.zim.txt` file in this directory, e.g. `wikivoyage_en_all_novid_2019-07.zim.txt`. The text file can be empty (0 bytes). You should also set the fields listed above in `www/js/init.js` to match, and additionally decide whether to set `params['showFileSelectors'] = false;` (if you want to simplify the interface in Config).
Advanced: If you wish to restrict the files that users can search for on the server, e.g. to ensure your app remains dedicated to WikiMed archives, and to aid discoverability of only those archives, then look in `kiwixServe.js` and search for `DEV:` (first comment labelled `DEV:`) for more info. Also, ensure `params['kiwixDownloadLink'] = "https://download.kiwix.org/zim/";` is set appropriately so that the download library opens in the directory where multilingual or updated versions of your packaged ZIM can be found.

View File

@ -0,0 +1,680 @@
<!DOCTYPE html>
<html class="client-js">
<head>
<meta charset="UTF-8">
<title>Wikipedia:WikiProject Medicine/Open Textbook of Medicine</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>
function importScript() {
return 1
} // this is to avoid the error from site.js
</script>
<link
href="../../-/s/css_modules/skins.minerva.base.reset|skins.minerva.content.styles|ext.cite.style|mobile.app.pagestyles.android|mediawiki.page.gallery.styles|mediawiki.skinning.content.parsoid.css"
rel="stylesheet" type="text/css" class="">
<link href="../../-/s/css_modules/style.css" rel="stylesheet" type="text/css" class="">
<link href="../../-/s/css_modules/content.parsoid.css" rel="stylesheet" type="text/css" class="">
<link href="../../-/s/css_modules/inserted_style.css" rel="stylesheet" type="text/css" class="">
<script src="../../-/j/js_modules/script.js" class=""></script>
<script src="../../-/j/js_modules/masonry.min.js" class=""></script>
<script src="../../-/j/js_modules/article_list_home.js" class=""></script>
<script src="../../-/j/js_modules/images_loaded.min.js" class=""></script>
<script src="../../-/j/js_modules/details_polyfill.js" class=""></script>
</head>
<body class="mediawiki mw-hide-empty-elt ns-0 ns-subject stable skin-minerva action-view animations">
<style data-mw-deduplicate="TemplateStyles:r886046994">
.mw-parser-output div.columns-2 div.column {
float: left;
width: 50%;
min-width: 300px
}
.mw-parser-output div.columns-3 div.column {
float: left;
width: 33.3%;
min-width: 200px
}
.mw-parser-output div.columns-4 div.column {
float: left;
width: 25%;
min-width: 150px
}
.mw-parser-output div.columns-5 div.column {
float: left;
width: 20%;
min-width: 120px
}
</style>
<div id="mw-mf-viewport" class="feature-header-v2">
<div id="mw-mf-page-center">
<div id="content" class="mw-body">
<a id="top"></a>
<div id="bodyContent" class="content mw-parser-output">
<div id="mw-content-text" style="direction: ltr;">
<div class="thumb tright">
<div class="thumbinner" style="width:202px"><img src="../../I/MedLogoNoWiFi.png.webp"
data-file-width="806" data-file-height="835" data-file-type="bitmap" height="150"
width="150"></div>
</div>
<h1 class="section-heading in-block collapsible-heading open-block" tabindex="0"
aria-haspopup="true" aria-controls="content-collapsible-block-0" data-section-id="0"
style="display:inline;">
<span class="mw-headline" id="title_0">Open Textbook of Medicine</span>
</h1>
<div id="mf-section-0" class="mf-section-0 collapsible-block open-block" aria-pressed="true"
aria-expanded="true" style="display:inline;">
<p>Welcome to the <b>Offline Medical Encyclopedia</b> by Wikipedias WikiProject Medicine.
Please bear in mind that this is volunteer generated content. While we try our best to
make it as accurate as possible, it is not perfect. Thus we request that you use common
sense when consulting this app.</p>
<table class="multicol" style="border-spacing:0;background:#d8d8ff;;clear:right;"
role="presentation">
<tbody>
<tr style="vertical-align:middle;">
<td style="min-width:135px;display:table-cell !important;">
<figure-inline><a href="../../A/Coronavirus_disease_2019" class="image"><img
src="../../I/SARS-CoV-2_without_background.png.webp"
data-file-width="1958" data-file-height="1966"
data-file-type="bitmap" width="125" height="125"></a>
</figure-inline>
</td>
<td style="width:0.5em;"></td>
<td style="width:auto;">
<div style="height: 0.5em;"></div><b><a href="../../A/Coronavirus_disease_2019" title="COVID-19">Coronavirus disease 2019</a></b><br>
<a href="../../A/Coronavirus_disease_2019" title="Coronavirus disease 2019">COVID-19 (diesease)</a>
• <a href="../../A/Severe_acute_respiratory_syndrome_coronavirus_2" title="Severe acute respiratory syndrome coronavirus 2">SARS-CoV-2 (virus strain)</a>
• <a href="../../A/COVID-19_pandemic" title="COVID-19 pandemic">COVID-19 pandemic</a>
• <a href="../../A/Coronavirus" title="Coronavirus">Coronavirus (family of viruses)</a>
• <a href="../../A/Transmission_of_COVID-19" title="Transmission of COVID-19">Transmission of COVID-19</a>
• <a href="../../A/COVID-19_testing" title="COVID-19 testing">COVID-19 testing</a>
• <a href="../../A/COVID-19_vaccine" title="COVIID-19 Vaccine">COVID-19 vaccine</a>
• <a href="../../A/AZD1222" title="AZD1222">Oxford-Astrazeneca COVID-19 vaccine (AZD1222)</a>
• <a href="../../A/Tozinameran" title="Tozinameran">PfizerBioNTech COVID-19 vaccine (Tozinameran)</a>
• <a href="../../A/Gam-COVID-Vac" title="Gam-COVID-Vac">Sputnik V COVID-19 vaccine (Gam-COVID-Vac)</a>
• <a href="../../A/COVID-19_drug_development" title="COVIID-19 drug development">COVID-19 drug development</a>
• <a href="../../A/Dexamethasone" title="Dexamethasone">Dexamethasone (COVID-19 treatment)</a>
• <a href="../../A/COVID-19_in_pregnancy" title="COVID-19 in pregnancy">COVID-19 in pregnancy</a>
• <a href="../../A/Social_distancing" title="Social distancing">Social distancing (control measure)</a>
• <a href="../../A/Contact_tracing" title="Contact tracing">Contact tracing (control measure)</a>
• <a href="../../A/Basic_reproduction_number" title="Basic Reproduction Number">R-Number</a>
• <a href="../../A/COVID-19_apps" title="COVID-19 apps">COVID-19 apps (control measure)</a>
• <a href="../../A/Impact_of_the_COVID-19_pandemic_on_aviation" title="Impact of the COVID-19 pandemic on aviation">Coronavirus impact on aviation</a>
• <a href="../../A/Impact_of_the_COVID-19_pandemic_on_education" title="Impact of the COVID-19 pandemic on education">Coronavirus impact on edcucation</a>
• <a href="../../A/Mental_health_during_the_COVID-19_pandemic" title="Mental health during the COVID-19 pandemic">Coronavirus impact on mental health</a>
• <a href="../../A/Impact_of_the_COVID-19_pandemic_on_politics" title="Impact of the 201920 coronavirus pandemic on politics">Coronavirus impact on politics</a>
• <a href="../../A/Social_impact_of_the_COVID-19_pandemic" title="Social impact of the COVID-19 pandemic">Coronavirus social impact</a>
• <a href="../../A/Impact_of_the_COVID-19_pandemic_on_domestic_violence" title="Impact of the COVID-19 pandemic on domestic violence">Coronavirus impact on domestic violence</a>
• <a href="../../A/Human_rights_issues_related_to_the_COVID-19_pandemic" title="Human rights issues related to the COVID-19 pandemic">Coronavirus impact on human rights</a>
• <a href="../../A/Impact_of_the_COVID-19_pandemic_on_the_environment" title="Impact of the COVID-19 pandemic on the environment">Coronavirus impact on the environment</a>
• <a href="../../A/Misinformation_related_to_the_COVID-19_pandemic" title="Coronavirus misinformation">Coronavirus misinformation</a>
• <a href="../../A/Coronavirus_party" title="Coronavirus party">Coronavirus party</a>
• <a href="../../A/COVID-19_pandemic_in_the_United_States" title="COVID-19 in USA">COVID-19 in USA</a>
• <a href="../../A/COVID-19_pandemic_in_Brazil" title="COVID-19 in Brazil">COVID-19 in Brazil</a>
• <a href="../../A/COVID-19_pandemic_in_India" title="COVID-19 in India">COVID-19 in India</a>
• <a href="../../A/COVID-19_pandemic_in_Mexico" title="COVID-19 in Mexico">COVID-19 in Mexico</a>
• <a href="../../A/COVID-19_pandemic_in_the_United_Kingdom" title="COVID-19 in the UK">COVID-19 in the UK</a>
• <a href="../../A/COVID-19_pandemic_in_Italy" title="COVID-19 in Italy">COVID-19 in Italy</a>
• <a href="../../A/COVID-19_pandemic_in_France" title="COVID-19 in France">COVID-19 in France</a>
• <a href="../../A/COVID-19_pandemic_in_Russia" title="COVID-19 in Russia">COVID-19 in Russia</a>
• <a href="../../A/COVID-19_pandemic_in_Iran" title="COVID-19 in Iran">COVID-19 in Iran</a>
• <a href="../../A/COVID-19_pandemic_in_Spain" title="COVID-19 in Spain">COVID-19 in Spain</a>
• <a href="../../A/COVID-19_pandemic_in_Colombia" title="COVID-19 in Colombia">COVID-19 in Colombia</a>
• <a href="../../A/COVID-19_pandemic_in_Argentina" title="COVID-19 in Argentina">COVID-19 in Argentina</a>
• <a href="../../A/COVID-19_pandemic_in_Germany" title="COVID-19 in Germany">COVID-19 in Germany</a>
• <a href="../../A/COVID-19_pandemic_in_Peru" title="COVID-19 in Peru">COVID-19 in Perú</a>
• <a href="../../A/COVID-19_pandemic_in_South_Africa" title="COVID-19 in South Africa">COVID-19 in South Africa</a>
• <a href="../../A/COVID-19_pandemic_in_Poland" title="COVID-19 in Poland">COVID-19 in Poland</a>
• <a href="../../A/COVID-19_pandemic_in_Indonesia" title="COVID-19 in Indonesia">COVID-19 in Indonesia</a>
• <a href="../../A/COVID-19_pandemic_in_Turkey" title="COVID-19 in Bangladesh">COVID-19 in Bangladesh</a>
• <a href="../../A/COVID-19_pandemic_in_Ukraine" title="COVID-19 in Ukraine">COVID-19 in Ukraine</a>
• <a href="../../A/COVID-19_pandemic_in_Belgium" title="COVID-19 in Belgium">COVID-19 in Belgium</a>
• <a href="../../A/COVID-19_pandemic_in_Canada" title="COVID-19 in Canada">COVID-19 in Canada</a>
• <a href="../../A/COVID-19_pandemic_in_Chile" title="COVID-19 in Chile">COVID-19 in Chile</a>
• <a href="../../A/COVID-19_pandemic_in_mainland_China" title="COVID-19 in China">COVID-19 in China</a>
</td>
</tr>
</tbody>
</table>
<table class="multicol" style="border-spacing:0;background:#ebebff;clear:right;"
role="presentation">
<tbody>
<tr style="vertical-align:middle;">
<td style="min-width:135px;display:table-cell !important;">
<figure-inline><a href="../../A/Book%3ACardiology" class="image"><img
src="../../I/CardiologyApp.jpg.webp" data-file-width="402"
data-file-height="402" data-file-type="bitmap" height="125"
width="125"></a></figure-inline>
</td>
<td style="width:0.5em;"></td>
<td style="width:auto;">
<div style="height: 0.5em;"></div><b><a href="../../A/Book%3ACardiology"
title="Book:Cardiology">Heart diseases</a></b><br><a
href="../../A/Abdominal_aortic_aneurysm"
title="Abdominal aortic aneurysm">Abdominal aortic aneurysm</a> • <a
href="../../A/Aortic_stenosis" title="Aortic stenosis">Aortic
stenosis</a> • <a href="../../A/Atrial_fibrillation"
title="Atrial fibrillation">Atrial fibrillation</a> • <a
href="../../A/Arrhythmia" title="Cardiac arrhythmia">Cardiac arrhythmia</a> • <a
href="../../A/Cardiovascular_disease"
title="Cardiovascular disease">Cardiovascular disease</a> • <a
href="../../A/Coronary_artery_disease"
title="Coronary artery disease">Coronary artery disease</a> • <a
href="../../A/Heart_failure" title="Heart failure">Heart failure</a> •
<a href="../../A/Myocardial_infarction"
title="Myocardial infarction">Myocardial infarction</a> • <a
href="../../A/Peripheral_artery_disease"
title="Peripheral artery disease">Peripheral artery disease</a> • <a
href="../../A/Pulmonary_embolism" title="Pulmonary embolism">Pulmonary
embolism</a> • <a href="../../A/Rheumatic_fever"
title="Rheumatic fever">Rheumatic fever</a> • <a
href="../../A/Syncope_(medicine)" title="Syncope (medicine)">Syncope</a>
</td>
</tr>
</tbody>
</table>
<table class="multicol" style="border-spacing:0;background:#d8d8ff;" role="presentation">
<tbody>
<tr style="vertical-align:middle;">
<td style="min-width:135px;display:table-cell !important;">
<figure-inline><a href="../../A/Book%3AChildren's_health" class="image"><img
src="../../I/PedsApp.jpg.webp" data-file-width="592"
data-file-height="592" data-file-type="bitmap" height="125"
width="125"></a></figure-inline>
</td>
<td style="width:0.5em;"></td>
<td style="width:auto;">
<div style="height: 0.5em;"></div><b><a href="../../A/Book%3AChildren's_health"
title="Children's health" class="mw-redirect">Children's
health</a></b><br><a href="../../A/Circumcision"
title="Circumcision">Circumcision</a> • <a
href="../../A/Cleft_lip_and_cleft_palate" title="Cleft lip and palate"
class="mw-redirect">Cleft lip and palate</a> • <a
href="../../A/Congenital_heart_defect"
title="Congenital heart defect">Congenital heart defect</a> • <a
href="../../A/Down_syndrome" title="Down syndrome">Down syndrome</a> •
<a href="../../A/Epilepsy" title="Epilepsy">Epilepsy</a> • <a
href="../../A/Female_genital_mutilation"
title="Female genital mutilation">Female genital mutilation</a> • <a
href="../../A/Fetal_alcohol_spectrum_disorder"
title="Fetal alcohol spectrum disorder">Fetal alcohol spectrum
disorder</a> • <a href="../../A/Klinefelter_syndrome"
title="Klinefelter syndrome">Klinefelter syndrome</a> • <a
href="../../A/Sickle_cell_disease" title="Sickle-cell disease"
class="mw-redirect">Sickle-cell disease</a> • <a
href="../../A/Spina_bifida" title="Spina bifida">Spina bifida</a> • <a
href="../../A/Sudden_infant_death_syndrome"
title="Sudden infant death syndrome">Sudden infant death syndrome</a> •
<a href="../../A/Turner_syndrome" title="Turner syndrome">Turner
syndrome</a>
</td>
</tr>
</tbody>
</table>
<table class="multicol" style="border-spacing:0;background:#ebebff;" role="presentation">
<tbody>
<tr style="vertical-align:middle;">
<td style="min-width:135px;display:table-cell !important;">
<figure-inline><a href="../../A/Book%3ASkin_diseases" class="image"><img
src="../../I/DermApp.jpg.webp" data-file-width="2304"
data-file-height="2304" data-file-type="bitmap" height="125"
width="125"></a></figure-inline>
</td>
<td style="width:0.5em;"></td>
<td style="width:auto;">
<div style="height: 0.5em;"></div><b><a href="../../A/Book%3ASkin_diseases"
title="Skin diseases" class="mw-redirect">Skin
diseases</a></b><br><a href="../../A/Abscess"
title="Abscess">Abscess</a> • <a href="../../A/Acne_vulgaris"
title="Acne vulgaris" class="mw-redirect">Acne vulgaris</a> • <a
href="../../A/Allergy" title="Allergy">Allergy</a> • <a
href="../../A/Angular_cheilitis" title="Angular cheilitis">Angular
cheilitis</a> • <a href="../../A/Atopic_dermatitis"
title="Atopic dermatitis">Atopic dermatitis</a> • <a
href="../../A/Candidiasis" title="Candidiasis">Candidiasis</a> • <a
href="../../A/Cellulitis" title="Cellulitis">Cellulitis</a> • <a
href="../../A/Chickenpox" title="Chickenpox">Chickenpox</a> • <a
href="../../A/Dermatitis" title="Dermatitis">Dermatitis</a> • <a
href="../../A/Hair_loss" title="Hair loss">Hair loss</a> • <a
href="../../A/Head_lice_infestation" title="Head lice infestation">Head
lice infestation</a> • <a href="../../A/Herpes_simplex"
title="Herpes simplex">Herpes simplex</a> • <a
href="../../A/Shingles" title="Herpes zoster"
class="mw-redirect">Shingles (herpes zoster)</a> • <a href="../../A/Measles"
title="Measles">Measles</a> • <a href="../../A/Psoriasis"
title="Psoriasis">Psoriasis</a> • <a href="../../A/Scabies"
title="Scabies">Scabies</a>
</td>
</tr>
</tbody>
</table>
<table class="multicol" style="border-spacing:0;background:#d8d8ff;" role="presentation">
<tbody>
<tr style="vertical-align:middle;">
<td style="min-width:135px;display:table-cell !important;">
<figure-inline><a href="../../A/Book%3AEars_nose_throat" class="image"><img
src="../../I/ENTApp.jpg.webp" data-file-width="951"
data-file-height="951" data-file-type="bitmap" height="125"
width="125"></a></figure-inline>
</td>
<td style="width:0.5em;"></td>
<td style="width:auto;">
<div style="height: 0.5em;"></div><b><a
href="../../A/Book%3AEars_nose_throat"
title="Book:Ears nose throat">Ears nose throat</a></b><br><a
href="../../A/Benign_paroxysmal_positional_vertigo"
title="Benign paroxysmal positional vertigo">Benign paroxysmal
positional vertigo</a> • <a href="../../A/Hearing_loss"
title="Hearing loss">Hearing loss</a> • <a
href="../../A/Mandibular_fracture"
title="Mandibular fracture">Mandibular fracture</a> • <a
href="../../A/Nasal_polyp" title="Nasal polyp">Nasal polyp</a> • <a
href="../../A/Nosebleed" title="Nose bleed" class="mw-redirect">Nose
bleed</a> • <a href="../../A/Otitis_externa"
title="Otitis externa">Otitis externa</a> • <a
href="../../A/Otitis_media" title="Otitis media">Otitis media</a> • <a
href="../../A/Pharyngitis" title="Pharyngitis">Pharyngitis</a> • <a
href="../../A/Streptococcal_pharyngitis" title="Strep throat"
class="mw-redirect">Strep throat</a> • <a href="../../A/Tinnitus"
title="Tinnitus">Tinnitus</a> • <a href="../../A/Vertigo"
title="Vertigo">Vertigo</a>
</td>
</tr>
</tbody>
</table>
<table class="multicol" style="border-spacing:0;background:#ebebff;" role="presentation">
<tbody>
<tr style="vertical-align:middle;">
<td style="min-width:135px;display:table-cell !important;">
<figure-inline><a href="../../A/Book%3AEndocrinology" class="image"><img
src="../../I/EndoApp.png.webp" data-file-width="244"
data-file-height="244" data-file-type="bitmap" height="125"
width="125"></a></figure-inline>
</td>
<td style="width:0.5em;"></td>
<td style="width:auto;">
<div style="height: 0.5em;"></div><b><a href="../../A/Book%3AEndocrinology"
title="Book:Endocrinology">Endocrine diseases</a></b><br><a
href="../../A/Addison's_disease" title="Addison's disease">Addison's
disease</a> • <a href="../../A/Cushing's_syndrome"
title="Cushing's syndrome">Cushing's syndrome</a> • <a
href="../../A/Delirium_tremens" title="Delirium tremens">Delirium
tremens</a> • <a href="../../A/Diabetes" title="Diabetes">Diabetes</a> •
<a href="../../A/DM_type_1" title="DM type 1" class="mw-redirect">DM type
1</a> • <a href="../../A/DM_type_2" title="DM type 2"
class="mw-redirect">DM type 2</a> • <a
href="../../A/Gestational_diabetes"
title="Gestational diabetes">Gestational diabetes</a> • <a
href="../../A/Graves'_disease" title="Graves' disease">Graves'
disease</a> • <a href="../../A/Hypernatremia"
title="Hypernatremia">Hypernatremia</a> • <a
href="../../A/Hyperthyroidism"
title="Hyperthyroidism">Hyperthyroidism</a> • <a
href="../../A/Hypoglycemia" title="Hypoglycemia">Hypoglycemia</a> • <a
href="../../A/Hyponatremia" title="Hyponatremia">Hyponatremia</a> • <a
href="../../A/Hypothyroidism" title="Hypothyroidism">Hypothyroidism</a>
• <a href="../../A/Obesity" title="Obesity">Obesity</a> • <a
href="../../A/Primary_hyperaldosteronism"
title="Primary hyperaldosteronism" class="mw-redirect">Primary
hyperaldosteronism</a> • <a href="../../A/Vitamin_B12_deficiency"
title="Vitamin B12 deficiency">Vitamin B12 deficiency</a>
</td>
</tr>
</tbody>
</table>
<table class="multicol" style="border-spacing:0;background:#d8d8ff;" role="presentation">
<tbody>
<tr style="vertical-align:middle;">
<td style="min-width:135px;display:table-cell !important;">
<figure-inline><a href="../../A/Book%3AGeneral_surgery" class="image"><img
src="../../I/GenSurgApp.jpg.webp" data-file-width="1575"
data-file-height="1574" data-file-type="bitmap" height="125"
width="125"></a></figure-inline>
</td>
<td style="width:0.5em;"></td>
<td style="width:auto;">
<div style="height: 0.5em;"></div><b><a
href="../../A/Book%3AGeneral_surgery"
title="Book:General surgery">General surgery</a></b><br><a
href="../../A/Appendicitis" title="Appendicitis">Appendicitis</a> • <a
href="../../A/Bowel_obstruction" title="Bowel obstruction">Bowel
obstruction</a> • <a href="../../A/Celiac_disease"
title="Celiac disease" class="mw-redirect">Celiac disease</a> • <a
href="../../A/Crohn's_disease" title="Crohn's disease">Crohn's
disease</a> • <a href="../../A/Diarrhea" title="Diarrhea">Diarrhea</a> •
<a href="../../A/Gallstone" title="Gallstone">Gallstone</a> • <a
href="../../A/Gastritis" title="Gastritis">Gastritis</a> • <a
href="../../A/Gastrointestinal_bleeding"
title="Gastrointestinal bleeding">Gastrointestinal bleeding</a> • <a
href="../../A/Gastrointestinal_perforation"
title="Gastrointestinal perforation">Gastrointestinal perforation</a> •
<a href="../../A/Hemorrhoid" title="Hemorrhoid">Hemorrhoid</a> • <a
href="../../A/Hernia" title="Hernia">Hernia</a> • <a
href="../../A/Irritable_bowel_syndrome"
title="Irritable bowel syndrome">Irritable bowel syndrome</a> • <a
href="../../A/Pancreatitis" title="Pancreatitis">Pancreatitis</a> • <a
href="../../A/Peptic_ulcer_disease" title="Peptic ulcer disease">Peptic
ulcer disease</a> • <a href="../../A/Pernicious_anemia"
title="Pernicious anemia" class="mw-redirect">Pernicious anemia</a> • <a
href="../../A/Ulcerative_colitis" title="Ulcerative colitis">Ulcerative
colitis</a> • <a href="../../A/Volvulus" title="Volvulus">Volvulus</a>
</td>
</tr>
</tbody>
</table>
<table class="multicol" style="border-spacing:0;background:#ebebff;" role="presentation">
<tbody>
<tr style="vertical-align:middle;">
<td style="min-width:135px;display:table-cell !important;">
<figure-inline><a href="../../A/Book%3AInfectious_disease"
class="image"><img src="../../I/IDApp.JPG.webp" data-file-width="1634"
data-file-height="1634" data-file-type="bitmap" height="125"
width="125"></a></figure-inline>
</td>
<td style="width:0.5em;"></td>
<td style="width:auto;">
<div style="height: 0.5em;"></div><b><a
href="../../A/Book%3AInfectious_disease"
title="Book:Infectious disease">Infectious diseases</a></b><br><a
href="../../A/African_trypanosomiasis"
title="African trypanosomiasis">African trypanosomiasis</a> • <a
href="../../A/Ascariasis" title="Ascariasis">Ascariasis</a> • <a
href="../../A/Buruli_ulcer" title="Buruli ulcer">Buruli ulcer</a> • <a
href="../../A/Cellulitis" title="Cellulitis">Cellulitis</a> • <a
href="../../A/Chagas_disease" title="Chagas disease">Chagas disease</a>
• <a href="../../A/Common_cold" title="Common cold">Common cold</a>
• <a href="../../A/Coronavirus_disease_2019"
title="Coronavius disease 2019">COVID-19</a>
• <a href="../../A/Cysticercosis" title="Cysticercosis">Cysticercosis</a> •
<a href="../../A/Drancunculiasis" title="Drancunculiasis"
class="mw-redirect">Drancunculiasis</a> • <a
href="../../A/Ebola_virus_disease" title="Ebola virus disease">Ebola
virus disease</a> • <a href="../../A/Hepatitis_A"
title="Hepatitis A">Hepatitis A</a> • <a href="../../A/Hepatitis_B"
title="Hepatitis B">Hepatitis B</a> • <a href="../../A/Hepatitis_C"
title="Hepatitis C">Hepatitis C</a> • <a href="../../A/HIV%2FAIDS"
title="HIV/AIDS">HIV/AIDS</a> • <a href="../../A/Leprosy"
title="Leprosy">Leprosy</a> • <a href="../../A/Lyme_disease"
title="Lyme disease">Lyme disease</a> • <a href="../../A/Malaria"
title="Malaria">Malaria</a> • <a href="../../A/Meningitis"
title="Meningitis">Meningitis</a> • <a href="../../A/Rabies"
title="Rabies">Rabies</a> • <a href="../../A/Syphilis"
title="Syphilis">Syphilis</a> • <a href="../../A/Tuberculosis"
title="Tuberculosis">Tuberculosis</a> • <a href="../../A/Yellow_fever"
title="Yellow fever">Yellow fever</a> • <a href="../../A/Zika_fever"
title="Zika fever">Zika fever</a>
</td>
</tr>
</tbody>
</table>
<table class="multicol" style="border-spacing:0;background:#d8d8ff;" role="presentation">
<tbody>
<tr style="vertical-align:middle;">
<td style="min-width:135px;display:table-cell !important;">
<figure-inline><a href="../../A/Book%3AMedications" class="image"><img
src="../../I/Rx_symbol_border.svg.png.webp" data-file-width="250"
data-file-height="250" data-file-type="drawing" height="125"
width="125"></a></figure-inline>
</td>
<td style="width:0.5em;"></td>
<td style="width:auto;">
<div style="height: 0.5em;"></div><b><a href="../../A/Book%3AMedications"
title="Book:Medications">Medications</a></b><br><a
href="../../A/Birth_control" title="Birth control">Birth control</a> •
<a href="../../A/Carbamazapine" title="Carbamazapine"
class="mw-redirect">Carbamazapine</a> • <a href="../../A/Cephalexin"
title="Cephalexin" class="mw-redirect">Cephalexin</a> • <a
href="../../A/Cholera_vaccine" title="Cholera vaccine">Cholera
vaccine</a> • <a href="../../A/Cocaine" title="Cocaine">Cocaine</a> • <a
href="../../A/Dapsone" title="Dapsone">Dapsone</a> • <a
href="../../A/Diazepam" title="Diazepam">Diazepam</a> • <a
href="../../A/Hydrochlorothiazide" title="Hydrochlorothiazide">HCTZ</a>
• <a href="../../A/Ibuprofen" title="Ibuprofen">Ibuprofen</a> • <a
href="../../A/Influenza_vaccine" title="Influenza vaccine">Influenza
vaccine</a> • <a href="../../A/Ipratropium_bromide"
title="Ipratropium bromide">Ipratropium bromide</a> • <a
href="../../A/Ketamine" title="Ketamine">Ketamine</a> • <a
href="../../A/Levofloxacin" title="Levofloxacin">Levofloxacin</a> • <a
href="../../A/Measles_vaccine" title="Measles vaccine">Measles
vaccine</a> • <a href="../../A/Metoprolol"
title="Metoprolol">Metoprolol</a> • <a href="../../A/Mifepristone"
title="Mifepristone">Mifepristone</a> • <a href="../../A/Morphine"
title="Morphine">Morphine</a> • <a href="../../A/Nystatin"
title="Nystatin">Nystatin</a> • <a href="../../A/Paracetamol"
title="Paracetamol">Paracetamol</a> (acetaminophen) • <a
href="../../A/Propofol" title="Propofol">Propofol</a> • <a
href="../../A/Salbutamol" title="Salbutamol">Salbutamol</a>
</td>
</tr>
</tbody>
</table>
<table class="multicol" style="border-spacing:0;background:#ebebff;" role="presentation">
<tbody>
<tr style="vertical-align:middle;">
<td style="min-width:135px;display:table-cell !important;">
<figure-inline><a href="../../A/Book%3ACancer" class="image"><img
src="../../I/CancerApp.jpg.webp" data-file-width="496"
data-file-height="496" data-file-type="bitmap" height="125"
width="125"></a></figure-inline>
</td>
<td style="width:0.5em;"></td>
<td style="width:auto;">
<div style="height: 0.5em;"></div><b><a href="../../A/Book%3ACancer"
title="Book:Cancer">Cancer care</a></b><br><a
href="../../A/Brain_tumor" title="Brain tumor">Brain tumor</a> • <a
href="../../A/Breast_cancer" title="Breast cancer">Breast cancer</a> •
<a href="../../A/Cancer" title="Cancer">Cancer</a> • <a
href="../../A/Cervical_cancer" title="Cervical cancer">Cervical
cancer</a> • <a href="../../A/Colon_cancer" title="Colon cancer"
class="mw-redirect">Colon cancer</a> • <a
href="../../A/Endometrial_cancer" title="Endometrial cancer">Endometrial
cancer</a> • <a href="../../A/Esophageal_cancer"
title="Esophageal cancer">Esophageal cancer</a> • <a
href="../../A/Glioblastoma_multiforme" title="Glioblastoma multiforme"
class="mw-redirect">Glioblastoma multiforme</a> • <a
href="../../A/Leukemia" title="Leukemia">Leukemia</a> • <a
href="../../A/Lung_cancer" title="Lung cancer">Lung cancer</a> • <a
href="../../A/Lymphoma" title="Lymphoma">Lymphoma</a> • <a
href="../../A/Melanoma" title="Melanoma">Melanoma</a> • <a
href="../../A/Mesothelioma" title="Mesothelioma">Mesothelioma</a> • <a
href="../../A/Ovarian_cancer" title="Ovarian cancer">Ovarian cancer</a>
• <a href="../../A/Pancreatic_cancer" title="Pancreatic cancer">Pancreatic
cancer</a> • <a href="../../A/Prostate_cancer"
title="Prostate cancer">Prostate cancer</a> • <a
href="../../A/Skin_cancer" title="Skin cancer">Skin cancer</a> • <a
href="../../A/Stomach_cancer" title="Stomach cancer">Stomach cancer</a>
</td>
</tr>
</tbody>
</table>
<table class="multicol" style="border-spacing:0;background:#d8d8ff;" role="presentation">
<tbody>
<tr style="vertical-align:middle;">
<td style="min-width:135px;display:table-cell !important;">
<figure-inline><a href="../../A/Book%3AOphthalmology" class="image"><img
src="../../I/OpthoApp.png.webp" data-file-width="1120"
data-file-height="1120" data-file-type="bitmap" height="125"
width="125"></a></figure-inline>
</td>
<td style="width:0.5em;"></td>
<td style="width:auto;">
<div style="height: 0.5em;"></div><b><a href="../../A/Book%3AEye_diseases"
title="Eye diseases" class="mw-redirect">Eye
diseases</a></b><br><a href="../../A/Amblyopia"
title="Amblyopia">Amblyopia</a> • <a href="../../A/Cataracts"
title="Cataracts" class="mw-redirect">Cataracts</a> • <a
href="../../A/Color_blind" title="Color blind" class="mw-redirect">Color
blind</a> • <a href="../../A/Conjunctivitis"
title="Conjunctivitis">Conjunctivitis</a> • <a
href="../../A/Detached_retina" title="Detached retina"
class="mw-redirect">Detached retina</a> • <a
href="../../A/Sj%C3%B6gren's_syndrome" title="Sjögren's syndrome"
class="mw-redirect">Sjögren's syndrome</a> • <a href="../../A/Glaucoma"
title="Glaucoma">Glaucoma</a> • <a href="../../A/Macular_degeneration"
title="Macular degeneration">Macular degeneration</a> • <a
href="../../A/Refractive_error" title="Refractive error">Refractive
error</a> • <a href="../../A/Trachoma" title="Trachoma">Trachoma</a>
</td>
</tr>
</tbody>
</table>
<table class="multicol" style="border-spacing:0;background:#ebebff;" role="presentation">
<tbody>
<tr style="vertical-align:middle;">
<td style="min-width:135px;display:table-cell !important;">
<figure-inline><a href="../../A/Book%3AMental_health" class="image"><img
src="../../I/PsycApp.JPG.webp" data-file-width="624"
data-file-height="624" data-file-type="bitmap" height="125"
width="125"></a></figure-inline>
</td>
<td style="width:0.5em;"></td>
<td style="width:auto;">
<div style="height: 0.5em;"></div><b><a href="../../A/Book%3AMental_health"
title="Psychiatry" class="mw-redirect">Mental
health</a></b><br><a href="../../A/ADHD" title="ADHD"
class="mw-redirect">ADHD</a> • <a href="../../A/Alcoholism"
title="Alcoholism">Alcoholism</a> • <a href="../../A/Anorexia_nervosa"
title="Anorexia nervosa">Anorexia nervosa</a> • <a
href="../../A/Anxiety_disorder" title="Anxiety disorder">Anxiety</a> •
<a href="../../A/Asperger_syndrome" title="Asperger syndrome">Asperger
syndrome</a> • <a href="../../A/Autism" title="Autism">Autism</a> • <a
href="../../A/Bipolar_disorder" title="Bipolar disorder">Bipolar
disorder</a> • <a href="../../A/Borderline_personality_disorder"
title="Borderline personality disorder">Borderline personality
disorder</a> • <a href="../../A/Bulimia_nervosa"
title="Bulimia nervosa">Bulimia nervosa</a> • <a
href="../../A/Eating_disorder" title="Eating disorder">Eating
disorder</a> • <a
href="../../A/Depression_(mood)" title="Depression (mood)">Depression</a> • <a
href="../../A/Obsessivecompulsive_disorder"
title="Obsessive-compulsive disorder"
class="mw-redirect">Obsessive-compulsive disorder</a> • <a
href="../../A/Phobia" title="Phobia">Phobia</a> • <a
href="../../A/Posttraumatic_stress_disorder"
title="Post traumatic stress disorder" class="mw-redirect">Post
traumatic stress disorder</a> • <a href="../../A/Schizophrenia"
title="Schizophrenia">Schizophrenia</a> • <a href="../../A/Suicide"
title="Suicide">Suicide</a>
</td>
</tr>
</tbody>
</table>
<table class="multicol" style="border-spacing:0;background:#d8d8ff;" role="presentation">
<tbody>
<tr style="vertical-align:middle;">
<td style="min-width:135px;display:table-cell !important;">
<figure-inline><a href="../../A/Book%3ARheumatology" class="image"><img
src="../../I/RheumApp.JPG.webp" data-file-width="3240"
data-file-height="3240" data-file-type="bitmap" height="125"
width="125"></a></figure-inline>
</td>
<td style="width:0.5em;"></td>
<td style="width:auto;">
<div style="height: 0.5em;"></div><b><a href="../../A/Book%3ARheumatology"
title="Book:Rheumatology">Bone and joint diseases</a></b><br><a
href="../../A/Carpal_tunnel_syndrome"
title="Carpal tunnel syndrome">Carpal tunnel syndrome</a> • <a
href="../../A/Fibromyalgia" title="Fibromyalgia">Fibromyalgia</a> • <a
href="../../A/Gout" title="Gout">Gout</a> • <a
href="../../A/Low_back_pain" title="Low back pain">Low back pain</a> •
<a href="../../A/Osteoarthritis" title="Osteoarthritis">Osteoarthritis</a> •
<a href="../../A/Osteoporosis" title="Osteoporosis">Osteoporosis</a> • <a
href="../../A/Plantar_fasciitis" title="Plantar fasciitis">Plantar
fasciitis</a> • <a href="../../A/Psoriasis"
title="Psoriasis">Psoriasis</a> • <a href="../../A/Rheumatoid_arthritis"
title="Rheumatoid arthritis">Rheumatoid arthritis</a> • <a
href="../../A/Sarcoidosis" title="Sarcoidosis">Sarcoidosis</a> • <a
href="../../A/Sciatica" title="Sciatica">Sciatica</a>
</td>
</tr>
</tbody>
</table>
<table class="multicol" style="border-spacing:0;background:#ebebff;" role="presentation">
<tbody>
<tr style="vertical-align:middle;">
<td style="min-width:135px;display:table-cell !important;">
<figure-inline><a href="../../A/Book%3AWomen's_health" class="image"><img
src="../../I/OBGYNApp.jpg.webp" data-file-width="400"
data-file-height="400" data-file-type="bitmap" height="125"
width="125"></a></figure-inline>
</td>
<td style="width:0.5em;"></td>
<td style="width:auto;">
<div style="height: 0.5em;"></div><b><a href="../../A/Book%3AWomen's_health"
title="Book:Women's health">Women's health</a></b><br><a
href="../../A/Abortion" title="Abortion">Abortion</a> • <a
href="../../A/Breastfeeding" title="Breastfeeding">Breastfeeding</a> •
<a href="../../A/Childbirth" title="Childbirth">Childbirth</a> • <a
href="../../A/Dysmenorrhea" title="Dysmenorrhea">Dysmenorrhea</a> • <a
href="../../A/Eclampsia" title="Eclampsia">Eclampsia</a> • <a
href="../../A/Ectopic_pregnancy" title="Ectopic pregnancy">Ectopic
pregnancy</a> • <a href="../../A/Endometriosis"
title="Endometriosis">Endometriosis</a> • <a
href="../../A/Hyperemesis_gravidarum"
title="Hyperemesis gravidarum">Hyperemesis gravidarum</a> • <a
href="../../A/Menopause" title="Menopause">Menopause</a> • <a
href="../../A/Menstruation" title="Menstruation">Menstruation</a> • <a
href="../../A/Morning_sickness" title="Morning sickness">Morning
sickness</a> • <a href="../../A/Obstructed_labor"
title="Obstructed labor" class="mw-redirect">Obstructed labor</a> • <a
href="../../A/Ovarian_cyst" title="Ovarian cyst">Ovarian cyst</a> • <a
href="../../A/Polycystic_ovarian_syndrome"
title="Polycystic ovarian syndrome" class="mw-redirect">Polycystic
ovarian syndrome</a> • <a href="../../A/Pre_eclampsia"
title="Pre eclampsia" class="mw-redirect">Pre eclampsia</a> • <a
href="../../A/Pregnancy" title="Pregnancy">Pregnancy</a> • <a
href="../../A/Premenstrual_syndrome"
title="Premenstrual syndrome">Premenstrual syndrome</a> • <a
href="../../A/Preterm_birth" title="Preterm birth">Preterm birth</a> •
<a href="../../A/Trichomoniasis" title="Trichomoniasis">Trichomoniasis</a> •
<a href="../../A/Uterine_fibroid" title="Uterine fibroid">Uterine
fibroid</a>
</td>
</tr>
</tbody>
</table>
</div>
<!--htdig_noindex-->
<div>
<div
style="clear:both; background-image:linear-gradient(180deg, #E8E8E8, white); border-top: dashed 2px #AAAAAA; padding: 0.5em 0.5em 0.5em 0.5em; margin-top: 1em; direction: ltr;">
This article is issued from
<a class="external text" title="Last edited on 2017-05-26"
href="https://en.wikipedia.org/wiki/Wikipedia%3AWikiProject_Medicine%2FOpen_Textbook_of_Medicine?oldid=782353640">
Wikipedia
</a>.
The text is licensed under <a class="external text"
href="https://creativecommons.org/licenses/by-sa/4.0/">
Creative
Commons - Attribution - Sharealike
</a>.
Additional terms may apply for the media files.
</div>
</div>
<!--/htdig_noindex-->
</div>
</div>
</div>
</div>
</div>
<noscript>
<style>
.collapsible-block {
display: block !important;
}
</style>
</noscript>
<script src="../../-/j/js_modules/jsConfigVars.js" class=""></script>
<script src="../../-/j/js_modules/startup.js" class=""></script>
<script src="../../-/j/js_modules/jquery.js" class=""></script>
<script src="../../-/j/js_modules/mediawiki.js" class=""></script>
<script src="../../-/j/js_modules/site.js" class=""></script>
</body>
</html>

View File

@ -2848,17 +2848,16 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett
//Load cached start page if it exists and we have loaded the packaged file
var htmlContent = 0;
var zimName = appstate.selectedArchive._file._files[0].name.replace(/\.[^.]+$/, '');
if (params.isLandingPage && params.cachedStartPage && (~params.packagedFile.indexOf(zimName) || ~params.fileVersion.indexOf(zimName))) {
var zimName = appstate.selectedArchive._file._files[0].name.replace(/\.[^.]+$/, '').replace('_\d+_\d+$', '');
if (params.isLandingPage && params.cachedStartPages[zimName]) {
htmlContent = -1;
// DEV: You should deal with the rare possibility that the cachedStartPage is not in the same namespace as the main page dirEntry...
// Ideally include the namespace in params.cachedStartPage and adjust/test code (not hard)
uiUtil.XHR(dirEntry.namespace + '/' + encodeURIComponent(encodeURIComponent(params.cachedStartPage).replace(/%2F/, '/')).replace(/%2F/, '/'), 'text', function (responseTxt, status) {
var encURL = encodeURIComponent(encodeURIComponent(params.cachedStartPages[zimName]).replace(/%2F/g, '/')).replace(/%2F/g, '/');
uiUtil.XHR(encURL, 'text', function (responseTxt, status) {
htmlContent = /<html[^>]*>/.test(responseTxt) ? responseTxt : 0;
if (htmlContent) {
console.log('Article retrieved from storage cache...');
// Alter the dirEntry url and title parameters in case we are overriding the start page
dirEntry.url = params.cachedStartPage;
dirEntry.url = params.cachedStartPages[zimName].replace(/[AC]\//, '');
var title = htmlContent.match(/<title[^>]*>((?:[^<]|<(?!\/title))+)/);
dirEntry.title = title ? title[1] : dirEntry.title;
displayArticleInForm(dirEntry, htmlContent);
@ -2876,7 +2875,6 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett
var goToRetrievedContent = function(html) {
if (/<html[^>]*>/.test(html)) {
console.log("Fast article retrieval from localStorage: " + lastPage);
//if (~lastPage.indexOf(params.cachedStartPage)) params.isLandingPage = true;
setTimeout(function () {
displayArticleInForm(dirEntry, html);
}, 10);
@ -3980,7 +3978,8 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett
//This removes any search highlighting
clearFindInArticle();
document.getElementById('searchingArticles').style.display = 'block';
if (~title.indexOf(params.cachedStartPage)) {
var zimName = appstate.selectedArchive._file._files[0].name.replace(/\.[^.]+$/, '').replace('_\d+_\d+$', '');
if (~title.indexOf(params.cachedStartPages[zimName])) {
goToMainArticle();
return;
}

View File

@ -1,415 +1,418 @@
/**
* init.js : Configuration for the library require.js
* This file handles the dependencies between javascript libraries
*
* Copyright 2013-2020 Mossroy 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.
*
* Kiwix is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Kiwix (file LICENSE-GPLv3.txt). If not, see <http://www.gnu.org/licenses/>
*/
'use strict';
// Set a global error handler to prevent app crashes
window.onerror = function (msg, url, line, col, error) {
console.error('Error caught in app [' + url + ':' + line + ']:\n' + msg, error);
return true;
};
/**
* Provides caching for assets contained in ZIM (variable needs to be available app-wide)
* It significantly speeds up subsequent page display. See kiwix-js issue #335
*/
var assetsCache = new Map();
/**
* A global parameter object for storing variables that need to be remembered between page loads,
* or across different functions and modules
*
* @type Object
*/
var params = {};
/**
* A global state object
*
* @type Object
*/
var appstate = {};
/******** UPDATE VERSION IN pwabuilder-sw.js TO MATCH VERSION *******/
params['version'] = "1.2.2"; //DEV: Manually update this version when there is a new release: it is compared to the Settings Store "version" in order to show first-time info, and the cookie is updated in app.js
/******* UPDATE THIS ^^^^^^ IN serveice worker!! ********************/
params['packagedFile'] = "wikipedia_en_100_maxi.zim"; //For packaged Kiwix JS (e.g. with Wikivoyage file), set this to the filename (for split files, give the first chunk *.zimaa) and place file(s) in default storage
params['archivePath'] = "archives"; //The directory containing the packaged archive(s) (relative to app's root directory)
params['fileVersion'] = "wikipedia_en_100_maxi_2021-01.zim (23-Jan-2021)"; //Use generic name for actual file, and give version here
params['cachedStartPage'] = false; //If you have cached the start page for quick start, give its URI here
params['kiwixDownloadLink'] = "https://download.kiwix.org/zim/"; //Include final slash
/******* DEV: ENSURE SERVERS BELOW ARE LISTED IN package.appxmanifest ************/
params['PWAServer'] = "https://pwa.kiwix.org/"; // Production server
// params['PWAServer'] = "https://kiwix.github.io/kiwix-js-windows/"; // Test server
params['PWAMode'] = getSetting('PWAMode'); // Set to true if the app should always operate in PWA mode
params['storeType'] = getBestAvailableStorageAPI();
params['keyPrefix'] = 'kiwixjs-'; // Prefix to use for localStorage keys
params['maxResults'] = ~~(getSetting('maxResults') || 25); //Number of search results to display
params['relativeFontSize'] = ~~(getSetting('relativeFontSize') || 100); //Sets the initial font size for articles (as a percentage) - user can adjust using zoom buttons
params['relativeUIFontSize'] = ~~(getSetting('relativeUIFontSize') || 100); //Sets the initial font size for UI (as a percentage) - user can adjust using slider in Config
params['cssSource'] = getSetting('cssSource') || "auto"; //Set default to "auto", "desktop" or "mobile"
params['removePageMaxWidth'] = getSetting('removePageMaxWidth') != null ? getSetting('removePageMaxWidth') : "auto"; //Set default for removing max-width restriction on Wikimedia pages ("auto" = removed in desktop, not in mobile; true = always remove; false = never remove)
params['openAllSections'] = getSetting('openAllSections') != null ? getSetting('openAllSections') : true; //Set default for opening all sections in ZIMs that have collapsible sections and headings ("auto" = let CSS decide according to screen width; true = always open until clicked by user; false = always closed until clicked by user)
params['cssCache'] = getSetting('cssCache') != null ? getSetting('cssCache') : true; //Set default to true to use cached CSS, false to use Zim only
params['cssTheme'] = getSetting('cssTheme') || 'light'; //Set default to 'auto', 'light', 'dark' or 'invert' to use respective themes for articles
params['cssUITheme'] = getSetting('cssUITheme') || 'light'; //Set default to 'auto', 'light' or 'dark' to use respective themes for UI
params['imageDisplay'] = getSetting('imageDisplay') != null ? getSetting('imageDisplay') : true; //Set default to display images from Zim
params['hideToolbars'] = getSetting('hideToolbars') != null ? getSetting('hideToolbars') : true; //Set default to true (hides both), 'top' (hides top only), or false (no hiding)
params['rememberLastPage'] = getSetting('rememberLastPage') != null ? getSetting('rememberLastPage') : true; //Set default option to remember the last visited page between sessions
params['useMathJax'] = getSetting('useMathJax') != null ? getSetting('useMathJax') : true; //Set default to true to display math formulae with MathJax, false to use fallback SVG images only
//params['showFileSelectors'] = getCookie('showFileSelectors') != null ? getCookie('showFileSelectors') : false; //Set to true to display hidden file selectors in packaged apps
params['showFileSelectors'] = true; //False will cause file selectors to be hidden on each load of the app (by ignoring cookie)
params['hideActiveContentWarning'] = getSetting('hideActiveContentWarning') != null ? getSetting('hideActiveContentWarning') : false;
params['allowHTMLExtraction'] = getSetting('allowHTMLExtraction') == true;
params['alphaChar'] = getSetting('alphaChar') || 'A'; //Set default start of alphabet string (used by the Archive Index)
params['omegaChar'] = getSetting('omegaChar') || 'Z'; //Set default end of alphabet string
params['contentInjectionMode'] = getSetting('contentInjectionMode') || 'jquery'; // Defaults to jquery mode (widest compatibility)
params['allowInternetAccess'] = getSetting('allowInternetAccess');
//Do not touch these values unless you know what they do! Some are global variables, some are set programmatically
params['imageDisplayMode'] = params.imageDisplay ? 'progressive' : 'manual';
params['storedFile'] = getSetting('lastSelectedArchive') || params['packagedFile'] || '';
params.storedFile = launchArguments ? launchArguments.files[0].name : params.storedFile;
params['lastPageVisit'] = params.rememberLastPage && params.storedFile ? getSetting(params.storedFile) || '' : '';
params.lastPageVisit = params.lastPageVisit ? params.lastPageVisit + '@kiwixKey@' + params.storedFile : '';
params['storedFilePath'] = getSetting('lastSelectedArchivePath');
params.storedFilePath = params.storedFilePath ? decodeURIComponent(params.storedFilePath) : params.archivePath + '/' + params.packagedFile;
params.storedFilePath = launchArguments ? launchArguments.files[0].path || '' : params.storedFilePath;
params.originalPackagedFile = params.packagedFile;
params['localStorage'] = params['localStorage'] || "";
params['pickedFile'] = launchArguments ? launchArguments.files[0] : "";
params['pickedFolder'] = params['pickedFolder'] || "";
params['themeChanged'] = params['themeChanged'] || false;
params['printIntercept'] = false;
params['printInterception'] = false;
params['appIsLaunching'] = true; // Allows some routines to tell if the app has just been launched
params['useCache'] = true; // This needs to be made optional in UI
params['PWAInstalled'] = getSetting('PWAInstalled');
params['appType'] = getAppType();
params['falFileToken'] = "zimfile"; // UWP support
params['falFolderToken'] = "zimfilestore"; // UWP support
params.pagesLoaded = 0; // Page counter used to show PWA Install Prompt only after user has played with the app for a while
params.localUWPSettings = /UWP/.test(params.appType) ? Windows.Storage.ApplicationData.current.localSettings.values : null;
// Apply any override parameters in querystring (done as a self-calling function to avoid creating global variables)
(function overrideParams() {
var rgx = /[?&]([^=]+)=([^&]+)/g;
var matches = rgx.exec(window.location.search);
while (matches) {
if (matches[1] && matches[2]) {
var paramKey = decodeURIComponent(matches[1]);
var paramVal = decodeURIComponent(matches[2]);
if (paramKey !== 'title') {
// Store new values
if (params.storeType === 'cookie') {
document.cookie = encodeUriComponent(paramKey) + '=' + encodeUriComponent(paramVal) + ';expires=Fri, 31 Dec 9999 23:59:59 GMT';
}
// Make Boolean value
paramVal = paramVal === 'false' ? false : paramVal === 'true' ? true : paramVal;
if (params.storeType === 'local_storage') {
localStorage.setItem(params.keyPrefix + paramKey, paramVal);
}
paramKey = paramKey === 'lastSelectedArchive' ? 'storedFile' : paramKey;
params[paramKey] = paramVal;
}
}
matches = rgx.exec(window.location.search);
}
})();
// This code runs on the PWA UWP app running from https://
if (/^http/i.test(window.location.protocol) && /UWP\|PWA/.test(params.appType)) {
// We are in a PWA, so signal success
params.localUWPSettings.PWA_launch = 'success';
// DEV: Internal code for testing. If you need to debug restart of app, pause in DevTools on line below,
// set params.reboot = true and then continue. App will reboot to local code.
if (params.reboot) {
window.location.href = 'ms-appx-web:///www/index.html';
beamMeDownScotty();
}
}
// This code runs on the basic UWP app running from ms-appx-web://
if (!/^http/i.test(window.location.protocol) && params.localUWPSettings &&
params.contentInjectionMode === 'serviceworker' && params.allowInternetAccess) {
// Test that there has been a successful handover to the PWA
if (params.localUWPSettings.PWA_launch === 'success') {
// Signal failure until the PWA has launched, where this will be changed to 'success'
params.localUWPSettings.PWA_launch = 'fail';
// User wants PWA mode and it has previously launched, so do quick reload now
window.location.href = params.PWAServer + 'www/index.html?allowInternetAccess=true';
// This will trigger the error catching above, cleanly dematerialize this script and transport us swiftly to PWA land
window.beamMeUpScotty();
} else if (params.localUWPSettings.PWA_launch === 'fail') {
console.error('PWA failed to launch correctly last time! Setting failsafe to avoid boot-loop...');
}
}
// Prevent app boot loop with problematic pages that cause an app crash
if (getSetting('lastPageLoad') === 'failed') {
params.lastPageVisit = '';
} else {
// Cookie will signal failure until article is fully loaded
if (params.storeType === 'cookie') {
document.cookie = 'lastPageLoad=failed;expires=Fri, 31 Dec 9999 23:59:59 GMT';
} else if (params.storeType === 'local_storage') {
localStorage.setItem(params.keyPrefix + 'lastPageLoad', 'failed');
}
}
// Initialize checkbox, radio and other values
document.getElementById('cssCacheModeCheck').checked = params.cssCache;
document.getElementById('imageDisplayModeCheck').checked = params.imageDisplay;
document.getElementById('removePageMaxWidthCheck').checked = params.removePageMaxWidth === true; // Will be false if false or auto
document.getElementById('removePageMaxWidthCheck').indeterminate = params.removePageMaxWidth == "auto";
document.getElementById('removePageMaxWidthCheck').readOnly = params.removePageMaxWidth == "auto";
document.getElementById('pageMaxWidthState').innerHTML = (params.removePageMaxWidth == "auto" ? "auto" : params.removePageMaxWidth ? "always" : "never");
document.getElementById('openAllSectionsCheck').checked = params.openAllSections;
document.getElementById('cssUIDarkThemeCheck').checked = params.cssUITheme == "dark"; // Will be true, or false if light or auto
document.getElementById('cssUIDarkThemeCheck').indeterminate = params.cssUITheme == "auto";
document.getElementById('cssUIDarkThemeCheck').readOnly = params.cssUITheme == "auto";
document.getElementById('cssUIDarkThemeState').innerHTML = params.cssUITheme;
document.getElementById('cssWikiDarkThemeCheck').checked = /dark|invert/.test(params.cssTheme);
document.getElementById('cssWikiDarkThemeCheck').indeterminate = params.cssTheme == "auto";
document.getElementById('cssWikiDarkThemeCheck').readOnly = params.cssTheme == "auto";
document.getElementById('cssWikiDarkThemeState').innerHTML = params.cssTheme;
document.getElementById('darkInvert').style.display = /dark|invert/i.test(params.cssTheme) ? "inline" : "none";
document.getElementById('cssWikiDarkThemeInvertCheck').checked = params.cssTheme == 'invert';
document.getElementById('useMathJaxRadio' + (params.useMathJax ? 'True' : 'False')).checked = true;
document.getElementById('rememberLastPageCheck').checked = params.rememberLastPage;
document.getElementById('displayFileSelectorsCheck').checked = params.showFileSelectors;
document.getElementById('hideActiveContentWarningCheck').checked = params.hideActiveContentWarning;
document.getElementById('allowHTMLExtractionCheck').checked = params.allowHTMLExtraction;
document.getElementById('alphaCharTxt').value = params.alphaChar;
document.getElementById('omegaCharTxt').value = params.omegaChar;
document.getElementById('maxResults').value = params.maxResults;
document.getElementById('hideToolbarsCheck').checked = params.hideToolbars === true; // Will be false if false or 'top'
document.getElementById('hideToolbarsCheck').indeterminate = params.hideToolbars === "top";
document.getElementById('hideToolbarsCheck').readOnly = params.hideToolbars === "top";
document.getElementById('hideToolbarsState').innerHTML = (params.hideToolbars === "top" ? "top" : params.hideToolbars ? "both" : "never");
document.getElementById('allowInternetAccessCheck').checked = params.allowInternetAccess;
// Howeever, if we're accessing the app from a server, add indication that we are online by default (user can turn off and will receive instructions)
if (/^http/i.test(window.location.protocol) && params.allowInternetAccess === null) {
document.getElementById('allowInternetAccessCheck').checked = true;
params.allowInternetAccess = true;
}
// If we're in a PWA served from http, change the app titles
if (/^http/i.test(window.location.protocol)) {
Array.prototype.slice.call(document.querySelectorAll('span.identity')).forEach(function (ele) {
ele.innerHTML = 'PWA';
});
}
// Get app type
function getAppType() {
var type = 'HTML5';
if (typeof Windows !== 'undefined' && typeof Windows.Storage !== 'undefined') type = 'UWP';
if (window.fs || window.nw) type = 'Electron';
if (navigator.serviceWorker) type += '|PWA';
return type;
}
// Set up storage types
if (params.storedFile && typeof Windows !== 'undefined' && typeof Windows.Storage !== 'undefined') { //UWP
Windows.ApplicationModel.Package.current.installedLocation.getFolderAsync(params.archivePath).done(function (folder) {
params.localStorage = folder;
}, function (err) {
console.error("This app doesn't appear to have access to local storage!");
});
var futureAccessList = Windows.Storage.AccessCache.StorageApplicationPermissions.futureAccessList;
if (futureAccessList.containsItem(params.falFolderToken)) {
futureAccessList.getFolderAsync(params.falFolderToken).done(function (folder) {
params.pickedFolder = folder;
}, function (err) {
console.error("The previously picked folder is no longer accessible: " + err.message);
});
}
//If we don't already have a picked file (e.g. by launching app with click on a ZIM file), then retrieve it from futureAccessList if possible
var listOfArchives = getSetting('listOfArchives');
// But don't get the picked file if we already have access to the folder and the file is in it!
if (listOfArchives && ~listOfArchives.indexOf(params.storedFile) && params.pickedFolder) {
params.pickedFile = '';
} else {
if (!params.pickedFile && futureAccessList.containsItem(params.falFileToken)) {
params.pickedFile = '';
futureAccessList.getFileAsync(params.falFileToken).done(function (file) {
if (file.name === params.storedFile) params.pickedFile = file;
}, function (err) {
console.error("The previously picked file is no longer accessible: " + err.message);
});
}
}
}
// Routine for installing the app adapted from https://pwa-workshop.js.org/
var deferredPrompt;
var divInstall1 = document.getElementById('divInstall1');
var btnInstall1 = document.getElementById('btnInstall1');
var divInstall2 = document.getElementById('divInstall2');
var btnInstall2 = document.getElementById('btnInstall2');
var btnLater = document.getElementById('btnLater');
window.addEventListener('beforeinstallprompt', function(e) {
console.log('beforeinstallprompt fired');
// Prevent Chrome 76 and earlier from automatically showing a prompt
e.preventDefault();
// Stash the event so it can be triggered later.
deferredPrompt = e;
// Show the install button
divInstall2.style.display = 'block';
btnInstall2.addEventListener('click', installApp);
// Don't display prompt if the PWA for this version is already installed
if (!params.beforeinstallpromptFired) {
params.beforeinstallpromptFired = true;
btnInstall1.addEventListener('click', installApp);
btnLater.addEventListener('click', function (e) {
e.preventDefault();
divInstall1.innerHTML = '<b>You can install this app later from Configuration</b>';
setTimeout(function() {
divInstall1.style.display = 'none';
}, 4000);
params.installLater = true;
});
}
// The app hasn't actually been installed or user has uninstalled, so we need to reset any setting
if (params.storeType === 'cookie') {
document.cookie = 'PWAInstalled=; expires=Thu, 01 Jan 1970 00:00:00 GMT';
} else if (params.storeType === 'local_storage') {
localStorage.removeItem(params.keyPrefix + 'PWAInstalled');
}
});
function installApp(e) {
e.preventDefault();
// Show the prompt
deferredPrompt.prompt();
btnInstall1.disabled = true;
btnInstall2.disabled = true;
// Wait for the user to respond to the prompt
deferredPrompt.userChoice.then(function(choiceResult) {
if (choiceResult.outcome === 'accepted') {
console.log('PWA installation accepted');
divInstall1.style.display = 'none';
divInstall2.style.display = 'none';
} else {
console.log('PWA installation rejected');
}
btnInstall1.disabled = false;
btnInstall2.disabled = false;
deferredPrompt = null;
params.beforeinstallpromptFired = false;
});
}
window.addEventListener('appinstalled', function(e) {
params.PWAInstalled = params.version;
if (params.storeType === 'cookie') {
document.cookie = 'PWAInstalled=' + encodeURIComponent(params.PWAInstalled) + '; expires=Fri, 31 Dec 9999 23:59:59 GMT';
} else if (params.storeType === 'local_storage') {
localStorage.setItem(params.keyPrefix + 'PWAInstalled', params.PWAInstalled);
}
});
function getSetting(name) {
var result;
if (params.storeType === 'cookie') {
var regexp = new RegExp('(?:^|;)\\s*' + name + '=([^;]+)(?:;|$)');
result = document.cookie.match(regexp);
result = result && result.length > 1 ? result[1] : null;
} else if (params.storeType === 'local_storage') {
// Use localStorage instead
result = localStorage.getItem(params.keyPrefix + name);
}
return result === null || result === "undefined" ? null : result === "true" ? true : result === "false" ? false : result;
}
// Tests for available Storage APIs (document.cookie or localStorage) and returns the best available of these
// DEV: This function is replicated from settingsStore.js because RequireJS has not yet loaded it,
// except that it returns 'cookie' if the always-present contentInjectionMode is still in cookie, which
// means the store previously used cookies and hasn't upgraded yet: this won't be done till app.js is loaded
function getBestAvailableStorageAPI() {
var type = 'none';
var localStorageTest;
try {
localStorageTest = 'localStorage' in window && window['localStorage'] !== null;
if (localStorageTest) {
localStorage.setItem('tempKiwixStorageTest', '');
localStorage.removeItem('tempKiwixStorageTest');
}
} catch (e) {
localStorageTest = false;
}
document.cookie = 'tempKiwixCookieTest=working; expires=Fri, 31 Dec 9999 23:59:59 GMT; SameSite=Strict';
var kiwixCookieTest = /tempKiwixCookieTest=working/.test(document.cookie);
document.cookie = 'tempKiwixCookieTest=; expires=Thu, 01 Jan 1970 00:00:00 GMT; SameSite=Strict';
if (kiwixCookieTest) type = 'cookie';
if (localStorageTest && !/contentInjectionMode=(?:jquery|serviceworker)/.test(document.cookie)) type = 'local_storage';
return type;
}
require.config({
//enforceDefine: true, //This is for debugging IE errors
baseUrl: 'js/lib',
config: { '../app': { params: params } },
paths: {
'jquery': 'jquery-3.2.1.slim',
//'jquery': 'jquery-3.2.1',
//'bootstrap': 'bootstrap'
'bootstrap': 'bootstrap.min',
'webpHeroBundle': 'webpHeroBundle_0.0.0-dev.27',
'webpHeroPolyfills': 'webpHeroPolyfills_0.0.0-dev.27'
},
shim: {
'jquery': {
exports: '$'
},
'bootstrap': {
deps: ['jquery']
},
'webpHeroBundle': {
deps: ['webpHeroPolyfills']
}
}
});
requirejs(['bootstrap'], function (bootstrap) {
requirejs(['../app']);
});
// Load the WebP Polyfills only if needed
var webpMachine = false;
// Using self-invoking function to avoid defining global functions and variables
(function (callback) {
// Tests for native WebP support
var webP = new Image();
webP.onload = webP.onerror = function () {
callback(webP.height === 2);
};
webP.src = 'data:image/webp;base64,UklGRjoAAABXRUJQVlA4IC4AAACyAgCdASoCAAIALmk0mk0iIiIiIgBoSygABc6WWgAA/veff/0PP8bA//LwYAAA';
})(function (support) {
if (!support) {
webpMachine = true;
}
/**
* init.js : Configuration for the library require.js
* This file handles the dependencies between javascript libraries
*
* Copyright 2013-2020 Mossroy 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.
*
* Kiwix is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Kiwix (file LICENSE-GPLv3.txt). If not, see <http://www.gnu.org/licenses/>
*/
'use strict';
// Set a global error handler to prevent app crashes
window.onerror = function (msg, url, line, col, error) {
console.error('Error caught in app [' + url + ':' + line + ']:\n' + msg, error);
return true;
};
/**
* Provides caching for assets contained in ZIM (variable needs to be available app-wide)
* It significantly speeds up subsequent page display. See kiwix-js issue #335
*/
var assetsCache = new Map();
/**
* A global parameter object for storing variables that need to be remembered between page loads,
* or across different functions and modules
*
* @type Object
*/
var params = {};
/**
* A global state object
*
* @type Object
*/
var appstate = {};
/******** UPDATE VERSION IN pwabuilder-sw.js TO MATCH VERSION *******/
params['version'] = "1.2.2"; //DEV: Manually update this version when there is a new release: it is compared to the Settings Store "version" in order to show first-time info, and the cookie is updated in app.js
/******* UPDATE THIS ^^^^^^ IN serveice worker!! ********************/
params['packagedFile'] = "wikipedia_en_100_maxi.zim"; //For packaged Kiwix JS (e.g. with Wikivoyage file), set this to the filename (for split files, give the first chunk *.zimaa) and place file(s) in default storage
params['archivePath'] = "archives"; //The directory containing the packaged archive(s) (relative to app's root directory)
params['fileVersion'] = "wikipedia_en_medicine-app_maxi_2021-02 (2-Feb-2021)"; //This will be displayed in the app - optionally include date of ZIM file
// List of known start pages cached in the FS:
params['cachedStartPages'] = {
'wikipedia_en_medicine-app_maxi': 'A/Wikipedia:WikiProject_Medicine/Open_Textbook_of_Medicine'
};
params['kiwixDownloadLink'] = "https://download.kiwix.org/zim/"; //Include final slash
/******* DEV: ENSURE SERVERS BELOW ARE LISTED IN package.appxmanifest ************/
params['PWAServer'] = "https://pwa.kiwix.org/"; // Production server
// params['PWAServer'] = "https://kiwix.github.io/kiwix-js-windows/"; // Test server
params['PWAMode'] = getSetting('PWAMode'); // Set to true if the app should always operate in PWA mode
params['storeType'] = getBestAvailableStorageAPI();
params['keyPrefix'] = 'kiwixjs-'; // Prefix to use for localStorage keys
params['maxResults'] = ~~(getSetting('maxResults') || 25); //Number of search results to display
params['relativeFontSize'] = ~~(getSetting('relativeFontSize') || 100); //Sets the initial font size for articles (as a percentage) - user can adjust using zoom buttons
params['relativeUIFontSize'] = ~~(getSetting('relativeUIFontSize') || 100); //Sets the initial font size for UI (as a percentage) - user can adjust using slider in Config
params['cssSource'] = getSetting('cssSource') || "auto"; //Set default to "auto", "desktop" or "mobile"
params['removePageMaxWidth'] = getSetting('removePageMaxWidth') != null ? getSetting('removePageMaxWidth') : "auto"; //Set default for removing max-width restriction on Wikimedia pages ("auto" = removed in desktop, not in mobile; true = always remove; false = never remove)
params['openAllSections'] = getSetting('openAllSections') != null ? getSetting('openAllSections') : true; //Set default for opening all sections in ZIMs that have collapsible sections and headings ("auto" = let CSS decide according to screen width; true = always open until clicked by user; false = always closed until clicked by user)
params['cssCache'] = getSetting('cssCache') != null ? getSetting('cssCache') : true; //Set default to true to use cached CSS, false to use Zim only
params['cssTheme'] = getSetting('cssTheme') || 'light'; //Set default to 'auto', 'light', 'dark' or 'invert' to use respective themes for articles
params['cssUITheme'] = getSetting('cssUITheme') || 'light'; //Set default to 'auto', 'light' or 'dark' to use respective themes for UI
params['imageDisplay'] = getSetting('imageDisplay') != null ? getSetting('imageDisplay') : true; //Set default to display images from Zim
params['hideToolbars'] = getSetting('hideToolbars') != null ? getSetting('hideToolbars') : true; //Set default to true (hides both), 'top' (hides top only), or false (no hiding)
params['rememberLastPage'] = getSetting('rememberLastPage') != null ? getSetting('rememberLastPage') : true; //Set default option to remember the last visited page between sessions
params['useMathJax'] = getSetting('useMathJax') != null ? getSetting('useMathJax') : true; //Set default to true to display math formulae with MathJax, false to use fallback SVG images only
//params['showFileSelectors'] = getCookie('showFileSelectors') != null ? getCookie('showFileSelectors') : false; //Set to true to display hidden file selectors in packaged apps
params['showFileSelectors'] = true; //False will cause file selectors to be hidden on each load of the app (by ignoring cookie)
params['hideActiveContentWarning'] = getSetting('hideActiveContentWarning') != null ? getSetting('hideActiveContentWarning') : false;
params['allowHTMLExtraction'] = getSetting('allowHTMLExtraction') == true;
params['alphaChar'] = getSetting('alphaChar') || 'A'; //Set default start of alphabet string (used by the Archive Index)
params['omegaChar'] = getSetting('omegaChar') || 'Z'; //Set default end of alphabet string
params['contentInjectionMode'] = getSetting('contentInjectionMode') || 'jquery'; // Defaults to jquery mode (widest compatibility)
params['allowInternetAccess'] = getSetting('allowInternetAccess');
//Do not touch these values unless you know what they do! Some are global variables, some are set programmatically
params['imageDisplayMode'] = params.imageDisplay ? 'progressive' : 'manual';
params['storedFile'] = getSetting('lastSelectedArchive') || params['packagedFile'] || '';
params.storedFile = launchArguments ? launchArguments.files[0].name : params.storedFile;
params['lastPageVisit'] = params.rememberLastPage && params.storedFile ? getSetting(params.storedFile) || '' : '';
params.lastPageVisit = params.lastPageVisit ? params.lastPageVisit + '@kiwixKey@' + params.storedFile : '';
params['storedFilePath'] = getSetting('lastSelectedArchivePath');
params.storedFilePath = params.storedFilePath ? decodeURIComponent(params.storedFilePath) : params.archivePath + '/' + params.packagedFile;
params.storedFilePath = launchArguments ? launchArguments.files[0].path || '' : params.storedFilePath;
params.originalPackagedFile = params.packagedFile;
params['localStorage'] = params['localStorage'] || "";
params['pickedFile'] = launchArguments ? launchArguments.files[0] : "";
params['pickedFolder'] = params['pickedFolder'] || "";
params['themeChanged'] = params['themeChanged'] || false;
params['printIntercept'] = false;
params['printInterception'] = false;
params['appIsLaunching'] = true; // Allows some routines to tell if the app has just been launched
params['useCache'] = true; // This needs to be made optional in UI
params['PWAInstalled'] = getSetting('PWAInstalled');
params['appType'] = getAppType();
params['falFileToken'] = "zimfile"; // UWP support
params['falFolderToken'] = "zimfilestore"; // UWP support
params.pagesLoaded = 0; // Page counter used to show PWA Install Prompt only after user has played with the app for a while
params.localUWPSettings = /UWP/.test(params.appType) ? Windows.Storage.ApplicationData.current.localSettings.values : null;
// Apply any override parameters in querystring (done as a self-calling function to avoid creating global variables)
(function overrideParams() {
var rgx = /[?&]([^=]+)=([^&]+)/g;
var matches = rgx.exec(window.location.search);
while (matches) {
if (matches[1] && matches[2]) {
var paramKey = decodeURIComponent(matches[1]);
var paramVal = decodeURIComponent(matches[2]);
if (paramKey !== 'title') {
// Store new values
if (params.storeType === 'cookie') {
document.cookie = encodeUriComponent(paramKey) + '=' + encodeUriComponent(paramVal) + ';expires=Fri, 31 Dec 9999 23:59:59 GMT';
}
// Make Boolean value
paramVal = paramVal === 'false' ? false : paramVal === 'true' ? true : paramVal;
if (params.storeType === 'local_storage') {
localStorage.setItem(params.keyPrefix + paramKey, paramVal);
}
paramKey = paramKey === 'lastSelectedArchive' ? 'storedFile' : paramKey;
params[paramKey] = paramVal;
}
}
matches = rgx.exec(window.location.search);
}
})();
// This code runs on the PWA UWP app running from https://
if (/^http/i.test(window.location.protocol) && /UWP\|PWA/.test(params.appType)) {
// We are in a PWA, so signal success
params.localUWPSettings.PWA_launch = 'success';
// DEV: Internal code for testing. If you need to debug restart of app, pause in DevTools on line below,
// set params.reboot = true and then continue. App will reboot to local code.
if (params.reboot) {
window.location.href = 'ms-appx-web:///www/index.html';
beamMeDownScotty();
}
}
// This code runs on the basic UWP app running from ms-appx-web://
if (!/^http/i.test(window.location.protocol) && params.localUWPSettings &&
params.contentInjectionMode === 'serviceworker' && params.allowInternetAccess) {
// Test that there has been a successful handover to the PWA
if (params.localUWPSettings.PWA_launch === 'success') {
// Signal failure until the PWA has launched, where this will be changed to 'success'
params.localUWPSettings.PWA_launch = 'fail';
// User wants PWA mode and it has previously launched, so do quick reload now
window.location.href = params.PWAServer + 'www/index.html?allowInternetAccess=true';
// This will trigger the error catching above, cleanly dematerialize this script and transport us swiftly to PWA land
window.beamMeUpScotty();
} else if (params.localUWPSettings.PWA_launch === 'fail') {
console.error('PWA failed to launch correctly last time! Setting failsafe to avoid boot-loop...');
}
}
// Prevent app boot loop with problematic pages that cause an app crash
if (getSetting('lastPageLoad') === 'failed') {
params.lastPageVisit = '';
} else {
// Cookie will signal failure until article is fully loaded
if (params.storeType === 'cookie') {
document.cookie = 'lastPageLoad=failed;expires=Fri, 31 Dec 9999 23:59:59 GMT';
} else if (params.storeType === 'local_storage') {
localStorage.setItem(params.keyPrefix + 'lastPageLoad', 'failed');
}
}
// Initialize checkbox, radio and other values
document.getElementById('cssCacheModeCheck').checked = params.cssCache;
document.getElementById('imageDisplayModeCheck').checked = params.imageDisplay;
document.getElementById('removePageMaxWidthCheck').checked = params.removePageMaxWidth === true; // Will be false if false or auto
document.getElementById('removePageMaxWidthCheck').indeterminate = params.removePageMaxWidth == "auto";
document.getElementById('removePageMaxWidthCheck').readOnly = params.removePageMaxWidth == "auto";
document.getElementById('pageMaxWidthState').innerHTML = (params.removePageMaxWidth == "auto" ? "auto" : params.removePageMaxWidth ? "always" : "never");
document.getElementById('openAllSectionsCheck').checked = params.openAllSections;
document.getElementById('cssUIDarkThemeCheck').checked = params.cssUITheme == "dark"; // Will be true, or false if light or auto
document.getElementById('cssUIDarkThemeCheck').indeterminate = params.cssUITheme == "auto";
document.getElementById('cssUIDarkThemeCheck').readOnly = params.cssUITheme == "auto";
document.getElementById('cssUIDarkThemeState').innerHTML = params.cssUITheme;
document.getElementById('cssWikiDarkThemeCheck').checked = /dark|invert/.test(params.cssTheme);
document.getElementById('cssWikiDarkThemeCheck').indeterminate = params.cssTheme == "auto";
document.getElementById('cssWikiDarkThemeCheck').readOnly = params.cssTheme == "auto";
document.getElementById('cssWikiDarkThemeState').innerHTML = params.cssTheme;
document.getElementById('darkInvert').style.display = /dark|invert/i.test(params.cssTheme) ? "inline" : "none";
document.getElementById('cssWikiDarkThemeInvertCheck').checked = params.cssTheme == 'invert';
document.getElementById('useMathJaxRadio' + (params.useMathJax ? 'True' : 'False')).checked = true;
document.getElementById('rememberLastPageCheck').checked = params.rememberLastPage;
document.getElementById('displayFileSelectorsCheck').checked = params.showFileSelectors;
document.getElementById('hideActiveContentWarningCheck').checked = params.hideActiveContentWarning;
document.getElementById('allowHTMLExtractionCheck').checked = params.allowHTMLExtraction;
document.getElementById('alphaCharTxt').value = params.alphaChar;
document.getElementById('omegaCharTxt').value = params.omegaChar;
document.getElementById('maxResults').value = params.maxResults;
document.getElementById('hideToolbarsCheck').checked = params.hideToolbars === true; // Will be false if false or 'top'
document.getElementById('hideToolbarsCheck').indeterminate = params.hideToolbars === "top";
document.getElementById('hideToolbarsCheck').readOnly = params.hideToolbars === "top";
document.getElementById('hideToolbarsState').innerHTML = (params.hideToolbars === "top" ? "top" : params.hideToolbars ? "both" : "never");
document.getElementById('allowInternetAccessCheck').checked = params.allowInternetAccess;
// Howeever, if we're accessing the app from a server, add indication that we are online by default (user can turn off and will receive instructions)
if (/^http/i.test(window.location.protocol) && params.allowInternetAccess === null) {
document.getElementById('allowInternetAccessCheck').checked = true;
params.allowInternetAccess = true;
}
// If we're in a PWA served from http, change the app titles
if (/^http/i.test(window.location.protocol)) {
Array.prototype.slice.call(document.querySelectorAll('span.identity')).forEach(function (ele) {
ele.innerHTML = 'PWA';
});
}
// Get app type
function getAppType() {
var type = 'HTML5';
if (typeof Windows !== 'undefined' && typeof Windows.Storage !== 'undefined') type = 'UWP';
if (window.fs || window.nw) type = 'Electron';
if (navigator.serviceWorker) type += '|PWA';
return type;
}
// Set up storage types
if (params.storedFile && typeof Windows !== 'undefined' && typeof Windows.Storage !== 'undefined') { //UWP
Windows.ApplicationModel.Package.current.installedLocation.getFolderAsync(params.archivePath).done(function (folder) {
params.localStorage = folder;
}, function (err) {
console.error("This app doesn't appear to have access to local storage!");
});
var futureAccessList = Windows.Storage.AccessCache.StorageApplicationPermissions.futureAccessList;
if (futureAccessList.containsItem(params.falFolderToken)) {
futureAccessList.getFolderAsync(params.falFolderToken).done(function (folder) {
params.pickedFolder = folder;
}, function (err) {
console.error("The previously picked folder is no longer accessible: " + err.message);
});
}
//If we don't already have a picked file (e.g. by launching app with click on a ZIM file), then retrieve it from futureAccessList if possible
var listOfArchives = getSetting('listOfArchives');
// But don't get the picked file if we already have access to the folder and the file is in it!
if (listOfArchives && ~listOfArchives.indexOf(params.storedFile) && params.pickedFolder) {
params.pickedFile = '';
} else {
if (!params.pickedFile && futureAccessList.containsItem(params.falFileToken)) {
params.pickedFile = '';
futureAccessList.getFileAsync(params.falFileToken).done(function (file) {
if (file.name === params.storedFile) params.pickedFile = file;
}, function (err) {
console.error("The previously picked file is no longer accessible: " + err.message);
});
}
}
}
// Routine for installing the app adapted from https://pwa-workshop.js.org/
var deferredPrompt;
var divInstall1 = document.getElementById('divInstall1');
var btnInstall1 = document.getElementById('btnInstall1');
var divInstall2 = document.getElementById('divInstall2');
var btnInstall2 = document.getElementById('btnInstall2');
var btnLater = document.getElementById('btnLater');
window.addEventListener('beforeinstallprompt', function(e) {
console.log('beforeinstallprompt fired');
// Prevent Chrome 76 and earlier from automatically showing a prompt
e.preventDefault();
// Stash the event so it can be triggered later.
deferredPrompt = e;
// Show the install button
divInstall2.style.display = 'block';
btnInstall2.addEventListener('click', installApp);
// Don't display prompt if the PWA for this version is already installed
if (!params.beforeinstallpromptFired) {
params.beforeinstallpromptFired = true;
btnInstall1.addEventListener('click', installApp);
btnLater.addEventListener('click', function (e) {
e.preventDefault();
divInstall1.innerHTML = '<b>You can install this app later from Configuration</b>';
setTimeout(function() {
divInstall1.style.display = 'none';
}, 4000);
params.installLater = true;
});
}
// The app hasn't actually been installed or user has uninstalled, so we need to reset any setting
if (params.storeType === 'cookie') {
document.cookie = 'PWAInstalled=; expires=Thu, 01 Jan 1970 00:00:00 GMT';
} else if (params.storeType === 'local_storage') {
localStorage.removeItem(params.keyPrefix + 'PWAInstalled');
}
});
function installApp(e) {
e.preventDefault();
// Show the prompt
deferredPrompt.prompt();
btnInstall1.disabled = true;
btnInstall2.disabled = true;
// Wait for the user to respond to the prompt
deferredPrompt.userChoice.then(function(choiceResult) {
if (choiceResult.outcome === 'accepted') {
console.log('PWA installation accepted');
divInstall1.style.display = 'none';
divInstall2.style.display = 'none';
} else {
console.log('PWA installation rejected');
}
btnInstall1.disabled = false;
btnInstall2.disabled = false;
deferredPrompt = null;
params.beforeinstallpromptFired = false;
});
}
window.addEventListener('appinstalled', function(e) {
params.PWAInstalled = params.version;
if (params.storeType === 'cookie') {
document.cookie = 'PWAInstalled=' + encodeURIComponent(params.PWAInstalled) + '; expires=Fri, 31 Dec 9999 23:59:59 GMT';
} else if (params.storeType === 'local_storage') {
localStorage.setItem(params.keyPrefix + 'PWAInstalled', params.PWAInstalled);
}
});
function getSetting(name) {
var result;
if (params.storeType === 'cookie') {
var regexp = new RegExp('(?:^|;)\\s*' + name + '=([^;]+)(?:;|$)');
result = document.cookie.match(regexp);
result = result && result.length > 1 ? result[1] : null;
} else if (params.storeType === 'local_storage') {
// Use localStorage instead
result = localStorage.getItem(params.keyPrefix + name);
}
return result === null || result === "undefined" ? null : result === "true" ? true : result === "false" ? false : result;
}
// Tests for available Storage APIs (document.cookie or localStorage) and returns the best available of these
// DEV: This function is replicated from settingsStore.js because RequireJS has not yet loaded it,
// except that it returns 'cookie' if the always-present contentInjectionMode is still in cookie, which
// means the store previously used cookies and hasn't upgraded yet: this won't be done till app.js is loaded
function getBestAvailableStorageAPI() {
var type = 'none';
var localStorageTest;
try {
localStorageTest = 'localStorage' in window && window['localStorage'] !== null;
if (localStorageTest) {
localStorage.setItem('tempKiwixStorageTest', '');
localStorage.removeItem('tempKiwixStorageTest');
}
} catch (e) {
localStorageTest = false;
}
document.cookie = 'tempKiwixCookieTest=working; expires=Fri, 31 Dec 9999 23:59:59 GMT; SameSite=Strict';
var kiwixCookieTest = /tempKiwixCookieTest=working/.test(document.cookie);
document.cookie = 'tempKiwixCookieTest=; expires=Thu, 01 Jan 1970 00:00:00 GMT; SameSite=Strict';
if (kiwixCookieTest) type = 'cookie';
if (localStorageTest && !/contentInjectionMode=(?:jquery|serviceworker)/.test(document.cookie)) type = 'local_storage';
return type;
}
require.config({
//enforceDefine: true, //This is for debugging IE errors
baseUrl: 'js/lib',
config: { '../app': { params: params } },
paths: {
'jquery': 'jquery-3.2.1.slim',
//'jquery': 'jquery-3.2.1',
//'bootstrap': 'bootstrap'
'bootstrap': 'bootstrap.min',
'webpHeroBundle': 'webpHeroBundle_0.0.0-dev.27',
'webpHeroPolyfills': 'webpHeroPolyfills_0.0.0-dev.27'
},
shim: {
'jquery': {
exports: '$'
},
'bootstrap': {
deps: ['jquery']
},
'webpHeroBundle': {
deps: ['webpHeroPolyfills']
}
}
});
requirejs(['bootstrap'], function (bootstrap) {
requirejs(['../app']);
});
// Load the WebP Polyfills only if needed
var webpMachine = false;
// Using self-invoking function to avoid defining global functions and variables
(function (callback) {
// Tests for native WebP support
var webP = new Image();
webP.onload = webP.onerror = function () {
callback(webP.height === 2);
};
webP.src = 'data:image/webp;base64,UklGRjoAAABXRUJQVlA4IC4AAACyAgCdASoCAAIALmk0mk0iIiIiIgBoSygABc6WWgAA/veff/0PP8bA//LwYAAA';
})(function (support) {
if (!support) {
webpMachine = true;
}
});