diff --git a/components/pas2js/frmpas2jsbrowserprojectoptions.lfm b/components/pas2js/frmpas2jsbrowserprojectoptions.lfm index fc88f8e38f..ee57281f2c 100644 --- a/components/pas2js/frmpas2jsbrowserprojectoptions.lfm +++ b/components/pas2js/frmpas2jsbrowserprojectoptions.lfm @@ -1,11 +1,11 @@ object WebBrowserProjectOptionsForm: TWebBrowserProjectOptionsForm Left = 431 - Height = 344 + Height = 383 Top = 310 - Width = 426 + Width = 491 Caption = 'Pas2JS Browser project options' - ClientHeight = 344 - ClientWidth = 426 + ClientHeight = 383 + ClientWidth = 491 OnCreate = FormCreate OnShow = FormShow Position = poScreenCenter @@ -14,9 +14,9 @@ object WebBrowserProjectOptionsForm: TWebBrowserProjectOptionsForm AnchorSideLeft.Control = Owner AnchorSideTop.Control = Owner Left = 6 - Height = 19 + Height = 23 Top = 6 - Width = 151 + Width = 164 BorderSpacing.Left = 6 BorderSpacing.Top = 6 Caption = 'Create initial HTML page' @@ -27,12 +27,12 @@ object WebBrowserProjectOptionsForm: TWebBrowserProjectOptionsForm end object CBUseBrowserApp: TCheckBox AnchorSideLeft.Control = CBCreateHTML - AnchorSideTop.Control = CBRunOnReady + AnchorSideTop.Control = cbShowUncaughtExceptions AnchorSideTop.Side = asrBottom Left = 6 - Height = 19 - Top = 81 - Width = 184 + Height = 23 + Top = 122 + Width = 200 BorderSpacing.Top = 6 Caption = 'Use Browser Application object' TabOrder = 1 @@ -42,18 +42,18 @@ object WebBrowserProjectOptionsForm: TWebBrowserProjectOptionsForm AnchorSideTop.Control = CBUseBrowserApp AnchorSideTop.Side = asrBottom Left = 6 - Height = 19 - Top = 106 - Width = 294 + Height = 23 + Top = 151 + Width = 314 BorderSpacing.Top = 6 Caption = 'Use Browser Console unit to display writeln() output' TabOrder = 2 end object BPHelpOptions: TButtonPanel Left = 6 - Height = 34 - Top = 304 - Width = 414 + Height = 39 + Top = 338 + Width = 479 OKButton.Name = 'OKButton' OKButton.DefaultCaption = True HelpButton.Name = 'HelpButton' @@ -70,8 +70,8 @@ object WebBrowserProjectOptionsForm: TWebBrowserProjectOptionsForm AnchorSideTop.Control = RBStartServerAt AnchorSideTop.Side = asrBottom Left = 70 - Height = 23 - Top = 177 + Height = 29 + Top = 234 Width = 75 BorderSpacing.Left = 32 BorderSpacing.Top = 2 @@ -85,9 +85,9 @@ object WebBrowserProjectOptionsForm: TWebBrowserProjectOptionsForm AnchorSideTop.Control = CBUseBrowserConsole AnchorSideTop.Side = asrBottom Left = 6 - Height = 19 - Top = 131 - Width = 168 + Height = 23 + Top = 180 + Width = 185 BorderSpacing.Top = 6 Caption = 'Project needs a HTTP Server' OnChange = CBUseHTTPServerChange @@ -98,9 +98,9 @@ object WebBrowserProjectOptionsForm: TWebBrowserProjectOptionsForm AnchorSideTop.Control = CBUseHTTPServer AnchorSideTop.Side = asrBottom Left = 38 - Height = 19 - Top = 156 - Width = 154 + Height = 23 + Top = 209 + Width = 169 BorderSpacing.Left = 32 BorderSpacing.Top = 6 Caption = 'Start HTTP Server on port' @@ -113,9 +113,9 @@ object WebBrowserProjectOptionsForm: TWebBrowserProjectOptionsForm AnchorSideTop.Control = SEPort AnchorSideTop.Side = asrBottom Left = 38 - Height = 19 - Top = 202 - Width = 148 + Height = 23 + Top = 265 + Width = 163 BorderSpacing.Top = 2 Caption = 'Use this URL to start app' TabOrder = 7 @@ -127,13 +127,13 @@ object WebBrowserProjectOptionsForm: TWebBrowserProjectOptionsForm AnchorSideRight.Control = Owner AnchorSideRight.Side = asrBottom Left = 70 - Height = 23 - Top = 223 - Width = 344 + Height = 29 + Top = 290 + Width = 409 Anchors = [akTop, akLeft, akRight] BorderSpacing.Top = 2 BorderSpacing.Right = 12 - ItemHeight = 15 + ItemHeight = 0 TabOrder = 8 end object CBMaintainPage: TCheckBox @@ -141,9 +141,9 @@ object WebBrowserProjectOptionsForm: TWebBrowserProjectOptionsForm AnchorSideTop.Control = CBCreateHTML AnchorSideTop.Side = asrBottom Left = 6 - Height = 19 - Top = 31 - Width = 132 + Height = 23 + Top = 35 + Width = 142 BorderSpacing.Top = 6 Caption = 'Maintain HTML Page' TabOrder = 9 @@ -153,11 +153,23 @@ object WebBrowserProjectOptionsForm: TWebBrowserProjectOptionsForm AnchorSideTop.Control = CBMaintainPage AnchorSideTop.Side = asrBottom Left = 6 - Height = 19 - Top = 56 - Width = 268 + Height = 23 + Top = 64 + Width = 290 BorderSpacing.Top = 6 Caption = 'Run rtl when all page resources are fully loaded' TabOrder = 10 end + object cbShowUncaughtExceptions: TCheckBox + AnchorSideLeft.Control = CBRunOnReady + AnchorSideTop.Control = CBRunOnReady + AnchorSideTop.Side = asrBottom + Left = 6 + Height = 23 + Top = 93 + Width = 208 + BorderSpacing.Top = 6 + Caption = 'Let rtl show uncaught exceptions' + TabOrder = 11 + end end diff --git a/components/pas2js/frmpas2jsbrowserprojectoptions.pp b/components/pas2js/frmpas2jsbrowserprojectoptions.pp index 9cbca2c1ad..90894f487c 100644 --- a/components/pas2js/frmpas2jsbrowserprojectoptions.pp +++ b/components/pas2js/frmpas2jsbrowserprojectoptions.pp @@ -21,6 +21,7 @@ type CBServerURL: TComboBox; CBMaintainPage: TCheckBox; CBRunOnReady: TCheckBox; + cbShowUncaughtExceptions: TCheckBox; RBUseURL: TRadioButton; RBStartServerAt: TRadioButton; SEPort: TSpinEdit; @@ -43,6 +44,7 @@ type property StartHTTPServer : Boolean Index 4 read GetB Write SetB; property UseURL : Boolean Index 5 read GetB Write SetB; property UseRunOnReady : Boolean Index 6 read GetB Write SetB; + property ShowUncaughtExceptions : Boolean Index 7 read GetB Write SetB; Property ServerPort : Word Read GetServerPort Write SetServerPort; Property URL : String Read GetURL Write SetURL; end; @@ -121,6 +123,7 @@ begin 4 : Result:=RBStartServerAt.Checked; 5 : Result:=RBUseURL.Checked; 6 : Result:=CBRunOnReady.Checked; + 7 : Result:=cbShowUncaughtExceptions.Checked; else Result:=False; end; @@ -157,6 +160,7 @@ begin CBUseHTTPServer.Checked:=true end; 6 : CBRunOnReady.Checked:=Avalue; + 7 : cbShowUncaughtExceptions.Checked:=aValue; end; end; diff --git a/components/pas2js/pjsdsgnregister.pas b/components/pas2js/pjsdsgnregister.pas index 348c483632..6b07a464ee 100644 --- a/components/pas2js/pjsdsgnregister.pas +++ b/components/pas2js/pjsdsgnregister.pas @@ -29,7 +29,8 @@ type baoUseBrowserApp, // Use browser app object baoUseBrowserConsole, // use browserconsole unit to display Writeln() baoStartServer, // Start simple server - baoUseURL // Use this URL to run/show project in browser + baoUseURL, // Use this URL to run/show project in browser + baoShowException // let RTL show uncaught exceptions ); TBrowserApplicationOptions = set of TBrowserApplicationOption; @@ -337,6 +338,7 @@ begin UseBrowserConsole:=CO(baoUseBrowserConsole); StartHTTPServer:=CO(baoStartServer); UseRunOnReady:=CO(baoRunOnReady); + ShowUncaughtExceptions:=CO(baoShowException); // We allocate the new port in all cases. ServerPort:=GetNextPort; URL:=''; @@ -351,6 +353,7 @@ begin SO(UseBrowserConsole,baoUseBrowserConsole); SO(StartHTTPServer,baoStartServer); SO(UseRunOnReady,baoRunOnReady); + SO(ShowUncaughtExceptions,baoShowException); DebugLN(['Start server:', CO(baoStartServer)]); if CO(baoStartServer) then begin @@ -424,10 +427,14 @@ begin Content:=''; if baoUseBrowserConsole in Options then Content:=ConsoleDiv; - if baoRunOnReady in Options then - RunScript:='window.addEventListener("load", rtl.run);'+LineEnding + if baoShowException in Options then + Runscript:='rtl.showUncaughtExceptions=true;'+LineEnding+' '; else - RunScript:='rtl.run();'+LineEnding; + RunScript:=''; + if baoRunOnReady in Options then + RunScript:=Runscript+'window.addEventListener("load", rtl.run);'+LineEnding + else + RunScript:=Runscript+'rtl.run();'+LineEnding; HTMLSource:=Format(TemplateHTMLSource,[aFileName,RunScript,Content]); HTMLFile.SetSourceText(HTMLSource); Result:=HTMLFile;