This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/ext/index/script.js

49 lines
1.7 KiB
JavaScript
Raw Normal View History

2014-04-25 02:29:29 +00:00
/*jshint bitwise:false, curly:true, eqeqeq:true, evil:true, forin:false, noarg:true, noempty:true, nonew:true, undef:false, strict:false, browser:true, jquery:true */
2020-03-02 17:12:43 +00:00
document.addEventListener('DOMContentLoaded', () => {
var blocked_tags = (shm_cookie_get("ui-blocked-tags") || "").split(" ");
2012-03-22 16:35:44 +00:00
var needs_refresh = false;
2015-09-12 10:43:28 +00:00
for(var i=0; i<blocked_tags.length; i++) {
2012-03-22 13:40:13 +00:00
var tag = blocked_tags[i];
2012-03-22 16:35:44 +00:00
if(tag) {
$(".shm-thumb[data-tags~='"+tag+"']").hide();
2012-03-22 16:35:44 +00:00
needs_refresh = true;
}
2012-03-22 13:40:13 +00:00
}
//Generate a random seed when using order:random
$('form > input[placeholder="Search"]').parent().submit(function(e){
var input = $('form > input[placeholder="Search"]');
var tagArr = input.val().split(" ");
var rand = (($.inArray("order:random", tagArr) + 1) || ($.inArray("order=random", tagArr) + 1)) - 1;
if(rand !== -1){
tagArr[rand] = "order:random_"+Math.floor((Math.random()*9999)+1);
input.val(tagArr.join(" "));
}
});
2018-11-05 22:59:53 +00:00
/*
* If an image list has a data-query attribute, append
* that query string to all thumb links inside the list.
* This allows us to cache the same thumb for all query
* strings, adding the query in the browser.
*/
2023-12-30 14:20:03 +00:00
document.querySelectorAll(".shm-image-list").forEach(function(list) {
var query = list.getAttribute("data-query");
2018-11-05 22:59:53 +00:00
if(query) {
2023-12-30 14:20:03 +00:00
list.querySelectorAll(".shm-thumb-link").forEach(function(thumb) {
thumb.setAttribute("href", thumb.getAttribute("href") + query);
2018-11-05 22:59:53 +00:00
});
}
});
2012-03-22 13:40:13 +00:00
});
2012-03-22 14:19:46 +00:00
function select_blocked_tags() {
var blocked_tags = prompt("Enter tags to ignore", shm_cookie_get("ui-blocked-tags") || "AI-generated");
if(blocked_tags !== null) {
shm_cookie_set("ui-blocked-tags", blocked_tags.toLowerCase());
2012-03-22 14:19:46 +00:00
location.reload(true);
}
}