Skip to content

Commit

Permalink
Remove old jQuery version
Browse files Browse the repository at this point in the history
  • Loading branch information
gfrn committed Nov 15, 2024
1 parent f7780e9 commit d5f843b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 54 deletions.
46 changes: 2 additions & 44 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', 'utils'], function(Marionette, DialogView, utils) {
define(['marionette', 'views/dialog'], function(Marionette, DialogView) {

return DialogView.extend({
className: 'fixedwidth',
Expand Down Expand Up @@ -50,48 +50,6 @@ define(['marionette', 'views/dialog', 'utils'], 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 @@ -104,7 +62,7 @@ define(['marionette', 'views/dialog', 'utils'], function(Marionette, DialogView,
if (mimeType.indexOf('text/plain') > -1) text = '<pre>'+escapeHTMLTags(text)+'</pre>'

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

Expand Down
Loading

0 comments on commit d5f843b

Please sign in to comment.