QScript HtmlBuilder
HtmlBuilder
append(content, style)
content | Plain text. HTML tags not supported. |
style | An optional style dictionary (see setStyle()) to override formatting for this text. |
Example: | var html = Q.htmlBuilder();
html.append('The highest rating brand was ');
html.append('Coca-Cola', { color: 'red' });
html.append('.');
|
appendBulletted(items, style)
items | An array of strings. Plain text. |
style | An optional style dictionary (see setStyle()) to override formatting for this list. |
Example: | var html = Q.htmlBuilder();
html.appendBulletted(['Coke tastes great', 'Diet drinks becoming more popular']);
|
appendParagraph(paragraph_text, style)
Appends a paragraph containing text to the end of the HTML fragment. The difference between append() and appendParagraph() is that this will leave a blank line after the text.
You may call this without any text to append a new blank line. For example, html.appendParagraph()
paragraph_text | Plain text. HTML tags not supported. |
style | An optional style dictionary (see setStyle()) to override formatting for this text. |
Example: | var html = Q.htmlBuilder();
html.appendParagraph('Most interesting results in the survey:');
|
appendTable(table, column_widths, row_separator, style)
table | The 2D array of text to show on the table. |
column_widths | An optional array of numbers. Each number represents the size of each column (in characters), after which the text will wrap onto a new line. |
row_separator | An optional string which can be used to separate rows in the table. If not null, this text will be repeated on a new line between each row. |
style | An optional style dictionary (see setStyle()) to override formatting for this table. |
Example: | var html = Q.htmlBuilder();
html.appendTable([
['Brand', 'NPS score'],
['Coke', '30'],
['Diet Coke', '40']
]);
html.appendTable([
['Brand', 'NPS score'],
['Coke', '30'],
['Diet Coke', '40'],
['This drink gives you wings', '10']
], [15, 10], '-', { size: 8 });
|
equals(obj)
obj | The object to compare against. |
Returns: | true or false |
Example: | data_file.getQuestionByName('Q2').equals(data_file.questions()[0])
|
htmlFragment
setStyle(style)
style | A dictionary of formatting properties and their values: font: string, name of a font. The font must be installed on your system to appear in exports (print, PDF, PowerPoint, etc.). Only the following fonts are safe to use if this text item is to appear on a web dashboard: Andale Mono, Arial, Arial Black, Century Gothic, Comic Sans MS, Courier New, Georgia, Impact, Times New Roman, Trebuchet MS, Verdana. size: number, font size in points. color: See JavaScript Color Table. bold: true or false. Whether text should be bold. italic: true or false. Whether text should be italicized. underline: true or false. Whether text should be underlined. |
Example: | var html = Q.htmlBuilder();
html.setStyle({ font: 'Times New Roman', size: 10, color: 'blue' });
html.appendParagraph('Small blue text.');
html.appendParagraph('More blue text.');
// leaving color out will make it reset to default (black)
html.setStyle({ font: 'Arial', size: 14, bold: true });
html.appendParagraph('Larger black bold text.');
|