Changeset View
Changeset View
Standalone View
Standalone View
swh/web/templates/includes/content-display.html
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | <div class="swh-content"> | ||||
{% elif content %} | {% elif content %} | ||||
Content with mime type {{ mimetype }} and encoding {{ encoding }} cannot be displayed. | Content with mime type {{ mimetype }} and encoding {{ encoding }} cannot be displayed. | ||||
{% else %} | {% else %} | ||||
{% include "includes/http-error.html" %} | {% include "includes/http-error.html" %} | ||||
{% endif %} | {% endif %} | ||||
</div> | </div> | ||||
</div> | </div> | ||||
{% if content %} | |||||
<script> | <script> | ||||
{% if "application/pdf" == mimetype %} | {% if "application/pdf" == mimetype %} | ||||
swh.webapp.renderPdf({{ top_right_link.url|jsonify }}); | swh.webapp.renderPdf({{ top_right_link.url|jsonify }}); | ||||
{% elif filename and filename|default:""|slice:"-5:" == "ipynb" %} | {% elif filename and filename|default:""|slice:"-5:" == "ipynb" %} | ||||
swh.webapp.renderNotebook({{ top_right_link.url|jsonify }}, '.swh-ipynb'); | swh.webapp.renderNotebook({{ top_right_link.url|jsonify }}, '.swh-ipynb'); | ||||
{% elif content %} | {% elif content %} | ||||
let codeContainer = $('code'); | let codeContainer = $('code'); | ||||
let content = codeContainer.text(); | let content = codeContainer.text(); | ||||
swh.webapp.highlightCode(); | swh.webapp.highlightCode(); | ||||
function updateLanguage(language) { | function updateLanguage(language) { | ||||
codeContainer.text(content); | codeContainer.text(content); | ||||
codeContainer.removeClass(); | codeContainer.removeClass(); | ||||
codeContainer.addClass(language); | codeContainer.addClass(language); | ||||
let urlParams = new URLSearchParams(window.location.search); | let urlParams = new URLSearchParams(window.location.search); | ||||
urlParams.set('language', language); | urlParams.set('language', language); | ||||
const newUrl = window.location.pathname + '?' + urlParams.toString() + window.location.hash; | const newUrl = window.location.pathname + '?' + urlParams.toString() + window.location.hash; | ||||
window.history.replaceState('', document.title, newUrl); | window.history.replaceState('', document.title, newUrl); | ||||
swh.webapp.highlightCode(); | swh.webapp.highlightCode(); | ||||
} | } | ||||
{% endif %} | {% endif %} | ||||
</script> | </script> | ||||
{% endif %} | {% endif %} | ||||
{% endif %} |