add optional id parameter; make extension working in templates

as proposed in
https://www.mediawiki.org/w/index.php?title=Extension_talk:AJAXPoll&dir=prev&offset=20130129204525&limit=20&lqt_mustshow=31153#Does_not_work_properly_within_templates_31145 and
https://www.mediawiki.org/w/index.php?title=Extension_talk:AJAXPoll&dir=prev&offset=20130129204525&limit=20&lqt_mustshow=31153#adding_an_id_parameter_would_be_helpful_31153

Change-Id: I5e633c1e76cbef9e78a5b1225794e11492b44c3c