Skip to content

Commit

Permalink
Revert "[LIMS-1552] Remove old jQuery version (#861)"
Browse files Browse the repository at this point in the history
This reverts commit 0904d6d.
  • Loading branch information
gfrn authored Nov 18, 2024
1 parent 0904d6d commit 122b5e5
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 2 deletions.
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

0 comments on commit 122b5e5

Please sign in to comment.