Hi Riaz,
Unfortunately, SkinExtensions alone will not help you here, because it
looks like you also need to fetch a script from an external location,
which is not currently supported in XWiki via SkinExtensions for
security reasons.
As far as I can see, you have 2 options:
1. The "cleaner" one:
- Modify the javascript.vm template by adding the line:
<script type="text/javascript"
src="https://www.google.com/jsapi?key=INSERT-YOUR-KEY"></sc…
You can do this either on the filesystem or by overriding this
template in a custom skin. See
http://platform.xwiki.org/xwiki/bin/view/DevGuide/Skins for details.
- Place the code you pasted in your email in a JavaScriptExtension
object as explained in the SkinExtensions tutorial, and pull this
extension in the page where you wish to see the results.
2. The "faster" (but less elegant) one:
- Create a wiki page, and add an html macro (either from the WYSIWYG
menu called "Macros" or by writing
{{html}}
<!-- your content here -->
{{/html}}
in the wiki editor.
The macro content should be the following:
<script type="text/javascript"
src="https://www.google.com/jsapi?key=INSERT-YOUR-KEY"></sc…
<script type="text/javascript">
// Add the js code from your email here
</script>
I hope this helps,
Marta
On Thu, Nov 3, 2011 at 6:29 AM, Riaz <riaz_shafi(a)hotmail.com> wrote:
Hi,
I had no luck on the users group, so I thought I would try my luck on the
devs group.
I would like to add the javascript below to my xwiki page.
Is this something that can easily be done?
If so please can you show me an example.
Thanks
Riaz
google.load('visualization', '1',
{'packages':['table']});
function changeData(scorer) {
var whereClause = "";
if(scorer) {
whereClause = " WHERE 'Scoring Team' = '" + scorer +
"'";
}
var queryText = encodeURIComponent("SELECT 'Scoring Team', 'Receiving
Team', 'Minute of goal' FROM 197026" + whereClause);
var query = new
google.visualization.Query('http://www.google.com/fusiontables/gvizdata…
+ queryText);
query.send(getData);
}
function getData(response) {
var table = new
google.visualization.Table(document.getElementById('visualization'));
table.draw(response.getDataTable(), {showRowNumber: true});
See this for more info:
http://gmaps-samples.googlecode.com/svn/trunk/fusiontables/gviz_datatable.ht
ml
-----Original Message-----
From: users-bounces(a)xwiki.org [mailto:users-bounces@xwiki.org] On Behalf Of
Riaz
Sent: 28 October 2011 10:35
To: users(a)xwiki.org
Subject: [xwiki-users] JavaScript example
Hi,
I'm new to XWiki, and I would like some help on how to add JavaScript to my
pages.
I have looked at the example SkinExtensionsTutorial and can now do basic
JavaScript for example:
alert ("HelloWorld"); via the JavaScriptExtension.
I would like to add Google fusion tables to my Xwiki page an example of what
I am after is below with the JavaScript:
http://gmaps-samples.googlecode.com/svn/trunk/fusiontables/gviz_datatable.ht
ml
The JavaScript is shown below:
google.load('visualization', '1',
{'packages':['table']});
function changeData(scorer) {
var whereClause = "";
if(scorer) {
whereClause = " WHERE 'Scoring Team' = '" + scorer +
"'";
}
var queryText = encodeURIComponent("SELECT 'Scoring Team', 'Receiving
Team', 'Minute of goal' FROM 197026" + whereClause);
var query = new
google.visualization.Query('http://www.google.com/fusiontables/gvizdata…
+ queryText);
query.send(getData);
}
function getData(response) {
var table = new
google.visualization.Table(document.getElementById('visualization'));
table.draw(response.getDataTable(), {showRowNumber: true});
How can I add this information to my Xwiki page.
Your help is much appreciated.
Best Regards,
Riaz
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs