|
1 | 1 | {%- include dependencies.html data=include.data -%} |
2 | | -{%- include code_and_testcases.html data=include.data -%} |
| 2 | + |
| 3 | +<h2>Code</h2> |
| 4 | + |
| 5 | +{%- comment -%}Build extended embedded array with minified versions{%- endcomment -%} |
| 6 | +{%- assign extended_embedded = include.data.embedded -%} |
| 7 | + |
| 8 | +{%- if include.data.minifiedCode -%} |
| 9 | +{%- assign minified_obj = '{"name":"minified","code":"PLACEHOLDER"}' | parse_json -%} |
| 10 | +{%- assign extended_embedded = extended_embedded | push: minified_obj -%} |
| 11 | +{%- endif -%} |
| 12 | + |
| 13 | +{%- if include.data.minifiedBundledCode -%} |
| 14 | +{%- assign minified_bundled_obj = '{"name":"minified + bundled","code":"PLACEHOLDER"}' | parse_json -%} |
| 15 | +{%- assign extended_embedded = extended_embedded | push: minified_bundled_obj -%} |
| 16 | +{%- endif -%} |
| 17 | + |
| 18 | +{%- comment -%}Display code with tabs{%- endcomment -%} |
| 19 | +{%- if extended_embedded.size >= 1 -%} |
| 20 | +<div class="code"> |
| 21 | +{%- for source in include.data.embedded -%} |
| 22 | + {%- assign codeBody = source.code -%} |
| 23 | + <pre class="hljs {% unless forloop.first %}disable{% endunless %}" id="code-body-{{forloop.index}}"><code class="language-{{include.data.pathExtension}}">{{ codeBody | xml_escape }}</code></pre> |
| 24 | +{%- endfor -%} |
| 25 | + |
| 26 | +{%- if include.data.minifiedCode -%} |
| 27 | + {%- assign idx = include.data.embedded.size | plus: 1 -%} |
| 28 | + <pre class="hljs disable" id="code-body-{{idx}}"><code class="language-{{include.data.pathExtension}}">{{ include.data.minifiedCode | xml_escape }}</code></pre> |
| 29 | +{%- endif -%} |
| 30 | + |
| 31 | +{%- if include.data.minifiedBundledCode -%} |
| 32 | + {%- assign idx = include.data.embedded.size -%} |
| 33 | + {%- if include.data.minifiedCode -%}{%- assign idx = idx | plus: 2 -%}{%- else -%}{%- assign idx = idx | plus: 1 -%}{%- endif -%} |
| 34 | + <pre class="hljs disable" id="code-body-{{idx}}"><code class="language-{{include.data.pathExtension}}">{{ include.data.minifiedBundledCode | xml_escape }}</code></pre> |
| 35 | +{%- endif -%} |
| 36 | + |
| 37 | + <div class="btn-area"> |
| 38 | + {%- assign total_tabs = include.data.embedded.size -%} |
| 39 | + {%- if include.data.minifiedCode -%}{%- assign total_tabs = total_tabs | plus: 1 -%}{%- endif -%} |
| 40 | + {%- if include.data.minifiedBundledCode -%}{%- assign total_tabs = total_tabs | plus: 1 -%}{%- endif -%} |
| 41 | + |
| 42 | + {%- if total_tabs >= 2 -%} |
| 43 | + <div class="btn-group"> |
| 44 | + {%- for source in include.data.embedded -%} |
| 45 | + <button type="button" class="code-btn code-toggle-btn {% if forloop.first %}selected{% endif %}" data-target="code-body-{{forloop.index}}">{{source.name}}</button> |
| 46 | + {%- endfor -%} |
| 47 | + |
| 48 | + {%- if include.data.minifiedCode -%} |
| 49 | + {%- assign idx = include.data.embedded.size | plus: 1 -%} |
| 50 | + <button type="button" class="code-btn code-toggle-btn" data-target="code-body-{{idx}}">minified</button> |
| 51 | + {%- endif -%} |
| 52 | + |
| 53 | + {%- if include.data.minifiedBundledCode -%} |
| 54 | + {%- assign idx = include.data.embedded.size -%} |
| 55 | + {%- if include.data.minifiedCode -%}{%- assign idx = idx | plus: 2 -%}{%- else -%}{%- assign idx = idx | plus: 1 -%}{%- endif -%} |
| 56 | + <button type="button" class="code-btn code-toggle-btn" data-target="code-body-{{idx}}">minified + bundled</button> |
| 57 | + {%- endif -%} |
| 58 | + </div> |
| 59 | + {%- endif -%} |
| 60 | + <div class="btn-group"><button type="button" class="code-btn code-copy-btn hint--top hint--always hint--disable" aria-label="Copied!">Copy</button></div> |
| 61 | + </div> |
| 62 | +</div> |
| 63 | +{%- else -%} |
| 64 | +<div style="height: 5em;">:x: <b>There is no code.</b></div> |
| 65 | +{%- endif -%} |
| 66 | + |
| 67 | +{%- if include.data.testcases and include.data.testcases.size != 0 -%} |
| 68 | +<h2>Test cases</h2> |
| 69 | +<table class="testcases-table"> |
| 70 | + <thead> |
| 71 | + <tr> |
| 72 | + <th class="col col1">Env</th> |
| 73 | + <th class="col col2">Name</th> |
| 74 | + <th class="col col3">Status</th> |
| 75 | + <th class="col col4">Elapsed</th> |
| 76 | + <th class="col col5">Memory</th> |
| 77 | + </tr> |
| 78 | + </thead> |
| 79 | + <tbody> |
| 80 | + {%- for case in include.data.testcases -%} |
| 81 | + <tr> |
| 82 | + <td class="col col1">{{ case.environment | xml_escape }}</td> |
| 83 | + <td class="col col2">{{ case.name | xml_escape }}</td> |
| 84 | + {%- if case.status == "AC" -%} |
| 85 | + <td class="col col3">{{ site.icons.TEST_ACCEPTED }} AC</td> |
| 86 | + {%- else -%} |
| 87 | + <td class="col col3">{{site.icons.TEST_WRONG_ANSWER}} {{ case.status | xml_escape }}</td> |
| 88 | + {%- endif -%} |
| 89 | + <td class="col col4">{{ case.elapsed | times: 1000 | round }} ms</td> |
| 90 | + <td class="col col5">{{ case.memory | round }} MB</td> |
| 91 | + </tr> |
| 92 | + {%- endfor -%} |
| 93 | + </tbody> |
| 94 | +</table> |
| 95 | +{%- endif -%} |
0 commit comments