This Forum has been archived

Visit the new Forums
Forums: Index Support Requests Preloading pages and adding elements to the right rail (RTE, javascript)
Fandom's forums are a place for the community to help other members.
To contact staff directly or to report bugs, please use Special:Contact.

50px-Replacement filing cabinet.svg

Note: This topic has been unedited for 1989 days. It is considered archived - the discussion is over. Do not add to unless it really needs a response.

I'm trying to write a preloader in Javascript which will fill the editor field with content specific to the type of page a user wants to create. The content is stored in wiki pages, read via an ajax call, and input into the editor. To aid in selecting the pre-defined page templates I want to add a box to the right rail, similar to the way "templates" or "categories" modules do (but via JS). Once I get the basic functionality going I'll add configurable parameters to the script for users to choose the number of page templates, locations of the templates, change language, icons, etc.

The current code is here. The file is imported from my userspace wikia.js. As it stands, I have no problems retrieving the contents of a wiki page (for now a sandbox page in my userspace) and parsing them to get the part I want. I also have the ready-to-insert html for the side box (a rapid prototype for testing so it's all in an ugly, long, html string), to be prettified later (custom icons, etc).

My two problems are as follows:

  1. I am able to populate the editor window, but only in RTE source mode, or when RTE is disabled. For now I'm using the inspection tools found in Chrome (not my personal machine, can't install FF with Firebug), and the visual RTE window has this structure. There seems to be an embedded html document within the editor iframe, and I have no idea how to access the body of that page using jQuery in order to replace the contents.
  2. I'm also having problems displaying the box on page load. The html is correct and the javascript works, as I can manually call the same line of code:
$('div#EditPageRail div.module.module_templates').after(prePane);

to add the box to the rail. Yet this does not happen when the script runs on page load. prePane is the variable that holds the html string for the box.

I would be grateful for any assistance with solving the two problems.

On a side note, could anyone recommend a guide/sample code to cannibalize/etc that shows how to write wikia modules that add boxes to the right rail? Source of the Templates module would be nice, don't know where to look for it. After I finish the JS version I was thinking about writing a proper wikia module/extension that does the same job and is easily configurable via special pages. I know where to look for info about page preloading and parsing wikia pages, but adding elements to the right rail is one thing I could not find examples of.

-- Gyumaou (Talk) 21:19, May 8, 2012 (UTC)

Preload is built into MediaWiki, if you add &preload=PAGENAME to the end of the URL, it will preload that page's content into the page -- RandomTime 21:21, May 8, 2012 (UTC)
Now that you mention it, I do recall hearing about it. I suppose I wanted to make something that didn't require refreshing the page (as this might evolve to provide ready-made snippets of code that can be inserted into editor. not requiring a page-refresh would allow users to use such functionality while modifying the existing content). In the worst case I could rely on the preload action. Still, I only need to figure out the visual editor, and there's the problem of adding the box to the rail on page load. Regardless of how preload is done I'd like to offer users a panel of templates that they can choose from. -- Gyumaou (Talk) 22:03, May 8, 2012 (UTC)