Hi mat,
here's a macro for that

/*\
title: $:/macros/buggyj/misc/location.js
type: application/javascript
module-type: macro

<<location field>>
use:
<<location "show">> to see the all the fields
then 
<<location "href">> for url

\*/
(function(){

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";


exports.name = "location";

exports.params = [
        { name: "field" }
];
/*
Run the macro
*/

exports.run = function(field) {
if (field === "show") {
        alert (JSON.stringify(window.location));
}else try {
                return window.location[field].toString();
        } catch(e){}
}


})();

cheers

bj



On Tuesday, August 18, 2015 at 2:01:37 PM UTC+1, Mat wrote:
>
> How can I sense "where" the current TW file is located? I.e what's in the 
> browser url address field.
>
> Is there a <<url>> or <<path>> macro or something similar? Seems like a 
> rather basic issue so I'm surprised I can't recall it being discussed and, 
> AFAICT, we have the components for it with the permalink and permaview 
> mechanisms.
>
> This would be useful in filters to decide if a file is local or on a 
> server. I came to think of the question when realizing that the 
> GettingStarted tiddler for a freshly created tiddlyspot TW5 of course(!) 
> ought to display the tiddlyspot saving fields.
>
> <:-)
>
>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/b816c9ca-baab-4384-a5b9-6bdf0a73110e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to