Skip to content

Commit 7df3396

Browse files
committed
Minor fixes (browser)
- Code formatting - Example errors - Typos
1 parent 8243434 commit 7df3396

File tree

81 files changed

+539
-635
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+539
-635
lines changed

functions/Browser/canBrowserNavigateBack.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ client:
1212
values:
1313
- type: bool
1414
name: result
15-
description: Returns true if the browser can navigate back, false otherwise.
15+
description: Returns **true** if the browser can navigate back, **false** otherwise.
1616
examples:
1717
- path: examples/canBrowserNavigateBack-1.lua
1818
description: This example creates a browser that can return to the last and previous pages and can also be refreshed.

functions/Browser/canBrowserNavigateForward.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ client:
1212
values:
1313
- type: bool
1414
name: result
15-
description: Returns true if the browser can go to the next page, false otherwise.
15+
description: Returns **true** if the browser can go to the next page, **false** otherwise.
1616
examples:
1717
- path: examples/canBrowserNavigateForward-1.lua
1818
description: This example creates a browser that can return to the last and previous pages and can also be refreshed.

functions/Browser/createBrowser.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ client:
2727
values:
2828
- type: element|false
2929
name: new browser
30-
description: Returns a [[texture]] of the [[browser]] if it was created successfully, false otherwise. Returns also false, if the user disabled remote pages and isLocal was set to false.
30+
description: Returns a [[texture]] of the [[browser]] if it was created successfully, **false** otherwise. Returns also **false**, if the user disabled remote pages and isLocal was set to false.
3131
examples:
3232
- path: examples/createBrowser-1.lua
3333
description: This example shows you how to create a fullscreen web browser (showing a local html file) without input-handling.

functions/Browser/examples/canBrowserNavigateBack-1.lua

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,31 @@ guiWindowSetSizable(window, false)
33

44
local navigateBackBtn = guiCreateButton(10, 19, 39, 36, "<", false, window)
55
local navigateForwardBtn = guiCreateButton(98, 19, 39, 36, ">", false, window)
6-
local addressBar = guiCreateEdit(137, 19, 701, 36, "", false, window)
7-
guiSetEnabled( addressBar, false )
6+
local addressBar = guiCreateEdit(137, 19, 701, 36, "", false, window)
7+
guiSetEnabled(addressBar, false)
88
local reloadBtn = guiCreateButton(49, 19, 49, 36, "reload", false, window)
99
local browser = guiCreateBrowser(10, 55, 828, 609, false, false, false, window)
1010

1111
-- Load our page on browser creation.
12-
local theBrowser = guiGetBrowser(browser)
13-
addEventHandler("onClientBrowserCreated", theBrowser,
14-
function()
15-
loadBrowserURL(source, "https://forum.mtasa.com/")
16-
end
17-
)
12+
local theBrowser = guiGetBrowser(browser)
13+
addEventHandler("onClientBrowserCreated", theBrowser, function()
14+
loadBrowserURL(source, "https://forum.mtasa.com/")
15+
end)
1816

1917
-- This checks to see if the browser can navigate in any direction and enables the back or forward buttons
20-
addEventHandler( "onClientBrowserDocumentReady", theBrowser, function( )
18+
addEventHandler("onClientBrowserDocumentReady", theBrowser, function()
2119
guiSetEnabled(navigateForwardBtn, canBrowserNavigateForward(theBrowser))
2220
guiSetEnabled(navigateBackBtn, canBrowserNavigateBack(theBrowser))
23-
guiSetText( addressBar, getBrowserURL( theBrowser ) )
24-
end )
21+
guiSetText(addressBar, getBrowserURL(theBrowser))
22+
end)
2523

2624
-- This part handles the GUI navigation buttons for the browser.
27-
addEventHandler( "onClientGUIClick", resourceRoot, function ( )
25+
addEventHandler("onClientGUIClick", resourceRoot, function()
2826
if source == navigateBackBtn then
2927
navigateBrowserBack(theBrowser)
3028
elseif source == navigateForwardBtn then
3129
navigateBrowserForward(theBrowser)
3230
elseif source == reloadBtn then
3331
reloadBrowserPage(theBrowser)
3432
end
35-
end )
33+
end)

functions/Browser/examples/canBrowserNavigateForward-1.lua

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,30 @@ guiWindowSetSizable(window, false)
33
local navigateBackBtn = guiCreateButton(10, 19, 39, 36, "<", false, window)
44
local navigateForwardBtn = guiCreateButton(98, 19, 39, 36, ">", false, window)
55
local reloadBtn = guiCreateButton(49, 19, 49, 36, "reload", false, window)
6-
local addressBar = guiCreateEdit(137, 19, 701, 36, "", false, window)
7-
guiSetEnabled(addressBar,false)
6+
local addressBar = guiCreateEdit(137, 19, 701, 36, "", false, window)
7+
guiSetEnabled(addressBar, false)
88
local webBrowser = guiCreateBrowser(10, 55, 828, 609, false, false, false, window)
9-
local theBrowser = guiGetBrowser(webBrowser)
9+
local theBrowser = guiGetBrowser(webBrowser)
1010

1111
-- Load our page on browser creation.
12-
addEventHandler("onClientBrowserCreated", theBrowser,
13-
function()
14-
showCursor(true)
15-
loadBrowserURL(source, "https://forum.mtasa.com/")
16-
end
17-
)
12+
addEventHandler("onClientBrowserCreated", theBrowser, function()
13+
showCursor(true)
14+
loadBrowserURL(source, "https://forum.mtasa.com/")
15+
end)
1816

19-
addEventHandler( "onClientBrowserDocumentReady", theBrowser, function( url )
20-
guiSetText( addressBar, getBrowserURL( theBrowser ) )
21-
end )
17+
addEventHandler("onClientBrowserDocumentReady", theBrowser, function(url)
18+
guiSetText(addressBar, getBrowserURL(theBrowser))
19+
end)
2220

2321
-- This part handles the GUI navigation buttons for the browser.
24-
addEventHandler( "onClientGUIClick", resourceRoot, function ( )
22+
addEventHandler("onClientGUIClick", resourceRoot, function()
2523
if source == navigateBackBtn then
26-
if (not canBrowserNavigateBack(theBrowser)) then return end -- This checks to see if the browser can navigate to the back
24+
if (not canBrowserNavigateBack(theBrowser)) then return end -- This checks to see if the browser can navigate to the back
2725
navigateBrowserBack(theBrowser)
2826
elseif source == navigateForwardBtn then -- This checks to see if the browser can navigate to the forward
29-
if (not canBrowserNavigateForward(theBrowser)) then return end
27+
if (not canBrowserNavigateForward(theBrowser)) then return end
3028
navigateBrowserForward(theBrowser)
3129
elseif source == reloadBtn then
3230
reloadBrowserPage(theBrowser)
3331
end
34-
end )
32+
end)
Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
1-
--In order to render the browser on the full screen, we need to know the dimensions.
1+
-- In order to render the browser on the full screen, we need to know the dimensions.
22
local screenWidth, screenHeight = guiGetScreenSize()
33

4-
--Let's create a new browser in local mode. We will not be able to load an external URL.
4+
-- Let's create a new browser in local mode. We will not be able to load an external URL.
55
local webBrowser = createBrowser(screenWidth, screenHeight, true, false)
6-
7-
--This is the function to render the browser.
6+
7+
-- This is the function to render the browser.
88
function webBrowserRender()
9-
--Render the browser on the full size of the screen.
10-
dxDrawImage(0, 0, screenWidth, screenHeight, webBrowser, 0, 0, 0, tocolor(255,255,255,255), true)
9+
-- Render the browser on the full size of the screen.
10+
dxDrawImage(0, 0, screenWidth, screenHeight, webBrowser, 0, 0, 0, tocolor(255, 255, 255, 255), true)
1111
end
1212

13-
--The event onClientBrowserCreated will be triggered, after the browser has been initialized.
14-
--After this event has been triggered, we will be able to load our URL and start drawing.
15-
addEventHandler("onClientBrowserCreated", webBrowser,
16-
function()
17-
--After the browser has been initialized, we can load our file.
18-
loadBrowserURL(webBrowser, "http://mta/local/html/site.html")
19-
--Now we can start to render the browser.
20-
addEventHandler("onClientRender", root, webBrowserRender)
21-
end
22-
)
13+
-- The event onClientBrowserCreated will be triggered, after the browser has been initialized.
14+
-- After this event has been triggered, we will be able to load our URL and start drawing.
15+
addEventHandler("onClientBrowserCreated", webBrowser, function()
16+
-- After the browser has been initialized, we can load our file.
17+
loadBrowserURL(webBrowser, "http://mta/local/html/site.html")
18+
-- Now we can start to render the browser.
19+
addEventHandler("onClientRender", root, webBrowserRender)
20+
end)
Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
1-
--In order to render the browser on the full screen, we need to know the dimensions.
1+
-- In order to render the browser on the full screen, we need to know the dimensions.
22
local screenWidth, screenHeight = guiGetScreenSize()
33

4-
--Let's create a new browser in remote mode.
4+
-- Let's create a new browser in remote mode.
55
local webBrowser = createBrowser(screenWidth, screenHeight, false, false)
6-
7-
--Function to render the browser.
6+
7+
-- Function to render the browser.
88
function webBrowserRender()
9-
--Render the browser on the full size of the screen.
10-
dxDrawImage(0, 0, screenWidth, screenHeight, webBrowser, 0, 0, 0, tocolor(255,255,255,255), true)
9+
-- Render the browser on the full size of the screen.
10+
dxDrawImage(0, 0, screenWidth, screenHeight, webBrowser, 0, 0, 0, tocolor(255, 255, 255, 255), true)
1111
end
1212

13-
--The event onClientBrowserCreated will be triggered, after the browser has been initialized.
14-
--After this event has been triggered, we will be able to load our URL and start drawing.
15-
addEventHandler("onClientBrowserCreated", webBrowser,
16-
function()
17-
--After the browser has been initialized, we can load www.youtube.com
18-
loadBrowserURL(webBrowser, "http://www.youtube.com")
19-
--Now we can start to render the browser.
20-
addEventHandler("onClientRender", root, webBrowserRender)
21-
end
22-
)
13+
-- The event onClientBrowserCreated will be triggered, after the browser has been initialized.
14+
-- After this event has been triggered, we will be able to load our URL and start drawing.
15+
addEventHandler("onClientBrowserCreated", webBrowser, function()
16+
-- After the browser has been initialized, we can load www.youtube.com
17+
loadBrowserURL(webBrowser, "http://www.youtube.com")
18+
-- Now we can start to render the browser.
19+
addEventHandler("onClientRender", root, webBrowserRender)
20+
end)
Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
1-
--In order to render the browser on the full screen, we need to know the dimensions.
1+
-- In order to render the browser on the full screen, we need to know the dimensions.
22
local screenWidth, screenHeight = GuiElement.getScreenSize()
33

4-
--Let's create a new browser in local mode. We will not be able to load an external URL.
4+
-- Let's create a new browser in local mode. We will not be able to load an external URL.
55
local webBrowser = Browser(screenWidth, screenHeight, true, false)
6-
7-
--This is the function to render the browser.
6+
7+
-- This is the function to render the browser.
88
function webBrowserRender()
9-
--Render the browser on the full size of the screen.
10-
dxDrawImage(0, 0, screenWidth, screenHeight, webBrowser, 0, 0, 0, tocolor(255,255,255,255), true)
9+
-- Render the browser on the full size of the screen.
10+
dxDrawImage(0, 0, screenWidth, screenHeight, webBrowser, 0, 0, 0, tocolor(255, 255, 255, 255), true)
1111
end
1212

13-
--The event onClientBrowserCreated will be triggered, after the browser has been initialized.
14-
--After this event has been triggered, we will be able to load our URL and start drawing.
15-
addEventHandler("onClientBrowserCreated", webBrowser,
16-
function()
17-
--After the browser has been initialized, we can load our file.
18-
webBrowser.url = "http://mta/local/html/site.html"
19-
--Now we can start to render the browser.
20-
addEventHandler("onClientRender", root, webBrowserRender)
21-
end
22-
)
13+
-- The event onClientBrowserCreated will be triggered, after the browser has been initialized.
14+
-- After this event has been triggered, we will be able to load our URL and start drawing.
15+
addEventHandler("onClientBrowserCreated", webBrowser, function()
16+
-- After the browser has been initialized, we can load our file.
17+
webBrowser.url = "http://mta/local/html/site.html"
18+
-- Now we can start to render the browser.
19+
addEventHandler("onClientRender", root, webBrowserRender)
20+
end)
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
local browser = guiGetBrowser(guiCreateBrowser(200, 200, 400, 200, true, false, false))
22

3-
addEventHandler("onClientBrowserCreated", browser,
4-
function ()
5-
loadBrowserURL(source, "http://mta/local/example.html") --Containing <span id="nick"></span> somewhere in the file
6-
end)
3+
addEventHandler("onClientBrowserCreated", browser, function()
4+
loadBrowserURL(source, "http://mta/local/example.html") -- Containing <span id="nick"></span> somewhere in the file
5+
end)
76

8-
--The page has to load first
9-
addEventHandler("onClientBrowserDocumentReady", browser,
10-
function ()
11-
executeBrowserJavascript(source, string.format("document.getElementById('nick').innerText = %q;", getPlayerName(localPlayer)))
12-
end)
7+
-- The page has to load first
8+
addEventHandler("onClientBrowserDocumentReady", browser, function()
9+
executeBrowserJavascript(source, string.format("document.getElementById('nick').innerText = %q;", getPlayerName(localPlayer)))
10+
end)
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
local browser = GuiBrowser(200, 200, 400, 200, true, false, false).browser
22

3-
addEventHandler("onClientBrowserCreated", browser,
4-
function ()
5-
source.url = "http://mta/local/example.html" --Containing <span id="nick"></span> somewhere in the file
6-
end)
3+
addEventHandler("onClientBrowserCreated", browser, function()
4+
source.url = "http://mta/local/example.html" -- Containing <span id="nick"></span> somewhere in the file
5+
end)
76

8-
--The page has to load first
9-
addEventHandler("onClientBrowserDocumentReady", browser,
10-
function ()
11-
source:executeJavascript(string.format("document.getElementById('nick').innerText = %q;", localPlayer.name))
12-
end)
7+
-- The page has to load first
8+
addEventHandler("onClientBrowserDocumentReady", browser, function()
9+
source:executeJavascript(string.format("document.getElementById('nick').innerText = %q;", localPlayer.name))
10+
end)

0 commit comments

Comments
 (0)