rejetto forum

rejetto, can you make an limit option?

marbulas · 22 · 14704

0 Members and 1 Guest are viewing this topic.

Offline bacter

  • Operator
  • Tireless poster
  • *****
    • Posts: 681
    • View Profile
rejetto
no need for javascript - you made macro ! ;D

Code: [Select]
{.set|uagent|{.header|User-Agent.}.}
{.for each|tt|MSIE|Firefox|Opera|Chrome|Safari|Mosaic|GranParadiso|Galeon|Konqueror|
{:{.if not|{.^browsername.}|{:{.if|{.pos|{.^tt.}|{.^uagent.}.}|{:{.set|browsername|{.^tt.}.}:}.}:}.}:}.}
{.set|tt|{.substring|{.^browsername.}| |{.^uagent.}.}.}
{.switch|{.^browsername.}|,|
MSIE        |{:{.set|brvers|{.cut|6||{.substring|{.^browsername.}|;|{.^uagent.}.}.}.}:}|
Firefox     |{:{.set|brvers|{.cut|9| |{.^tt.}.}.}:}|
Opera,Mosaic  |{:{.set|brvers|{.cut|7| |{.^tt.}.}.}:}|
Chrome,Galeon|{:{.set|brvers|{.cut|8| |{.^tt.}.}.}:}|
Safari     |{:{.set|brvers|{.cut|9||{.substring|Version| |{.^uagent.}.}.}.}:}|
Konqueror       |{:{.set|brvers|{.cut|11||{.substring|{.^browsername.}|;|{.^uagent.}.}.}.}:}|
default:|
.}
{.for each|tt|iphone|ipod|Android|Symbian|IEMobile|Elinks|Googlebot|Yahoo|
{:{.if not|{.^browserext.}|{:{.if|{.pos|{.^tt.}|{.^uagent.}.}|{:{.set|browserext|{.^tt.}.}:}.}:}.}:}.}

this returns browsername, brvers (and browserext for mobiledevices and bots)
Executing it with first connection you have all the information you need. ;)
your computer has no brain - use your own !


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile

Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile

Offline bacter

  • Operator
  • Tireless poster
  • *****
    • Posts: 681
    • View Profile
from mars:
Quote
why not include it as an alias? Wink

from rejetto:
Quote
what does bacter think about it?

Sorry, but even with the help of the search function of this forum and the wiki i was not able to find out what mars means by an alias.

I can imagine that he means to define the functions in a way that they are not directly executed.
something like:
Code: [Select]
{.set|browsername|{:
     {.for each|tt|MSIE|Firefox|Opera|Chrome|Safari|Mosaic|GranParadiso|Galeon|Konqueror|
{:{.if|{.pos|{.^tt.}|{.header|User-Agent.}.}|{:{.^tt.}:}.}
        :}.}
     :}.}
{.set|brvers|{: .. the whole junk of code ..  :}
...


if you mean this, that is another way to do it  :D

« Last Edit: November 27, 2009, 06:22:12 PM by bacter »
your computer has no brain - use your own !


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2068
    • View Profile
there is already compiled four aliases found in the sources of hfs

Quote
var length=length|var=$1

cache=trim|{.set|#tempCache123|{.from table|$1|$2.}.} {.if not|{.^#tempCache123.}|{:{.set|#tempCache123|{.dequote|$3.}.}{.set table|$1|$2={.^#tempCache123.}.}:}.} {.^#tempCache123.} {.set|#tempCache123.}

is substring=pos|$1|$2

set append=set|$1|$2|mode=append

an alias could be defined as follows

Code: [Select]
get browser={.set|uagent|{.header|User-Agent.}.}
{.for each|tt|MSIE|Firefox|Opera|Chrome|Safari|Mosaic|GranParadiso|Galeon|Konqueror|
{:{.if not|{.^browsername.}|{:{.if|{.pos|{.^tt.}|{.^uagent.}.}|{:{.set|browsername|{.^tt.}.}:}.}:}.}:}.}
{.set|tt|{.substring|{.^browsername.}| |{.^uagent.}.}.}
{.switch|{.^browsername.}|,|
MSIE        |{:{.set|brvers|{.cut|6||{.substring|{.^browsername.}|;|{.^uagent.}.}.}.}:}|
Firefox     |{:{.set|brvers|{.cut|9| |{.^tt.}.}.}:}|
Opera,Mosaic  |{:{.set|brvers|{.cut|7| |{.^tt.}.}.}:}|
Chrome,Galeon|{:{.set|brvers|{.cut|8| |{.^tt.}.}.}:}|
Safari     |{:{.set|brvers|{.cut|9||{.substring|Version| |{.^uagent.}.}.}.}:}|
Konqueror       |{:{.set|brvers|{.cut|11||{.substring|{.^browsername.}|;|{.^uagent.}.}.}.}:}|
default:|
.}
{.for each|tt|iphone|ipod|Android|Symbian|IEMobile|Elinks|Googlebot|Yahoo|
{:{.if not|{.^browserext.}|{:{.if|{.pos|{.^tt.}|{.^uagent.}.}|{:{.set|browserext|{.^tt.}.}:}.}:}.}:}.}
{.^browserext.}

then the macro {.get browser.} give the distant browsername or nothing if unknow ;)


Offline bacter

  • Operator
  • Tireless poster
  • *****
    • Posts: 681
    • View Profile
I don't know if it would be interesting to include such aliases for two reasons:

1) the actual list of browsers isn't very complete, so we would have to update that definitions from time to time.

2) This aliases are called very few times, as in a well written template you only need this information when a user establishes his first connection - after you save the interesting value for the browser in a #global-user-style variable or in a cookie.

So we can keep this things more flexible, including this macros when needed with a {.load.} in special:begin.

In my case i only use this macro only for statistical purposes, and to distinguish IE from the rest of browsers, - not to support IE , but to give the users the advice that they should use a browser that complies with the standards and with IE the template does not work as expected. And to distinguish if its a mobile device: there information is presented in a more 'spartanic' matter through the template.

your computer has no brain - use your own !


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
i'm a bit late on this :)
we have already the {.get|agent.}
we may just improve his detection system, if it's not enough.