Produced by Araxis Merge on 7/25/2018 3:40:56 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
# | Location | File | Last Modified |
---|---|---|---|
1 | Pain_Coach_v3.0_Jun_2018.zip\vpc-patient-web.zip\vpc-patient-web\app\veteran\cordova\grunt_merge\ios\common\lib | app_utils.js | Fri Jun 1 14:26:04 2018 UTC |
2 | Pain_Coach_v3.0_Jun_2018.zip\vpc-patient-web.zip\vpc-patient-web\app\veteran\cordova\grunt_merge\ios\common\lib | app_utils.js | Tue Jul 24 19:09:07 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 1330 |
Changed | 1 | 2 |
Inserted | 0 | 0 |
Removed | 0 | 0 |
Whitespace | |
---|---|
Character case | Differences in character case are significant |
Line endings | Differences in line endings (CR and LF characters) are ignored |
CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
1 | var roaWin dow = null ; | |
2 | var submit Roa = fals e; | |
3 | ||
4 | var App_Ut ils = { | |
5 | GetDom ainPath: f unction () { | |
6 | Ap p.debug = false; | |
7 | if (!App.Deb ugMode) { | |
8 | App.Debu gMode = tr ue; | |
9 | App_Util s.DebugMod e(); | |
10 | } | |
11 | re turn App_U tils.GetRe ferencePat h(); | |
12 | }, | |
13 | GetRef erencePath : function () { | |
14 | if (document .location. hostname = = "localho st" || win dow.locati on.protoco l == "file :" ) { | |
15 | return A pp_Resourc es.hostnam e; | |
16 | return e ncodeURI(A pp_Resourc es.hostnam e); | |
17 | } | |
18 | }, | |
19 | SetReq uestHeader : function () { | |
20 | va r sync = B ackbone.sy nc; | |
21 | Ba ckbone.syn c = functi on (method , model, o ptions) { | |
22 | options. beforeSend = functio n (xhr) { | |
23 | if ( App_Utils. GetSession Token() != null) { | |
24 | xhr.setReq uestHeader ('Authoriz ation', 'B earer ' + App_Utils. GetSession Token()); | |
25 | } | |
26 | }; | |
27 | sync(met hod, model , options) ; | |
28 | }; | |
29 | }, | |
30 | DebugM ode: funct ion() { | |
31 | if (document .location. hostname = = "localho st" && App _Utils.Get SessionTok en() === n ull){ | |
32 | //Quick and dirty input to a dd token i f developi ng and tok en is not present | |
33 | var html = '<form class="for m-inline"> ' + | |
34 | '<di v class="f orm-group" >' + | |
35 | '<la bel for="t okenInput" >Token:</l abel> ' + | |
36 | '<in put type=" text" clas s="form-co ntrol inpu t-sm" id=" tokenInput " placehol der="Enter Token">' + | |
37 | '</d iv>' + | |
38 | '<bu tton type= "button" c lass="btn- default bt n-sm" id=" setToken"> Set Token< /button>' + | |
39 | '</f orm>'; | |
40 | if (!$(" #debug").l ength) { | |
41 | $("b ody").appe nd("<div i d='token' style='pos ition:abso lute; righ t:10px; to p:0;'>" + html + "</ div>"); | |
42 | } | |
43 | $("#setT oken").on( "click", f unction () { | |
44 | var token = $( "#tokenInp ut").val() ; | |
45 | App_ Utils.SetS essionToke n('token', token); | |
46 | loca tion.reloa d(); | |
47 | }); | |
48 | } | |
49 | if (document .location. hostname = = "localho st" && App _Utils.Get LocalStora ge('VPC_Eu la')) { | |
50 | //Add bu tton to cl ear Eula l ocalStorag e value | |
51 | var html 2 = '<butt on type="b utton" cla ss="btn-de fault btn- sm" id="eu laBtn" sty le="positi on:absolut e; right:3 35px; top: 0;">Delete Eula</but ton>'; | |
52 | if (!$(" #eulaBtn") .length) { | |
53 | $("b ody").appe nd(html2); | |
54 | } | |
55 | $("#eula Btn").on(" click", fu nction () { | |
56 | App_ Utils.Dele teLocalSto rage('VPC_ Eula'); | |
57 | loca tion.reloa d(); | |
58 | }); | |
59 | } | |
60 | ||
61 | if (document .location. hostname = = "localho st" && App _Utils.Get SessionTok en() != nu ll) { | |
62 | //Add bu tton to cl ear user t oken | |
63 | var html 3 = '<butt on type="b utton" cla ss="btn-de fault btn- sm" id="to kenBtn" st yle="posit ion:absolu te; right: 425px; top :0px;">Del ete Token< /button>'; | |
64 | if (!$(" #tokenBtn" ).length) { | |
65 | $("b ody").appe nd(html3); | |
66 | } | |
67 | $("#toke nBtn").on( "click", f unction () { | |
68 | App_ Utils.Clea rSessionTo ken('token '); | |
69 | loca tion.reloa d(); | |
70 | }); | |
71 | } | |
72 | ||
73 | // Any other code to qu ickly aid in develop ment | |
74 | }, | |
75 | /** | |
76 | * Upd ate audio URLs to po int to fil es hosted on externa l server ( Cordova au dio work-a round) | |
77 | */ | |
78 | Update AudioUrls: function () { | |
79 | $( 'audio sou rce').each (function( num,val){ | |
80 | var rela tiveUrl = $(this).at tr('src'); | |
81 | var abso luteUrl = App_Resour ces.hostna me + 'pain coach/' + relativeUr l; | |
82 | $(this). attr('src' , absolute Url) | |
83 | }) ; | |
84 | ||
85 | $( 'audio').e ach(functi on(num,val ){ | |
86 | $(this). load(); | |
87 | }) ; | |
88 | }, | |
89 | /** | |
90 | * Upd ate video URLs to po int to fil es hosted on externa l server ( Cordova vi deo work-a round) | |
91 | */ | |
92 | Update VideoUrls: function () { | |
93 | $( 'video sou rce').each (function( num,val){ | |
94 | var rela tiveUrl = $(this).at tr('src'); | |
95 | var abso luteUrl = App_Resour ces.hostna me + 'pain coach/' + relativeUr l; | |
96 | $(this). attr('src' , absolute Url) | |
97 | }) ; | |
98 | ||
99 | $( 'video tra ck').each( function(n um,val){ | |
100 | var rela tiveUrl = $(this).at tr('src'); | |
101 | var abso luteUrl = App_Resour ces.hostna me + 'pain coach/' + relativeUr l; | |
102 | $(this). attr('src' , absolute Url) | |
103 | }) ; | |
104 | ||
105 | $( 'video').e ach(functi on(num,val ){ | |
106 | $(this). load(); | |
107 | }) ; | |
108 | }, | |
109 | /** | |
110 | * Def ault focus on page l oad | |
111 | */ | |
112 | FocusO nLoad: fun ction () { | |
113 | $( '#header-l ogin-link' ).focus(); | |
114 | th is.UpdateA udioUrls() ; | |
115 | th is.UpdateV ideoUrls() ; | |
116 | ||
117 | }, | |
118 | /** | |
119 | * For modals in side <head er>, e.g. About, Hel p | |
120 | * @pa ram modalI d - the ac tive modal id | |
121 | */ | |
122 | Header ModalShown : function (modalId) { | |
123 | $( ".va-title -area, .ap p-title-ar ea, #error Section, # content, f ooter, .sc rollbar-gr adient").a ttr("aria- hidden", t rue); | |
124 | $( "#" + moda lId).remov eAttr('ari a-hidden') ; // ari a-hidden=f alse can b e unreliab le | |
125 | th is.FocusOn Modal(); | |
126 | }, | |
127 | ||
128 | Header ModalHidde n: functio n (modalId ) { | |
129 | $( ".va-title -area, .ap p-title-ar ea, #error Section, # content, f ooter, .sc rollbar-gr adient").r emoveAttr( "aria-hidd en"); | |
130 | $( "#" + moda lId).attr( "aria-hidd en", true) ; | |
131 | }, | |
132 | /** | |
133 | * For modals in side <foot er>, e.g. Too Early To Take Wa rning Moda ls | |
134 | */ | |
135 | Footer ModalShown : function (modalId) { | |
136 | $( "header, # errorSecti on, #conte nt, .foote r-content, .scrollba r-gradient ").attr("a ria-hidden ", "true") ; | |
137 | $( "#" + moda lId).remov eAttr('ari a-hidden') ; // ari a-hidden=f alse can b e unreliab le | |
138 | th is.FocusOn Modal(); | |
139 | }, | |
140 | Footer ModalHidde n: functio n (modalId ) { | |
141 | $( "header, # errorSecti on, #conte nt, .foote r-content, .scrollba r-gradient ").removeA ttr("aria- hidden"); | |
142 | $( "#" + moda lId).attr( "aria-hidd en", true) ; | |
143 | }, | |
144 | /** | |
145 | * For modals th at are emb edded in < main> as p art of the invoking view, | |
146 | * @pa ram modal - ID of th e modal be ing manipu lated | |
147 | * @pa ram focus - optional : the HTML element t o get focu s when mod al is dism issed; | |
148 | * can be either a CSS class name (if u nique) or an element ID; defau lt | |
149 | * to '.m odal-title ' if not p rovided | |
150 | */ | |
151 | SetMai nModal: fu nction (mo dal, focus ) { | |
152 | // on displa y | |
153 | $( modal).on( 'shown.bs. modal', fu nction () { | |
154 | $("heade r, #errorS ection, #m ain-conten t, footer, .scrollba r-gradient ").attr('a ria-hidden ', 'true') ; | |
155 | var targ et = focus ? focus : '.modal-t itle'; // default to .modal -title (us ually <h4> ) | |
156 | $(target ).focus(); | |
157 | }) ; | |
158 | ||
159 | // on dismis s | |
160 | $( modal).on( 'hidden.bs .modal', f unction () { | |
161 | $("heade r, #errorS ection, #m ain-conten t, footer, .scrollba r-gradient ").removeA ttr('aria- hidden'); | |
162 | }) ; | |
163 | }, | |
164 | /** | |
165 | * For modals th at are NOT part of s ame templa te as its invoking v iew, e.g. About, Hel p, | |
166 | * Tim eout, and EULA. Moda l code seg ment is en closed wit hin the .m odal-conta iner that is | |
167 | * out side of th e core ele ments (hea der, main, footer). See HTML s tructure i n layout.h tml. | |
168 | * @pa ram modal - The moda l ID (pref ixed with '#") or un ique CSS s elector (p refixed wi th '.') | |
169 | */ | |
170 | SetMod alContaine r: functio n (modal) { | |
171 | $( modal).on( 'shown.bs. modal', fu nction () { | |
172 | $("heade r, #errorS ection, #c ontent, fo oter, .scr ollbar-gra dient").at tr('aria-h idden', 't rue'); | |
173 | $(".moda l-title"). focus(); | |
174 | }) ; | |
175 | $( modal).on( 'hidden.bs .modal', f unction () { | |
176 | $("heade r, #errorS ection, #c ontent, fo oter, .scr ollbar-gra dient").re moveAttr(' aria-hidde n'); | |
177 | $(modal) .attr('ari a-hidden', 'true'); // hide t he modal | |
178 | }) ; | |
179 | }, | |
180 | /** | |
181 | * Def ault focus on modal display | |
182 | * @pa ram elemen t - the HT ML element to get fo cus; can b e either a CSS class name (if unique) | |
183 | * or an element ID ; default to '.modal -title' if not provi ded | |
184 | */ | |
185 | FocusO nModal: fu nction (el ement) { | |
186 | va r target = element ? element : '.modal-t itle'; // default to .modal -title (us ually <h4> ) | |
187 | $( target).fo cus(); | |
188 | }, | |
189 | /** | |
190 | * For the Selec t Report m enu | |
191 | * @pa ram contai ner - ID o f the list container unique to each view , e.g. #hi storyListC ontainer | |
192 | */ | |
193 | Select TitleMenu: function (appView, container) { | |
194 | va r _self = this; | |
195 | // On dropdo wn open | |
196 | $( '#titleMen u').on('sh own.bs.dro pdown', fu nction() { | |
197 | // Set a ria-expand ed to true | |
198 | $('#sele ctBtn').at tr('aria-e xpanded', true); | |
199 | ||
200 | // Set f ocus on th e first li nk in the dropdown | |
201 | // delay ed by 0.5 second to allow VO a nnouncemen t of expan ded state | |
202 | setTimeo ut(functio n() { | |
203 | $('# titleMenu .dropdown- menu li:fi rst-child a').focus( ); | |
204 | }, 500); | |
205 | ||
206 | // hide other elem ents | |
207 | _self.Se lectMenuOn ShownAria( appView, c ontainer); | |
208 | }) ; | |
209 | ||
210 | // On dropdo wn close | |
211 | $( '#titleMen u').on('hi dden.bs.dr opdown', f unction() { | |
212 | // Set a ria-expand ed to fals e | |
213 | $('#sele ctBtn').at tr('aria-e xpanded', false); | |
214 | ||
215 | // un-hi de other e lements | |
216 | _self.Se lectMenuOn HiddenAria (appView, container) ; | |
217 | }) ; | |
218 | }, | |
219 | ||
220 | /** | |
221 | * The elements to hide wh en user in teracts wi th the Sel ect Menu | |
222 | * @pa ram contai ner - ID o f the list container unique to each view | |
223 | * @pa ram appVie w - whethe r this fun ction is t riggered o n the Vete ran or Pro vider view . Elements to hide a re unique per view. | |
224 | */ | |
225 | Select MenuOnShow nAria: fun ction (app View, cont ainer) { | |
226 | if (appView == 'provid erView') { | |
227 | $('heade r, #errorS ection, .t itle-back- btn, #cont ent-title, #patientH eaderSecti on, footer , .scrollb ar-gradien t').attr(' aria-hidde n', 'true' ); | |
228 | $(contai ner).attr( 'aria-hidd en', 'true '); | |
229 | } else { // Veteran V iew | |
230 | $('heade r, #errorS ection, .t itle-back- btn, #cont ent-title, footer, . scrollbar- gradient') .attr('ari a-hidden', 'true'); | |
231 | $(contai ner).attr( 'aria-hidd en', 'true '); | |
232 | } | |
233 | }, | |
234 | /** | |
235 | * The elements to un-hide when user interacts with the Select Men u | |
236 | * @pa ram contai ner - ID o f the list container unique to each view | |
237 | * @pa ram appVie w - whethe r this fun ction is t riggered o n the Vete ran or Pro vider view . Elements to hide a re unique per view. | |
238 | */ | |
239 | Select MenuOnHidd enAria: fu nction (ap pView, con tainer) { | |
240 | if (appView == 'provid erView') { | |
241 | $('heade r, #errorS ection, .t itle-back- btn, #cont ent-title, #patientH eaderSecti on, footer , .scrollb ar-gradien t').remove Attr('aria -hidden'); | |
242 | $(contai ner).remov eAttr('ari a-hidden') ; | |
243 | } else { // Veteran V iew | |
244 | $('heade r, #errorS ection, .t itle-back- btn, #cont ent-title, footer, . scrollbar- gradient') .removeAtt r('aria-hi dden'); | |
245 | $(contai ner).remov eAttr('ari a-hidden') ; | |
246 | } | |
247 | }, | |
248 | ErrorH andling: f unction () { | |
249 | va r sync = B ackbone.sy nc; | |
250 | Ba ckbone.syn c = functi on (method , model, o ptions) { | |
251 | var erro r = option s.error; | |
252 | options. error = fu nction (xh r, statusT xt, thrown ) { | |
253 | cons ole.log('I n global e rror handl er. key=' + model.ke y + ' XHR' , xhr); | |
254 | cons ole.log('e rror: ' + statusTxt) ; | |
255 | if ( !VPC.View. Header) {/ /early err ors before full star t | |
256 | VPC.Layout .header.sh ow(VPC.Vie w.Header = new VPC.V iew.header ()); | |
257 | } | |
258 | if ( xhr.status === 401) { | |
259 | //User in not authen ticated | |
260 | App_Utils. VAMFLogout (); | |
261 | ||
262 | if (App.de bug) { | |
263 | if (mo del.key == = "Last Ac cessed Tim e") { | |
264 | cl earInterva l(App.Keep AliveInter val); //st op the loo p for heav ens sake | |
265 | } | |
266 | } | |
267 | /* if (mod el.key === "Last Acc essed Time ") { | |
268 | clearInte rval(App.K eepAliveIn terval); / /stop the loop for h eavens sak e | |
269 | } | |
270 | else { | |
271 | App.login Utils.chec kForAuthCo de(); | |
272 | }*/ | |
273 | } | |
274 | if ( xhr.status === 404 & & model.ke y === "Rig ht of Acce ss") { | |
275 | //User has not accep ted Right of Access, redirect so they ca n be promp ted. | |
276 | App_Utils. ROARedirec t(); | |
277 | } | |
278 | /* | |
279 | else if (xhr.s tatus == 4 04 && (mod el.key == "Reminder" || model. key == 'Mo nthly Asse ssment' || model.key == 'Pain Diary')) { | |
280 | // ignore | |
281 | //return; | |
282 | App.vent.t rigger('ig nore:error '); | |
283 | } | |
284 | else if (xhr.s tatusText == 'Not Fo und' && (m odel.key = = 'Monthly Assessmen t' || mode l.key == ' Pain Diary ')) { | |
285 | // ignore | |
286 | //return; | |
287 | App.vent.t rigger('ig nore:error '); | |
288 | } | |
289 | else if (xhr.s tatusText == 'Not Fo und' && mo del.key == 'Monthly Assessment s') { | |
290 | App.vent.t rigger('as sessments: missing'); | |
291 | } | |
292 | else if (xhr.s tatusText == 'Not Fo und' && mo del.key == 'Pain Dia ries') { | |
293 | // ignore | |
294 | App.vent.t rigger('da ily:missin g'); | |
295 | } | |
296 | else if (xhr.s tatusText == 'Not Fo und' && mo del.key == 'Latest M onthly') { | |
297 | App.vent.t rigger("la test-month ly:loaded" , undefine d); | |
298 | } | |
299 | else if (xhr.s tatusText == 'Not Fo und' && mo del.key == 'Latest D aily') { | |
300 | App.vent.t rigger("la test-daily :loaded", undefined) ; | |
301 | } | |
302 | else if (xhr.s tatusText == 'Not Fo und' && mo del.key == 'Activity Pacing') { | |
303 | App.vent.t rigger("ap :load-erro r"); | |
304 | } | |
305 | else if (xhr.s tatus == 4 04 && (mod el.key == "Monthly A ssessments " || model .key == "A ssessments ")) { | |
306 | //Pass err or to mode l | |
307 | error(xhr, statusTxt , null); | |
308 | } | |
309 | */ | |
310 | else if (model .key == 'r esource-di rectory-pv s' || mode l.key == ' resource-d irectory-v pc') { | |
311 | App.vent.t rigger('re sources:fa iled', mod el.key); | |
312 | } | |
313 | else { | |
314 | //Broadcas t model er ror | |
315 | App.vent.t rigger(((m odel.key ? model.key : "genera l") + ":fa iled"), { model: mod el, xhr: x hr }); | |
316 | //Let form at this fo r a human | |
317 | App_Utils. FormatErro rMSG(model , xhr); | |
318 | //Pass err or to mode l | |
319 | error(xhr, statusTxt , thrown); | |
320 | } | |
321 | }; | |
322 | sync(met hod, model , options) ; | |
323 | }; | |
324 | }, | |
325 | Format ErrorMSG: function ( model, xhr ) { | |
326 | va r key, res , status, statustext , msg, dev msg; | |
327 | ke y = res = status = s tatustext = msg = '' ; | |
328 | ke y = model. key ? mode l.key : "" ; | |
329 | if (xhr.resp onseJSON) { | |
330 | res = xh r.response JSON.devel operMessag e ? xhr.re sponseJSON .developer Message : ""; | |
331 | devmsg = xhr.respo nseJSON.me ssage ? xh r.response JSON.messa ge : ""; | |
332 | } | |
333 | ||
334 | st atus = xhr .status ? xhr.status : "No sta tus"; | |
335 | st atustext = xhr.statu sText ? xh r.statusTe xt : "No s tatus text "; | |
336 | ms g = key + " encounte red the fo llowing er ror: " + r es + " (St atus: " + status + " / " + sta tustext+") " + devms g; | |
337 | Ap p.vent.tri gger('webs ite:error' , msg); | |
338 | }, | |
339 | BackBu tton: func tion () { | |
340 | // first loo k for back button on page | |
341 | va r backButt on = $('a. back'); | |
342 | va r backButt on2 = $('a .back'); | |
343 | va r backButt on3 = $('b utton .bac k'); | |
344 | if (backButt on.length == 1) { | |
345 | // if fo und, click it | |
346 | backButt on.click() ; | |
347 | } | |
348 | el se if (bac kButton2.l ength == 1 ) { | |
349 | backButt on2.click( ); | |
350 | } | |
351 | el se if (bac kButton3.l ength === 1) { | |
352 | backButt on3.click( ); | |
353 | } | |
354 | el se { | |
355 | window.h istory.bac k(); | |
356 | } | |
357 | }, | |
358 | RightO fAccess: f unction () { | |
359 | // console.lo g("RightOf Access " + App.debug ); | |
360 | // if (App.de bug) { / / bypass i f running locally | |
361 | // App.ve nt.trigger ('roa:acce pted'); | |
362 | // } | |
363 | // else { | |
364 | // store old value of emulate | |
365 | va r oldEmula teHTTP = B ackbone.em ulateHTTP; | |
366 | Ba ckbone.emu lateHTTP = true; | |
367 | VP C.Model.RO A = new VP C.Model.ro a; | |
368 | VP C.Model.RO A.fetch({ | |
369 | success: function (model, re sponse) { | |
370 | //co nsole.log( "ROA succe ss"); | |
371 | resp onse.right OfAccessAc cepted ? A pp.vent.tr igger('roa :accepted' ) : App_Ut ils.ROARed irect(); | |
372 | }, | |
373 | error: f unction (m odel, resp onse, opti ons) { | |
374 | //co nsole.log( "ROA faile d"); | |
375 | if ( response.s tatus == 2 00) { | |
376 | response.r ightOfAcce ssAccepted ? App.ven t.trigger( 'roa:accep ted') : Ap p_Utils.RO ARedirect( ); | |
377 | } | |
378 | } | |
379 | }) ; | |
380 | Ba ckbone.emu lateHTTP = oldEmulat eHTTP; // reset bac k to old v alue after fetch | |
381 | // } | |
382 | }, | |
383 | /* | |
384 | ROARe direct: fu nction () { | |
385 | var u rl = App_U tils.GetDo mainPath() + 'Mobile HealthPlat formWeb/ro a/index.ht ml?url=' + App_Utils .GetDomain Path()+"rx -refill/"; | |
386 | conso le.log("Re directing to roa sit e " + url) ; | |
387 | windo w.location = encodeU RI(url); | |
388 | }, | |
389 | */ | |
390 | ROARed irect: fun ction () { | |
391 | // App_Utils. SetRequest Header(); | |
392 | //var temp Url = 'htt ps:// URL /MobileHea lthPlatfor mWeb/roa/i ndex.html? url=https: // URL /mhpro/'; | |
393 | va r tempUrl = App_Util s.GetDomai nPath() + 'MobileHea lthPlatfor mWeb/roa/i ndex.html? url=' + Ap p_Utils.Ge tDomainPat h() + 'pai ncoach/'; | |
394 | va r urlx = encodeURI( tempUrl); | |
395 | ||
396 | // roaWindow = cordova. InAppBrows er.open(ur lx, '_blan k', 'locat ion=no,too lbar=no'); | |
397 | ro aWindow = cordova.In AppBrowser .open(urlx , '_blank' , 'locatio n=no,toolb ar=no,clos ebuttoncap tion="",' + | |
398 | 'suppres sesIncreme ntalRender ing=yes'); | |
399 | ||
400 | va r pathName ; | |
401 | ||
402 | ro aWindow.ad dEventList ener('load start', fu nction(eve nt) { | |
403 | ||
404 | App_Util s.setRemot eReqHeader (); | |
405 | App_Util s.setRemot eEULA(); | |
406 | ||
407 | var xurl = event.u rl; | |
408 | var urlP arser = do cument.cre ateElement ('a'); | |
409 | urlParse r.href = x url; | |
410 | ||
411 | pathName = urlPars er.pathnam e; | |
412 | pathName = pathNam e.replace( /\//g, '') ; | |
413 | ||
414 | // alert ('loadstar t -> url: ' + event. url + '\np athname: ' + pathNam e); | |
415 | ||
416 | var hash Value = xu rl.split(' #')[1]; | |
417 | if (hash Value) { | |
418 | if( hashValue === 'form- review'){ | |
419 | submitRoa = true; | |
420 | }el se{ | |
421 | submitRoa = false; | |
422 | } | |
423 | } | |
424 | ||
425 | // alert ('pathname : ' + urlP arser.path name + '<b r>\ -> pat hName: ' + pathName + ' <br>\ Token: ' + App_Utils .GetSessio nToken()); | |
426 | //consol e.log(xurl ); | |
427 | ||
428 | if (subm itRoa && p athName == = 'paincoa ch'){ | |
429 | VPC. Data.Track ing.isRoaA ccepted = true; | |
430 | VPC. Data.Track ing.isUser PressedCan celOnROA = false; | |
431 | //ro aWindow.cl ose(); | |
432 | App. vent.trigg er('roa:cl ose'); | |
433 | //Ap p.vent.tri gger('iab: close'); | |
434 | App. vent.trigg er('load:u ser', { in it: true } ); | |
435 | } | |
436 | ||
437 | if (path Name === ' launchpad' ){ | |
438 | //al ert('direc t to launc hpad'); | |
439 | VPC. Data.Track ing.isRoaA ccepted = false; | |
440 | VPC. Data.Track ing.isUser PressedCan celOnROA = true; | |
441 | App_ Utils.remo veRemoteRe qHeader(); | |
442 | App_ Utils.remo veRemoteEU LA(); | |
443 | App. vent.trigg er('roa:cl ose'); | |
444 | //MH PRO.View.h eader.logo ut(); | |
445 | //Ap p_Utils.Er rorHandlin g(); | |
446 | App. vent.trigg er('load:u ser', { in it: true } ); | |
447 | ||
448 | //va r msg = 'P lease acce pt ROA con ditions to continue using the applicatio n.'; | |
449 | //Ap p.vent.tri gger('webs ite:error' , msg); | |
450 | } | |
451 | ||
452 | }) ; | |
453 | ||
454 | ro aWindow.ad dEventList ener('load stop', fun ction(even t) { | |
455 | //consol e.log('loa dstop: ' + event.url ); | |
456 | //if (ev ent.url.in dexOf('#fo rm-review' ) > 0) { | |
457 | // su bmitRoa = true; | |
458 | //} | |
459 | }) ; | |
460 | ||
461 | Ap p.vent.on( 'roa:close ', functio n(){ | |
462 | roaWindo w.close(); | |
463 | }) ; | |
464 | ||
465 | Ap p.vent.on( 'roa:exit' , function (){ | |
466 | //alert( '......roa ...exit'); | |
467 | }) ; | |
468 | }, | |
469 | setRem oteReqHead er: functi on(){ | |
470 | ro aWindow.ex ecuteScrip t( | |
471 | {code : "xhr.setRe questHeade r('Authori zation', ' Bearer '" + App_Util s.GetSessi onToken() + ");"}, | |
472 | function (data){ | |
473 | if(d ata){} | |
474 | }); | |
475 | }, | |
476 | setRem oteEULA: f unction(){ | |
477 | ro aWindow.ex ecuteScrip t({code : "localStor age.setIte m('VPC_Eul a', " + Ap p_Utils.Ge tLocalStor age('VPC_E ula') + ") ;"}, | |
478 | function (data){ | |
479 | if(d ata){} | |
480 | }); | |
481 | }, | |
482 | remove RemoteReqH eader: fun ction(){ | |
483 | ro aWindow.ex ecuteScrip t( | |
484 | {code : "sessionSt orage.setI tem('token ', null);" }, | |
485 | function (data){ | |
486 | if(d ata){} | |
487 | }); | |
488 | }, | |
489 | remove RemoteEULA : function (){ | |
490 | ro aWindow.ex ecuteScrip t( | |
491 | {code : "localStor age.remove Item('VPC_ Eula');"}, | |
492 | function (data){ | |
493 | if(d ata){} | |
494 | }); | |
495 | }, | |
496 | GetLoc alStorage: function (key) { | |
497 | re turn local Storage.ge tItem(key) ; | |
498 | }, | |
499 | SetLoc alStorage: function (key, valu e) { | |
500 | lo calStorage .setItem(k ey, JSON.s tringify(v alue)); | |
501 | }, | |
502 | Delete LocalStora ge: functi on (key) { | |
503 | lo calStorage .removeIte m(key); | |
504 | }, | |
505 | Cookie Exists: fu nction (co okieName) { | |
506 | re turn docum ent.cookie .indexOf(c ookieName) > 0; | |
507 | }, | |
508 | Delete Cookie: fu nction (co okieName) { | |
509 | do cument.coo kie = enco deURICompo nent(cooki eName) + " =deleted; expires=" + new Date (0).toUTCS tring(); | |
510 | }, | |
511 | SetSes sionToken: function (name, val ue) { | |
512 | va lue = valu e.replace( /"/g, ""). replace(/' /g, ""); | |
513 | se ssionStora ge.setItem (name, '"' + value.t oString() +'"'); | |
514 | }, | |
515 | ClearS essionToke n: functio n (name) { | |
516 | se ssionStora ge.setItem (name, nul l); | |
517 | }, | |
518 | Retrie veToken: f unction (n ame) { | |
519 | va r token = sessionSto rage.getIt em(name); | |
520 | if (token != 'null' && token != null) { | |
521 | return t oken.repla ce(/"/g, " "); | |
522 | } | |
523 | el se { retur n null; } | |
524 | }, | |
525 | GetSes sionToken: function () { | |
526 | re turn App_U tils.Retri eveToken(' token'); | |
527 | }, | |
528 | GetMHV Token: fun ction () { | |
529 | re turn App_U tils.Retri eveToken(' mhvToken') ; | |
530 | }, | |
531 | AppCle anup: func tion () { | |
532 | // console.lo g("In appU tils.appCl eanup...") ; | |
533 | if (App_Util s.GetSessi onToken() != null) { | |
534 | VPC.Mode l.DeleteTo ken = new VPC.Model. deleteToke n(); | |
535 | VPC.Mode l.DeleteTo ken.destro y({ | |
536 | data Type: "tex t", | |
537 | cont entType: f alse, | |
538 | proc essData: f alse, | |
539 | comp lete: func tion (mode l, respons e) { | |
540 | App.vent.t rigger('to ken:delete d'); | |
541 | } | |
542 | }); | |
543 | App_Util s.ClearSes sionToken( 'token'); | |
544 | App_Util s.ClearSes sionToken( 'mhvToken' ); | |
545 | } | |
546 | el se { | |
547 | App.vent .trigger(' token:dele ted'); | |
548 | } | |
549 | Ap p.vent.on( 'token:del eted', fun ction (dat a) { | |
550 | //consol e.log("tok en deleted ..."); | |
551 | if (App_ Utils.Cook ieExists(' JSESSIONID ')) { | |
552 | App_ Utils.Dele teCookie(' JSESSIONID '); | |
553 | App. vent.trigg er('cookie :deleted') ; | |
554 | } | |
555 | else { A pp.vent.tr igger('coo kie:delete d'); } | |
556 | App.vent .trigger(' AppCleanup :complete' ); | |
557 | }) ; | |
558 | }, | |
559 | GetUrl Parameter: function (sParam) { | |
560 | va r sPageURL = window. location.s earch.subs tring(1); | |
561 | va r sURLVari ables = sP ageURL.spl it('&'); | |
562 | fo r (var i = 0; i < sU RLVariable s.length; i++) | |
563 | { | |
564 | var sPar ameterName = sURLVar iables[i]. split('=') ; | |
565 | if (sPar ameterName [0] == sPa ram) | |
566 | { | |
567 | retu rn sParame terName[1] ; | |
568 | } | |
569 | } | |
570 | }, | |
571 | SetUrl : function () { | |
572 | va r url = wi ndow.locat ion.href; | |
573 | ur l = url.sl ice(0, url .indexOf(' ?')); | |
574 | ur l = encode URI(url); | |
575 | re turn url; | |
576 | }, | |
577 | Return ToLaunchpa d: functio n () { | |
578 | // Redirect b ack to Lau nchpad her e. | |
579 | wi ndow.locat ion = App_ Utils.GetD omainPath( ) + "launc hpad"; | |
580 | }, | |
581 | Launch padLogin: function ( ) { | |
582 | // Redirect b ack to Lau nchpad Log in. User i s not logg edin | |
583 | if (App.debu g) { | |
584 | console. log("Redir ect back t o Launchpa d Login.") | |
585 | console. log(VPC.Re sources.HA Resources. get('oauth -login').t oJSON().hr ef + '?&re direct_uri =' + App_U tils.GetRe ferencePat h() + 'pai ncoach/') | |
586 | } | |
587 | el se { windo w.location = VPC.Res ources.HAR esources.g et('oauth- login').to JSON().hre f + '?&red irect_uri= ' + App_Ut ils.GetRef erencePath (); } | |
588 | ||
589 | }, | |
590 | VAMFLo gout: func tion () { | |
591 | va r url = "" ; | |
592 | if (VPC.Data .app.appCo nfig.prod) { | |
593 | // For veteran in pre-produ ction and production environme nts, a log out page h as to be s et up with VAAFI tea m. Once th e page is set up, th e client w ill use an endpoint similar to : | |
594 | // http s://<auth- environmen t-address> /pkmslogou t?filename =app-x-log out.html | |
595 | url = Ap p_Utils.Ge tDomainPat h() + 'pkm slogout?fi lename=mbb -logout.ht ml'; | |
596 | } | |
597 | el se { | |
598 | // For veteran in developme nt environ ments: | |
599 | // http s://<envir onment-add ress>/ssoe proxy/logo ut | |
600 | ||
601 | // A re direct_uri parameter may be sp ecified in developme nt to redi rect the b rowser aft er a succe ssful logo ut: | |
602 | // http s://<envir onment-add ress>/ssoe proxy/logo ut?redirec t_uri=(you r app home page) | |
603 | url = Ap p_Utils.Ge tDomainPat h() + 'sso eproxy/log out' + '?' + new Dat e().getTim e() + '&re direct_uri =' + App_U tils.GetDo mainPath() + 'painco ach/'; | |
604 | } | |
605 | // window.loc ation = ur l; | |
606 | ||
607 | $. ajax({ | |
608 | url: url , | |
609 | async: f alse, | |
610 | success: function (response) { | |
611 | var url = ""; | |
612 | wind ow.locatio n.replace( url); | |
613 | App. start(); | |
614 | } | |
615 | }) ; | |
616 | }, | |
617 | ||
618 | /** | |
619 | * For modals in side the . modal-cont ainer div, e.g. EULA , Timeout, Exit, Pre scription successful ly refille d | |
620 | */ | |
621 | ModalC ontainerSh own: funct ion (eleme nt) { | |
622 | $( "header, m ain, foote r, .scroll bar-gradie nt").attr( "aria-hidd en", "true "); | |
623 | th is.FocusOn Modal(elem ent); | |
624 | }, | |
625 | ModalC ontainerHi dden: func tion () { | |
626 | $( "header, m ain, foote r, .scroll bar-gradie nt").remov eAttr("ari a-hidden") ; | |
627 | }, | |
628 | /** | |
629 | * For the Sort menu/subme nu | |
630 | */ | |
631 | SetSor t: functio n () { | |
632 | va r _self = this; | |
633 | // On dropdo wn open | |
634 | $( '#sortMenu ').on('sho wn.bs.drop down', fun ction() { | |
635 | // Set a ria-expand ed to true | |
636 | $('#sort Btn').attr ('aria-exp anded', tr ue); | |
637 | ||
638 | // Set f ocus on th e first li nk in the dropdown | |
639 | // delay ed by 0.5 second to allow VO a nnouncemen t of expan ded state | |
640 | setTimeo ut(functio n() { | |
641 | $('# sortMenu . dropdown-m enu li:fir st-child a ').focus() ; | |
642 | }, 500); | |
643 | ||
644 | // hide other elem ents | |
645 | $('heade r, #errorS ection, .s ort-hide, footer, .s crollbar-g radient'). attr('aria -hidden', 'true'); | |
646 | }) ; | |
647 | ||
648 | // On dropdo wn close | |
649 | $( '#sortMenu ').on('hid den.bs.dro pdown', fu nction() { | |
650 | // Set a ria-expand ed to fals e | |
651 | $('#sort Btn').attr ('aria-exp anded', fa lse); | |
652 | ||
653 | // un-hi de other e lements | |
654 | $('heade r, #errorS ection, .s ort-hide, footer, .s crollbar-g radient'). removeAttr ('aria-hid den'); | |
655 | }) ; | |
656 | }, | |
657 | Initia lizeAffix: function (element) { | |
658 | $( element).a ffix({ | |
659 | offset: { | |
660 | top: function () { | |
661 | return ( t his.top = $(element) .offset(). top ); // this retur ns whateve r is set i n data-off set-top in html | |
662 | } | |
663 | } | |
664 | }) ; | |
665 | } | |
666 | }; |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.