1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
MORLA's JAVASCRIPT
~~~~~~~~~~~~~~~~~~
Functions
~~~~~~~~~
The Javascript code for the functionInit, functionCheck, functionDestroy and
functionSave is able to use these internal functions:
- morla_alert(something) - it shows a popup and returns NULL.
ex: morla_alert("test 1");
- morla_confirm(something) - it asks something to the user and returns 1 if it
has choosed "OK", otherwise 0.
ex: if(morla_confirm("Do you like morla?"))
morla_alert("Cool!");
else
morla_alert("Doh...");
- morla_get_value() - it returns an array. This is an example:
ex: var what=morla_get_value();
var text="The value is: " + what[MORLA_VALUE] +
"\nThe lang is: " + what[MORLA_LANGUAGE] +
"\nThe datatype is: " + what[MORLA_DATATYPE] +
"\nThe type is: ";
switch(what[MORLA_TYPE]) {
case MORLA_RDF_RESOURCE: text+="Resource"; break;
case MORLA_RDF_LITERAL: text+="Language"; break;
case MORLA_RDF_BLANKNODE: text+="Bnode"; break;
default: text+="Unknown"; break;
}
morla_alert(text);
- morla_set_value(array) - it sets the values into the current input.
ex: morla_set_value(["value", "lang", "datatype", MORLA_RDF_LITERAL]);
- morla_version() - it returns the morla version as a string.
Global Variables
~~~~~~~~~~~~~~~~
There are these variables:
- MORLA_OK -> 0
- MORLA_FAILURE -> 1
- MORLA_VALUE -> 0
- MORLA_LANGUAGE -> 1
- MORLA_DATATYPE -> 2
- MORLA_TYPE -> 3
- MORLA_RDF_BLANKNODE -> 0
- MORLA_RDF_LITERAL -> 1
- MORLA_RDF_RESOURCE -> 2
Morla must return a morla_status=0 if every thing is fine. If it is not, the
template does't show messages so the javascript code must do it.
functionInit
~~~~~~~~~~~~
The functioInit must be a Javascript that contains the init procedure. You can
manage the inputs and the single elements of it. For example you can set a
default value or creates variables for the next functions. It is not important
the morla_status flag.
functionDestroy
~~~~~~~~~~~~~~~
This function is executed when the object is destroied. It is really useless
but maybe you can show popup, messages, or other info when the template will
be closed. The morla_status is not important.
functionCheck
~~~~~~~~~~~~~
You can use this function if you want check the value of the input. The
important info about this function is the check: the morla_status must be 0
and it means "no error about this input". If the morla_status contains other
values (1, -1, what you want) the checking procedure will be stopped.
The checking procedure runs before saving the data so if you stop this
procedure with a functionCheck returing a morla_status to 1, the template
doesn't save the data.
An important stuff is the message. This function must show the reason of
the error with a morla_alert of something like that.
functionSave
~~~~~~~~~~~~
This function is the latest function before saving. If you want change the
value of the current input you must use morla_set_value here. The morla_status
variable is not important here.
Questions, contacts
~~~~~~~~~~~~~~~~~~~
Write me: bakunin@morlardf.net
|