Skip to content

Commit

Permalink
fix(helper.py): fixes add_data_to_viewer to add data in the way that …
Browse files Browse the repository at this point in the history
…pollinationviewer.html expects (#306)
  • Loading branch information
NGimbal authored Dec 9, 2021
1 parent e885f57 commit b40282f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ tox.ini
# Rhino Backup files
*.3dm.rhl
*3dmbak
#generate html model
model.html

14 changes: 12 additions & 2 deletions honeybee_vtk/vtkjs/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,20 @@ def add_data_to_viewer(data_path, src_html_path=None):
with open(src_html_path, mode="r", encoding="utf-8") as srcHtml:
with open(dstHtmlPath, mode="w", encoding="utf-8") as dstHtml:
for line in srcHtml:
if "<!–– insert ––>" in line:
if "<noscript>You need to enable JavaScript to run this app.</noscript>" in line:
strings = line.split(
"<noscript>You need to enable JavaScript to run this app.</noscript>", 1)
dstHtml.write(strings[0])
dstHtml.write("<script>\n")
dstHtml.write('var contentToLoad = "%s";\n\n' % base64Content)
dstHtml.write("function _getContent() { return contentToLoad }</script>\n")
dstHtml.write("function _getContent() { return contentToLoad }\n")
dstHtml.write('var contentToLoad = "%s";\n' %
base64Content)
dstHtml.write(
"function _getContent() { return contentToLoad }</script>\n")
dstHtml.write(
"<noscript>You need to enable JavaScript to run this app.</noscript>")
dstHtml.write(strings[1])
continue
dstHtml.write(line)
return dstHtmlPath
Expand Down

0 comments on commit b40282f

Please sign in to comment.