Class JsonVCard
jsonvcard.js:34
This class doesn't do anything, it is here just to force YuiDoc generating the documentation
Constructor
JsonVCard
()
Methods
- addStyleSheet static
- cookTemplate static
- getFunctions static
- getVariables static
- process static
- process_date static
- process_mark static
- process_social static
- processArray static
- processData static
- processFiles static
- processJSON static
- processObject static
- processTheme static
- readFile static
- setRelativePath static
- setStyleName static
- setStyleName static
- setThemeName static
- setThemesPath static
Methods
addStyleSheet
-
url
Link a stylsheet to the current document
Parameters:
-
url
Stringthe URL of the tageted CSS
cookTemplate
-
data
-
template
This function is used to initiate the process of binding the data with the template
getFunctions
-
template
Get all the function defined in the template
Parameters:
-
template
type[description]
Returns:
[description]
getVariables
-
template
Save all template defined variables in a global variable called vars
Parameters:
-
template
Stringthe HTML template used to create the final HTML code
Returns:
the HTML template after deliting variables
process
-
jsonURL
Initialization of process; this method searches for "vcard.json" in the javascript location "jsonvcard.js". Then when retrieved, it sends its content as a string to process(json) Where it will be processed
Parameters:
-
jsonURL
StringThe location of json file
process_date
-
date
-
template
-
marker
-
pattern
-
months
Special function (date) to process dates. You can define a function in template.htm like this:
Parameters:
-
date
Stringthe date in the format "yyyymmdd", "yyyymm" or "yyyy"
-
template
Stringthe HTML template to be replaced
-
marker
Stringthe marker which will be replaced in the template
-
pattern
Stringthe pattern using the words "yyyy", "yy", "mm", "dd". The pattern uses also "<...>" which specifies the content which will be erased if there is no days and "[]" which specifies the content related to month "mm[ dd<, >]yyyy"
-
months
Arrayarray of 12 strings containing months names. If this is given, the "mm" will be replaced with the equivalent month name in the array
Returns:
the HTML content after replacement
process_mark
-
value
-
template
-
marker
-
type
Special function (mark) to process percentages. You can define a function in template.htm like this:
Parameters:
Returns:
the HTML content after replacement
processArray
-
key
-
data
-
template
Process the data of an array. It recovers the begining and ending of this array in the template. Then, it pushes each element of the array into that area.
Parameters:
Returns:
the HTML content after merging with the data
processData
-
key
-
value
-
template
Process the data of an object. It detects if the data is an object, a list of elements or a simple element
Parameters:
-
key
Stringthe name or key of the element; for example "perso.name"
-
value
Objectthe value of the data: it may be an object, a list, or a simple element. In our example, it is a simple string: "Karim"
-
template
Stringthe HTML template used to push the data
Returns:
the HTML content after merging with the data
processFiles
()
private
static
Process the files stored in a global variable (files) while processing the json data and the template
processJSON
-
json
This method parses the json content
Parameters:
-
json
StringThe content of JSON file
processObject
-
key
-
data
-
template
Process an object which contains many elements in it
Parameters:
Returns:
the HTML content after merging with the data
processTheme
()
String
private
static
Process a theme element (json) which has a name and a style
Returns:
path to the template constructed from the theme name, or the dafault one
readFile
-
marker
-
url
Read a file and push the content into its reserved area in the template.
Here, the content is pushed into a global variable containing the template.
We can't use the template as an argument, nor return the merged html, because
the files call is asynchronious.
A mutex is used so the html code is pushed into the browser once all the
files are being processed
setRelativePath
-
path
Specifies the relative path of the files called in json file
Parameters:
-
path
Stringthe path
setStyleName
-
name
Specifies the style name (the css) and load it
Parameters:
-
name
Stringthe style's name
setStyleName
-
name
Specifies the style name (the css)
Parameters:
-
name
Stringthe style's name
Returns:
this object
setThemeName
-
name
Specifies the theme name
Parameters:
-
name
Stringthe theme's name
setThemesPath
-
path
specifies the themes path, in case the themes are not beside the html file
Parameters:
-
path
Stringthe path