mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-08-24 07:00:05 +02:00
* trunc now dynamically creates Math.trunc on IE
This commit is contained in:
parent
e24a9c6b04
commit
0daa2404ea
@ -151,7 +151,7 @@ function Sin(const A: Double): Double; external name 'Math.sin';
|
|||||||
function Sqr(const A: Integer): Integer; assembler; overload;
|
function Sqr(const A: Integer): Integer; assembler; overload;
|
||||||
function Sqr(const A: Double): Double; assembler; overload;
|
function Sqr(const A: Double): Double; assembler; overload;
|
||||||
function sqrt(const A: Double): Double; external name 'Math.sqrt';
|
function sqrt(const A: Double): Double; external name 'Math.sqrt';
|
||||||
function Trunc(const A: Double): NativeInt; external name 'Math.trunc'; // not on IE
|
function Trunc(const A: Double): NativeInt;
|
||||||
|
|
||||||
{*****************************************************************************
|
{*****************************************************************************
|
||||||
String functions
|
String functions
|
||||||
@ -243,6 +243,19 @@ asm
|
|||||||
return A*A;
|
return A*A;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function Trunc(const A: Double): NativeInt; assembler;
|
||||||
|
asm
|
||||||
|
if (!Math.trunc) {
|
||||||
|
Math.trunc = function(v) {
|
||||||
|
v = +v;
|
||||||
|
if (!isFinite(v)) return v;
|
||||||
|
return (v - v % 1) || (v < 0 ? -0 : v === 0 ? v : 0);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
$mod.Trunc = Math.trunc;
|
||||||
|
return Math.trunc(A);
|
||||||
|
end;
|
||||||
|
|
||||||
function Copy(const S: string; Index, Size: Integer): String; assembler;
|
function Copy(const S: string; Index, Size: Integer): String; assembler;
|
||||||
asm
|
asm
|
||||||
if (Index<1) Index = 1;
|
if (Index<1) Index = 1;
|
||||||
|
@ -1693,6 +1693,8 @@ Type
|
|||||||
touchend : TJSTouchEventHandler;
|
touchend : TJSTouchEventHandler;
|
||||||
touchmove : TJSTouchEventHandler;
|
touchmove : TJSTouchEventHandler;
|
||||||
touchcancel : TJSTouchEventHandler;
|
touchcancel : TJSTouchEventHandler;
|
||||||
|
procedure addEventListener(aname : string; aListener : TJSEventHandler);
|
||||||
|
procedure addEventListener(aname : string; aListener : JSValue);
|
||||||
Procedure alert(Const Msg : String);
|
Procedure alert(Const Msg : String);
|
||||||
Function atob(Const aValue : string) : string;
|
Function atob(Const aValue : string) : string;
|
||||||
procedure blur;
|
procedure blur;
|
||||||
@ -1714,6 +1716,8 @@ Type
|
|||||||
procedure print;
|
procedure print;
|
||||||
function prompt(const aMessage : String) : String; overload;
|
function prompt(const aMessage : String) : String; overload;
|
||||||
function prompt(const aMessage,aDefault : String) : String; overload;
|
function prompt(const aMessage,aDefault : String) : String; overload;
|
||||||
|
procedure removeEventListener(aname : string; aListener : TJSEventHandler);
|
||||||
|
procedure removeEventListener(aname : string; aListener : JSValue);
|
||||||
procedure resizeBy(aWidth,aHeight : NativeInt);
|
procedure resizeBy(aWidth,aHeight : NativeInt);
|
||||||
procedure resizeTo(aWidth,aHeight : NativeInt);
|
procedure resizeTo(aWidth,aHeight : NativeInt);
|
||||||
procedure scrollBy(x,y : NativeInt);
|
procedure scrollBy(x,y : NativeInt);
|
||||||
|
Loading…
Reference in New Issue
Block a user