Files
Erupe/www/erupe/js/main.js
Andrew Gutekanst 501cfc2267 Add multi-region launcher support
Add custom launcher as well as support for both the original TW and JP
launchers.
2019-12-30 07:38:48 +09:00

93 lines
2.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Helper function to dynamically create a bootstrap alert box.
function createErrorAlert(message) {
var tmpDiv = $('<div/>')
.attr("id", "myAlertBoxID")
.attr("role", "alert")
.addClass("alert alert-danger alert-dismissible fade show")
tmpDiv.append(message);
tmpDiv.append($("<button/>")
.attr("type", "button")
.addClass("close")
.attr("data-dismiss", "alert")
.attr("aria-label", "Close")
.append($("<span/>")
.attr("aria-hidden", "true")
.text("×")
));
$("#alertBox").append(tmpDiv);
}
function doLauncherInitalize() {
try{
window.external.getMhfMutexNumber();
} catch(e){
createErrorAlert("Error getting Mhf mutex number! " + e);
}
try{
var serverListXml = window.external.getServerListXml();
} catch(e){
createErrorAlert("Error getting serverlist.xml! " + e);
}
if(serverListXml == ""){
createErrorAlert("Got empty serverlist.xml!");
}
console.log(serverListXml);
try{
var lastServerIndex = window.external.getIniLastServerIndex();
} catch(e){
createErrorAlert("Error on getIniLastServerIndex: " + e);
}
console.log("Last server index:" + lastServerIndex);
try{
window.external.setIniLastServerIndex(0);
} catch(e){
createErrorAlert("Error on setIniLastServerIndex: " + e);
}
try{
var mhfBootMode = window.external.getMhfBootMode();
} catch(e){
createErrorAlert("Error on getMhfBootMode: " + e);
}
console.log("mhfBootMode:" + mhfBootMode);
try{
var userId = window.external.getUserId();
} catch(e){
createErrorAlert("Error on getUserId: " + e);
}
console.log("userId:" + userId);
try{
var password = window.external.getPassword();
} catch(e){
createErrorAlert("Error on getPassword: " + e);
}
console.log("password:" + password);
}
$(function() {
// Setup the titlebar and exit button so that the window works how you would expect.
$("#titlebar").on("click", function(e) {
window.external.beginDrag(true);
});
$("#exit").on("click", function(e) {
window.external.closeWindow();
});
// Setup the error message passthrough
$(window).on("message onmessage", function(e) {
var data = e.originalEvent.data;
createErrorAlert(data)
});
// Initialize the launcher by calling the native/external functions it exposes in the proper order.
doLauncherInitalize();
});