Jump to content

URLs markeren in tekstvelden


Marsau

Recommended Posts

Posted

In het verlengde van mijn eerder tip (URLs klikbaar maken in tekstvelden) bijgaand een nieuwe: URL's markeren in tekstvelden. Na wat rommelen vandaag een nieuwe CF gemaakt die precies doet wat we hier willen. Geen rocket-science, maar wel superhandig om een wat meer complete gebruikerservaring neer te zetten direct in een FileMaker tekst-veld.

Bijgaande custom-functie zou moeten worden opgehangen aan een scripttrigger bij verlaten veld, of met een auto-enter (niet getest).

Alle URLs worden opgemaakt conform de opgemaakte kleur.

 

Let ( 
[ input = Get(InhoudActiefVeld)
; rgb_code = RGB ( 0 ; 0 ; 250 ) // wijzig naar smaak...
; underlined = True // URLs wel/niet onderstrepen...
; urllist  = 
// de lijst van URLs in de opgegeven content
While ( 
[ content = input
; content = Substitute ( content  ;  [ " " ; ¶ ]  )  // end Substitute 
; q = ValueCount ( content )
; i = 1
; allowedprotocols = "http¶https¶ftp¶fmp¶fmnet¶ftps¶webdav¶evernote¶file"
; result = ""
] ;

 i ≤ q ; 

[ probe = GetValue ( content; i )
; protocol = Let ( p = Position ( probe ; ":/" ; 1 ; 1 ); If ( p = 0; ""; Left ( probe; p - 1 ) ) )
; result = List ( result; If ( FilterValues ( allowedprotocols ; protocol ) ≠ ""; probe; ""  ))
; i = i + 1
];

result

)  // end While 1

; formatted_text = 

While ( 
[ result = input 
; urllist = urllist 
; i = 1
; q = ValueCount ( result )
] ;
 i ≤ q ; 

[ probe = GetValue ( urllist; i )
; styled_probe = TextColor ( probe ; rgb_code )
; styled_probe = If ( underlined; TextStyleAdd ( styled_probe ; Onderstreept ); styled_probe )
; result = Substitute ( result ; probe ; styled_probe )
; i = i + 1

] 

; result

)   // end While

] ;

formatted_text


) // end Let

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...