Embedding of writeurl
The writeurl editor can be embedded in other web pages through a set of functions.
<link rel="stylesheet" href="http://www.writeurl.com/style.css" type="text/css">
The most general function is
nbe.site.embed(el_text, el_title, el_panel, ids, new_doc, ws_url, local_storage, html_title, callback)
The arguments are
el_text : a dom element where the text of the editor should be inserted.
el_title : a dom element for the title.
el_panel : a dom element for the formatting panel.
The elements can be null in which case there will be no insertion.
ids : an object with keys 'id', 'read', 'write'. The values are strings of characters [a-z0-9]. If write is null, the editor is a read only editor.
new_doc : a boolean that designates whether the document with the ids is new or not. If it is not new, a document with these ids must exist on the server.
ws_url : the url for the web socket. The writeurl server uses 'ws://www.writeurl.com:8043'.
local_storage : a boolean that contrls the use of local storage to store the document.
html_title : a boolean that tells whether the title of the document should be the title of the entire html page.
callback(key, value) : a function that is called at certain events.
The important keys are :
nunsaved : the value is the number of unsaved operations. The important point is whether the value is zero or not.
network : The value connected means that there is a connection to the server. Anythng else that there is no connection.
There are three helper functions
nbe.site.embed_write(el, ids) : This function displays an editable document with ids that already exist.
nbe.site.embed_read(el, ids) : This function displays a read only version of the document.
nbe.site.embed_new(el) : This function creates a new document, displays it like embed_write and returns the ids.
The arguments are ids, which are like above, and el which is ether an element or an id of an element.