Detect When on Mobile

153 views
Skip to first unread message

Tony Grosinger

unread,
Jan 22, 2017, 8:03:20 PM1/22/17
to TiddlyWiki

I am trying to create a tiddler which has different content depending on whether on mobile or not. This will be used to alter configuration options.

I noticed that from the console I can view the user agent in navigator.userAgent. Is there any way I can access this information from a macro or widget?

Danielo Rodríguez

unread,
Jan 22, 2017, 8:36:39 PM1/22/17
to TiddlyWiki
Can't you just do the same ?

Jeremy Ruston

unread,
Jan 22, 2017, 8:40:24 PM1/22/17
to tiddl...@googlegroups.com
Search for $:/info on tiddlywiki.com

Best wishes

Jeremy

--
Jeremy Ruston


> On 22 Jan 2017, at 18:36, Danielo Rodríguez <rdan...@gmail.com> wrote:
>
> Can't you just do the same ?
>
> --
> You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
> To post to this group, send email to tiddl...@googlegroups.com.
> Visit this group at https://groups.google.com/group/tiddlywiki.
> To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/ac7bfcc5-1402-4413-bb09-03c63ad1b5b3%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Tony Grosinger

unread,
Jan 22, 2017, 9:19:11 PM1/22/17
to TiddlyWiki
Wow, perfect. Thank you.

Tony Grosinger

unread,
Jan 22, 2017, 11:40:13 PM1/22/17
to tiddl...@googlegroups.com

I have created this snippet which I intended to use for the body of $:/config/EditorTypeMappings/text/vnd.tiddlywiki

<$reveal type="match" state="$:/info/browser/is/android" text="yes">
text
</$reveal>
<$reveal type="nomatch" state="$:/info/browser/is/android" text="yes">
codemirror
</$reveal>

Unfortunately this does not work. The value of the tiddler is exactly correct when you view it normally, but it seems when it is used to actually determine which editor to use it does not actually render the contents first. (I guess the $view widget doesn’t do that by default). Is there another way to accomplish this? I feel like it’s really close, just missing some trick I don’t know about.

Thank you.

Tony Grosinger

unread,
Jan 24, 2017, 10:23:26 AM1/24/17
to TiddlyWiki
I have a feeling the problem I am running into has something to do with this function:


But I am having trouble getting that function to be executed and hit my breakpoint in Chrome developer tools. Developing...

Jeremy Ruston

unread,
Jan 24, 2017, 10:32:21 AM1/24/17
to tiddl...@googlegroups.com
Hi Tony

As you have discovered, tiddlers are only wikified for rendering, and not when their values are used in settings such as configuration. That's why you can't use the list widget within $:/DefaultTiddlers, for instance.

As things stand, I think you'd need a little JS startup module to switch the editor according to the platform. Having said that, the need to disable codemirror on mobile is a widespread problem, and so I wouldn't be averse to fixing it in the core.

Best wishes

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.

Tony Grosinger

unread,
Jan 24, 2017, 11:27:22 AM1/24/17
to TiddlyWiki
Thank you Jeremy. I have moved this question to a Github issue since it seems more like a development task now than a user-configurable option.

Tobias Beer

unread,
Jan 24, 2017, 1:15:03 PM1/24/17
to TiddlyWiki
Hi Tony,

You can use tobibeer/sysinfo
to probe the kind of environment you're in.

Best wishes,

Tobias.
Reply all
Reply to author
Forward
0 new messages