Skip to content

Commit

Permalink
6.0.0-alpha.8 (#1458)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwarren authored Mar 1, 2025
2 parents b489b14 + 54e99a4 commit 26376fe
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 11 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.0.0-alpha.7
6.0.0-alpha.8
7 changes: 3 additions & 4 deletions src/PlayerCore/Resources/playercore.js
Original file line number Diff line number Diff line change
Expand Up @@ -698,16 +698,15 @@ function bindMenu(linkid, verbs, text, elementId) {
function buildMenuOptions(verbs, text, elementId) {
var verbsList = verbs.split("/");
var options = [];
var metadata = new Object();
var metadata = {};
metadata[text] = elementId;
var metadataString = JSON.stringify(metadata);

$.each(verbsList, function (key, value) {
options = options.concat({
title: value,
action: {
callback: function (selectedValue) {
sendCommand(selectedValue.toLowerCase() + " " + text, metadataString);
sendCommand(selectedValue.toLowerCase() + " " + text, metadata);
}
}
});
Expand Down Expand Up @@ -1431,7 +1430,7 @@ function SaveTranscript(text){
writeToTranscript(text);
}

var transcriptUrl = 'TranscriptViewer';
var transcriptUrl = 'TranscriptViewer/index.html';

// Another fallback to avoid errors
function showTranscript(){
Expand Down
File renamed without changes.
46 changes: 40 additions & 6 deletions src/WebPlayer/wwwroot/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,7 @@ function sendCommand(text, metadata) {

// TODO: See if setTimeout is still needed here
window.setTimeout(async function () {
// TODO: Check metadata format
await WebPlayer.sendCommand(text, getTickCountAndStopTimer(), {
command: text,
metadata
});
await WebPlayer.sendCommand(text, getTickCountAndStopTimer(), metadata);
}, 100);
}

Expand All @@ -171,7 +167,7 @@ function ASLEvent(event, parameter) {
// using setTimeout here to work around a double-submission race condition which seems to only affect Firefox,
// even though we use "return false" to suppress submission of the form with the Enter key.
window.setTimeout(async function () {
await WebPlayer.uiSendEvent(event, parameter);
await WebPlayer.uiSendEvent(event, "" + parameter);
}, 100);
return true;
}
Expand Down Expand Up @@ -260,4 +256,42 @@ function addExternalScript(url) {
const script = document.createElement("script");
script.src = url;
document.head.appendChild(script);
}

function WriteToLog(data){
// Do nothing.
}

function WriteToTranscript(data){
if (noTranscript){
// Do nothing.
return;
}
if (!isLocalStorageAvailable()){
console.error("There is no localStorage. Disabling transcript functionality.");
noTranscript = true;
savingTranscript = false;
return;
}
var tName = transcriptName || "Transcript";
if (data.indexOf("___SCRIPTDATA___") > -1) {
tName = data.split("___SCRIPTDATA___")[0].trim() || tName;
data = data.split("___SCRIPTDATA___")[1];
}
var oldData = localStorage.getItem("questtranscript-" + tName) || "";
localStorage.setItem("questtranscript-" + tName, oldData + data);
}

// Make sure localStorage is available, hopefully without throwing any errors!

/* https://stackoverflow.com/a/16427747 */
function isLocalStorageAvailable(){
var test = 'test';
try {
localStorage.setItem(test, test);
localStorage.removeItem(test);
return true;
} catch(e) {
return false;
}
}

0 comments on commit 26376fe

Please sign in to comment.