-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
40c7260
commit f29b5a2
Showing
12 changed files
with
135 additions
and
7 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
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 |
---|---|---|
|
@@ -238,8 +238,12 @@ <h3 class="panel-title">Upload Game</h3> | |
<script src="https://cdn.jsdelivr.net/npm/[email protected]/particles.min.js"></script> | ||
<script src="/js/theme-loader.js"></script> | ||
<script src="/js/auth/auth.js"></script> | ||
<script src="/js/upload.js"></script> | ||
<script src="/js/particles-config.js"></script> | ||
<!-- Other script references --> | ||
<script src="/js/upload/accesskey.js"></script> | ||
<script src="/js/upload/place/uploadform.js"></script> | ||
<script src="/js/upload/alert.js"></script> | ||
<script src="/js/upload/place/init.js"></script> | ||
<script src="/js/particles-config.js"></script> | ||
|
||
</body> | ||
</html> |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
function getAccessKey() { | ||
let accessKey = localStorage.getItem('uploadAccessKey'); | ||
if (!accessKey) { | ||
accessKey = prompt('Please enter the upload access key:'); | ||
if (accessKey) { | ||
localStorage.setItem('uploadAccessKey', accessKey); | ||
} | ||
} | ||
return accessKey; | ||
} | ||
|
||
function showAccessKeyModal() { | ||
$('#access-key-modal').modal({ | ||
backdrop: 'static', | ||
keyboard: false, | ||
show: true | ||
}); | ||
} | ||
|
||
function verifyAccessKey(key) { | ||
$.ajax({ | ||
url: '/api/verify-upload-access', | ||
method: 'POST', | ||
data: JSON.stringify({ accessKey: key }), | ||
contentType: 'application/json', | ||
success: function (response) { | ||
if (response.success) { | ||
localStorage.setItem('uploadAccessKey', key); | ||
$('#access-key-modal').modal('hide'); | ||
$('#content-wrapper').show(); | ||
initializeUploadForm(); | ||
} else { | ||
alert('Invalid access key. Please try again.'); | ||
showAccessKeyModal(); | ||
} | ||
}, | ||
error: function () { | ||
alert('Error verifying access key. Please try again.'); | ||
showAccessKeyModal(); | ||
} | ||
}); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
function showAlert(type, message) { | ||
const alertHtml = ` | ||
<div class="alert alert-${type} alert-dismissible" role="alert"> | ||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> | ||
${message} | ||
</div> | ||
`; | ||
$('#alert-container').html(alertHtml); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
$(document).ready(function () { | ||
const accessKey = localStorage.getItem('uploadAccessKey'); | ||
if (!accessKey) { | ||
showAccessKeyModal(); | ||
} else { | ||
verifyAccessKey(accessKey); | ||
} | ||
|
||
$('#access-key-form').on('submit', function (e) { | ||
e.preventDefault(); | ||
const enteredKey = $('#access-key').val(); | ||
verifyAccessKey(enteredKey); | ||
}); | ||
|
||
$('#access-key-modal').on('hide.bs.modal', function (e) { | ||
if (!localStorage.getItem('uploadAccessKey')) { | ||
window.location.href = '/'; | ||
} | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
function initializeUploadForm() { | ||
$('#upload-form').on('submit', function (e) { | ||
e.preventDefault(); | ||
|
||
const formData = new FormData(this); | ||
formData.append('year', $('input[name="year"]:checked').val()); | ||
const token = localStorage.getItem('token'); | ||
const accessKey = localStorage.getItem('uploadAccessKey'); | ||
|
||
// Validate file size | ||
const thumbnailFile = $('#thumbnail')[0].files[0]; | ||
const rbxlFile = $('#rbxlFile')[0].files[0]; | ||
|
||
if (thumbnailFile && thumbnailFile.size > 20 * 1024 * 1024) { | ||
showAlert('danger', 'Thumbnail file size must be less than 20MB'); | ||
return; | ||
} | ||
|
||
if (rbxlFile && rbxlFile.size > 20 * 1024 * 1024) { | ||
showAlert('danger', '.rbxl file size must be less than 20MB'); | ||
return; | ||
} | ||
|
||
$.ajax({ | ||
url: '/api/games/upload', | ||
method: 'POST', | ||
data: formData, | ||
contentType: false, | ||
processData: false, | ||
headers: { | ||
'Authorization': `Bearer ${token}`, | ||
'X-Access-Token': accessKey | ||
}, | ||
success: function (response) { | ||
showAlert('success', `Game uploaded successfully! Asset ID: ${response.assetId}`); | ||
setTimeout(() => { | ||
window.location.href = `/game?id=${response.gameId}`; | ||
}, 2000); | ||
}, | ||
error: function (xhr, status, error) { | ||
let errorMessage = 'Unknown error'; | ||
if (xhr.responseJSON && xhr.responseJSON.error) { | ||
errorMessage = xhr.responseJSON.error; | ||
if (xhr.responseJSON.details) { | ||
errorMessage += ': ' + xhr.responseJSON.details; | ||
} | ||
} | ||
console.error('Upload error:', errorMessage); | ||
showAlert('danger', 'Error uploading game: ' + errorMessage); | ||
} | ||
}); | ||
}); | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.