1/* 2requests is used on both /users/bookmarks + /nodes/index.... needs to be central 3*/ 4 5console.log("requests.js loaded"); 6 7 8//save request to database and return requestID 9function ajaxCall_saveRequest(available, restricted, title, message, request, digital) { 10 $.ajax({ 11 type: "POST", 12 url: jsRoot + "requests/store/", 13 data: { 14 available: available, 15 restricted: restricted, 16 message: message, 17 title: title 18 }, 19 beforeSend: function (data) { 20 $('#loading-overlay').show(); 21 $('#proloader').css('display', 'flex'); 22 }, 23 success: function (data) { 24 console.log(data); 25 var data = JSON.parse(data); 26 //return data['r_id']; 27 var rid = data['r_id']; 28 29 $('#loading-overlay').hide(); 30 $('#proloader').css('display', 'none'); 31 //BB once i've got the requestID - trigger the actions 32 requestActions(rid, digital, request, available); 33 }, 34 error: function (data) { 35 console.log('An error occurred.'); 36 console.log(data); 37 $('#loading-overlay').hide(); 38 $('#proloader').css('display', 'none'); 39 }, 40 }); 41} 42 43// return request id (after saveRequest) and fire actions 44function requestActions(rid, digital, request, available) { 45 console.log("action... digital: " + digital + " ... available: " + available); 46 47 //var availJson = JSON.stringify 48 49 50 // download actions 51 if (digital == 1) { 52 // $message = $('<div>').html("<p style='font-size:14px;'>The downloading of \"Available\" items are in progress.<br />You will receive an email once the downloading process has completed<br /> If you requested any \"Restricted\" Items an Administrator will email you.</p>").dialog({ 53 // close: function () { $(this).empty().dialog("destroy"); }, 54 // width: 450, 55 // height: 250, 56 // title: "Request Items - Submitted" 57 // }); 58 // 59 // 60 // $.get( 61 // window.location.origin + '/nodes/searchDownload/node:{"nodeIds":' + available + '}', 62 // setTimeout(function () { 63 // $message.dialog("close"); 64 // }, 6000) 65 // ); 66 requestDownload(available); 67 68 // if any restricted items are requested fire email to administrator 69 if (request == 1) { 70 // $.get( 71 // //window.location.origin + '/requests/sendNotifications/request:{"request":' + rid + '}', 72 // window.location.origin + '/requests/sendNotifications/request:' + rid, 73 // console.log("email: true") 74 // ); 75 // $.ajax({ 76 // type: "POST", 77 // url: jsRoot + "requests/sendNotifications/", 78 // data: { 79 // request: rid, 80 // }, 81 // beforeSend: function (data) { 82 // //$('#loading-overlay').show(); 83 // }, 84 // success: function (data) { 85 // console.log(data); 86 // $('#loading-overlay').hide(); 87 // }, 88 // error: function (data) { 89 // console.log('An error occurred.'); 90 // console.log(data); 91 // $('#loading-overlay').hide(); 92 // }, 93 // }); 94 requestNotification(rid, 1); 95 } 96 97 } else { 98 // $message = $('<div>').html("<p style='font-size:14px;'>Your request for \"Restricted\" Items has been sent, an Administrator will email you shortly.</p>").dialog({ 99 // close: function () { $(this).empty().dialog("destroy"); }, 100 // width: 450, 101 // height: 250, 102 // title: "Request Items - Submitted" 103 // }); 104 105 // fire function to email administrator a list of restricted item ID's 106 // $.get( 107 // /*//window.location.origin + '/requests/sendNotifications/request:{"request":' + rid + '}', 108 // //window.location.origin + '/requests/sendNotifications/{"request":' + rid + '}',*/ 109 // window.location.origin + '/requests/sendNotifications/request:' + rid, 110 // setTimeout(function () { 111 // $message.dialog("close"); 112 // }, 6000), 113 // console.log("email: true") 114 // ) 115 requestNotification(rid, 2); 116 117 } 118 119 120} 121 122 123 124//BB 2019-11-15: function to send Notification to administrator of requests 125function requestNotification(rid, msg) { 126 $.ajax({ 127 type: "POST", 128 url: jsRoot + "requests/sendnotifications/", 129 data: { 130 rid: rid, 131 }, 132 beforeSend: function (data) { 133 //$('#loading-overlay').show(); 134 }, 135 success: function (data) { 136 console.log(data); 137 //$('#loading-overlay').hide(); 138 if (msg == 2) { 139 $message = $('<div>').html("<p style='font-size:14px;'>Your order has been sent, an Administrator will email you shortly.</p>").dialog({ 140 close: function () { $(this).empty().dialog("destroy"); }, 141 width: 450, 142 height: 250, 143 title: "Items Ordered" 144 }); 145 setTimeout(function () { 146 $message.dialog("close"); 147 }, 6000); 148 } 149 }, 150 error: function (data) { 151 console.log('An error occurred.'); 152 console.log(data); 153 //$('#loading-overlay').hide(); 154 }, 155 }); 156} 157 158 159//BB 2019-11-15: function to download zip 160// $.get( 161// window.location.origin + '/nodes/searchDownload/node:{"nodeIds":' + available + '}', 162// setTimeout(function () { 163// $message.dialog("close"); 164// }, 6000) 165// ); 166function requestDownload(available, email, request) { 167 //availTemp = available.split(","); 168 var availX = JSON.stringify(available); 169 $.ajax({ 170 type: "GET", 171 url: jsRoot + "nodes/searchDownload/node:{\"nodeIds\":" + availX + "}", 172 data: { 173 //node: '{"nodeIds":' + available + '}', 174 metadata: "1", // do we only want the assets for the my-list? 175 digital: "1", 176 email: email, 177 request: request 178 }, 179 beforeSend: function (data) { 180 //$('#loading-overlay').show(); 181 }, 182 success: function (data) { 183 console.log(data); 184 //$('#loading-overlay').hide(); 185 186 //$message = $('<div>').html("<p style='font-size:14px;'>The downloading of \"Available\" items are in progress.<br />You will receive an email once the downloading process has completed<br /> If you requested any \"Restricted\" Items an Administrator will email you.</p>").dialog({ 187 $message = $('<div>').html("<p style='font-size:14px;'>Your requested items are currently being prepared for downloading, and a download link will be emailed to you as soon as they are ready.<br />
187If you requested other items we will contact you to discuss how you can access these.</p>").dialog({ 188 close: function () { $(this).empty().dialog("destroy"); }, 189 width: 450, 190 height: 250, 191 title: "Items Ordered" 192 }); 193 setTimeout(function () { 194 $message.dialog("close"); 195 }, 6000); 196 197 }, 198 error: function (data) { 199 console.log('An error occurred.'); 200 console.log(data); 201 //$('#loading-overlay').hide(); 202 }, 203 }); 204} 205 206 207//update the status of a request 208function updateLoggedStatus(rid) { 209 $.ajax({ 210 type: "POST", 211 url: jsRoot + "requests/updateStatus/" + rid, 212 beforeSend: function (data) { 213 $('#loading-overlay').show(); 214 $('#proloader').css('display', 'flex'); 215 }, 216 success: function (data) { 217 $("td.log_" + rid).html("Logged"); 218 $('#loading-overlay').hide(); 219 $('#proloader').css('display', 'none'); 220 }, 221 error: function (data) { 222 console.log('An error occurred.'); 223 $('#loading-overlay').hide(); 224 $('#proloader').css('display', 'none'); 225 }, 226 }); 227}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.