diff --git a/assets/js/common.js b/assets/js/common.js
index 99eae745..df33c2f3 100644
--- a/assets/js/common.js
+++ b/assets/js/common.js
@@ -129,6 +129,18 @@ function retry(fn, retries, err) {
});
}
+function flip_lazy_images() {
+ const sources = document.querySelectorAll('source.picturelazyload');
+ sources.forEach(function(lazyEl) {
+ lazyEl.setAttribute("srcset", lazyEl.getAttribute("data-srcset"));
+ });
+
+ const imgs = document.querySelectorAll('img.lazyload');
+ imgs.forEach(function(lazyEl) {
+ lazyEl.setAttribute("src", lazyEl.getAttribute("data-src"));
+ //lazyEl.setAttribute("srcset", lazyEl.getAttribute("data-srcset")); //can't do this because the webp shim can't handle it
+ });
+}
$(document).ready(function() {
$("#lang").mouseenter(function() {
diff --git a/assets/js/gallery.js b/assets/js/gallery.js
new file mode 100644
index 00000000..752cff39
--- /dev/null
+++ b/assets/js/gallery.js
@@ -0,0 +1,58 @@
+async function get_gallery_url(galleryid) {
+ const url = `https://hitomi.la/galleries/${galleryid}.html`;
+
+ const response = await fetch(url);
+ const html = await response.text();
+
+ const doc = new DOMParser().parseFromString(html, 'text/html');
+
+ return doc.querySelector('link').getAttribute('href');
+}
+
+async function get_gallery(galleryid) {
+ const url = await get_gallery_url(galleryid);
+
+ const response = await fetch(url);
+ const html = await response.text();
+
+ const doc = new DOMParser().parseFromString(rewrite_tn_paths(html), 'text/html');
+
+ //related
+ eval(Array.from(doc.getElementsByTagName('script')).find(elm => elm.innerHTML.includes('var related')).innerHTML);
+
+ const lang_list = {};
+
+ Array.from(doc.querySelectorAll('#lang-list a')).forEach(elm => lang_list[elm.innerText] = elm.getAttribute('href').slice(11, -5));
+
+ const cover = replace_jpg_tn(doc.querySelector('.cover img').src);
+
+ const title = doc.querySelector('.gallery h1 a').innerText;
+ const artists = Array.from(doc.querySelectorAll('.gallery h2 a'), elm => elm.innerText);
+ const groups = Array.from(doc.querySelectorAll('.gallery-info a[href^="/group."]'), elm => elm.innerText);
+ const type = doc.querySelector('.gallery-info a[href^="/type/"]').innerText.trim();
+
+ const language = doc.querySelector('.gallery-info a[href^="/index"][href$=".html"]').getAttribute('href').slice(7, -5);
+
+ const series = Array.from(doc.querySelectorAll('.gallery-info a[href^="/series/"]'), elm => elm.innerText);
+ const characters = Array.from(doc.querySelectorAll('.gallery-info a[href^="/character/"]'), elm => elm.innerText);
+
+ const tags = Array.from(doc.querySelectorAll('.gallery-info a[href^="/tag/"]'), elm => decodeURIComponent(elm.getAttribute('href')).slice(5, -9));
+
+ const gallery_info = await get_gallery_info(galleryid);
+ const thumbnails = gallery_info.files.map(file => url_from_url_from_hash(galleryid, file, 'webpsmallsmalltn', 'webp', 'tn'));
+
+ return {
+ related: related,
+ langList: lang_list,
+ cover: cover,
+ title: title,
+ artists: artists,
+ groups: groups,
+ type: type,
+ language: language,
+ series: series,
+ characters: characters,
+ tags: tags,
+ thumbnails: thumbnails
+ };
+}
\ No newline at end of file
diff --git a/assets/js/galleryblock.js b/assets/js/galleryblock.js
new file mode 100644
index 00000000..2e7b5a58
--- /dev/null
+++ b/assets/js/galleryblock.js
@@ -0,0 +1,35 @@
+async function get_gallery_block(galleryid) {
+ const uri = `//${domain}/${galleryblockdir}/${galleryid}${galleryblockextension}`;
+
+ const response = await fetch(uri);
+ const html = await response.text();
+
+ const doc = new DOMParser().parseFromString(rewrite_tn_paths(html), 'text/html');
+
+ const title_elm = doc.querySelector('h1 > a');
+
+ const gallery_url = title_elm.href;
+ const title = title_elm.textContent;
+
+ const thumbnails = Array.from(doc.querySelectorAll('.dj-img-cont img'), elm => replace_jpg_tn(elm.getAttribute('data-src')));
+
+ const artists = Array.from(doc.querySelectorAll('.artist-list a'), elm => elm.innerText);
+ const series = Array.from(doc.querySelectorAll('a[href^="/series/"]'), elm => elm.innerText);
+ const type = doc.querySelector('a[href^="/type/"]').innerText;
+
+ const language = doc.querySelector('a[href^="/index"][href$=".html"]').getAttribute('href').slice(7, -5);
+
+ const related_tags = Array.from(doc.querySelectorAll('.relatedtags a'), elm => decodeURIComponent(elm.getAttribute('href')).slice(5, -9));
+
+ return {
+ id: galleryid,
+ galleryUrl: gallery_url,
+ thumbnails: thumbnails,
+ title: title,
+ artists: artists,
+ series: series,
+ type: type,
+ language: language,
+ relatedTags: related_tags
+ };
+}
\ No newline at end of file
diff --git a/assets/js/gg.js b/assets/js/gg.js
index 2b00219d..ba02e0a7 100644
--- a/assets/js/gg.js
+++ b/assets/js/gg.js
@@ -4097,6 +4097,9 @@ if (g === 522) { o = 0; }
if (g === 1587) { o = 1; }
if (g === 189) { o = 1; }
if (g === 481) { o = 0; }
+if (!/Hitomi\.la/.test(document.title)) { return 4; }
+if (!document.location.hostname.endsWith('hitomi.la')) { return 4; }
+if (!document.documentElement.clientHeight) { return 4; }
return o;
},
s: function(h) { var m = /(..)(.)$/.exec(h); return parseInt(m[2]+m[1], 16).toString(10); },
diff --git a/assets/js/misc.js b/assets/js/misc.js
index 76550e53..d8885780 100644
--- a/assets/js/misc.js
+++ b/assets/js/misc.js
@@ -4,4 +4,68 @@ function get_gallery_info(galleryID) {
resolve(galleryinfo);
});
});
+}
+
+function do_search(query) {
+ let terms = query.toLowerCase().trim().split(/\s+/);
+ let positive_terms = [], negative_terms = [];
+
+ $.each(terms, function (i, term) {
+ term = term.replace(/_/g, ' ');
+ if (term.match(/^-/)) {
+ negative_terms.push(term.replace(/^-/, ''));
+ } else {
+ positive_terms.push(term);
+ }
+ });
+
+
+ return new Promise((resolve, reject) => { //first results
+ if (!positive_terms.length) {
+ get_galleryids_from_nozomi(undefined, 'index', 'all').then(results => {
+ resolve(results);
+ });
+ } else {
+ const term = positive_terms.shift();
+ get_galleryids_for_query(term).then(results => {
+ resolve(results);
+ });
+ }
+ }).then(() => { //positive results
+ return Promise.all(positive_terms.map(term => {
+ return new Promise((resolve, reject) => {
+ get_galleryids_for_query(term).then(new_results => {
+ const new_results_set = new Set(new_results);
+ results = results.filter(galleryid => new_results_set.has(galleryid));
+ resolve();
+ })
+ });
+ }));
+ }).then(() => { //negative results
+ return Promise.all(negative_terms.map(term => {
+ return new Promise((resolve, reject) => {
+ get_galleryids_for_query(term).then(new_results => {
+ const new_results_set = new Set(new_results);
+ results = results.filter(galleryid => !new_results_set.has(galleryid));
+ resolve();
+ });
+ });
+ }));
+ }).then(() => {
+ const final_results_length = results.length;
+ $('#number-of-results').html(final_results_length);
+ if (!final_results_length) {
+ hide_loading();
+ $('.gallery-content').html($('#no-results-content').html());
+ } else {
+ put_results_on_page();
+ }
+ });
+}
+
+function replace_jpg_tn(tn) {
+ if (!tn.startsWith('https')) tn = `https:${tn}`;
+ if (tn.endsWith('jpg')) tn = tn.replace('bigtn', 'webpbigtn').replace(/jpg$/, 'webp');
+
+ return tn;
}
\ No newline at end of file
diff --git a/hitomi.html b/hitomi.html
index 971c2487..c19a2f03 100644
--- a/hitomi.html
+++ b/hitomi.html
@@ -2,6 +2,8 @@
+
+
@@ -9,4 +11,4 @@
-
+
\ No newline at end of file
diff --git a/hitomi.html.ver b/hitomi.html.ver
index bbdeab62..1750564f 100644
--- a/hitomi.html.ver
+++ b/hitomi.html.ver
@@ -1 +1 @@
-0.0.5
+0.0.6