mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 10:21:11 +00:00
A path to fixing Nano loading issues. (#22584)
Makes template loading time out instead of hang forever if necessary. This will make it easier to diagnose the problem causing load failures with Nano. Also made all of Nano's .js files use tabs.
This commit is contained in:
committed by
DamianX
parent
14a156d135
commit
56cbd6788d
@@ -3,12 +3,12 @@ NanoBaseCallbacks = function ()
|
||||
{
|
||||
// _canClick is used to disable clicks for a short period after each click (to avoid mis-clicks)
|
||||
var _canClick = true;
|
||||
|
||||
|
||||
var _baseBeforeUpdateCallbacks = {}
|
||||
|
||||
|
||||
var _baseAfterUpdateCallbacks = {
|
||||
// this callback is triggered after new data is processed
|
||||
// it updates the status/visibility icon and adds click event handling to buttons/links
|
||||
// it updates the status/visibility icon and adds click event handling to buttons/links
|
||||
status: function (updateData) {
|
||||
var uiStatusClass;
|
||||
if (updateData['config']['status'] == 2)
|
||||
@@ -32,62 +32,62 @@ NanoBaseCallbacks = function ()
|
||||
$('.linkActive').removeClass('linkPending');
|
||||
|
||||
$('.linkActive')
|
||||
.off('click')
|
||||
.on('click', function (event) {
|
||||
event.preventDefault();
|
||||
var href = $(this).data('href');
|
||||
if (href != null && _canClick)
|
||||
{
|
||||
_canClick = false;
|
||||
$('body').oneTime(300, 'enableClick', function () {
|
||||
_canClick = true;
|
||||
});
|
||||
if (updateData['config']['status'] == 2)
|
||||
{
|
||||
$(this).oneTime(300, 'linkPending', function () {
|
||||
$(this).addClass('linkPending');
|
||||
});
|
||||
}
|
||||
window.location.href = href;
|
||||
}
|
||||
});
|
||||
|
||||
return updateData;
|
||||
.off('click')
|
||||
.on('click', function (event) {
|
||||
event.preventDefault();
|
||||
var href = $(this).data('href');
|
||||
if (href != null && _canClick)
|
||||
{
|
||||
_canClick = false;
|
||||
$('body').oneTime(300, 'enableClick', function () {
|
||||
_canClick = true;
|
||||
});
|
||||
if (updateData['config']['status'] == 2)
|
||||
{
|
||||
$(this).oneTime(300, 'linkPending', function () {
|
||||
$(this).addClass('linkPending');
|
||||
});
|
||||
}
|
||||
window.location.href = href;
|
||||
}
|
||||
});
|
||||
|
||||
return updateData;
|
||||
},
|
||||
nanomap: function (updateData) {
|
||||
$('.mapIcon')
|
||||
.off('mouseenter mouseleave')
|
||||
.on('mouseenter',
|
||||
function (event) {
|
||||
var self = this;
|
||||
$('#uiMapTooltip')
|
||||
.html($(this).children('.tooltip').html())
|
||||
.show()
|
||||
.stopTime()
|
||||
.oneTime(5000, 'hideTooltip', function () {
|
||||
$(this).fadeOut(500);
|
||||
});
|
||||
}
|
||||
);
|
||||
nanomap: function (updateData) {
|
||||
$('.mapIcon')
|
||||
.off('mouseenter mouseleave')
|
||||
.on('mouseenter',
|
||||
function (event) {
|
||||
var self = this;
|
||||
$('#uiMapTooltip')
|
||||
.html($(this).children('.tooltip').html())
|
||||
.show()
|
||||
.stopTime()
|
||||
.oneTime(5000, 'hideTooltip', function () {
|
||||
$(this).fadeOut(500);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
$('.zoomLink')
|
||||
.off('click')
|
||||
.on('click', function (event) {
|
||||
event.preventDefault();
|
||||
var zoomLevel = $(this).data('zoomLevel');
|
||||
var uiMapObject = $('#uiMap');
|
||||
var uiMapWidth = uiMapObject.width() * zoomLevel;
|
||||
var uiMapHeight = uiMapObject.height() * zoomLevel;
|
||||
$('.zoomLink')
|
||||
.off('click')
|
||||
.on('click', function (event) {
|
||||
event.preventDefault();
|
||||
var zoomLevel = $(this).data('zoomLevel');
|
||||
var uiMapObject = $('#uiMap');
|
||||
var uiMapWidth = uiMapObject.width() * zoomLevel;
|
||||
var uiMapHeight = uiMapObject.height() * zoomLevel;
|
||||
|
||||
uiMapObject.css({
|
||||
zoom: zoomLevel,
|
||||
left: '50%',
|
||||
top: '50%',
|
||||
marginLeft: '-' + Math.floor(uiMapWidth / 2) + 'px',
|
||||
marginTop: '-' + Math.floor(uiMapHeight / 2) + 'px'
|
||||
});
|
||||
});
|
||||
|
||||
uiMapObject.css({
|
||||
zoom: zoomLevel,
|
||||
left: '50%',
|
||||
top: '50%',
|
||||
marginLeft: '-' + Math.floor(uiMapWidth / 2) + 'px',
|
||||
marginTop: '-' + Math.floor(uiMapHeight / 2) + 'px'
|
||||
});
|
||||
});
|
||||
|
||||
$('#uiMapImage').attr('src', updateData['config']['mapName'] + updateData['config']['mapZLevel'] + '.png');
|
||||
$('#uiMapImage').css('width', updateData['config']['worldmaxx']);
|
||||
$('#uiMapImage').css('height', updateData['config']['worldmaxy']);
|
||||
@@ -97,9 +97,9 @@ NanoBaseCallbacks = function ()
|
||||
|
||||
$('#uiMapContent').css('width', updateData['config']['worldmaxx']);
|
||||
$('#uiMapContent').css('height', updateData['config']['worldmaxy']);
|
||||
|
||||
return updateData;
|
||||
}
|
||||
|
||||
return updateData;
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
@@ -115,17 +115,17 @@ NanoBaseCallbacks = function ()
|
||||
NanoStateManager.removeBeforeUpdateCallback(callbackKey);
|
||||
}
|
||||
}
|
||||
for (var callbackKey in _baseAfterUpdateCallbacks)
|
||||
{
|
||||
if (_baseAfterUpdateCallbacks.hasOwnProperty(callbackKey))
|
||||
{
|
||||
NanoStateManager.removeAfterUpdateCallback(callbackKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var callbackKey in _baseAfterUpdateCallbacks)
|
||||
{
|
||||
if (_baseAfterUpdateCallbacks.hasOwnProperty(callbackKey))
|
||||
{
|
||||
NanoStateManager.removeAfterUpdateCallback(callbackKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
} ();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user