Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend Speedup #2183

Merged
merged 10 commits into from
Jan 22, 2025
5 changes: 2 additions & 3 deletions garrysmod/html/js/menu/control.Saves.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

save = new WorkshopFiles();

function ControllerSaves($scope, $rootScope, $location, $timeout, $routeParams)
Expand Down Expand Up @@ -93,14 +92,14 @@ function ControllerSaves($scope, $rootScope, $location, $timeout, $routeParams)

// This is just to fix the spawnmenu initial size being 512x512 for first few frames
$scope.ReloadView();
$( window ).resize( function() {
window.addEventListener('resize', function() {
//if ( $scope.ResizeTimeout ) $timeout.cancel( $scope.ResizeTimeout );
//$scope.ResizeTimeout = $timeout( function() { $scope.ReloadView(); }, 250 );

if ( $scope.ReloadedView ) return;
$scope.ReloadedView = true;
$scope.ResizeTimeout = $timeout( function() { $scope.ReloadView(); }, 250 );
} );
});
}

function OnGameSaved()
Expand Down
30 changes: 16 additions & 14 deletions garrysmod/html/js/svc.Tranny.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,32 @@ angular.module( 'tranny', [] )

var update = function()
{
var text = strName + " " + strSuffix;

if ( !IN_ENGINE )
{
$(element).text( strName + " " + strSuffix );
$(element).attr( "placeholder", strName + " " + strSuffix );
element.text(text);
element.attr( "placeholder", text );
return;
}

var outStr_old = languageCache[ strName ] || language.Update( strName, function( outStr )
{
languageCache[ strName ] = outStr;
$(element).text( outStr + " " + strSuffix );
$(element).attr( "placeholder", outStr + " " + strSuffix );
var updatedText = outStr + " " + strSuffix;
element.text(updatedText);
element.attr( "placeholder", updatedText );
} );

if ( outStr_old )
{
// Compatibility with Awesomium
languageCache[ strName ] = outStr_old;
$(element).text( outStr_old + " " + strSuffix );
$(element).attr( "placeholder", outStr_old + " " + strSuffix );
var updatedText = outStr_old + " " + strSuffix;
element.text(updatedText);
element.attr( "placeholder", updatedText );
}
}
};

scope.$watch( attrs.ngTranny, function( value )
{
Expand All @@ -56,22 +60,20 @@ angular.module( 'tranny', [] )
{
return function ( scope, element, attrs )
{
var strName = "";

scope.$watch( attrs.ngSeconds, function ( value )
{
if ( value < 60 )
return $(element).text( Math.floor( value ) + " sec" );
return element.text( Math.floor( value ) + " sec" );

if ( value < 60 * 60 )
return $( element ).text( Math.floor( value / 60 ) + " min" );
return element.text( Math.floor( value / 60 ) + " min" );

if ( value < 60 * 60 * 24 )
return $( element ).text( Math.floor( value / 60 / 60 ) + " hr" );
return element.text( Math.floor( value / 60 / 60 ) + " hr" );

$( element ).text( "a long time" );
element.text( "a long time" );

});

}
} );
} );
Loading