AriosJentu

[REL] Custom Web Browser

Recommended Posts

Thank you all. But I need help with next/previous/reload page functions, I dont know, how I can realize it :D I will consider all your suggestions :D

Share this post


Link to post

You can make a table that saves the last pages you visit, like:

local lastVisited = { } 
  
-- When you enter to a website 
table.insert ( lastVisited, guiGetText ( url ) ) 
-- Or 
lastVisited = guiGetText ( url ) 

And when the players clicks the last page button, set the URL to the last visited page.

Keep it up, it's a very nice script :)

Sorry for my bad English :S

Share this post


Link to post
You can make a table that saves the last pages you visit, like:
local lastVisited = { } 
  
-- When you enter to a website 
table.insert ( lastVisited, guiGetText ( url ) ) 
-- Or 
lastVisited = guiGetText ( url ) 

And when the players clicks the last page button, set the URL to the last visited page.

Keep it up, it's a very nice script :)

Sorry for my bad English :S

Thank, Ive using tables, and inserts works correct, but not works correctly navigation from urls in table. I dont know why, bcs in theory it works good, but in practice - doesnt work xD

Share this post


Link to post

This sounds very stupid, but, ¿do you try to make it 'tostring'? Like...

local url = guiGetText ( url ) 
local urlTable = tostring ( url ) 
table.insert ( last, urlTable ) 

I make this with a script that i have and it works in setting text to memo. :roll:

Share this post


Link to post
This sounds very stupid, but, ¿do you try to make it 'tostring'? Like...
local url = guiGetText ( url ) 
local urlTable = tostring ( url ) 
table.insert ( last, urlTable ) 

I make this with a script that i have and it works in setting text to memo. :roll:

-_- Again - tables works perfectly. How to make navigation with this tables? Next and previous pages, reload page.

Share this post


Link to post

I'm sorry, I did not understand very well. Now, your system works with a little memo, just save the previous url in the table and load it in the memo when you click the button :P

I think is the easiest way to make it.

Share this post


Link to post
-_- Again - tables works perfectly. How to make navigation with this tables? Next and previous pages, reload page.

You can try something like this:

-- define these two at the start 
history = {} 
curPos = 1 
  
-- define these when navigating 
total = #history 
history[url] = getBrowserURL(browser) -- store the current page url 
  
-- in example 
  
function back() 
    if curPos > 1 then 
        curPos = curPos - 1 
    end 
    setBrowserURL(browser,history[curPos]) 
end 
  
function forward() 
    local total = #history 
     
    if curPos < #history then 
        curPos = curPos + 1 
    end 
end 

There are some mistakes here and there but you get the idea.

Edited by Guest

Share this post


Link to post
-_- Again - tables works perfectly. How to make navigation with this tables? Next and previous pages, reload page.

You could try something like this:

-- define these two at the start 
history = {} 
curPos = 1 
  
-- define these when navigating 
total = #history 
history[url] = getBrowserURL(browser) -- store the current page url 
  
-- in example 
  
function back() 
    if curPos > 1 then 
        curPos = curPos - 1 
    end 
    setBrowserURL(browser,history[curPos]) 
end 
  
function forward() 
    local total = #history 
     
    if curPos < #history then 
        curPos = curPos + 1 
    end 
end 

Not tested sorry if I made any mistakes.

Yea, something like this is what i wanna say :lol:

Share this post


Link to post
-_- Again - tables works perfectly. How to make navigation with this tables? Next and previous pages, reload page.

You can try something like this:

-- define these two at the start 
history = {} 
curPos = 1 
  
-- define these when navigating 
total = #history 
history[url] = getBrowserURL(browser) -- store the current page url 
  
-- in example 
  
function back() 
    if curPos > 1 then 
        curPos = curPos - 1 
    end 
    setBrowserURL(browser,history[curPos]) 
end 
  
function forward() 
    local total = #history 
     
    if curPos < #history then 
        curPos = curPos + 1 
    end 
end 

There are some mistakes here and there but you get the idea.

It doesnt works, i dont know why, but the same system ive created for browser, of course with browser tab navigation history, and it doesnt work.

Share this post


Link to post

¿What doesnt work? ¿Putting the text of table or loading the page?

Share this post


Link to post
It doesnt works, i dont know why, but the same system ive created for browser, of course with browser tab navigation history, and it doesnt work.

Well, then something is conflicting in your script or you're not doing it right. Can you show us what you have that doesn't work?

Share this post


Link to post
Well, then something is conflicting in your script or you're not doing it right. Can you show us what you have that doesn't work?

Main file.

Line 338: Element - Cache (it is table of visited pages), element - Position (number of link in history), element - SaveInCache (when navigating from next/prev, it false, bcs no need to save link)

Line 250 and 260: Event for click on buttons Next and Previous

Line 445 and 448, 523 and 526: check for cache to make buttons enabled or disabled for click (like in browser)

Line 462: Enabling cache saving

Line 533: When loading page, insert loaded link in Cache table

Line 631: Function loadWebURL have argument to saving URL in Cache

Share this post


Link to post

Ah, just ignore those changes on Github I wasn't paying attention to the "return false end". I will take a better look at it tonight. Apologies!

Can you answer BluePie's question, though? What is it exactly that's not working in your code? Are the pages not loading or are you unable to navigate? What's happening in-game?

Share this post


Link to post

Again. Doesnt work correctly moving between table links. For ex - when clicking "Back", sometimes browser thinks that previous page is first, and block this button, in forward - same.

Share this post


Link to post
Again. Doesnt work correctly moving between table links. For ex - when clicking "Back", sometimes browser thinks that previous page is first, and block this button, in forward - same.

Yeah, I made a small test browser and I had the same issue. It seems that some of the events sometimes return more than just one page so it can make it a little difficult for you.

Maybe you can look at the official webbrowser resource that comes with the MTA server, to see how they did it.

Share this post


Link to post

Awesome resource! Thanks so much for this :lol: Been looking for it for some time now.

Share this post


Link to post

So time to report bugs :P

1. If I go to google, I can't open any link from there (just nothing happens, I guess it's same with all external links).

2. When I open youtube and minimize MTA the sound still continues, wouldn't it be better to link it to the MTA volume and when game minimized=sound muted?

3. Maybe make it possible for each client to set his own bookmarks (admin should set one main homepage for all)? That would be cool.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.