Skip to content

Commit

Permalink
2.1
Browse files Browse the repository at this point in the history
Added local file picker, made changes to how files are removed on server connection
  • Loading branch information
HunterBoy344 committed Sep 7, 2022
1 parent b78f96a commit 2ece8de
Show file tree
Hide file tree
Showing 28 changed files with 8,609 additions and 26 deletions.
1 change: 1 addition & 0 deletions .cache/replit/nix/env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"entries":{"replit.nix":{"env":{"AR":"ar","AS":"as","CC":"gcc","CONFIG_SHELL":"/nix/store/bm7jr70d9ghn5cczb3q0w90apsm05p54-bash-5.1-p8/bin/bash","CXX":"g++","HOST_PATH":"/nix/store/mj9madzlh0xwcccb30qsnsclfjxr5k1s-vscode-langservers-extracted-3.0.1/bin:/nix/store/rszcnphk27fvfr2hq5pcr07jccf2dqy1-typescript-language-server-0.9.6/bin:/nix/store/jd1y449cf66yx5d1hwyjvc4562b1p1am-coreutils-9.0/bin:/nix/store/jjvw20r6pz3ff7pn91yhvfx8s7izsqan-findutils-4.8.0/bin:/nix/store/ndd6gh8zigjy0j68arj7nyrbcw4kcw01-diffutils-3.8/bin:/nix/store/bpg0ia8nkavzw7s66avi1f9nz72i1p3r-gnused-4.8/bin:/nix/store/df3ff57sbkgbdhc4ar19zs4y0hrhggii-gnugrep-3.7/bin:/nix/store/4fv981732jqzirah3h2y6ynmlsfbxb37-gawk-5.1.1/bin:/nix/store/k5ifa08z0qlkknnb8s1bdh2kdrx0qmd0-gnutar-1.34/bin:/nix/store/dcird3wn9xywy49w3qq1hpjwvjfn3lph-gzip-1.11/bin:/nix/store/s85iyc3p9nbinwvwx9rcqirf1m68zpmm-bzip2-1.0.6.0.2-bin/bin:/nix/store/msncxcf5lgy5by9cqjyxchxd26x47d64-gnumake-4.3/bin:/nix/store/bm7jr70d9ghn5cczb3q0w90apsm05p54-bash-5.1-p8/bin:/nix/store/gi3psbgxbf2fmvgi36pmw77nnh58vq3l-patch-2.7.6/bin:/nix/store/sqb20f4rk80lw21j4is85qwljlphmn3g-xz-5.2.5-bin/bin","LD":"ld","LOCALE_ARCHIVE":"/usr/lib/locale/locale-archive","NIX_BINTOOLS":"/nix/store/spm7d6ncyx2k5w8yl6clzynv2s4wf1kp-binutils-wrapper-2.35.2","NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu":"1","NIX_BUILD_CORES":"8","NIX_BUILD_TOP":"/tmp","NIX_CC":"/nix/store/2qwnn6lizc9d119kp3zig3q19gbfm4n6-gcc-wrapper-10.3.0","NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu":"1","NIX_CFLAGS_COMPILE":" -frandom-seed=qfbj2w45kl","NIX_ENFORCE_NO_NATIVE":"1","NIX_HARDENING_ENABLE":"fortify stackprotector pic strictoverflow format relro bindnow","NIX_INDENT_MAKE":"1","NIX_LDFLAGS":"-rpath /nix/store/qfbj2w45kliilxjmvsvz3iqm4mxk1qf1-nix-shell/lib64 -rpath /nix/store/qfbj2w45kliilxjmvsvz3iqm4mxk1qf1-nix-shell/lib ","NIX_STORE":"/nix/store","NM":"nm","OBJCOPY":"objcopy","OBJDUMP":"objdump","PATH":"/nix/store/bccsypsvjskpzsgzww8bzjgqmck4bjbf-bash-interactive-5.1-p8/bin:/nix/store/bqmg7l0jn6nhgjlfc981g1imzb6ny8xl-patchelf-0.13/bin:/nix/store/2qwnn6lizc9d119kp3zig3q19gbfm4n6-gcc-wrapper-10.3.0/bin:/nix/store/6r5h4h7nqx73m87j5b9sjwy2x9kyri0k-gcc-10.3.0/bin:/nix/store/csz8v8xi2f644j26n84i20dnqmq43sih-glibc-2.33-117-bin/bin:/nix/store/jd1y449cf66yx5d1hwyjvc4562b1p1am-coreutils-9.0/bin:/nix/store/spm7d6ncyx2k5w8yl6clzynv2s4wf1kp-binutils-wrapper-2.35.2/bin:/nix/store/h19zwlkrp6b0hp3ypbqdcggnyarn3af6-binutils-2.35.2/bin:/nix/store/mj9madzlh0xwcccb30qsnsclfjxr5k1s-vscode-langservers-extracted-3.0.1/bin:/nix/store/rszcnphk27fvfr2hq5pcr07jccf2dqy1-typescript-language-server-0.9.6/bin:/nix/store/jd1y449cf66yx5d1hwyjvc4562b1p1am-coreutils-9.0/bin:/nix/store/jjvw20r6pz3ff7pn91yhvfx8s7izsqan-findutils-4.8.0/bin:/nix/store/ndd6gh8zigjy0j68arj7nyrbcw4kcw01-diffutils-3.8/bin:/nix/store/bpg0ia8nkavzw7s66avi1f9nz72i1p3r-gnused-4.8/bin:/nix/store/df3ff57sbkgbdhc4ar19zs4y0hrhggii-gnugrep-3.7/bin:/nix/store/4fv981732jqzirah3h2y6ynmlsfbxb37-gawk-5.1.1/bin:/nix/store/k5ifa08z0qlkknnb8s1bdh2kdrx0qmd0-gnutar-1.34/bin:/nix/store/dcird3wn9xywy49w3qq1hpjwvjfn3lph-gzip-1.11/bin:/nix/store/s85iyc3p9nbinwvwx9rcqirf1m68zpmm-bzip2-1.0.6.0.2-bin/bin:/nix/store/msncxcf5lgy5by9cqjyxchxd26x47d64-gnumake-4.3/bin:/nix/store/bm7jr70d9ghn5cczb3q0w90apsm05p54-bash-5.1-p8/bin:/nix/store/gi3psbgxbf2fmvgi36pmw77nnh58vq3l-patch-2.7.6/bin:/nix/store/sqb20f4rk80lw21j4is85qwljlphmn3g-xz-5.2.5-bin/bin","RANLIB":"ranlib","READELF":"readelf","SIZE":"size","SOURCE_DATE_EPOCH":"315532800","STRINGS":"strings","STRIP":"strip","XDG_DATA_DIRS":"/nix/store/bqmg7l0jn6nhgjlfc981g1imzb6ny8xl-patchelf-0.13/share","_":"/nix/store/jd1y449cf66yx5d1hwyjvc4562b1p1am-coreutils-9.0/bin/env","__ETC_PROFILE_SOURCED":"1","buildInputs":"/nix/store/mj9madzlh0xwcccb30qsnsclfjxr5k1s-vscode-langservers-extracted-3.0.1 /nix/store/rszcnphk27fvfr2hq5pcr07jccf2dqy1-typescript-language-server-0.9.6","builder":"/nix/store/bm7jr70d9ghn5cczb3q0w90apsm05p54-bash-5.1-p8/bin/bash","configureFlags":"","depsBuildBuild":"","depsBuildBuildPropagated":"","depsBuildTarget":"","depsBuildTargetPropagated":"","depsHostHost":"","depsHostHostPropagated":"","depsTargetTarget":"","depsTargetTargetPropagated":"","doCheck":"","doInstallCheck":"","name":"nix-shell","nativeBuildInputs":"","nobuildPhase":"echo\necho \"This derivation is not meant to be built, aborting\";\necho\nexit 1\n","out":"/nix/store/qfbj2w45kliilxjmvsvz3iqm4mxk1qf1-nix-shell","outputs":"out","patches":"","phases":"nobuildPhase","propagatedBuildInputs":"","propagatedNativeBuildInputs":"","shell":"/nix/store/bm7jr70d9ghn5cczb3q0w90apsm05p54-bash-5.1-p8/bin/bash","shellHook":"","stdenv":"/nix/store/z7wz8q1i0j4jmfpn87wpakwma6q0k90n-stdenv-linux","strictDeps":"","system":"x86_64-linux"},"dependencies":[{"path":"replit.nix","mod_time":"2022-03-14T23:31:45.35298035Z"}],"channel":"stable-21_11","channel_nix_path":"/nix/store/1m2fssfawvn6krbv3rc6hmq7xaa45v5a-nixpkgs-stable-21_11-21.11.tar.gz/nixpkgs-stable-21_11"}}}
4 changes: 4 additions & 0 deletions .config/configstore/update-notifier-npm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"optOut": false,
"lastUpdateCheck": 1661112557880
}
Empty file.
179 changes: 179 additions & 0 deletions .replit
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
hidden=[".config"]

# hosting is currently hardcoded for this language
# [hosting]
# route = "/"
# directory= "/"

[nix]
channel = "stable-21_11"

[languages.html]
pattern = "**/*.html"
[languages.html.languageServer]
start = ["vscode-html-language-server", "--stdio"]
[languages.html.languageServer.initializationOptions]
provideFormatter = true
[languages.html.languageServer.configuration.html]
customData = [ ]
autoCreateQuotes = true
autoClosingTags = true
mirrorCursorOnMatchingTag = false

[languages.html.languageServer.configuration.html.completion]
attributeDefaultValue = "doublequotes"

[languages.html.languageServer.configuration.html.format]
enable = true
wrapLineLength = 120
unformatted = "wbr"
contentUnformatted = "pre,code,textarea"
indentInnerHtml = false
preserveNewLines = true
indentHandlebars = false
endWithNewline = false
extraLiners = "head, body, /html"
wrapAttributes = "auto"
templating = false
unformattedContentDelimiter = ""

[languages.html.languageServer.configuration.html.suggest]
html5 = true

[languages.html.languageServer.configuration.html.validate]
scripts = true
styles = true

[languages.html.languageServer.configuration.html.hover]
documentation = true
references = true

[languages.html.languageServer.configuration.html.trace]
server = "off"

[languages.javascript]
pattern = "**/{*.js,*.jsx,*.ts,*.tsx,*.mjs,*.cjs}"
[languages.javascript.languageServer]
start = ["typescript-language-server", "--stdio"]

[gitHubImport]
requiredFiles = [".replit", "replit.nix", ".config"]

[languages.css]
pattern = "**/{*.less,*.scss,*.css}"
[languages.css.languageServer]
start = ["vscode-css-language-server", "--stdio"]
[languages.css.languageServer.configuration.css]
customData = [ ]
validate = true

[languages.css.languageServer.configuration.css.completion]
triggerPropertyValueCompletion = true
completePropertyWithSemicolon = true

[languages.css.languageServer.configuration.css.hover]
documentation = true
references = true

[languages.css.languageServer.configuration.css.lint]
# Configure linting
# ignore = don't show any warning or error
# warning = show yellow underline
# error = show red underline
argumentsInColorFunction = "error" # Invalid number of parameters
boxModel = "ignore" # Do not use width or height when using padding or border
compatibleVendorPrefixes = "ignore" # When using a vendor-specific prefix make sure to also include all other vendor-specific properties"
duplicateProperties = "warning" # Do not use duplicate style definitions
emptyRules = "warning" # Do not use empty rulesets
float = "ignore" # Avoid using 'float'. Floats lead to fragile CSS that is easy to break if one aspect of the layout changes.
fontFaceProperties = "warning" # @font-face rule must define 'src' and 'font-family' properties
hexColorLength = "error" # Hex colors must consist of three, four, six or eight hex numbers
idSelector = "ignore" # Selectors should not contain IDs because these rules are too tightly coupled with the HTML.
ieHack = "ignore" # IE hacks are only necessary when supporting IE7 and older
important = "ignore" # Avoid using !important. It is an indication that the specificity of the entire CSS has gotten out of control and needs to be refactored.
importStatement = "ignore" # Import statements do not load in parallel
propertyIgnoredDueToDisplay = "warning" # Property is ignored due to the display
universalSelector = "ignore" # The universal selector (*) is known to be slow
unknownAtRules = "warning" # Unknown at-rule
unknownProperties = "warning" # Unknown property.
validProperties = [ ] # add some properties that the linter doesn't know about
unknownVendorSpecificProperties = "ignore" # Unknown vendor specific property.
vendorPrefix = "warning" # When using a vendor-specific prefix also include the standard property
zeroUnits = "ignore" # No unit for zero needed

[languages.css.languageServer.configuration.css.trace]
server = "off"

[languages.css.languageServer.configuration.scss]
validate = true

[languages.css.languageServer.configuration.scss.completion]
triggerPropertyValueCompletion = true
completePropertyWithSemicolon = true

[languages.css.languageServer.configuration.scss.hover]
documentation = true
references = true

[languages.css.languageServer.configuration.scss.lint]
# Configure linting
# ignore = don't show any warning or error
# warning = show yellow underline
# error = show red underline
argumentsInColorFunction = "error" # Invalid number of parameters
boxModel = "ignore" # Do not use width or height when using padding or border
compatibleVendorPrefixes = "ignore" # When using a vendor-specific prefix make sure to also include all other vendor-specific properties"
duplicateProperties = "warning" # Do not use duplicate style definitions
emptyRules = "warning" # Do not use empty rulesets
float = "ignore" # Avoid using 'float'. Floats lead to fragile CSS that is easy to break if one aspect of the layout changes.
fontFaceProperties = "warning" # @font-face rule must define 'src' and 'font-family' properties
hexColorLength = "error" # Hex colors must consist of three, four, six or eight hex numbers
idSelector = "ignore" # Selectors should not contain IDs because these rules are too tightly coupled with the HTML.
ieHack = "ignore" # IE hacks are only necessary when supporting IE7 and older
important = "ignore" # Avoid using !important. It is an indication that the specificity of the entire CSS has gotten out of control and needs to be refactored.
importStatement = "ignore" # Import statements do not load in parallel
propertyIgnoredDueToDisplay = "warning" # Property is ignored due to the display
universalSelector = "ignore" # The universal selector (*) is known to be slow
unknownAtRules = "warning" # Unknown at-rule
unknownProperties = "warning" # Unknown property.
validProperties = [ ] # add some properties that the linter doesn't know about
unknownVendorSpecificProperties = "ignore" # Unknown vendor specific property.
vendorPrefix = "warning" # When using a vendor-specific prefix also include the standard property
zeroUnits = "ignore" # No unit for zero needed"

[languages.css.languageServer.configuration.less]
validate = true

[languages.css.languageServer.configuration.less.completion]
triggerPropertyValueCompletion = true
completePropertyWithSemicolon = true

[languages.css.languageServer.configuration.less.hover]
documentation = true
references = true

[languages.css.languageServer.configuration.less.lint]
# Configure linting
# ignore = don't show any warning or error
# warning = show yellow underline
# error = show red underline
argumentsInColorFunction = "error" # Invalid number of parameters
boxModel = "ignore" # Do not use width or height when using padding or border
compatibleVendorPrefixes = "ignore" # When using a vendor-specific prefix make sure to also include all other vendor-specific properties"
duplicateProperties = "warning" # Do not use duplicate style definitions
emptyRules = "warning" # Do not use empty rulesets
float = "ignore" # Avoid using 'float'. Floats lead to fragile CSS that is easy to break if one aspect of the layout changes.
fontFaceProperties = "warning" # @font-face rule must define 'src' and 'font-family' properties
hexColorLength = "error" # Hex colors must consist of three, four, six or eight hex numbers
idSelector = "ignore" # Selectors should not contain IDs because these rules are too tightly coupled with the HTML.
ieHack = "ignore" # IE hacks are only necessary when supporting IE7 and older
important = "ignore" # Avoid using !important. It is an indication that the specificity of the entire CSS has gotten out of control and needs to be refactored.
importStatement = "ignore" # Import statements do not load in parallel
propertyIgnoredDueToDisplay = "warning" # Property is ignored due to the display
universalSelector = "ignore" # The universal selector (*) is known to be slow
unknownAtRules = "warning" # Unknown at-rule
unknownProperties = "warning" # Unknown property.
validProperties = [ ] # add some properties that the linter doesn't know about
unknownVendorSpecificProperties = "ignore" # Unknown vendor specific property.
vendorPrefix = "warning" # When using a vendor-specific prefix also include the standard property
zeroUnits = "ignore" # No unit for zero needed"
6 changes: 5 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@
<canvas id="jsdos"></canvas>
<div class="frameParent">
<div id="leaderboard" width="300px" height="150px"></div>
<div id="chatview" width="300px" height="150px"></div>
<div id="chatview" width="300px" height="150px">
<input id=downloadinput type="text" placeholder="Filename to download..."/><button onClick='downloadFile(document.getElementById("downloadinput").value); document.getElementById("downloadinput").value = ""'>Download</button>
<input id=uploadinput type="file"/><button onClick='uploadFile()'>Upload</button>
<p>To protect against cheating, these options will be removed when you connect to a server.</p>
</div>
</div>
</div>
<div style="text-align: center">
Expand Down
6 changes: 6 additions & 0 deletions replit.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{ pkgs }: {
deps = [
pkgs.nodePackages.vscode-langservers-extracted
pkgs.nodePackages.typescript-language-server
];
}
87 changes: 62 additions & 25 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var ws
var input = document.getElementById('usernameinput')
var input2 = document.getElementById('serverinput')
var input3 = document.getElementById('downloadinput')
var connectbutton = document.getElementById("connectbutton");
var connectunsecure = document.getElementById("connectunsecure");
var inputFocused = false
Expand All @@ -10,18 +11,20 @@ var trackName
let leaderboardFrame = $("#leaderboard").contents().find('body');

connectbutton.addEventListener("click", function(event) {
FS.unlink('/BERNIES.TRK')
FS.unlink('/CHERRIS.TRK')
FS.unlink('/DEFAULT.TRK')
FS.unlink('/HELENS.TRK')
FS.unlink('/JOES.TRK')
FS.unlink('/SKIDS.TRK')
FS.unlink('/BERNIES.HIG')
FS.unlink('/CHERRIS.HIG')
FS.unlink('/DEFAULT.HIG')
FS.unlink('/HELENS.HIG')
FS.unlink('/JOES.HIG')
FS.unlink('/SKIDS.HIG')
document.getElementById('chatview').innerHTML = "";
let filesArray = FS.readdir('/');
let tracksToDelete = filesArray.filter(element => element.includes(".TRK"));
tracksToDelete.forEach((element, index) => {
FS.unlink(`/${element}`)
});
tracksToDelete = filesArray.filter(element => element.includes(".HIG"));
tracksToDelete.forEach((element, index) => {
FS.unlink(`/${element}`)
});
tracksToDelete = filesArray.filter(element => element.includes(".RPL"));
tracksToDelete.forEach((element, index) => {
FS.unlink(`/${element}`)
});
connectbutton.disabled = true;
connectbutton.innerHTML = 'Connected!'
connectunsecure.disabled = true;
Expand Down Expand Up @@ -100,18 +103,20 @@ connectbutton.addEventListener("click", function(event) {
});

connectunsecure.addEventListener("click", function(event) {
FS.unlink('/BERNIES.TRK')
FS.unlink('/CHERRIS.TRK')
FS.unlink('/DEFAULT.TRK')
FS.unlink('/HELENS.TRK')
FS.unlink('/JOES.TRK')
FS.unlink('/SKIDS.TRK')
FS.unlink('/BERNIES.HIG')
FS.unlink('/CHERRIS.HIG')
FS.unlink('/DEFAULT.HIG')
FS.unlink('/HELENS.HIG')
FS.unlink('/JOES.HIG')
FS.unlink('/SKIDS.HIG')
document.getElementById('chatview').innerHTML = "";
let filesArray = FS.readdir('/');
let tracksToDelete = filesArray.filter(element => element.includes(".TRK"));
tracksToDelete.forEach((element, index) => {
FS.unlink(`/${element}`)
});
tracksToDelete = filesArray.filter(element => element.includes(".HIG"));
tracksToDelete.forEach((element, index) => {
FS.unlink(`/${element}`)
});
tracksToDelete = filesArray.filter(element => element.includes(".RPL"));
tracksToDelete.forEach((element, index) => {
FS.unlink(`/${element}`)
});
connectbutton.disabled = true;
connectbutton.innerHTML = 'Connected!'
connectunsecure.disabled = true;
Expand Down Expand Up @@ -294,6 +299,31 @@ function simulateKeyEvent(charCode, pressed)
element.dispatchEvent(event);
}

function downloadFile(name) {
var fileToDownload = FS.readFile(`/${name}`, { encoding : 'binary' })
saveByteArray(name, fileToDownload)
}
function uploadFile() {
let file = $("#uploadinput").prop("files")[0];
let filename = file.name
let promise = file.arrayBuffer()
promise.then(function(result) {
let view = new Uint8Array(result);
FS.writeFile(`/${filename}`, view)
console.log(`Uploaded ${filename}`)
document.getElementById('uploadinput').value = ""
});
}

function saveByteArray(reportName, byte) {
var blob = new Blob([byte], {type: "application/octet-stream"});
var link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
var fileName = reportName;
link.download = fileName;
link.click();
};


window.addEventListener('keydown', function(event){
if (inputFocused == true) {
Expand Down Expand Up @@ -329,10 +359,17 @@ input.addEventListener('focus', (event) => {
input2.addEventListener('focus', (event) => {
inputFocused = true
}, true);
input3.addEventListener('focus', (event) => {
inputFocused = true
}, true);

input.addEventListener('blur', (event) => {
inputFocused = false
}, true);
input2.addEventListener('blur', (event) => {
inputFocused = false
}, true);
}, true);
input3.addEventListener('blur', (event) => {
inputFocused = false
}, true);

36 changes: 36 additions & 0 deletions test/digger.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="utf-8">
<title>js-dos 6.22, Digger</title>
<script src="../js-dos.js"></script>
<style>
html, body, canvas, .dosbox-container {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
</style>
</head>

<body>
<canvas id="jsdos"></canvas>
<script>
Dos(document.getElementById("jsdos"), {
wdosboxUrl: "../wdosbox.js",
cycles: 1000,
autolock: false,
}).ready(function (fs, main) {
fs.extract("https://js-dos.com/6.22/current/test/digger.zip").then(function () {
main(["-c", "DIGGER.COM"]).then(function (ci) {
window.ci = ci;
});
});
});
</script>
</body>

</html>
Binary file added test/digger.jsdos
Binary file not shown.
Binary file added test/digger.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/digger.zip
Binary file not shown.
Binary file added test/dosboxconf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/elonmusk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2ece8de

Please sign in to comment.