@@ -920,12 +920,16 @@ var Module = null;
920920 if ( has_started )
921921 return false ;
922922 has_started = true ;
923+ var defaultOptions = { waitAfterDownloading : false ,
924+ hasCustomCSS : false } ;
923925 if ( typeof options !== 'object' ) {
924- options = { waitAfterDownloading : false } ;
926+ options = defaultOptions ;
927+ } else {
928+ options . __proto__ = defaultOptions ;
925929 }
926930
927931 var k , c , game_data ;
928- setupSplash ( canvas , splash ) ;
932+ setupSplash ( canvas , splash , options ) ;
929933 drawsplash ( ) ;
930934
931935 var loading ;
@@ -1168,6 +1172,7 @@ var Module = null;
11681172 } ;
11691173
11701174 var fetch_file = function ( title , url , rt , optional ) {
1175+ var needsCSS = ! splash . table . dataset . hasCustomCSS ;
11711176 var row = addRow ( splash . table ) ;
11721177 var titleCell = row [ 0 ] , statusCell = row [ 1 ] ;
11731178 titleCell . textContent = title ;
@@ -1201,17 +1206,23 @@ var Module = null;
12011206 } ;
12021207 function success ( ) {
12031208 statusCell . textContent = "✔" ;
1209+ titleCell . parentNode . classList . add ( 'emularity-download-success' ) ;
12041210 titleCell . textContent = title ;
1205- titleCell . style . fontWeight = 'bold' ;
1206- titleCell . parentNode . style . backgroundColor = splash . getColor ( 'foreground' ) ;
1207- titleCell . parentNode . style . color = splash . getColor ( 'background' ) ;
1211+ if ( needsCSS ) {
1212+ titleCell . style . fontWeight = 'bold' ;
1213+ titleCell . parentNode . style . backgroundColor = splash . getColor ( 'foreground' ) ;
1214+ titleCell . parentNode . style . color = splash . getColor ( 'background' ) ;
1215+ }
12081216 }
12091217 function failure ( ) {
12101218 statusCell . textContent = "✘" ;
1219+ titleCell . parentNode . classList . add ( 'emularity-download-failure' ) ;
12111220 titleCell . textContent = title ;
1212- titleCell . style . fontWeight = 'bold' ;
1213- titleCell . parentNode . style . backgroundColor = splash . getColor ( 'failure' ) ;
1214- titleCell . parentNode . style . color = splash . getColor ( 'background' ) ;
1221+ if ( needsCSS ) {
1222+ titleCell . style . fontWeight = 'bold' ;
1223+ titleCell . parentNode . style . backgroundColor = splash . getColor ( 'failure' ) ;
1224+ titleCell . parentNode . style . color = splash . getColor ( 'background' ) ;
1225+ }
12151226 }
12161227 xhr . send ( ) ;
12171228 } ) ;
@@ -1253,48 +1264,57 @@ var Module = null;
12531264 console . log ( "canvas cleared" ) ;
12541265 } ;
12551266
1256- function setupSplash ( canvas , splash ) {
1267+ function setupSplash ( canvas , splash , globalOptions ) {
12571268 splash . splashElt = document . getElementById ( "emularity-splash-screen" ) ;
12581269 if ( ! splash . splashElt ) {
12591270 splash . splashElt = document . createElement ( 'div' ) ;
1260- splash . splashElt . setAttribute ( 'id' , "emularity-splash-screen" ) ;
1261- splash . splashElt . style . position = 'absolute' ;
1262- splash . splashElt . style . top = canvas . offsetTop + 'px' ;
1263- splash . splashElt . style . left = canvas . offsetLeft + 'px' ;
1264- splash . splashElt . style . width = canvas . offsetWidth + 'px' ;
1265- splash . splashElt . style . color = splash . getColor ( 'foreground' ) ;
1266- splash . splashElt . style . backgroundColor = splash . getColor ( 'background' ) ;
1271+ splash . splashElt . classList . add ( "emularity-splash-screen" ) ;
1272+ if ( ! globalOptions . hasCustomCSS ) {
1273+ splash . splashElt . style . position = 'absolute' ;
1274+ splash . splashElt . style . top = '0' ;
1275+ splash . splashElt . style . left = '0' ;
1276+ splash . splashElt . style . right = '0' ;
1277+ splash . splashElt . style . color = splash . getColor ( 'foreground' ) ;
1278+ splash . splashElt . style . backgroundColor = splash . getColor ( 'background' ) ;
1279+ }
12671280 canvas . parentElement . appendChild ( splash . splashElt ) ;
12681281 }
12691282
1270- splash . splashimg . setAttribute ( 'id' , "emularity-splash-image" ) ;
1271- splash . splashimg . style . display = 'block' ;
1272- splash . splashimg . style . marginLeft = 'auto' ;
1273- splash . splashimg . style . marginRight = 'auto' ;
1283+ splash . splashimg . classList . add ( "emularity-splash-image" ) ;
1284+ if ( ! globalOptions . hasCustomCSS ) {
1285+ splash . splashimg . style . display = 'block' ;
1286+ splash . splashimg . style . marginLeft = 'auto' ;
1287+ splash . splashimg . style . marginRight = 'auto' ;
1288+ }
12741289 splash . splashElt . appendChild ( splash . splashimg ) ;
12751290
12761291 splash . titleElt = document . createElement ( 'span' ) ;
1277- splash . titleElt . setAttribute ( 'id' , "emularity-splash-title" ) ;
1278- splash . titleElt . style . display = 'block' ;
1279- splash . titleElt . style . width = '100%' ;
1280- splash . titleElt . style . marginTop = "1em" ;
1281- splash . titleElt . style . marginBottom = "1em" ;
1282- splash . titleElt . style . textAlign = 'center' ;
1283- splash . titleElt . style . font = "24px sans-serif" ;
1292+ splash . titleElt . classList . add ( "emularity-splash-title" ) ;
1293+ if ( ! globalOptions . hasCustomCSS ) {
1294+ splash . titleElt . style . display = 'block' ;
1295+ splash . titleElt . style . width = '100%' ;
1296+ splash . titleElt . style . marginTop = "1em" ;
1297+ splash . titleElt . style . marginBottom = "1em" ;
1298+ splash . titleElt . style . textAlign = 'center' ;
1299+ splash . titleElt . style . font = "24px sans-serif" ;
1300+ }
12841301 splash . titleElt . textContent = " " ;
12851302 splash . splashElt . appendChild ( splash . titleElt ) ;
12861303
1287- var table = document . getElementById ( "dosbox -progress-indicator" ) ;
1304+ var table = document . getElementById ( "emularity -progress-indicator" ) ;
12881305 if ( ! table ) {
12891306 table = document . createElement ( 'table' ) ;
1290- table . setAttribute ( 'id' , "dosbox-progress-indicator" ) ;
1291- table . style . width = "75%" ;
1292- table . style . color = splash . getColor ( 'foreground' ) ;
1293- table . style . backgroundColor = splash . getColor ( 'background' ) ;
1294- table . style . marginLeft = 'auto' ;
1295- table . style . marginRight = 'auto' ;
1296- table . style . borderCollapse = 'separate' ;
1297- table . style . borderSpacing = "2px" ;
1307+ table . classList . add ( "emularity-progress-indicator" ) ;
1308+ table . dataset . hasCustomCSS = globalOptions . hasCustomCSS ;
1309+ if ( ! globalOptions . hasCustomCSS ) {
1310+ table . style . width = "75%" ;
1311+ table . style . color = splash . getColor ( 'foreground' ) ;
1312+ table . style . backgroundColor = splash . getColor ( 'background' ) ;
1313+ table . style . marginLeft = 'auto' ;
1314+ table . style . marginRight = 'auto' ;
1315+ table . style . borderCollapse = 'separate' ;
1316+ table . style . borderSpacing = "2px" ;
1317+ }
12981318 splash . splashElt . appendChild ( table ) ;
12991319 }
13001320 splash . table = table ;
@@ -1314,20 +1334,31 @@ var Module = null;
13141334 } ;
13151335
13161336 var addRow = function ( table ) {
1337+ var needsCSS = ! table . dataset . hasCustomCSS ;
13171338 var row = table . insertRow ( - 1 ) ;
1318- row . style . textAlign = 'center' ;
1339+ if ( needsCSS ) {
1340+ row . style . textAlign = 'center' ;
1341+ }
13191342 var cell = row . insertCell ( - 1 ) ;
1320- cell . style . position = 'relative' ;
1343+ if ( needsCSS ) {
1344+ cell . style . position = 'relative' ;
1345+ }
13211346 var titleCell = document . createElement ( 'span' ) ;
1347+ titleCell . classList . add ( "emularity-download-title" ) ;
13221348 titleCell . textContent = '—' ;
1323- titleCell . style . verticalAlign = 'center' ;
1324- titleCell . style . minHeight = "24px" ;
1325- titleCell . style . whiteSpace = "nowrap" ;
1349+ if ( needsCSS ) {
1350+ titleCell . style . verticalAlign = 'center' ;
1351+ titleCell . style . minHeight = "24px" ;
1352+ titleCell . style . whiteSpace = "nowrap" ;
1353+ }
13261354 cell . appendChild ( titleCell ) ;
13271355 var statusCell = document . createElement ( 'span' ) ;
1328- statusCell . style . position = 'absolute' ;
1329- statusCell . style . left = "0" ;
1330- statusCell . style . paddingLeft = "0.5em" ;
1356+ statusCell . classList . add ( "emularity-download-progress" ) ;
1357+ if ( needsCSS ) {
1358+ statusCell . style . position = 'absolute' ;
1359+ statusCell . style . left = "0" ;
1360+ statusCell . style . paddingLeft = "0.5em" ;
1361+ }
13311362 cell . appendChild ( statusCell ) ;
13321363 return [ titleCell , statusCell ] ;
13331364 } ;
0 commit comments