Javascript API documentation?

I checked out XWiki Javascript API: https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/FrontendResources/JavaScriptAPI/

But it contains very little explanation. Is there a full Javascript API docs?

I’d like to do from the front-end many things: get XWiki objects on some or all pages, remove XWiki objects, add objects, add wiki pages, get wiki pages, edit wiki pages, remove wiki pages and other things that I can’t remember atm.

Are there javascript gateway objects and/or backend XWiki end points to do this? Something like objectsgateway.js with a respective object that I can use to operate on objects on the page, something like: ObjectsGateway.AddObject('MyPage.WebHome', MyXClass, MyObject);.

In the tutorials: https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Tutorials/Add%20Remove%20Objects%20Inline%20Tutorial

I found that sometimes it does: $doc.getURL('objectremove' and $doc.getURL('edit'. Are those wiki pages? When I go to page index in my XWiki, it can’t find those pages. In the tutorials it just inlines a bunch of stuff in the url: <a href="$doc.getURL('objectremove', "form_token=$!{services.csrf.token}&amp;classname=${escapetool.url($class)}&amp;classid=${obj.number}&amp;xredirect=${escapetool.url($doc.getURL('edit'))}")" class="xobject-action delete" title="$services.localization.render('core.editors.object.removeObject.tooltip')">$services.localization.render('core.editors.object.removeObject')</a>.
This isn’t readable and I can’t understand any of it. The only thing that comes to mind is “What?”

Then in those tutorials I found editableproperty.js and dataeditors.js and other javascript files. Where can I find them to read the code to see how they work: add, remove and edit objects? I mean find and open actual projects how they were written: so I can open project in IntelliJ IDEA and jump through code, not just open compiled .js files in shipped XWiki.

I’m trying to understand how things work and how to write things but I’m having problems finding my way around in XWiki docs and it seems that Javascript docs are missing but then how do I figure out how to do things that I want to do?

Indeed, we’ve not been very good at documenting our javascript apis, especially in older times…

When you don’t find any JS API for doing something, you always have the possibility of creating a wiki page to perform the business logic and then calling it from javascript to get the results. See https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Scripting/ for writing scripts in wiki pages.

This is server-side scripting, not front end javascript.

These are java api called from inside velocity scripts located in wiki pages (or in templates).

The source code of XWiki is available at https://dev.xwiki.org/xwiki/bin/view/Community/SourceRepository (Hint: you can search for files at GitHub - xwiki/xwiki-platform: The XWiki platform ).

For example editableproperty.js is at: xwiki-platform/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-war/src/main/webapp/resources/uicomponents/edit/editableProperty.js at master · xwiki/xwiki-platform · GitHub

1 Like