Bugzilla – Attachment 63756 Details for
Bug 4437
acq.js uses XMLHttpRequest() directly; should use jQuery
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 4437: acq.js uses XMLHttpRequest() directly; should use jQuery
Bug-4437-acqjs-uses-XMLHttpRequest-directly-should.patch (text/plain), 5.62 KB, created by
Mark Tompsett
on 2017-05-27 03:27:24 UTC
(
hide
)
Description:
Bug 4437: acq.js uses XMLHttpRequest() directly; should use jQuery
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2017-05-27 03:27:24 UTC
Size:
5.62 KB
patch
obsolete
>From 8d6d7ddc8d3e9b7e84f65827399195c8eb4a93bb Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Fri, 26 May 2017 23:22:39 -0400 >Subject: [PATCH] Bug 4437: acq.js uses XMLHttpRequest() directly; should use > jQuery > >The acq.js file used a few calls to XMLHttpRequest, which have been >changed to use jQuery.ajax instead. > >The fetchSortDropbox no longer exists, which is why this patch >did not apply. However, the other three functions still had direct >XMLHttpRequest calls: >- totalExceedsBudget >- budgetExceedsParent >- checkBudgetParent > >A test plan would require triggering these three javascript functions. >--- > koha-tmpl/intranet-tmpl/prog/js/acq.js | 112 +++++++++++++-------------------- > 1 file changed, 44 insertions(+), 68 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/acq.js b/koha-tmpl/intranet-tmpl/prog/js/acq.js >index 9d3983c..906877e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/acq.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/acq.js >@@ -242,29 +242,24 @@ function getAuthValueDropbox( name, cat, destination, selected ) { > //USED BY NEWORDEREMPTY.PL > function totalExceedsBudget(budgetId, total) { > >- var xmlhttp = null; >- xmlhttp = new XMLHttpRequest(); >- if ( typeof xmlhttp.overrideMimeType != 'undefined') { >- xmlhttp.overrideMimeType('text/xml'); >- } >- > var url = '../acqui/check_budget_total.pl?budget_id=' + budgetId + "&total=" + total; >- xmlhttp.open('GET', url, false); >- xmlhttp.send(null); >- >- xmlhttp.onreadystatechange = function() { >- if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { >- >+ var ret = undefined; >+ jQuery.ajax({ >+ url: url, >+ mimeType: 'text/xml', >+ async: false, // non-async because we need to return a value based on the result >+ success: function(data, textStatus, xmlhttp) { > actTotal = eval ( xmlhttp.responseText ); > > if ( Math.abs(actTotal) < Math.abs(total) ) { > // if budget is to low :( >- return true ; >+ ret = true ; > } else { >- return false; >+ ret = false; > } > } >- } >+ }); >+ return ret; > } > > >@@ -272,42 +267,31 @@ function totalExceedsBudget(budgetId, total) { > function budgetExceedsParent(budgetTotal, budgetId, newBudgetParent, periodID) { > > >- var xmlhttp = null; >- xmlhttp = new XMLHttpRequest(); >- if ( typeof xmlhttp.overrideMimeType != 'undefined') { >- xmlhttp.overrideMimeType('text/xml'); >- } >- > // make the call... yawn > // var url = '../admin/check_parent_total.pl?budget_id=' + budgetId + '&parent_id=' + newBudgetParent + "&total=" + budgetTotal + "&period_id="+ periodID ; > > > var url = '../admin/check_parent_total.pl?total=' + budgetTotal + "&period_id="+ periodID ; >- > if (budgetId ) { url += '&budget_id=' + budgetId }; > if ( newBudgetParent ) { url += '&parent_id=' + newBudgetParent}; >- >- >- xmlhttp.open('GET', url, false); >- xmlhttp.send(null); >- >- xmlhttp.onreadystatechange = function() { >- if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { >- // stupid JS... >- } else { >- // wait for the call to complete >+ var ret = undefined; >+ jQuery.ajax({ >+ url: url, >+ mimeType: 'text/xml', >+ async: false, // non-async because we need to return a value based on the result >+ success: function(data, textStatus, xmlhttp) { >+ var result = eval ( xmlhttp.responseText ); >+ >+ if (result == '1') { >+ ret = MSG_BUDGET_PARENT_ALLOCATIONl; >+ } else if (result == '2') { >+ ret = MSG_BUDGET_PERIOD_ALLOCATION; >+ } else { >+ ret = false; >+ } > } >- }; >- >- var result = eval ( xmlhttp.responseText ); >- >- if (result == '1') { >- return MSG_BUDGET_PARENT_ALLOCATION; >- } else if (result == '2') { >- return MSG_BUDGET_PERIOD_ALLOCATION; >- } else { >- return false; >- } >+ }); >+ return ret; > } > > >@@ -315,33 +299,25 @@ if ( newBudgetParent ) { url += '&parent_id=' + newBudgetParent}; > > //USED BY AQBUDGETS.TMPL > function checkBudgetParent(budgetId, newBudgetParent) { >- var xmlhttp = null; >- xmlhttp = new XMLHttpRequest(); >- if ( typeof xmlhttp.overrideMimeType != 'undefined') { >- xmlhttp.overrideMimeType('text/xml'); >- } >- > var url = '../admin/check_budget_parent.pl?budget_id=' + budgetId + '&new_parent=' + newBudgetParent; >- xmlhttp.open('GET', url, false); >- xmlhttp.send(null); >- >- xmlhttp.onreadystatechange = function() { >- if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { >- // do something with the results >- } else { >- // wait for the call to complete >+ var ret = undefined; >+ jQuery.ajax({ >+ url: url, >+ mimeType: 'text/xml', >+ async: false, // non-async because we need to return a value based on the result >+ success: function(data, textStatus, xmlhttp) { >+ var result = eval ( xmlhttp.responseText ); >+ >+ if (result == '1') { >+ ret = MSG_PARENT_BENEATH_BUDGET; >+// } else if (result == '2') { >+// ret = "- New budget-parent has insufficent funds\n"; >+// } else { >+// ret = false; >+ } > } >- }; >- >- var result = eval ( xmlhttp.responseText ); >- >- if (result == '1') { >- return MSG_PARENT_BENEATH_BUDGET; >-// } else if (result == '2') { >-// return "- New budget-parent has insufficent funds\n"; >-// } else { >-// return false; >- } >+ }); >+ return ret; > } > > function hideColumn(num) { >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 4437
:
14646
|
14649
|
63756
|
152859