comparison OrthancExplorer/explorer.js @ 482:b05eb8708aee

fix history in Orthanc Explorer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 16 Jul 2013 11:30:24 +0200
parents be93b666ed79
children b8ace6fc1d1f
comparison
equal deleted inserted replaced
481:4f5b4b0fa626 482:b05eb8708aee
9 9
10 // http://jquerymobile.com/demos/1.1.0/docs/api/globalconfig.html 10 // http://jquerymobile.com/demos/1.1.0/docs/api/globalconfig.html
11 //$.mobile.ajaxEnabled = false; 11 //$.mobile.ajaxEnabled = false;
12 //$.mobile.page.prototype.options.addBackBtn = true; 12 //$.mobile.page.prototype.options.addBackBtn = true;
13 //$.mobile.defaultPageTransition = 'slide'; 13 //$.mobile.defaultPageTransition = 'slide';
14
15
16 var currentPage = '';
17 var currentUuid = '';
18
14 19
15 // http://stackoverflow.com/a/4673436 20 // http://stackoverflow.com/a/4673436
16 String.prototype.format = function() { 21 String.prototype.format = function() {
17 var args = arguments; 22 var args = arguments;
18 return this.replace(/{(\d+)}/g, function(match, number) { 23 return this.replace(/{(\d+)}/g, function(match, number) {
361 if ('AnonymizedFrom' in resource) 366 if ('AnonymizedFrom' in resource)
362 { 367 {
363 $(buttonSelector).closest('li').show(); 368 $(buttonSelector).closest('li').show();
364 $(buttonSelector).click(function(e) { 369 $(buttonSelector).click(function(e) {
365 window.location.assign('explorer.html#' + resourceType + '?uuid=' + resource.AnonymizedFrom); 370 window.location.assign('explorer.html#' + resourceType + '?uuid=' + resource.AnonymizedFrom);
366 window.location.reload(); 371 //window.location.reload();
367 }); 372 });
368 } 373 }
369 else 374 else
370 { 375 {
371 $(buttonSelector).closest('li').hide(); 376 $(buttonSelector).closest('li').hide();
372 } 377 }
373 } 378 }
374 379
375 380
376 $('#patient').live('pagebeforeshow', function() { 381 function RefreshPatient()
382 {
377 if ($.mobile.pageData) { 383 if ($.mobile.pageData) {
378 GetSingleResource('patients', $.mobile.pageData.uuid, function(patient) { 384 GetSingleResource('patients', $.mobile.pageData.uuid, function(patient) {
379 GetMultipleResources('studies', patient.Studies, function(studies) { 385 GetMultipleResources('studies', patient.Studies, function(studies) {
380 SortOnDicomTag(studies, 'StudyDate', false, true); 386 SortOnDicomTag(studies, 'StudyDate', false, true);
381 387
412 success: function (s) { 418 success: function (s) {
413 var v = (s == '1') ? 'on' : 'off'; 419 var v = (s == '1') ? 'on' : 'off';
414 $('#protection').val(v).slider('refresh'); 420 $('#protection').val(v).slider('refresh');
415 } 421 }
416 }); 422 });
423
424 currentPage = 'patient';
425 currentUuid = $.mobile.pageData.uuid;
417 }); 426 });
418 }); 427 });
419 } 428 }
420 }); 429 }
421 430
422 431
423 $('#study').live('pagebeforeshow', function() { 432 function RefreshStudy()
433 {
424 if ($.mobile.pageData) { 434 if ($.mobile.pageData) {
425 GetSingleResource('studies', $.mobile.pageData.uuid, function(study) { 435 GetSingleResource('studies', $.mobile.pageData.uuid, function(study) {
426 GetSingleResource('patients', study.ParentPatient, function(patient) { 436 GetSingleResource('patients', study.ParentPatient, function(patient) {
427 GetMultipleResources('series', study.Series, function(series) { 437 GetMultipleResources('series', study.Series, function(series) {
428 SortOnDicomTag(series, 'SeriesDate', false, true); 438 SortOnDicomTag(series, 'SeriesDate', false, true);
447 (FormatDicomDate(series[i].MainDicomTags.SeriesDate))); 457 (FormatDicomDate(series[i].MainDicomTags.SeriesDate)));
448 } 458 }
449 target.append(FormatSeries(series[i], '#series?uuid=' + series[i].ID)); 459 target.append(FormatSeries(series[i], '#series?uuid=' + series[i].ID));
450 } 460 }
451 target.listview('refresh'); 461 target.listview('refresh');
462
463 currentPage = 'study';
464 currentUuid = $.mobile.pageData.uuid;
452 }); 465 });
453 }); 466 });
454 }); 467 });
455 } 468 }
456 }); 469 }
457 470
458 471
459 $('#series').live('pagebeforeshow', function() { 472 function RefreshSeries()
473 {
460 if ($.mobile.pageData) { 474 if ($.mobile.pageData) {
461 GetSingleResource('series', $.mobile.pageData.uuid, function(series) { 475 GetSingleResource('series', $.mobile.pageData.uuid, function(series) {
462 GetSingleResource('studies', series.ParentStudy, function(study) { 476 GetSingleResource('studies', series.ParentStudy, function(study) {
463 GetSingleResource('patients', study.ParentPatient, function(patient) { 477 GetSingleResource('patients', study.ParentPatient, function(patient) {
464 GetMultipleResources('instances', series.Instances, function(instances) { 478 GetMultipleResources('instances', series.Instances, function(instances) {
483 $('li', target).remove(); 497 $('li', target).remove();
484 for (var i = 0; i < instances.length; i++) { 498 for (var i = 0; i < instances.length; i++) {
485 target.append(FormatInstance(instances[i], '#instance?uuid=' + instances[i].ID)); 499 target.append(FormatInstance(instances[i], '#instance?uuid=' + instances[i].ID));
486 } 500 }
487 target.listview('refresh'); 501 target.listview('refresh');
502
503 currentPage = 'series';
504 currentUuid = $.mobile.pageData.uuid;
488 }); 505 });
489 }); 506 });
490 }); 507 });
491 }); 508 });
492 } 509 }
493 }); 510 }
494 511
495 512
496 513
497 function ConvertForTree(dicom) 514 function ConvertForTree(dicom)
498 { 515 {
543 560
544 return result; 561 return result;
545 } 562 }
546 563
547 564
548 $('#instance').live('pagebeforeshow', function() { 565 function RefreshInstance()
566 {
549 if ($.mobile.pageData) { 567 if ($.mobile.pageData) {
550 GetSingleResource('instances', $.mobile.pageData.uuid, function(instance) { 568 GetSingleResource('instances', $.mobile.pageData.uuid, function(instance) {
551 GetSingleResource('series', instance.ParentSeries, function(series) { 569 GetSingleResource('series', instance.ParentSeries, function(series) {
552 GetSingleResource('studies', series.ParentStudy, function(study) { 570 GetSingleResource('studies', series.ParentStudy, function(study) {
553 GetSingleResource('patients', study.ParentPatient, function(patient) { 571 GetSingleResource('patients', study.ParentPatient, function(patient) {
575 success: function(s) { 593 success: function(s) {
576 $('#dicom-tree').tree('loadData', ConvertForTree(s)); 594 $('#dicom-tree').tree('loadData', ConvertForTree(s));
577 } 595 }
578 }); 596 });
579 597
598 currentPage = 'instance';
599 currentUuid = $.mobile.pageData.uuid;
580 }); 600 });
581 }); 601 });
582 }); 602 });
583 }); 603 });
584 } 604 }
585 }); 605 }
606
607 $(document).live('pagebeforehide', function() {
608 currentPage = '';
609 currentUuid = '';
610 });
611
612
613
614 $('#patient').live('pagebeforeshow', RefreshPatient);
615 $('#study').live('pagebeforeshow', RefreshStudy);
616 $('#series').live('pagebeforeshow', RefreshSeries);
617 $('#instance').live('pagebeforeshow', RefreshInstance);
618
619 $(function() {
620 $(window).hashchange(function(e, data) {
621 // This fixes the navigation with the back button and with the anonymization
622 if ('uuid' in $.mobile.pageData &&
623 currentPage == $.mobile.pageData.active &&
624 currentUuid != $.mobile.pageData.uuid) {
625 if (currentPage == 'patient')
626 RefreshPatient();
627 else if (currentPage == 'study')
628 RefreshStudy();
629 else if (currentPage == 'series')
630 RefreshSeries();
631 else if (currentPage == 'instance')
632 RefreshInstance();
633 }
634 });
635 });
636
637
586 638
587 639
588 640
589 function DeleteResource(path) 641 function DeleteResource(path)
590 { 642 {
861 success: function(s) { 913 success: function(s) {
862 // The following line does not work... 914 // The following line does not work...
863 //$.mobile.changePage('explorer.html#patient?uuid=' + s.PatientID); 915 //$.mobile.changePage('explorer.html#patient?uuid=' + s.PatientID);
864 916
865 window.location.assign('explorer.html#patient?uuid=' + s.PatientID); 917 window.location.assign('explorer.html#patient?uuid=' + s.PatientID);
866 window.location.reload(); 918 //window.location.reload();
867 } 919 }
868 }); 920 });
869 }, 921 },
870 icon: "delete", 922 icon: "delete",
871 theme: "c" 923 theme: "c"