Dbrant has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/366311 )
Change subject: Update Zim postprocessing to account for lazy loading of images.
......................................................................
Update Zim postprocessing to account for lazy loading of images.
Change-Id: I36f7c2b8b39decbb8befc58a3b2df95d9981a94e
---
M app/src/main/assets/bundle.js
M www/js/sections.js
2 files changed, 26 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia
refs/changes/11/366311/1
diff --git a/app/src/main/assets/bundle.js b/app/src/main/assets/bundle.js
index 25d7139..b8df1ec 100644
--- a/app/src/main/assets/bundle.js
+++ b/app/src/main/assets/bundle.js
@@ -529,7 +529,8 @@
var sectionJson;
var i;
- var currentSectionNode = document.createElement( "div" );
+ var lazyDocument = document.implementation.createHTMLDocument( );
+ var currentSectionNode = lazyDocument.createElement( "div" );
currentSectionNode.setAttribute( "dir", window.directionality );
currentSectionNode.id = "content_block_" + sectionIndex;
contentElem.appendChild( currentSectionNode );
@@ -553,7 +554,8 @@
sectionJson.anchor = "heading_" + sectionIndex;
sectionsJson.push(sectionJson);
- currentSectionNode = document.createElement( "div" );
+ lazyDocument = document.implementation.createHTMLDocument( );
+ currentSectionNode = lazyDocument.createElement( "div" );
currentSectionNode.setAttribute( "dir", window.directionality );
currentSectionNode.id = "content_block_" + sectionIndex;
contentElem.appendChild( currentSectionNode );
@@ -583,6 +585,7 @@
window.scrollTo( 0, payload.scrollY );
}
document.getElementById( "loading_sections").className = "";
+ lazyLoadTransformer.loadPlaceholders();
bridge.sendMessage( "pageLoadComplete", {
"sequence": payload.sequence,
"savedPage": payload.savedPage,
@@ -600,6 +603,14 @@
imgTags[i].setAttribute( 'src', imgSrc.replace("../I/",
window.offlineContentProvider + "I/") );
}
}
+
+ var placeholderTags = currentSectionNode.querySelectorAll(
'span.pagelib-lazy-load-placeholder' );
+ for ( i = 0; i < placeholderTags.length; i++ ) {
+ var dataSrc = placeholderTags[i].getAttribute( 'data-src' );
+ if (dataSrc !== null) {
+ placeholderTags[i].setAttribute( 'data-src',
dataSrc.replace("../I/", window.offlineContentProvider + "I/") );
+ }
+ }
}
// -- End custom processing of ZIM html data --
diff --git a/www/js/sections.js b/www/js/sections.js
index 74c7943..2e04988 100644
--- a/www/js/sections.js
+++ b/www/js/sections.js
@@ -266,7 +266,8 @@
var sectionJson;
var i;
- var currentSectionNode = document.createElement( "div" );
+ var lazyDocument = document.implementation.createHTMLDocument( );
+ var currentSectionNode = lazyDocument.createElement( "div" );
currentSectionNode.setAttribute( "dir", window.directionality );
currentSectionNode.id = "content_block_" + sectionIndex;
contentElem.appendChild( currentSectionNode );
@@ -290,7 +291,8 @@
sectionJson.anchor = "heading_" + sectionIndex;
sectionsJson.push(sectionJson);
- currentSectionNode = document.createElement( "div" );
+ lazyDocument = document.implementation.createHTMLDocument( );
+ currentSectionNode = lazyDocument.createElement( "div" );
currentSectionNode.setAttribute( "dir", window.directionality );
currentSectionNode.id = "content_block_" + sectionIndex;
contentElem.appendChild( currentSectionNode );
@@ -320,6 +322,7 @@
window.scrollTo( 0, payload.scrollY );
}
document.getElementById( "loading_sections").className = "";
+ lazyLoadTransformer.loadPlaceholders();
bridge.sendMessage( "pageLoadComplete", {
"sequence": payload.sequence,
"savedPage": payload.savedPage,
@@ -337,6 +340,14 @@
imgTags[i].setAttribute( 'src', imgSrc.replace("../I/",
window.offlineContentProvider + "I/") );
}
}
+
+ var placeholderTags = currentSectionNode.querySelectorAll(
'span.pagelib-lazy-load-placeholder' );
+ for ( i = 0; i < placeholderTags.length; i++ ) {
+ var dataSrc = placeholderTags[i].getAttribute( 'data-src' );
+ if (dataSrc !== null) {
+ placeholderTags[i].setAttribute( 'data-src',
dataSrc.replace("../I/", window.offlineContentProvider + "I/") );
+ }
+ }
}
// -- End custom processing of ZIM html data --
--
To view, visit https://gerrit.wikimedia.org/r/366311
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I36f7c2b8b39decbb8befc58a3b2df95d9981a94e
Gerrit-PatchSet: 1
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Dbrant <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits