Mattthew
commited on
Commit
•
16ae0cf
1
Parent(s):
89f2ef2
tag updates, fix export bug
Browse files- artists_and_tags.js +0 -0
- index.js +30 -14
artists_and_tags.js
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
index.js
CHANGED
@@ -74,13 +74,11 @@ function checkStoringAccessType() {
|
|
74 |
})
|
75 |
.catch(error => {
|
76 |
console.warn('no settings can be saved; we only have read access to cache: ' + error);
|
77 |
-
alertNoStoringAccess(2000);
|
78 |
resolve();
|
79 |
});
|
80 |
})
|
81 |
.catch(error => {
|
82 |
console.warn('no settings can be saved; no access to any storage method: ' + error);
|
83 |
-
alertNoStoringAccess(2000);
|
84 |
resolve();
|
85 |
});
|
86 |
}
|
@@ -185,7 +183,7 @@ function alertNoStoringAccess(wait) {
|
|
185 |
msg += '1. Try Firefox, Safari, or Edge\n'
|
186 |
msg += '2. Download the app to use offline\n';
|
187 |
msg += '3. On Chrome, enable 3rd-party cookies (not recommended)\n\n';
|
188 |
-
msg += 'This app doesn\'t use cookies, never sends data to any server, and saves all data locally.
|
189 |
alert(msg);
|
190 |
},wait);
|
191 |
}
|
@@ -775,8 +773,10 @@ function unhideBasedOnPermissiveSetting() {
|
|
775 |
var unHidden = document.querySelectorAll('.image-item').length - document.querySelectorAll('.image-item.hidden').length;
|
776 |
if(unHidden == 0) {
|
777 |
document.getElementById('filtersHidingAll').classList.add('shown');
|
|
|
778 |
} else {
|
779 |
document.getElementById('filtersHidingAll').classList.remove('shown');
|
|
|
780 |
}
|
781 |
}
|
782 |
|
@@ -908,15 +908,7 @@ function showExport() {
|
|
908 |
loadItemBasedOnAccessType('favoritedArtists').then(state => {
|
909 |
var value = '';
|
910 |
if(state) {
|
911 |
-
value += '
|
912 |
-
for (let key in state) {
|
913 |
-
if (state[key] === true) {
|
914 |
-
let names = key.split("|");
|
915 |
-
if(!names[0]) { names[0] = '(no first name)'; }
|
916 |
-
value += '•' + names[0] + ',' + names[1] + '\r\n';
|
917 |
-
}
|
918 |
-
}
|
919 |
-
value += '\r\n\r\nTo import these favorites later, click "copy to clipboard" and save to any file. Then paste the text from that file into this text box, and click "import". The imported text must contain the JSON string below (the curly brackets and what\'s between them). It must not contain any other more than one set of curly brackets.\r\n\r\n' + state;
|
920 |
textareaF.value = value;
|
921 |
} else {
|
922 |
value += 'You haven\'t favorited any artists yet.\r\n\r\n';
|
@@ -940,9 +932,33 @@ function showExport() {
|
|
940 |
// db
|
941 |
var textareaA = document.getElementById('export_artists_list');
|
942 |
value = '';
|
|
|
|
|
|
|
|
|
|
|
943 |
for(i=0,il=artistsData.length;i<il;i++) {
|
944 |
-
|
945 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
946 |
}
|
947 |
textareaA.value = value;
|
948 |
}
|
|
|
74 |
})
|
75 |
.catch(error => {
|
76 |
console.warn('no settings can be saved; we only have read access to cache: ' + error);
|
|
|
77 |
resolve();
|
78 |
});
|
79 |
})
|
80 |
.catch(error => {
|
81 |
console.warn('no settings can be saved; no access to any storage method: ' + error);
|
|
|
82 |
resolve();
|
83 |
});
|
84 |
}
|
|
|
183 |
msg += '1. Try Firefox, Safari, or Edge\n'
|
184 |
msg += '2. Download the app to use offline\n';
|
185 |
msg += '3. On Chrome, enable 3rd-party cookies (not recommended)\n\n';
|
186 |
+
msg += 'This app doesn\'t use cookies, never sends data to any server, and saves all data locally. But since this app is hosted on Hugging Face, Chrome treats it as a "3rd-party". Other browsers give you more nuanced control of your privacy settings.';
|
187 |
alert(msg);
|
188 |
},wait);
|
189 |
}
|
|
|
773 |
var unHidden = document.querySelectorAll('.image-item').length - document.querySelectorAll('.image-item.hidden').length;
|
774 |
if(unHidden == 0) {
|
775 |
document.getElementById('filtersHidingAll').classList.add('shown');
|
776 |
+
document.getElementById('copy-all-names').style.display = 'none'
|
777 |
} else {
|
778 |
document.getElementById('filtersHidingAll').classList.remove('shown');
|
779 |
+
document.getElementById('copy-all-names').style.display = ''
|
780 |
}
|
781 |
}
|
782 |
|
|
|
908 |
loadItemBasedOnAccessType('favoritedArtists').then(state => {
|
909 |
var value = '';
|
910 |
if(state) {
|
911 |
+
value += '\r\n\r\nTo import these favorites later, click "copy to clipboard" and save to any file. Then paste the text from that file into this text box, and click "import". The imported text must contain the JSON string below (the curly brackets and what\'s between them).\r\n\r\n' + JSON.stringify(state);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
912 |
textareaF.value = value;
|
913 |
} else {
|
914 |
value += 'You haven\'t favorited any artists yet.\r\n\r\n';
|
|
|
932 |
// db
|
933 |
var textareaA = document.getElementById('export_artists_list');
|
934 |
value = '';
|
935 |
+
artistData = artistsData.sort(function(a, b) {
|
936 |
+
var aValue = a[0].toLowerCase();
|
937 |
+
var bValue = b[0].toLowerCase();
|
938 |
+
return aValue.localeCompare(bValue);
|
939 |
+
});
|
940 |
for(i=0,il=artistsData.length;i<il;i++) {
|
941 |
+
// output artists sorted by alpha and their tags sorted by alpha
|
942 |
+
let artist = artistsData[i];
|
943 |
+
let tags = artist[2].split('|');
|
944 |
+
tags = tags.sort(function(a, b) {
|
945 |
+
var aValue = a.toLowerCase();
|
946 |
+
var bValue = b.toLowerCase();
|
947 |
+
return aValue.localeCompare(bValue);
|
948 |
+
});
|
949 |
+
let newTags = [];
|
950 |
+
let added = '';
|
951 |
+
// move the 'added' tag to the end
|
952 |
+
for (let i=0, il=tags.length; i<il; i++) {
|
953 |
+
if(tags[i].match(/added-(\d|-)*/)) {
|
954 |
+
added = tags[i];
|
955 |
+
} else {
|
956 |
+
newTags.push(tags[i]);
|
957 |
+
}
|
958 |
+
}
|
959 |
+
newTags.push(added);
|
960 |
+
artist[2] = newTags.join('|');
|
961 |
+
value += '["'+artist[0]+'","'+artist[1]+'","'+artist[2]+'",'+artist[3]+'],\r\n';
|
962 |
}
|
963 |
textareaA.value = value;
|
964 |
}
|