Source language: Translate to:

Pass a variable that contains a Link on a real link

General questions about NeoAppBuilder - our rapid application development tool for building HTML5, web and mobile apps.

Moderator: Neosoft Support

Pass a variable that contains a Link on a real link

Postby Palamar » Thu Apr 27, 2017 7:30 am

Hello;
I need to pass a variable that contains a Link on a real link. For example: that when you type www.neosoftware.com you will actually see the link.
I have tried some scripts in JS but they have not worked .... Any idea or action that works?
Regards!!
Palamar
 
Posts: 157
Joined: Wed Apr 06, 2005 4:34 pm

Re: Pass a variable that contains a Link on a real link

Postby luishp » Fri Apr 28, 2017 12:15 pm

Sorry, I do not understand the problem...
Luis Hernández - SinLios Soluciones Digitales
http://sinlios.com
User avatar
luishp
 
Posts: 359
Joined: Wed May 23, 2007 10:17 am
Location: Spain

Re: Pass a variable that contains a Link on a real link

Postby dpayer » Fri Apr 28, 2017 2:23 pm

Something like this?

http://yourswebsite.com/?myvar=myvalue

In many cases, it will take you to the website without error. If you needed to process that variable's value on the server side, you'd need to have a php / asp / aspx file to do that.
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1382
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: Pass a variable that contains a Link on a real link

Postby Palamar » Thu May 04, 2017 3:31 am

Hello!

I wanted to say that for example if I have a String that says "Hello, visit me on my website http://www.mi-sitio.com" is returned: "Hello, visit me on my website <a> http://www.mi-sitio.com </a> ".That is, that links are recognized in a string and that they are shown as such, and not as a simple text.


Spanish:
Quise decir que por ejemplo si tengo una String que diga: "Hola, visitame en mi página web http://www.mi-sitio.com" se devuelva: "Hola, visitame en mi página web <a>www.mi-sitio.com</a>". O sea, que se reconozcan links en una strings y que se muestren como tal, y no como un simple texto

Thanks!
Palamar
 
Posts: 157
Joined: Wed Apr 06, 2005 4:34 pm

Re: Pass a variable that contains a Link on a real link

Postby Gaev » Thu May 04, 2017 9:58 am

Palamar:

I wanted to say that for example if I have a String that says "Hello, visit me on my website http://www.mi-sitio.com" is returned: "Hello, visit me on my website <a> http://www.mi-sitio.com </a> ".That is, that links are recognized in a string and that they are shown as such, and not as a simple text.

In a Container object, I placed this text in the HTML property ...
Code: Select all
<a href="https://www.neosoftware.com">Visit NeoSoft Corp</a>

... and it displays as expected.

If you want the website page to be opened in a new tab/window (at least on desktop browsers), you can add target="_blank".
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Pass a variable that contains a Link on a real link

Postby Palamar » Thu May 04, 2017 5:59 pm

No, what I need is for the program to recognize when it is a link, for example if it starts with http, or https, or www or ends in a .com. That converts that part into a link (from text to link). The initial text would be for example in a variable.
Thank you!
Palamar
 
Posts: 157
Joined: Wed Apr 06, 2005 4:34 pm

Re: Pass a variable that contains a Link on a real link

Postby Gaev » Thu May 04, 2017 6:40 pm

Palamar:
what I need is for the program to recognize when it is a link, for example if it starts with http, or https, or www or ends in a .com. That converts that part into a link (from text to link). The initial text would be for example in a variable.

It can be done with Javascript ... the hard part is parsing the text to identify such patterns ... then, wrapping the html tags around them is the easy part.

I can give it a go ... but first, let us nail down all the cases of text patterns that need to be "wrapped" ...

a) starts with (space)http:// ... until another (space)
b) starts with (space)https:// ... until another (space)
c) starts with (space)www. ... until another (space)
d) starts with (space) ... until .com(space)

Any other case ?
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Pass a variable that contains a Link on a real link

Postby luishp » Sat May 06, 2017 2:15 am

Luis Hernández - SinLios Soluciones Digitales
http://sinlios.com
User avatar
luishp
 
Posts: 359
Joined: Wed May 23, 2007 10:17 am
Location: Spain

Re: Pass a variable that contains a Link on a real link

Postby Palamar » Mon May 08, 2017 5:27 am

Gaev, I think those cases would be enough, the problem is to find the link in the middle of a String.
Luishp I saw before both links, the library did not finish understanding how to use it, I have already used others successfully but I do not achieve anything with this one. I would put an example of the script to use it in Neo? ... because the example that mentions on the web gives an error ...
Greetings and thanks!
Palamar
 
Posts: 157
Joined: Wed Apr 06, 2005 4:34 pm

Re: Pass a variable that contains a Link on a real link

Postby Gaev » Mon May 08, 2017 5:56 am

Palamar:

Gaev, I think those cases would be enough, the problem is to find the link in the middle of a String.

I did some experimenting on the weekend ... using NeoBook (and its native commands only), I was able to achieve a lot.

Finding (and changing) strings in the middle of the text was not an issue ... I just looked for the string with a space before it.

But I came across some exception cases that I need to discuss with you ...

a) the text starts with "http://" or "https://" etc. i.e. no leading space ... if you need to include this scenario, there is more logic (code) required to handle it ... if not required (i.e. there will always be some text and a space before the first link), let me know.

b) I am not sure how the text string will be composed ... I look for a space after "http://" or "//https:" to extract the link ... this may not always be true e.g. there is a <br/> or NeoBook's "CRLF" ([#13][#10]) at the end of the link ... can you advise if there is always going to be a space after the link e.g.
Code: Select all
(space)http://www.website.com(space)
(space)http://www.website.com?name=Smith(space)

... including if a link is the very last part of the text string.
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Pass a variable that contains a Link on a real link

Postby Palamar » Mon May 08, 2017 6:59 am

I see that this code works for me, what happens is that when the variable changes text it still shows the previous link. Is there any routine that changes the "each" to just that div ...?

Code: Select all
$('p').each(function(){
   $(this).html( $(this).html().replace(/((http|https|ftp):\/\/[\w?=&.\/-;#~%-]+(?![\w\s?&.\/;#~%"=-]*>))/g, '<a href="$1">$1</a> ') );
});
Palamar
 
Posts: 157
Joined: Wed Apr 06, 2005 4:34 pm

Re: Pass a variable that contains a Link on a real link

Postby Palamar » Mon May 08, 2017 7:05 am

Gaev,

The String may or may not contain a space before, since it will be entered by the user in an InputBox. So you should use a syntax in which you always recognize the link in the middle of a more lake text, for example:

"Hello Juan, my page is www.juan.com, visit it"

or

"Www.juan.com, this is my web"

or

"Juan.com" ..

Regards!
Palamar
 
Posts: 157
Joined: Wed Apr 06, 2005 4:34 pm

Re: Pass a variable that contains a Link on a real link

Postby Gaev » Mon May 08, 2017 7:39 am

Palamar:

1) Input Box does not allow multi-line text ... so this makes the logic a bit simpler.

2) Link text beginning at the first character can also be handled

3) However, from your examples, I see that link text can be immediately followed by a comma ... if this is expected/allowed, then it is another pattern that needs to be searched (not just ending with a space) ... let me know if links can end with characters other than a space ... if so ...

a) what other characters can they end with ?

b) do all links end with .com ... or other domain names (like .edu, .org, .uk etc.) also expected/allowed
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Pass a variable that contains a Link on a real link

Postby Palamar » Tue May 09, 2017 4:55 am

hello!:
There was a routine in Neobook (the usual) that allowed reading a String from another, here would need something similar. It does not matter if it ends with .com, .edu. Net. Or whatever, if it is a link it should convert it to such. I understand that to do the routine we should detect the beginning that could well contain these beginnings:
Code: Select all
(Http, https, www)

And the endings that could have these:
Code: Select all
(.com .net .org .info .tv .biz .ws. Com.ar)


:)
Palamar
 
Posts: 157
Joined: Wed Apr 06, 2005 4:34 pm

Re: Pass a variable that contains a Link on a real link

Postby Gaev » Tue May 09, 2017 5:42 am

Palamar:

It does not matter if it ends with .com, .edu. Net. Or whatever, if it is a link it should convert it to such.

More easily said than done ... do you know how many different domains there are out there ? ... even using Regex (like the references in posts by luishp and you), it takes a huge amount of logic to accomplish.

And things get really complicated when you want to allow such links to be preceeded/succeeded by characters other than spaces ... now you are trying to do AI using NeoBook.


I understand that to do the routine we should detect the beginning that could well contain these beginnings: (Http, https, www)

But you also want to catch strings like juan.com i.e. ones that do not begin with Http, https, www ... so, if there is text like "visit my websitejuan.com", how does the logic know where your link starts ?

And if you allow such links to be preceeded by characters other than a space, how can the logic differentiate between ...
Code: Select all
www.abc.com

and

subdomain.www.abc.com


And the endings that could have these: (.com .net .org .info .tv .biz .ws. Com.ar)

1) are these the only ones you are interested ? ... or are these just examples ?

2) one of your choices is .com.ar ... which would require a lot of logic to make sure the link is not cut off after .com ... UK and many countries in the British Commonwealth use such patterns ... as well as .org.xx, .edu.xx etc. etc. ... so you can see that the patterns to check soon multiply beyond resonableness.


Bottom line, you have to place some restrictions on the patterns in order to get even Regex to give you the results you need. I think that requiring "a space" before the link (except the first one) and "a space or comma or dot" after it would go a long way towards reducing the logic ... then, having "a finite number of link endings" would keep the logic to a manageable level.

In any case, I can't develop any logic until the specifications are nailed down ... because the "devil is in the details" ... and the design depends on the specifications.
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Next

Return to General NeoAppBuilder Discussion

Who is online

Users browsing this forum: No registered users and 1 guest