Remove debug logs with DOM queries

0f9cd5f48d9d3ac1c66e83d7c8581360915c5acf

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +2 -18Ignore whitespace
public/scripts/world-info.js+2 -18
@@ -1943,23 +1943,20 @@ function clearEntryList() {
19431943
19441944
1945 if (!$list.children().length) {1945 if (!$list.children().length) {
1946 console.warn('List already empty, skipping cleanup.');1946 console.debug('List already empty, skipping cleanup.');
1947 console.timeEnd('clearEntryList');1947 console.timeEnd('clearEntryList');
1948 return;1948 return;
1949 }1949 }
19501950
1951 // Step 1: Clean all <option> elements within <select>1951 // Step 1: Clean all <option> elements within <select>
1952 console.warn(`Before cleaning: ${$list.find('option').length} options in list`);
1953 $list.find('option').each(function () {1952 $list.find('option').each(function () {
1954 const $option = $(this);1953 const $option = $(this);
1955 $option.off();1954 $option.off();
1956 $.cleanData([$option[0]]);1955 $.cleanData([$option[0]]);
1957 $option.remove();1956 $option.remove();
1958 });1957 });
1959 console.warn(`Post-clean: ${$list.find('option').length} options in list`);
19601958
1961 // Step 2: Clean all <select> elements1959 // Step 2: Clean all <select> elements
1962 console.warn(`Before cleaning: ${$list.find('select').length} selects in list`);
1963 $list.find('select').each(function () {1960 $list.find('select').each(function () {
1964 const $select = $(this);1961 const $select = $(this);
1965 // Remove Select2-related data and container if present1962 // Remove Select2-related data and container if present
@@ -1967,7 +1964,7 @@ function clearEntryList() {
1967 try {1964 try {
1968 $select.select2('destroy');1965 $select.select2('destroy');
1969 } catch (e) {1966 } catch (e) {
1970 console.warn('Select2 destroy failed:', e);1967 console.debug('Select2 destroy failed:', e);
1971 }1968 }
1972 }1969 }
1973 const $container = $select.parent();1970 const $container = $select.parent();
@@ -1975,47 +1972,34 @@ function clearEntryList() {
1975 $container.find('*').off();1972 $container.find('*').off();
1976 $.cleanData($container.find('*').get());1973 $.cleanData($container.find('*').get());
1977 $container.remove();1974 $container.remove();
1978 } else {
1979 console.warn('container not found');
1980 console.warn($select.parent().html());
1981 }1975 }
1982 // Destroy Select2 if applicable
19831976
1984 $select.off();1977 $select.off();
1985 $.cleanData([$select[0]]);1978 $.cleanData([$select[0]]);
19861979
1987 });1980 });
1988 console.warn(`Post-clean: ${$list.find('select').length} selects in list`);
19891981
1990 // Step 3: Clean <div>, <span>, <input>1982 // Step 3: Clean <div>, <span>, <input>
1991 console.warn(`Before cleaning: ${$list.find('div, span, input').length} divs, spans, inputs in list`);
1992 $list.find('div, span, input').each(function () {1983 $list.find('div, span, input').each(function () {
1993 const $elem = $(this);1984 const $elem = $(this);
1994 $elem.off();1985 $elem.off();
1995 $.cleanData([$elem[0]]);1986 $.cleanData([$elem[0]]);
1996 $elem.remove();1987 $elem.remove();
1997 });1988 });
1998 console.warn(`Post-clean: ${$list.find('div, span, input').length} divs, spans, inputs in list`);
19991989
2000 // Destroy Sortable1990 // Destroy Sortable
2001 console.warn(`Before cleaning: ${$list.sortable('instance') ? 1 : 0} sortable instance in list`);
2002 if ($list.sortable('instance')) {1991 if ($list.sortable('instance')) {
2003 $list.sortable('destroy');1992 $list.sortable('destroy');
2004 }1993 }
2005 console.warn(`Post-cleaning: ${$list.sortable('instance') ? 1 : 0} sortable instance in list`);
20061994
2007 let totalElementsOfanyKindLeftInList = $list.children().length;1995 let totalElementsOfanyKindLeftInList = $list.children().length;
20081996
2009 // Final cleanup1997 // Final cleanup
2010 if (totalElementsOfanyKindLeftInList !== 0) {1998 if (totalElementsOfanyKindLeftInList !== 0) {
2011 console.time('empty');1999 console.time('empty');
2012 console.warn(`Before .empty(): ${totalElementsOfanyKindLeftInList} elements left in list`);
2013 $list.empty();2000 $list.empty();
2014 totalElementsOfanyKindLeftInList = $list.children().length;2001 totalElementsOfanyKindLeftInList = $list.children().length;
2015 console.warn(`After .empty(): ${totalElementsOfanyKindLeftInList} elements left in list`);
2016 console.timeEnd('empty');2002 console.timeEnd('empty');
2017 } else {
2018 console.warn('Entry List is already totally empty, no need to call .empty()');
2019 }2003 }
20202004
2021 console.timeEnd('clearEntryList');2005 console.timeEnd('clearEntryList');