Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions client/src/js/vendor/jquery/jquery-1.9.1.min.js

Large diffs are not rendered by default.

46 changes: 44 additions & 2 deletions client/src/js/views/log.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
define(['marionette', 'views/dialog'], function(Marionette, DialogView) {
define(['marionette', 'views/dialog', 'utils'], function(Marionette, DialogView, utils) {

return DialogView.extend({
className: 'fixedwidth',
Expand Down Expand Up @@ -50,6 +50,48 @@ define(['marionette', 'views/dialog'], function(Marionette, DialogView) {
var m = h.match(/^Content-Type\:\s*(.*?)$/mi)
var mimeType = m[1] || 'image/png'

var blob = new Blob([this.response], { type: mimeType })

// inject sign handler
// Note this uses an old jquery copied from src into assets dir
var sh = '<script src="/assets/js/jquery-1.9.1.min.js"></script>\n\
<script type="text/javascript">\n\
$(document).ready(function() {\n\
var app = { apiurl: "'+app.apiurl+'", prop: "'+app.prop+'"}\n\
app.token = sessionStorage.getItem(\'token\')\n\
var root = "'+self.url.replace(/\?token=.*/, '')+'"\n\
var ajax = function(options) {\n\
options.data.prop = app.prop\n\
if (app.token) {\n\
options.beforeSend = function(request){\n\
request.setRequestHeader(\'Authorization\', \'Bearer \' + app.token);\n\
}\n\
}\n\
return $.ajax.call(this, options)\n\
}\n\
var Backbone = { ajax: ajax }\n\
var sign = '+utils.sign.toString()+'\n\
$("a").click(function(e) {\n\
var is_relative_to_page = function(href) {\n\
return href.match(/^\\/|(http:|https:|ftp:|mailto:|javascript:)/) === null;\n\
}\n\
var is_routable = function(href) {\n\
return href.indexOf("#") === -1 && is_relative_to_page(href);\n\
}\n\
var href = $(this).attr("href")\n\
if (!is_routable(href)) return true\n\
e.preventDefault()\n\
var url = root+\'/\'+href\n\
\sign({\n\
url: url,\n\
callback: function(resp) {\n\
window.location = url+\'?token=\'+resp.token\n\
}\n\
})\n\
})\n\
});\n\
</script>'

if (mimeType == 'application/pdf' || mimeType == 'image/png') {
var url = URL.createObjectURL(new Blob([this.response], { type: mimeType }))
self.iframe[0].src = url
Expand All @@ -62,7 +104,7 @@ define(['marionette', 'views/dialog'], function(Marionette, DialogView) {
if (mimeType.indexOf('text/plain') > -1) text = '<pre>'+escapeHTMLTags(text)+'</pre>'

doc.open()
doc.write(text)
doc.write(sh+text)
doc.close()
}

Expand Down
5 changes: 5 additions & 0 deletions client/touchscreen/js/vendor/jquery/jquery-1.9.1.min.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions client/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,11 @@ module.exports = (env, argv) => ({
from: 'js/config.json',
to: path.resolve(__dirname, 'assets/js/')
},
{
context: path.resolve(__dirname, 'src'),
from: 'js/vendor/jquery/jquery-1.9.1.min.js',
to: path.resolve(__dirname, 'assets/js/')
},
{
context: path.resolve(__dirname, 'src'),
from: 'files/**',
Expand Down