Table almos there

This commit is contained in:
Luis Fernando Molina committed 2020-12-14 18:42:26 +01:00
1 parent 4f0010b534
commit 32b5260283
8 files changed
+170 -207

No files matched your search

+1
View File
@@ -120,6 +120,7 @@
<li class="menu-item" onClick="window.contextMenu.toList()">List Style</li>
<li class="menu-item" onClick="window.contextMenu.toJavascript()">JS Code Style</li>
<li class="menu-item" onClick="window.contextMenu.toJson()">JSON Code Style</li>
<li class="menu-item" onClick="window.contextMenu.toTable()">Table Style</li>
</ul>
</body>
@@ -1,4 +1,3 @@
{
"type": "Data Tasks",
"definition": "This is the definition of Data Tasks"
"type": "Data Tasks"
}
@@ -1,6 +1,6 @@
{
"type": "Dataset Definition",
"definition": "A dataset definition contains a configuration file that defines many aspects of the dataset. There are two types of dataset definitions: Multi-Period-Market and Multi-Period-Daily.",
"definition": "A data set is a collection of files stored in the designated location, as per the definitions on the referenced data product in the corresponding data mine.",
"paragraphs": [
{
"style": "Title",
@@ -8,151 +8,15 @@
},
{
"style": "Text",
"text": "In the context of a trading system, formulas are used to determine the values for several properties, such as the target rate, target size, managed stop loss, managed take profit, and so on."
"text": "In the context of the trading engine, formulas are used to create user defined statistics."
},
{
"style": "Text",
"text": "Formulas may use indicators and trading engine properties. The main difference between writing a formula and writing a condition is that while conditions must evaluate to true or false, formulas must evaluate to a number."
},
{
"style": "Text",
"text": "A simple math example:"
},
{
"style": "Text",
"text": "This simple formula may be used to define an initial take profit target 3% above the rate at which the position was taken."
},
{
"style": "Text",
"text": "tradingEngine.current.position.entryTargetRate.value * 1.03"
"text": "Formulas may use indicators and object properties made available by the trading engine. They must evaluate to a number."
},
{
"style": "Note",
"text": "You may use any variable made available by the trading engine, as explained on the accessing runtime data page."
},
{
"style": "Text",
"text": "A simple JavaScript example:"
},
{
"style": "Text",
"text": "A bit of very basic JavaScript, introducing conditional statements, allows more intelligence. For example, in this case, we ask if the proposed formula results in a number greater than the current stop loss value; if it does, then the proposed formula is used; if not, then the current stop loss value is left as is."
},
{
"style": "Text",
"text": "This is&mdash;basically&mdash;a trailing stop loss 2% below the moving average that may go higher if the moving average goes up, but it may never come down&mdash;thanks to the use of the IF ELSE clause."
},
{
"style": "Text",
"text": "if (chart.at01hs.bollingerBand.movingAverage * 0.98 > tradingEngine.current.position.stopLoss.value)"
},
{
"style": "Text",
"text": " {chart.at01hs.bollingerBand.movingAverage * 0.98}"
},
{
"style": "Text",
"text": " else"
},
{
"style": "Text",
"text": " {tradingEngine.current.position.stopLoss.value}"
},
{
"style": "Text",
"text": "For developers:"
},
{
"style": "Text",
"text": "To build more complex logic within a formula, create a function that implements the logic and returns a numerical value, and then call the function:"
},
{
"style": "Text",
"text": "function orderRate() {"
},
{
"style": "Text",
"text": " const ORDER_STEP_NUMBER = 1 // Secuential step number, starting with 1 from the closest to the price."
},
{
"style": "Text",
"text": " const BUY_SELL_SIGN = -1 // 1 for buy orders, -1 for sell orders."
},
{
"style": "Text",
"text": " const STEP_SEPARATION = 0.15 // % of separation of stair steps between them."
},
{
"style": "Text",
"text": " const BASE_FACTOR = 0.2 // % above or below bollinger band without bias."
},
{
"style": "Text",
"text": " const BIAS_FACTOR = 0.3 // % to move the whole stair of orders up or down depending on the bias."
},
{
"style": "Text",
"text": " const BAND_RATE = chart.at01min.bollingerBand.lowerBand // Upper Bollinger Band for sell orders, and Lower for buy orders."
},
{
"style": "Text",
"text": " let inbalance = tradingEngine.current.episode.episodeBaseAsset.beginBalance.value - tradingEngine.current.episode.episodeBaseAsset.balance.value"
},
{
"style": "Text",
"text": " let BIAS_SIGN"
},
{
"style": "Text",
"text": " if (inbalance === 0) {"
},
{
"style": "Text",
"text": " BIAS_SIGN = 0"
},
{
"style": "Text",
"text": " }"
},
{
"style": "Text",
"text": " if (inbalance < 0) {"
},
{
"style": "Text",
"text": " BIAS_SIGN = + 1"
},
{
"style": "Text",
"text": " }"
},
{
"style": "Text",
"text": " if (inbalance > 0) {"
},
{
"style": "Text",
"text": " BIAS_SIGN = - 1"
},
{
"style": "Text",
"text": " }"
},
{
"style": "Text",
"text": " let rate = BAND_RATE + BUY_SELL_SIGN BAND_RATE (BASE_FACTOR + ORDER_STEP_NUMBER STEP_SEPARATION + BIAS_SIGN BIAS_FACTOR) / 100"
},
{
"style": "Text",
"text": " return rate"
},
{
"style": "Text",
"text": "}"
},
{
"style": "Text",
"text": "orderRate()"
"text": "To learn how to write formulas, see syntax overview."
},
{
"style": "Title",
@@ -160,7 +24,7 @@
},
{
"style": "Text",
"text": "To add a formula, select Add Formula on the corresponding parent node menu."
"text": "To add the formula node, select Add Missing Items on the parent node menu."
}
]
}
@@ -68,39 +68,39 @@
},
{
"style": "Text",
"text": "<table class=\"docs-table\"><tr><td> Value </td><td> Image</td></tr>"
"text": "| Value | Image|"
},
{
"style": "Text",
"text": "<tr><td> :---: </td><td> :---: </td></tr>"
"text": "| :---: | :---: |"
},
{
"style": "Text",
"text": "<tr><td> default </td><td> <img src=\"Projects/Superalgos/Icons/default-banner.png\"></img> </td></tr>"
"text": "| default | <img src=\"Projects/Superalgos/Icons/default-banner.png\"></img> |"
},
{
"style": "Text",
"text": "<tr><td> histogram </td><td> <img src=\"Projects/Superalgos/Icons/histogram-banner.png\"></img> </td></tr>"
"text": "| histogram | <img src=\"Projects/Superalgos/Icons/histogram-banner.png\"></img> |"
},
{
"style": "Text",
"text": "<tr><td> band </td><td> <img src=\"Projects/Superalgos/Icons/bands-banner.png\"></img> </td></tr>"
"text": "| band | <img src=\"Projects/Superalgos/Icons/bands-banner.png\"></img> |"
},
{
"style": "Text",
"text": "<tr><td> moving-average </td><td> <img src=\"Projects/Superalgos/Icons/moving-average-banner.png\"></img> </td></tr>"
"text": "| moving-average | <img src=\"Projects/Superalgos/Icons/moving-average-banner.png\"></img> |"
},
{
"style": "Text",
"text": "<tr><td> oscillator </td><td> <img src=\"Projects/Superalgos/Icons/oscillator-banner.png\"></img> </td></tr>"
"text": "| oscillator | <img src=\"Projects/Superalgos/Icons/oscillator-banner.png\"></img> |"
},
{
"style": "Text",
"text": "<tr><td> trend </td><td> <img src=\"Projects/Superalgos/Icons/trends-banner.png\"></img> </td></tr>"
"text": "| trend | <img src=\"Projects/Superalgos/Icons/trends-banner.png\"></img> |"
},
{
"style": "Text",
"text": "</table>Custom images may be added too. To do that:"
"text": "Custom images may be added too. To do that:"
},
{
"style": "Text",
@@ -128,75 +128,75 @@
},
{
"style": "Text",
"text": "<table class=\"docs-table\"><tr><td> Variable Value </td><td> RGB Value </td><td> Color Sample </td></tr>"
"text": "| Variable Value | RGB Value | Color Sample |"
},
{
"style": "Text",
"text": "<tr><td> :--- </td><td> :---: </td><td> :------------------- </td></tr>"
"text": "| :--- | :---: | :------------------- |"
},
{
"style": "Text",
"text": "<tr><td> DARK </td><td> 48, 48, 54 </td><td> <span style=\"display: block; background: RGB(48, 48, 54); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| DARK | 48, 48, 54 | <span style=\"display: block; background: RGB(48, 48, 54); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> LIGHT </td><td> 234, 226, 222 </td><td> <span style=\"display: block; background: RGB(234, 226, 222); border: 1px black; border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| LIGHT | 234, 226, 222 | <span style=\"display: block; background: RGB(234, 226, 222); border: 1px black; border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> GREY </td><td> 150, 150, 150 </td><td> <span style=\"display: block; background: RGB(150, 150, 150); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| GREY | 150, 150, 150 | <span style=\"display: block; background: RGB(150, 150, 150); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> LIGHT_GREY </td><td> 247, 247, 247 </td><td> <span style=\"display: block; background: RGB(247, 247, 247); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| LIGHT_GREY | 247, 247, 247 | <span style=\"display: block; background: RGB(247, 247, 247); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> WHITE </td><td> 255, 255, 255 </td><td> <span style=\"display: block; background: RGB(255, 255, 255); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| WHITE | 255, 255, 255 | <span style=\"display: block; background: RGB(255, 255, 255); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> BLACK </td><td> 0, 0, 0 </td><td> <span style=\"display: block; background: RGB(0, 0, 0); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| BLACK | 0, 0, 0 | <span style=\"display: block; background: RGB(0, 0, 0); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> GOLDEN_ORANGE </td><td> 240, 162, 2 </td><td> <span style=\"display: block; background: RGB(240, 162, 2); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| GOLDEN_ORANGE | 240, 162, 2 | <span style=\"display: block; background: RGB(240, 162, 2); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> RUSTED_RED </td><td> 204, 88, 53 </td><td> <span style=\"display: block; background: RGB(204, 88, 53); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| RUSTED_RED | 204, 88, 53 | <span style=\"display: block; background: RGB(204, 88, 53); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> GREEN </td><td> 188, 214, 67 </td><td> <span style=\"display: block; background: RGB(188, 214, 67); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| GREEN | 188, 214, 67 | <span style=\"display: block; background: RGB(188, 214, 67); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> RED </td><td> 223, 70, 60 </td><td> <span style=\"display: block; background: RGB(223, 70, 60); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| RED | 223, 70, 60 | <span style=\"display: block; background: RGB(223, 70, 60); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> PATINATED_TURQUOISE </td><td> 27, 153, 139 </td><td> <span style=\"display: block; background: RGB(27, 153, 139); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| PATINATED_TURQUOISE | 27, 153, 139 | <span style=\"display: block; background: RGB(27, 153, 139); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> TITANIUM_YELLOW </td><td> 244, 228, 9 </td><td> <span style=\"display: block; background: RGB(244, 228, 9); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| TITANIUM_YELLOW | 244, 228, 9 | <span style=\"display: block; background: RGB(244, 228, 9); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> MANGANESE_PURPLE </td><td> 91,80, 122 </td><td> <span style=\"display: block; background: RGB(91,80, 122); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| MANGANESE_PURPLE | 91,80, 122 | <span style=\"display: block; background: RGB(91,80, 122); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> TURQUOISE </td><td> 74, 207, 217 </td><td> <span style=\"display: block; background: RGB(74, 207, 217); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| TURQUOISE | 74, 207, 217 | <span style=\"display: block; background: RGB(74, 207, 217); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> DARK_TURQUOISE </td><td> 2, 149, 170 </td><td> <span style=\"display: block; background: RGB(2, 149, 170); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| DARK_TURQUOISE | 2, 149, 170 | <span style=\"display: block; background: RGB(2, 149, 170); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "</table>."
"text": "."
}
]
}
@@ -148,75 +148,75 @@
},
{
"style": "Text",
"text": "<table class=\"docs-table\"><tr><td> Variable Value </td><td> RGB Value </td><td> Color Sample </td></tr>"
"text": "| Variable Value | RGB Value | Color Sample |"
},
{
"style": "Text",
"text": "<tr><td> :--- </td><td> :---: </td><td> :------------------- </td></tr>"
"text": "| :--- | :---: | :------------------- |"
},
{
"style": "Text",
"text": "<tr><td> DARK </td><td> 48, 48, 54 </td><td> <span style=\"display: block; background: RGB(48, 48, 54); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| DARK | 48, 48, 54 | <span style=\"display: block; background: RGB(48, 48, 54); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> LIGHT </td><td> 234, 226, 222 </td><td> <span style=\"display: block; background: RGB(234, 226, 222); border: 1px black; border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| LIGHT | 234, 226, 222 | <span style=\"display: block; background: RGB(234, 226, 222); border: 1px black; border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> GREY </td><td> 150, 150, 150 </td><td> <span style=\"display: block; background: RGB(150, 150, 150); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| GREY | 150, 150, 150 | <span style=\"display: block; background: RGB(150, 150, 150); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> LIGHT_GREY </td><td> 247, 247, 247 </td><td> <span style=\"display: block; background: RGB(247, 247, 247); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| LIGHT_GREY | 247, 247, 247 | <span style=\"display: block; background: RGB(247, 247, 247); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> WHITE </td><td> 255, 255, 255 </td><td> <span style=\"display: block; background: RGB(255, 255, 255); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| WHITE | 255, 255, 255 | <span style=\"display: block; background: RGB(255, 255, 255); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> BLACK </td><td> 0, 0, 0 </td><td> <span style=\"display: block; background: RGB(0, 0, 0); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| BLACK | 0, 0, 0 | <span style=\"display: block; background: RGB(0, 0, 0); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> GOLDEN_ORANGE </td><td> 240, 162, 2 </td><td> <span style=\"display: block; background: RGB(240, 162, 2); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| GOLDEN_ORANGE | 240, 162, 2 | <span style=\"display: block; background: RGB(240, 162, 2); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> RUSTED_RED </td><td> 204, 88, 53 </td><td> <span style=\"display: block; background: RGB(204, 88, 53); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| RUSTED_RED | 204, 88, 53 | <span style=\"display: block; background: RGB(204, 88, 53); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> GREEN </td><td> 188, 214, 67 </td><td> <span style=\"display: block; background: RGB(188, 214, 67); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| GREEN | 188, 214, 67 | <span style=\"display: block; background: RGB(188, 214, 67); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> RED </td><td> 223, 70, 60 </td><td> <span style=\"display: block; background: RGB(223, 70, 60); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| RED | 223, 70, 60 | <span style=\"display: block; background: RGB(223, 70, 60); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> PATINATED_TURQUOISE </td><td> 27, 153, 139 </td><td> <span style=\"display: block; background: RGB(27, 153, 139); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| PATINATED_TURQUOISE | 27, 153, 139 | <span style=\"display: block; background: RGB(27, 153, 139); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> TITANIUM_YELLOW </td><td> 244, 228, 9 </td><td> <span style=\"display: block; background: RGB(244, 228, 9); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| TITANIUM_YELLOW | 244, 228, 9 | <span style=\"display: block; background: RGB(244, 228, 9); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> MANGANESE_PURPLE </td><td> 91,80, 122 </td><td> <span style=\"display: block; background: RGB(91,80, 122); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| MANGANESE_PURPLE | 91,80, 122 | <span style=\"display: block; background: RGB(91,80, 122); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> TURQUOISE </td><td> 74, 207, 217 </td><td> <span style=\"display: block; background: RGB(74, 207, 217); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| TURQUOISE | 74, 207, 217 | <span style=\"display: block; background: RGB(74, 207, 217); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "<tr><td> DARK_TURQUOISE </td><td> 2, 149, 170 </td><td> <span style=\"display: block; background: RGB(2, 149, 170); border: 1px solid black;\">&nbsp;</span> </td></tr>"
"text": "| DARK_TURQUOISE | 2, 149, 170 | <span style=\"display: block; background: RGB(2, 149, 170); border: 1px solid black;\">&nbsp;</span> |"
},
{
"style": "Text",
"text": "</table>* lineWidth is the width of the border line, which should be greater than 0."
"style": "List",
"text": "lineWidth is the width of the border line, which should be greater than 0."
},
{
"style": "List",
@@ -65,7 +65,8 @@ function newSuperalgosDocSpace() {
toWarning: toWarning,
toImportant: toImportant,
toSuccess: toSuccess,
toList: toList
toList: toList,
toTable: toTable
}
function editParagraph() {
@@ -178,6 +179,12 @@ function newSuperalgosDocSpace() {
docSchemaParagraph.style = 'List'
renderPage()
}
function toTable() {
let docSchemaParagraph = docSchemaParagraphMap.get(selectedParagraph.id)
docSchemaParagraph.style = 'Table'
renderPage()
}
}
function setUpMenuItemsMap() {
@@ -256,12 +263,12 @@ function newSuperalgosDocSpace() {
let paragraphs = []
let paragraph = ''
let splittedSelectedParagraph = selectedParagraph.id.split('-')
let selectedParagraphIndex = Number(splittedSelectedParagraph[1])
let selectedParagraphStyle = splittedSelectedParagraph[2]
let selectedParagraphIndex = Number(splittedSelectedParagraph[2])
let selectedParagraphStyle = splittedSelectedParagraph[3]
let style = selectedParagraphStyle.charAt(0).toUpperCase() + selectedParagraphStyle.slice(1);
for (let i = 0; i < textArea.value.length; i++) {
if (textArea.value.charCodeAt(i) === 10 && style !== 'Javascript' && style !== 'Json') {
if (textArea.value.charCodeAt(i) === 10 && style !== 'Javascript' && style !== 'Json' && style !== 'Table') {
if (paragraph !== '') {
paragraphs.push(paragraph)
}
@@ -381,45 +388,58 @@ function newSuperalgosDocSpace() {
if (paragraphNode.id === undefined || paragraphNode.id.indexOf('paragraph') < 0) {
paragraphNode = paragraphNode.parentNode
}
if (paragraphNode.id === undefined || paragraphNode.id.indexOf('paragraph') < 0) {
paragraphNode = paragraphNode.parentNode
}
if (paragraphNode.id === undefined || paragraphNode.id.indexOf('paragraph') < 0) {
paragraphNode = paragraphNode.parentNode
}
if (paragraphNode.id === undefined || paragraphNode.id.indexOf('paragraph') < 0) {
paragraphNode = paragraphNode.parentNode
}
if (paragraphNode.id === undefined || paragraphNode.id.indexOf('paragraph') < 0) {
return false
}
/*
Depending on the Style of Paragraph we will need to remove
some info from the innerText.
*/
if (paragraphNode.id.indexOf('definition') >= 0) {
if (paragraphNode.id.indexOf('-definition') >= 0) {
selectedParagraphData = paragraphNode.innerText
}
if (paragraphNode.id.indexOf('text') >= 0) {
if (paragraphNode.id.indexOf('-text') >= 0) {
selectedParagraphData = paragraphNode.innerText
}
if (paragraphNode.id.indexOf('title') >= 0) {
if (paragraphNode.id.indexOf('-title') >= 0) {
selectedParagraphData = paragraphNode.innerText
}
if (paragraphNode.id.indexOf('subtitle') >= 0) {
if (paragraphNode.id.indexOf('-subtitle') >= 0) {
selectedParagraphData = paragraphNode.innerText
}
if (paragraphNode.id.indexOf('note') >= 0) {
if (paragraphNode.id.indexOf('-note') >= 0) {
selectedParagraphData = paragraphNode.innerText.substring(6, paragraphNode.innerText.length)
}
if (paragraphNode.id.indexOf('success') >= 0) {
if (paragraphNode.id.indexOf('-success') >= 0) {
selectedParagraphData = paragraphNode.innerText.substring(5, paragraphNode.innerText.length)
}
if (paragraphNode.id.indexOf('important') >= 0) {
if (paragraphNode.id.indexOf('-important') >= 0) {
selectedParagraphData = paragraphNode.innerText.substring(11, paragraphNode.innerText.length)
}
if (paragraphNode.id.indexOf('warning') >= 0) {
if (paragraphNode.id.indexOf('-warning') >= 0) {
selectedParagraphData = paragraphNode.innerText.substring(10, paragraphNode.innerText.length)
}
if (paragraphNode.id.indexOf('list') >= 0) {
if (paragraphNode.id.indexOf('-list') >= 0) {
selectedParagraphData = paragraphNode.innerText
}
if (paragraphNode.id.indexOf('javascript') >= 0) {
if (paragraphNode.id.indexOf('-table') >= 0) {
selectedParagraphData = reverseParseTable(paragraphNode.innerHTML)
}
if (paragraphNode.id.indexOf('-javascript') >= 0) {
selectedParagraphData = paragraphNode.innerText.substring(1, paragraphNode.innerText.length - 1)
}
if (paragraphNode.id.indexOf('json') >= 0) {
if (paragraphNode.id.indexOf('-json') >= 0) {
selectedParagraphData = paragraphNode.innerText.substring(1, paragraphNode.innerText.length - 1)
}
@@ -576,7 +596,6 @@ function newSuperalgosDocSpace() {
let key = 'editable-paragraph-' + paragraphIndex
let paragraph = nodeDocsDefinition.paragraphs[i]
renderParagraph(paragraph, key)
docSchemaParagraphMap.set(key, paragraph)
paragraphIndex++
}
}
@@ -745,7 +764,7 @@ function newSuperalgosDocSpace() {
generateReferencingRules()
generateConfiguration()
generateCode()
generateFormula()
generateFormula()
function generateMenuItems() {
/*
@@ -1339,7 +1358,19 @@ function newSuperalgosDocSpace() {
sufix = '</li>'
role = ''
key = key + '-list'
innerHTML = addBold(paragraph.text)
innerHTML = addBold(innerHTML)
innerHTML = addItalics(innerHTML)
innerHTML = addToolTips(innerHTML)
break
}
case 'Table': {
styleClass = ''
prefix = '<table class="docs-info-table">'
sufix = '</table>'
role = ''
key = key + '-table'
innerHTML = parseTable(paragraph.text)
innerHTML = addBold(innerHTML)
innerHTML = addItalics(innerHTML)
innerHTML = addToolTips(innerHTML)
break
@@ -1365,6 +1396,8 @@ function newSuperalgosDocSpace() {
}
HTML = HTML + '<p><div id="' + key + '" ' + styleClass + ' ' + role + '>' + prefix + ' ' + innerHTML + sufix + '</div></p>'
docSchemaParagraphMap.set(key, paragraph)
}
function hightlightEmbeddedCode() {
@@ -1408,6 +1441,72 @@ function newSuperalgosDocSpace() {
}
}
function parseTable(text) {
let HTML = ''
let odd = false
let rows = text.split(String.fromCharCode(10))
for (let i = 0; i < rows.length; i++) {
let row = rows[i]
let colums = row.split('|')
if (i === 0) {
HTML = HTML + '<thead>'
}
if (i === 1) {
HTML = HTML + '<tbody>'
}
if (odd === true) {
HTML = HTML + '<tr class="docs-info-table-alt-bg">'
odd = false
} else {
HTML = HTML + '<tr>'
odd = true
}
if (colums.length < 2) {
return text
} else {
/* We discard anything before the first | and after the last | */
for (let j = 1; j < colums.length - 1; j++) {
let column = colums[j]
if (i === 0) {
HTML = HTML + '<th>' + column + '</th>'
} else {
HTML = HTML + '<td>' + column + '</td>'
}
}
}
HTML = HTML + '</tr>'
if (i === 0) {
HTML = HTML + '</thead>'
}
if (i === rows.length - 1) {
HTML = HTML + '</tbody>'
}
}
return HTML
}
function reverseParseTable(HTML) {
text = HTML
text = text.replace('<table class="docs-info-table"> ', '')
text = text.replace(' </table>', '')
text = text.replace('<thead>', '')
text = text.replace('</thead>', '')
text = text.replace('<tbody>', '')
text = text.replace('</tr></tbody>', '')
text = text.replaceAll('<tr>', '')
text = text.replaceAll('<tr class="docs-info-table-alt-bg">', '')
text = text.replaceAll('</td><td>', '|')
text = text.replaceAll('</th><th>', '|')
text = text.replaceAll('</tr>', String.fromCharCode(10))
text = text.replaceAll('<th>', '|')
text = text.replaceAll('</th>', '|')
text = text.replaceAll('<td>', '|')
text = text.replaceAll('</td>', '|')
return text
}
function addBold(text) {
let splittedText = text.split(':')
if (splittedText.length > 1 && splittedText[1].length > 0) {