Hi!

I just tried to write my first plugin/macro for tiddlywiki and I'm not 
sure, whether I did it right. Maybe someone can take a look and suggest 
corrections?

The macro is used like this: <<LyncPhoneNumber +4971150885524>> and will 
display the Number, followed by a Phone Symbol (\u260e) as a link. When 
clicked, it will set the source of a hidden iFrame to "tel:" + phonenumber. 
If you configured your browser to open Microsoft's Lync with these kind of 
links, it will popup allowing you to call the number.

Here is the source:

/***
|''Name:''|LyncPhoneNumber|
|''Description:''|To link a phone number to Lync|
|''Version:''|0.1|
|''Date:''|2013-03-14|
|''Source:''|http://www.tiddlywiki.com/#NOWHEREYET|
|''Author:''|Stephan Hradek tiddly(dot)wiki(dot)hradek(at)xoxy(dot)net|
|''License:''|[[BSD open source license]]|
|''~CoreVersion:''|2.7.1|
***/
//{{{
// my first macro
{ // new scope
    var LPN= {};
    config.macros.LyncPhoneNumber= LPN;

    var iFr= document.createElement('iframe');
    iFr.style.display= 'none';
    iFr.name= 'LyncPhoneNumberFrame';
    document.getElementsByTagName('body')[0].appendChild(iFr);

    LPN.MakeCall = function () {
        iFr.src="tel:"+this.text.substr(0,this.text.length-2);
    }

    LPN.handler = function 
(place,macroName,params,wikifier,paramString,tiddler){ 
        // this will run when macro is called from a tiddler
        var phoneNo = params.length > 0 ? params[0] : "n/a";
        var phone= createTiddlyElement(place, "a", null, null, phoneNo+" 
\u260e");
        phone.onclick= config.macros.LyncPhoneNumber.MakeCall;
    }
}
//}}}

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" 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/tiddlywikidev?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to