Skip to content

Commit

Permalink
added CSSpreloadClasses(doc, msDelay, classNames)
Browse files Browse the repository at this point in the history
  • Loading branch information
DarrenSem authored Jan 6, 2024
1 parent e8780d8 commit 7a0696b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
23 changes: 22 additions & 1 deletion catan-gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let DEBUG_RUNS_FILLTILES = 1;



const DEBUG_SKIP_FILLTILES_ON_LOAD = !"DEBUG_SKIP_FILLTILES_ON_LOAD"; // useful during testing of OPTIONS with RandomWithSeed
const DEBUG_SKIP_FILLTILES_ON_LOAD = !!"DEBUG_SKIP_FILLTILES_ON_LOAD"; // useful during testing of OPTIONS with RandomWithSeed

const DEBUG_INITIAL_resource_multiple_6_8 = !"DEBUG_INITIAL_resource_multiple_6_8";
// e.g. seed12 = 20 - 50 SECONDS due to resource_multiple_6_8: false
Expand Down Expand Up @@ -830,8 +830,29 @@ const test_js_only = () => {
// Start the board. Do this when page is first opened, or when mode is changed.
const initialLoadEventName = !!"LOAD" ? "load" : "DOMContentLoaded";

const CSSpreloadClasses = (doc, msDelay, ...classes) => {
let el, loadNextClass = () => (
classes.length
? setTimeout(
loadNextClass,
msDelay,
el.className = classes.shift()
)
: doc.body.removeChild(el)
);

return doc.body && loadNextClass(
classes = classes.flat(),
doc.body.appendChild(
el = doc.createElement("span")
)
);
};

const initialLoad = evt => {

CSSpreloadClasses(doc, 9, globalResourceTypes);

const skipFillTiles = DEBUG_SKIP_FILLTILES_ON_LOAD
&& ( !!evt || !"evt NOT passed therefore NEVER skipFillTiles" );

Expand Down
23 changes: 22 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ <h2>Generation Custom Rules</h2><br>



const DEBUG_SKIP_FILLTILES_ON_LOAD = !"DEBUG_SKIP_FILLTILES_ON_LOAD"; // useful during testing of OPTIONS with RandomWithSeed
const DEBUG_SKIP_FILLTILES_ON_LOAD = !!"DEBUG_SKIP_FILLTILES_ON_LOAD"; // useful during testing of OPTIONS with RandomWithSeed

const DEBUG_INITIAL_resource_multiple_6_8 = !"DEBUG_INITIAL_resource_multiple_6_8";
// e.g. seed12 = 20 - 50 SECONDS due to resource_multiple_6_8: false
Expand Down Expand Up @@ -926,8 +926,29 @@ <h2>Generation Custom Rules</h2><br>
// Start the board. Do this when page is first opened, or when mode is changed.
const initialLoadEventName = !!"LOAD" ? "load" : "DOMContentLoaded";

const CSSpreloadClasses = (doc, msDelay, ...classes) => {
let el, loadNextClass = () => (
classes.length
? setTimeout(
loadNextClass,
msDelay,
el.className = classes.shift()
)
: doc.body.removeChild(el)
);

return doc.body && loadNextClass(
classes = classes.flat(),
doc.body.appendChild(
el = doc.createElement("span")
)
);
};

const initialLoad = evt => {

CSSpreloadClasses(doc, 9, globalResourceTypes);

const skipFillTiles = DEBUG_SKIP_FILLTILES_ON_LOAD
&& ( !!evt || !"evt NOT passed therefore NEVER skipFillTiles" );

Expand Down

0 comments on commit 7a0696b

Please sign in to comment.