-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Artony4444
authored and
Artony4444
committed
Dec 23, 2023
1 parent
c1dc0ca
commit 0c0cf40
Showing
7 changed files
with
62 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,83 @@ | ||
|
||
|
||
// ---------- Import Files ---------- // | ||
// ---------- Installing ---------- // | ||
|
||
|
||
let dcs = document.currentScript; | ||
let address = dcs.getAttribute("src").split("static-chess.js").join(""); | ||
let boardID = dcs.staticChess; | ||
let boardID = "sc:"+parseInt(Math.random()*10000); | ||
|
||
|
||
//---------- css | ||
// ---------- css | ||
|
||
let cssStyles = ` | ||
<link rel="stylesheet" href="`+address+`src/css/root.css"> | ||
<link rel="stylesheet" href="`+address+`src/css/blocks.css"> | ||
<link rel="stylesheet" href="`+address+`src/css/main.css"> | ||
<link rel="stylesheet" href="`+address+`src/css/chess.board.css"> | ||
<div static-chess="`+boardID+`"> | ||
<link rel="stylesheet" href="`+address+`src/css/root.css"> | ||
<link rel="stylesheet" href="`+address+`src/css/blocks.css"> | ||
<link rel="stylesheet" href="`+address+`src/css/main.css"> | ||
<link rel="stylesheet" href="`+address+`src/css/chess.board.css"> | ||
</div> | ||
`; | ||
|
||
let head = document.getElementsByTagName('head')[0]; | ||
head.insertAdjacentHTML("beforeend", cssStyles); | ||
|
||
|
||
//---------- js | ||
// ---------- board container | ||
|
||
let div = document.createElement('div'); | ||
div.id = boardID; | ||
div.staticChess = boardID; | ||
dcs.replaceWith(div); | ||
let container = document.createElement('div'); | ||
container.id = boardID; | ||
container.setAttribute("static-chess", boardID); | ||
container.className = "container"; | ||
dcs.replaceWith(container); | ||
|
||
|
||
// ---------- js | ||
|
||
let jsClassesSRC = [ | ||
let jsSRC = [ | ||
address+"src/js/tools/strings.js", | ||
address+"src/js/tools/converter.js", | ||
address+"src/js/ui/objects/drag-drop.js", | ||
address+"src/js/ui/ui.js", | ||
address+"src/js/chess/objects/pieces.js", | ||
address+"src/js/chess/objects/square.js", | ||
address+"src/js/chess/objects/logic.js", | ||
address+"src/js/chess/objects/board.js", | ||
address+"src/js/chess/pieces.js", | ||
address+"src/js/chess/square.js", | ||
address+"src/js/chess/logic.js", | ||
address+"src/js/chess/board.js", | ||
address+"src/js/main.js" | ||
]; | ||
|
||
let loadedCount = 0; | ||
let body = document.getElementsByTagName('body')[0]; | ||
let div = document.createElement('div'); | ||
div.setAttribute("static-chess", boardID); | ||
div.className = "static-chess-script"; | ||
body.appendChild(div); // if error => use this format <div> <STATIC-CHESS-SCRIPT> </div> or (use static-chess inside body) | ||
|
||
document.addEventListener("DOMContentLoaded", function() {loadScriptSequentially();}); | ||
document.addEventListener("DOMContentLoaded", addScript); | ||
let loadedCount = 0; | ||
|
||
function loadScriptSequentially() | ||
function addScript() | ||
{ | ||
if(loadedCount < jsClassesSRC.length) | ||
if(loadedCount < jsSRC.length) | ||
{ | ||
let src = jsClassesSRC[loadedCount]; | ||
let src = jsSRC[loadedCount]; | ||
|
||
let sc = document.createElement('script'); | ||
sc.type = "text/javascript"; | ||
sc.src = src; | ||
div.staticChess = boardID; | ||
|
||
sc.onload = function() | ||
{ | ||
loadedCount++; | ||
loadScriptSequentially(); | ||
}; | ||
|
||
div.appendChild(sc); | ||
sc.insertAdjacentHTML("afterend", "\n "); | ||
let script = document.createElement('script'); // script.type = "text/javascript"; | ||
script.src = src; | ||
script.boardID = boardID; | ||
script.onload = function() { loadedCount++; addScript(); }; | ||
|
||
div.appendChild(script); | ||
script.insertAdjacentHTML("beforebegin", "\n "); | ||
} | ||
} | ||
|
||
|
||
/* | ||
<---- debug ----> | ||
/* ---------- DEBUG | ||
if(loadedCount == jsClassesSRC.length - 1) | ||
if(loadedCount == jsSRC.length - 1) | ||
{ | ||
//document.querySelectorAll('[staticChess]').forEach((e) => console.log(e)); | ||
console.log(document.getElementsByTagName('html')[0].innerHTML); | ||
} | ||
<---- changes ----> | ||
body.appendChild >> div.appendChild | ||
*/ | ||
------------- */ |