MCPcopy Create free account
hub / github.com/Tampermonkey/tampermonkey / initMultiSelect

Function initMultiSelect

src/options.js:2133–2194  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2131};
2132
2133var initMultiSelect= function() {
2134 var mode = 0;
2135 gCallbacks['multiselect'] = {};
2136
2137 gCallbacks['multiselect']['single_click'] = function() {
2138 var m = 0;
2139
2140 var all = document.getElementsByName('scriptselectors')
2141 var all_native = true;
2142 var any_native = false;
2143 var found_native = false;
2144 var all_scripts = true;
2145 var any_script = false;
2146 var found_scripts = false;
2147
2148 for (var a = 0; a < all.length; a++) {
2149 if (all[a].s_type == 'n') {
2150 found_native = true;
2151 all_native = all_native && all[a].checked;
2152 any_native = any_native || all[a].checked;
2153 } else if (all[a].s_type == 's') {
2154 found_scripts = true;
2155 all_scripts = all_scripts && all[a].checked;
2156 any_script = any_script || all[a].checked;
2157 }
2158 }
2159
2160 if (found_native) {
2161 if (all_native && !any_script) {
2162 m = 1;
2163 } else if (all_scripts && !any_native && any_script) {
2164 m = 2;
2165 }
2166 } else if (found_scripts && all_scripts) {
2167 m = 3;
2168 }
2169 if (m != mode) {
2170 mode = m;
2171 var ch = cr('input', 'sms', 'all');
2172 ch.checked = (m != 0);
2173 }
2174 };
2175
2176 gCallbacks['multiselect']['un_selectAll'] = function() {
2177 if (++mode > 3) mode = 0;
2178 var any_script = false;
2179
2180 var all = document.getElementsByName('scriptselectors')
2181 for (var a = 0; a < all.length; a++) {
2182 if (a == 0 && (mode == 1 || mode == 3) && all[a].s_type == 's') {
2183 // first element shows that no native scripts are installed :(
2184 if (++mode > 3) mode = 0;
2185 }
2186 any_script |= (all[a].s_type == 's');
2187
2188 all[a].checked = (mode == 3 || mode == 1 && all[a].s_type == 'n' || mode == 2 && all[a].s_type == 's');
2189 }
2190 if (mode > 1 && !any_script) mode = 0;

Callers 1

options.jsFile · 0.85

Calls 1

crFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…