134. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 3/25/2019 8:58:09 AM 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.

134.1 Files compared

# Location File Last Modified
1 C:\AraxisMergeCompare\Pri_un\IMAG_VIX\common\ZFViewerServices\ViewerRender-2.2.6968.19079\VIX.Viewer.Service\Viewer\js\dash dash.js Tue Jan 29 15:43:40 2019 UTC
2 C:\AraxisMergeCompare\Pri_re\IMAG_VIX\common\ZFViewerServices\ViewerRender-2.2.6968.19079\VIX.Viewer.Service\Viewer\js\dash dash.js Tue Mar 19 19:06:48 2019 UTC

134.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 6960
Changed 1 2
Inserted 0 0
Removed 0 0

134.3 Comparison options

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

134.4 Active regular expressions

No regular expressions were active.

134.5 Comparison detail

  1   /**
  2    * Admin P references  file
  3    */
  4  
  5   var dicomV iewer = (f unction (d icomViewer ) {
  6  
  7       if (di comViewer  === undefi ned) {
  8           di comViewer  = {};
  9       }
  10  
  11       var MT _TypeCol =  [];
  12       var MT _EX_TypeCo l = [];
  13       var MT _Lbl_Col =  [];
  14       var MT _PS_TypeCo l = [];
  15       var ci nePreferen ce = {};
  16       var ec gPreferenc e = {};
  17       var di splayPrefe rence = {} ;
  18       var co pyAttribut esPreferen ce = {};
  19       var an notationPr eference =  {};
  20       var lo gPreferenc e = {};
  21  
  22       MT_PS_ TypeCol =  ["LENGTH",  "LINE", " ARROW", "P OINT", "AN GLE", "ELL IPSE", "HO UNSFIELDEL LIPSE", "R ECT", "HOU NSFIELDREC T", "TEXT" , "TRACE",  "MG", "AS PV", "ARPV ", "MRPV",  "ARL", "M RL", "MVAL T", "FREEH AND", "PEN ", "LBLANN OTATION",  "LBLOVERLA Y", "LBLOR IENTATION" , "LBLSCOU T", "LBLRU LER"];
  23  
  24       MT_Typ eCol = [
  25           "A NNOTATION" , "MEASURE MENT", "EL LIPSE & RE CTANGLE",  "LABEL", " TEXT", "MI TRAL & AOR TIC (US)"
  26       ];
  27  
  28       MT_EX_ TypeCol["A NNOTATION" ] = [
  29           "A STROKESTYL E", "LINE" , "ARROW"
  30       ];
  31  
  32       MT_EX_ TypeCol["M EASUREMENT "] = [
  33           "M STROKESTYL E", "LENGT H", "ANGLE ",
  34       ];
  35  
  36       MT_EX_ TypeCol["E LLIPSE & R ECTANGLE"]  = [
  37           "E RSTROKESTY LE", "HOUN SFIELD"
  38       ];
  39  
  40       MT_EX_ TypeCol["L ABEL"] = [
  41           "L ABEL"
  42       ];
  43  
  44       MT_EX_ TypeCol["T EXT"] = [
  45           "T EXT"
  46       ];
  47  
  48       MT_EX_ TypeCol["M ITRAL & AO RTIC (US)" ] = [
  49           "M A", "MITRA L", "AORTI C"
  50       ];
  51  
  52       MT_Lbl _Col = [
  53           "L BLANNOTATI ON", "LBLO VERLAY", " LBLORIENTA TION", "LB LSCOUT", " LBLRULER"
  54       ];
  55  
  56       MODALI TY = [
  57           'U S', 'CT'
  58       ];
  59  
  60  
  61       var sy stemMeasur ementStyle  = {
  62           li neColor: " #00FFFF",
  63           li neWidth: 1 ,
  64           fo ntName: "A rial",
  65           fo ntSize: 12 ,
  66           te xtColor: " #FFFF00",
  67           is Bold: fals e,
  68           is Italic: tr ue,
  69           is Underlined : false,
  70           is Strikeout:  false,
  71           is Fill: fals e,
  72           fi llColor: " #00FFFF",
  73           ga ugeLength:  7,
  74           ga ugeStyle:  "Line",
  75           pr ecision: 2 ,
  76           me asurementU nits: "cm" ,
  77           ar cRadius: 2 0
  78       };
  79  
  80       var de faultCineP reference  = {
  81           pa lyselectio n: 'Stack' ,
  82           ti mesToRepea t: 1,
  83           fr amesToRepe at: 2,
  84           id leTime: 1
  85       };
  86       var de faultEcgPr eference =  {
  87           le adType: '3 x4+3',
  88           fi rstSignal:  "II",
  89           se condSignal : "V2",
  90           th irdSignal:  "V5",
  91           si gnalValue:  "II"
  92       };
  93       var de faultAnnot ationPrefe rence = {
  94  
  95       };
  96       var de faultDispl ayPreferen ce = {
  97  
  98       };
  99       var sy sDisplayPr eference =  {
  100  
  101       };
  102       var de faultCopyA ttributesP reference  = {
  103           wi ndowLevel:  true,
  104           br ightnessCo ntrast: tr ue,
  105           sc ale: true,
  106           in vert: true ,
  107           or ientation:  true,
  108           pa n: false
  109       };
  110       var de faultLogPr eference =  {
  111           lo gLevel: "I nfo",
  112           li neLimit: " 1000",
  113           ke ys: "CTRL+ I"
  114       };
  115  
  116       $.each (MT_PS_Typ eCol, func tion (key,  value) {
  117           se tDefaultAn notationPr eferenceBy Type(value , true, sy stemMeasur ementStyle );
  118       });
  119  
  120       $.each (MODALITY,  function  (key, valu e) {
  121           se tDefaultLa youtPrefer encesByMod ality(valu e);
  122       });
  123  
  124       /**
  125        *Set  the defaul t annotati on prefere nce by typ e
  126        */
  127       functi on setDefa ultAnnotat ionPrefere nceByType( type, useD efault, st yleCol) {
  128           tr y {
  129                if (defa ultAnnotat ionPrefere nce === un defined ||  defaultAn notationPr eference = == null) {
  130                    defa ultAnnotat ionPrefere nce = {};
  131                }
  132                var meas urementSty le = {
  133                    useD efault: us eDefault,
  134                    styl eCol: styl eCol
  135                };
  136  
  137                defaultA nnotationP reference[ "" + type  + ""] = me asurementS tyle;
  138           }  catch (e)  {}
  139       }
  140  
  141       /**
  142        * Sen d study qu ery reques t to get S ecurityTok en, AuthSi teNumber a nd SiteNum ber
  143        * @pa ram {Type}   
  144        */
  145       functi on studyQu eryRequest () {
  146  
  147       }
  148  
  149       /**
  150        *Set  the defaul t layout p reference  by modalit y
  151        */
  152       functi on setDefa ultLayoutP references ByModality (modality)  {
  153           tr y {
  154                if (defa ultDisplay Preference  === undef ined || de faultDispl ayPreferen ce === nul l) {
  155                    defa ultDisplay Preference  = {};
  156                }
  157                sysDispl ayPreferen ce["" + mo dality + " "] = {
  158                    moda lity: moda lity,
  159                    rows : 1,
  160                    colu mns: 1,
  161                    zoom Mode: '100 %',
  162                    useE mbedPdfVie wer: "fals e"
  163                };
  164                defaultD isplayPref erence = {
  165                    pref erence: sy sDisplayPr eference,
  166                    useD efault: tr ue
  167                };
  168           }  catch (e)  {}
  169       }
  170  
  171       /**
  172        * upd ate the sy stem prefe rence load ing status
  173        * @pa ram {Type}  preferenc e - Specif ies the pr eference t ype
  174        * @pa ram {Type}  preferenc eData - Sp ecifies th e preferen ce data
  175        */
  176       var pr eferenceLo adingStatu s = [];
  177  
  178       functi on updateP referenceL oadingStat us(prefere nce, prefe renceData,  isUpdate)  {
  179           tr y {
  180                var load ingStatus  = {};
  181                var disp layText =  preference  + " syste m preferen ces.";
  182                if (!pre ferenceLoa dingStatus [preferenc e]) {
  183                    load ingStatus  = {
  184                         status: (i sUpdate ?  " Sending  " : " Fetc hing ") +  displayTex t,
  185                         canDisplay : true,
  186                         isSuccess:  true,
  187                         preference : preferen ce
  188                    };
  189                    pref erenceLoad ingStatus[ preference ] = loadin gStatus;
  190                } else {
  191                    load ingStatus  = preferen ceLoadingS tatus[pref erence];
  192                    load ingStatus. status = ( isUpdate ?  "Updated  " : " Appl ied ") + d isplayText ;
  193                    load ingStatus. canDisplay  = false;
  194                    if ( !preferenc eData) {
  195                         loadingSta tus.isSucc ess = fals e;
  196                         loadingSta tus.status  = "Failed  to " + (i sUpdate ?  "update "  : "fetch " ) + displa yText + "  Restoring  to default ";
  197                    }
  198                }
  199  
  200                switch ( preference ) {
  201                    case  "cine":
  202                         showAndHid eStatus("d ashboard-c ine-loadin g-status",  "dashboar d-cine-loa ding-icon" , loadingS tatus);
  203                         break;
  204                    case  "ecg":
  205                         showAndHid eStatus("d ashboard-e cg-loading -status",  "dashboard -ecg-loadi ng-icon",  loadingSta tus);
  206                         break;
  207                    case  "annotati on":
  208                         showAndHid eStatus("d ashboard-a nnotation- loading-st atus", "da shboard-an notation-l oading-ico n", loadin gStatus);
  209                         break;
  210                    case  "display" :
  211                         showAndHid eStatus("d ashboard-d isplay-loa ding-statu s", "dashb oard-displ ay-loading -icon", lo adingStatu s);
  212                         break;
  213                    case  "copyattr ibutes":
  214                         showAndHid eStatus("d ashboard-c opyattr-lo ading-stat us", "dash board-copy attr-loadi ng-icon",  loadingSta tus);
  215                         break;
  216                    case  "log":
  217                         showAndHid eStatus("d ashboard-l og-loading -status",  "dashboard -log-loadi ng-icon",  loadingSta tus);
  218                         break;
  219                    defa ult:
  220                         console.lo g("Unsuppo rted prefe rence type : " + pref erence);
  221                         break;
  222                }
  223           }  catch (e)  {}
  224       }
  225  
  226       /**
  227        * Sho w and hide  dashboard  status ba sed on fol lowing par am
  228        */
  229       functi on showAnd HideStatus (statusId,  iconId, l oadingStat us) {
  230           $( '#' + icon Id).show() ;
  231           $( '#' + stat usId).html ('');
  232           $( '#' + stat usId).html (loadingSt atus.statu s);
  233  
  234           if  (loadingS tatus.isSu ccess && ! loadingSta tus.canDis play) {
  235                $('#' +  statusId). removeClas s('dashboa rd-status- fail-style ');
  236                $('#' +  statusId). addClass(' dashboard- status-suc cess-style ');
  237           }  else if (! loadingSta tus.isSucc ess) {
  238                $('#' +  statusId). removeClas s('dashboa rd-status- success-st yle');
  239                $('#' +  statusId). addClass(' dashboard- status-fai l-style');
  240           }
  241  
  242           if  (!loading Status.can Display) {
  243                setTimeo ut(functio n () {
  244                    $('# ' + iconId ).hide();
  245                    if ( preference LoadingSta tus[loadin gStatus.pr eference])  {
  246                         delete pre ferenceLoa dingStatus [loadingSt atus.prefe rence];
  247                         $('#' + st atusId).re moveClass( 'dashboard -status-fa il-style') ;
  248                         $('#' + st atusId).re moveClass( 'dashboard -status-su ccess-styl e');
  249                    }
  250                }, 2000) ;
  251           }
  252       }
  253  
  254       /**
  255        * Upd ate the sy stem prefe rences 
  256        * @pa ram {Type}  preferenc e - Specif ies the pr eference t ype
  257        * @pa ram {Type}  preferenc eData - Sp ecifies th e preferen ce data
  258        */
  259       functi on updateS ystemPrefe rences(pre ference, p referenceD ata) {
  260           tr y {
  261                updatePr eferenceLo adingStatu s(preferen ce, prefer enceData);
  262  
  263                switch ( preference ) {
  264                    case  "cine":
  265                         if (!prefe renceData)  {
  266                             prefer enceData =  defaultCi nePreferen ce;
  267                         }
  268                         setCinePre ference(pr eferenceDa ta);
  269                         cinePrefer ence = pre ferenceDat a;
  270                         break;
  271                    case  "ecg":
  272                         if (!prefe renceData)  {
  273                             prefer enceData =  defaultEc gPreferenc e;
  274                         }
  275                         setEcgPref erence(pre ferenceDat a);
  276                         ecgPrefere nce = pref erenceData ;
  277                         break;
  278                    case  "annotati on":
  279                         if (!prefe renceData)  {
  280                             prefer enceData =  defaultAn notationPr eference;
  281                         }
  282                         setAnnotat ionPrefere nce(prefer enceData);
  283                         annotation Preference  = prefere nceData;
  284                         break;
  285                    case  "display" :
  286                         if (!prefe renceData)  {
  287                             prefer enceData =  defaultDi splayPrefe rence;
  288                         }
  289                         setDisplay Preference (preferenc eData.pref erence);
  290                         displayPre ference =  preference Data;
  291                         break;
  292                    case  "copyattr ibutes":
  293                         if (!prefe renceData)  {
  294                             prefer enceData =  defaultCo pyAttribut esPreferen ce;
  295                         }
  296                         setCopyAtt ributesPre ference(pr eferenceDa ta);
  297                         copyAttrib utesPrefer ence = pre ferenceDat a;
  298                         break;
  299                    case  "log":
  300                         if (!prefe renceData)  {
  301                             prefer enceData =  defaultLo gPreferenc e;
  302                         }
  303                         setLogPref erence(pre ferenceDat a);
  304                         logPrefere nce = pref erenceData ;
  305                         break;
  306                    defa ult:
  307                         console.lo g("Unsuppo rted prefe rence type : " + pref erence);
  308                         break;
  309                }
  310           }  catch (e)  {}
  311       }
  312  
  313       /**
  314        * Loa d all pref ernces
  315        */
  316       functi on loadAll Preference s() {
  317           pr eferenceLo adingStatu s = [];
  318           lo adPreferen ce("annota tion", tru e);
  319           lo adPreferen ce("displa y", true);
  320           lo adPreferen ce("copyat tributes",  true);
  321           lo adPreferen ce("cine",  true);
  322           lo adPreferen ce("log",  true);
  323       }
  324  
  325       /**
  326        * Set  system pr eference t o controls
  327        * @pa ram {Type}  preferenc
  328        */
  329       functi on loadPre ference(pr eference,  runAsAsync ) {
  330           va r t0 = Dat e.now();
  331           co nsole.log( "info: loa dPreferenc e - start" );
  332  
  333           tr y {
  334                // updat e the pref erence loa ding statu s
  335                updatePr eferenceLo adingStatu s(preferen ce);
  336  
  337                $.ajax({
  338                         url: getPr efUrl(pref erence),
  339                         cache: fal se,
  340                         async: (ru nAsAsync = = true ? t rue : fals e)
  341                    })
  342                    .don e(function  (data) {
  343                         updateSyst emPreferen ces(prefer ence, JSON .parse(dat a));
  344                    })
  345                    .fai l(function  (data) {
  346                         updateSyst emPreferen ces(prefer ence, null );
  347                    })
  348                    .err or(functio n (xhr, st atus) {
  349                         updateSyst emPreferen ces(prefer ence, null );
  350                         console.lo g("error :  " + xhr.s tatusText  + "\nFaile d to load  the system  preferenc e from ser ver");
  351                    });
  352           }  catch (e)  {
  353                console. log("error : loadPref erence" +  e.message) ;
  354           }  finally {
  355                console. log("info  : loadPref erence - e nd" + (Dat e.now() -  t0));
  356           }
  357       }
  358  
  359       /**
  360        * Get  request u rl for spe cified pre ference
  361        * @pa ram {Type}  preferenc
  362        */
  363       functi on getPref Url(prefer ence) {
  364           va r requestU rl = null;
  365           sw itch (pref erence) {
  366                case "ci ne":
  367                    requ estUrl = g etCineUrl( );
  368                    brea k;
  369                case "ec g":
  370                    requ estUrl = g etEcgUrl() ;
  371                    brea k;
  372                case "an notation":
  373                    requ estUrl = g etMeasurem entPrefUrl ();
  374                    brea k;
  375                case "di splay":
  376                    requ estUrl = g etSettings Url();
  377                    brea k;
  378                case "co pyattribut es":
  379                    requ estUrl = g etCopyAttr ibUrl();
  380                    brea k;
  381                case "lo g":
  382                    requ estUrl = g etLogUrl() ;
  383                    brea k;
  384                default:
  385                    retu rn null;
  386           }
  387           re turn reque stUrl;
  388       }
  389  
  390       /**
  391        * Cin e Url
  392        */
  393       functi on getCine Url() {
  394           re turn BASE_ URL + "dic t/SYS/cine ?SecurityT oken=" + S ECURITY_TO KEN;
  395       }
  396  
  397       /**
  398        * Ecg  Url
  399        */
  400       functi on getEcgU rl() {
  401           re turn BASE_ URL + "dic t/SYS/ecg? SecurityTo ken=" + SE CURITY_TOK EN;
  402       }
  403  
  404       /**
  405        * Cop yAttribute s Url
  406        */
  407       functi on getCopy AttribUrl( ) {
  408           re turn BASE_ URL + "dic t/SYS/copy attributes ?SecurityT oken=" + S ECURITY_TO KEN;
  409       }
  410  
  411       /**
  412        * Log  Url
  413        */
  414       functi on getLogU rl() {
  415           re turn BASE_ URL + "dic t/SYS/log? SecurityTo ken=" + SE CURITY_TOK EN;
  416       }
  417  
  418       /**
  419        * Set tings Url  (Hanging P rotocol)
  420        */
  421       functi on getSett ingsUrl()  {
  422           re turn BASE_ URL + "dic t/SYS/layo uts?Securi tyToken="  + SECURITY _TOKEN;
  423       }
  424  
  425       /**
  426        * Mea surement p references  Url
  427        */
  428       functi on getMeas urementPre fUrl() {
  429           re turn BASE_ URL + "dic t/SYS/mpre f?Security Token=" +  SECURITY_T OKEN;
  430       }
  431  
  432       /**
  433        * Pra se html te xt
  434        * @pa ram {Type}  id 
  435        */
  436       functi on parseHT MLText(id)  {
  437           re turn $(id) .html().sp lit(':')[1 ].trim();
  438       }
  439  
  440       /**
  441        * Set  system pr eference f rom viewer  service
  442        * @pa ram {Type}  preferenc
  443        * @pa ram {Type}  data 
  444        */
  445       functi on setSyst emPreferen ce(prefere nce, data)  {
  446           va r requestU rl = getPr efUrl(pref erence);
  447           va r t0 = Dat e.now();
  448           co nsole.log( "info: set SystemPref erence - s tart");
  449  
  450           tr y {
  451  
  452                // updat e the pref erence loa ding statu s
  453                updatePr eferenceLo adingStatu s(preferen ce, undefi ned, true) ;
  454  
  455                $.ajax({
  456                         type: 'POS T',
  457                         url: reque stUrl,
  458                         data: JSON .stringify (data),
  459                         beforeSend : function  (xhr) {
  460                             xhr.ov errideMime Type("text /plain; ch arset=x-us er-defined ");
  461                         }
  462                    })
  463                    .suc cess(funct ion (data)  {
  464                         updatePref erenceValu es(prefere nce);
  465                         updatePref erenceLoad ingStatus( preference , {}, true );
  466                    })
  467                    .fai l(function  (data) {
  468                         updatePref erenceLoad ingStatus( preference , undefine d, true);
  469                    })
  470                    .err or(functio n (xhr, st atus) {
  471                         var descri ption = xh r.statusTe xt + "\nFa iled to sa ve the sys tem prefer ence to se rver";
  472                         console.lo g("error :  " + descr iption);
  473                    });
  474           }  catch (e)  {
  475                console. log("error  : " + e.m essage);
  476           }  finally {
  477                console. log("info  : setSyste mPreferenc e - end" +  (Date.now () - t0));
  478           }
  479       }
  480  
  481       /**
  482        * Set  cine pref erence to  controls
  483        * @pa ram {Type}  preferenc
  484        */
  485       functi on setCine Preference (data) {
  486           se t('palysel ection', d ata.palyse lection);
  487           se t('timesTo Repeat', d ata.timesT oRepeat);
  488           se t('framesT oRepeat',  data.frame sToRepeat) ;
  489           se t('idleTim e', data.i dleTime);
  490       }
  491  
  492       /**
  493        * Get  cine pref erence fro m controls
  494        * 
  495        */
  496       functi on getCine Preference () {
  497           va r preferen ce = {
  498                palysele ction: get ('palysele ction'),
  499                timesToR epeat: get ('timesToR epeat'),
  500                framesTo Repeat: ge t('framesT oRepeat'),
  501                idleTime : get('idl eTime')
  502           };
  503           re turn prefe rence;
  504       }
  505  
  506       /**
  507        * Set  ecg prefe rence to c ontrols
  508        * @pa ram {Type}  preferenc
  509        */
  510       functi on setEcgP reference( data) {
  511           se t('ledsele ction', da ta.leadTyp e);
  512           se t('3x43one ', data.fi rstSignal) ;
  513           se t('3x43two ', data.se condSignal );
  514           se t('3x43thr ee', data. thirdSigna l);
  515           se t('3x41Val ue', data. signalValu e);
  516           $( '#ledselec tion').cha nge();
  517       }
  518  
  519       /**
  520        * Get  ecg prefe rence from  controls
  521        * 
  522        */
  523       functi on getEcgP reference( ) {
  524           va r preferen ce = {
  525                leadType : get('led selection' ),
  526                firstSig nal: get(' 3x43one'),
  527                secondSi gnal: get( '3x43two') ,
  528                thirdSig nal: get(' 3x43three' ),
  529                signalVa lue: get(' 3x41Value' )
  530           };
  531           re turn prefe rence;
  532       }
  533  
  534       /**
  535        * Set  annotatio n preferen ce to cont rols
  536        * @pa ram {Type}  preferenc
  537        */
  538       functi on setAnno tationPref erence(dat a) {
  539           se tStyleFrom Measuremen tCol(data) ;
  540       }
  541  
  542       /**
  543        * Get  annotatio n preferen ce from co ntrols
  544        * 
  545        */
  546       functi on getAnno tationPref erence() {
  547           re turn getMe asurementC olFromStyl e();
  548       }
  549  
  550       /**
  551        * Set  display p reference  to control s
  552        * @pa ram {Type}  preferenc
  553        */
  554       functi on setDisp layPrefere nce(data)  {
  555           va r tdAction  = '<butto n type="bu tton" clas s="btn btn -sm btn-pr imary" sty le="margin : 2px;widt h: 35px;"  onclick="d icomViewer .systemPre ferences.a ddOrEditHP (this.pare ntElement. parentElem ent.childN odes,  &qu ot;edit&qu ot;)"><spa n class="g lyphicon g lyphicon-e dit"></spa n></button ><button t ype="butto n" class=" btn btn-sm  btn-dange r" style=" width: 35p x;" onclic k="dicomVi ewer.syste mPreferenc es.deleteH P(this)">< span class ="glyphico n glyphico n-trash">< /span></bu tton>'
  556  
  557           va r tr = nul l;
  558           $. each(data,  function  (key, valu e) {
  559                if (key  == "useDef ault") {
  560                    retu rn;
  561                }
  562                tr = $(' <tr/>');
  563                tr.appen d("<td>" +  value.mod ality + "< /td>");
  564                tr.appen d("<td>" +  value.row s + "</td> ");
  565                tr.appen d("<td>" +  value.col umns + "</ td>");
  566                tr.appen d("<td>" +  value.zoo mMode + "< /td>");
  567                tr.appen d("<td sty le='paddin g: 0px'>"  + tdAction  + "</td>" );
  568                $("#hpTa bleList"). append(tr) ;
  569  
  570                if (key  == 'ECG')  {
  571                    $('# useEmbedPd fViewer')[ 0].isECGPd f = value. useEmbedPd fViewer;
  572                } else i f (key ==  'General')  {
  573                    $('# useEmbedPd fViewer')[ 0].isGener al = value .useEmbedP dfViewer;
  574                }
  575           }) ;
  576  
  577           $( '#useEmbed PdfViewer' ).val("tru e");
  578       }
  579  
  580       /**
  581        * Get  display p reference  from contr ols
  582        * 
  583        */
  584       functi on getDisp layPrefere nce() {
  585           va r preferen ce = {};
  586  
  587           $( "#hpTableL ist").find ('tr').eac h(function  (i, el) {
  588                tdData =  $(this).f ind('td');
  589                if (tdDa ta.length  >= 4) {
  590                    var  tdmodality  = tdData. eq(0).text ();
  591  
  592                    var  isUseEmbed PdfViewer  = true;
  593                    if ( tdmodality  == "Gener al") {
  594                         isUseEmbed PdfViewer  = $('#useE mbedPdfVie wer')[0].i sGeneral;
  595                    } el se if (tdm odality ==  "ECG") {
  596                         isUseEmbed PdfViewer  = $('#useE mbedPdfVie wer')[0].i sECGPdf;
  597                    }
  598  
  599                    pref erence[""  + tdmodali ty + ""] =  {
  600                         modality:  tdmodality ,
  601                         rows: tdDa ta.eq(1).t ext(),
  602                         columns: t dData.eq(2 ).text(),
  603                         zoomMode:  tdData.eq( 3).text(),
  604                         useEmbedPd fViewer: i sUseEmbedP dfViewer
  605                    };
  606                }
  607           }) ;
  608  
  609           re turn prefe rence;
  610       }
  611  
  612       /**
  613        * Set  copy attr ibutes pre ference to  controls
  614        * @pa ram {Type}  preferenc
  615        */
  616       functi on setCopy Attributes Preference (data) {
  617           se tCheck('wi ndowlevel' , data.win dowLevel);
  618           se tCheck('br ightnessco ntrast', d ata.bright nessContra st);
  619           se tCheck('sc ale', data .scale);
  620           se tCheck('in vert', dat a.invert);
  621           se tCheck('or ientation' , data.ori entation);
  622           se tCheck('pa n', data.p an);
  623       }
  624  
  625       /**
  626        * Set  copy attr ibutes pre ference to  controls
  627        * @pa ram {Type}  preferenc
  628        */
  629       functi on setLogP reference( data) {
  630           se t('logLeve lPref', da ta.logLeve l);
  631           se t('lineLim itPref', d ata.lineLi mit);
  632           se tLogPrefer enceKey(da ta.keys);
  633       }
  634  
  635       /**
  636        * Par se and set  the short cut key to  the contr ol
  637        * @pa ram {strin g}   value     shortc ut key
  638        */
  639       functi on setLogP referenceK ey(value)  {
  640           tr y {
  641                if (!val ue) {
  642                    retu rn;
  643                }
  644  
  645                var spli tValue = v alue.split ("+");
  646  
  647                value.in dexOf("CTR L") > -1 ?  setCheck( "ctrlkeyPr ef", true)  : setChec k("ctrlkey Pref", fal se);
  648                value.in dexOf("ALT ") > -1 ?  setCheck(" altkeyPref ", true) :  setCheck( "altkeyPre f", false) ;
  649                value.in dexOf("SHI FT") > -1  ? setCheck ("shiftkey Pref", tru e) : setCh eck("shift keyPref",  false);
  650                set("key 3Pref", sp litValue[s plitValue. length - 1 ]);
  651           }  catch (e)  {}
  652       }
  653  
  654       /**
  655        * Get  copy attr ibutes pre ference fr om control s
  656        * 
  657        */
  658       functi on getCopy Attributes Preference () {
  659           va r preferen ce = {
  660                windowLe vel: getCh eck('windo wlevel'),
  661                brightne ssContrast : getCheck ('brightne sscontrast '),
  662                scale: g etCheck('s cale'),
  663                invert:  getCheck(' invert'),
  664                orientat ion: getCh eck('orien tation'),
  665                pan: get Check('pan ')
  666           };
  667           re turn prefe rence;
  668       }
  669  
  670       /**
  671        * Get  copy attr ibutes pre ference fr om control s
  672        * 
  673        */
  674       functi on getLogP reference( ) {
  675           va r preferen ce = {
  676                logLevel : get('log LevelPref' ),
  677                lineLimi t: get('li neLimitPre f'),
  678                keys: ge tLogPrefer enceKey()
  679           };
  680           re turn prefe rence;
  681       }
  682  
  683       /**
  684        * Get  and forma t the shor tcut key f rom contro l
  685        * @re turns {str ing} Shotc ut key
  686        */
  687       functi on getLogP referenceK ey() {
  688           tr y {
  689                var shor tCutKey =  "";
  690                if (getC heck("ctrl keyPref"))  {
  691                    shor tCutKey =  $("#ctrlke yPref")[0] .value;
  692                    shor tCutKey +=  "+";
  693                }
  694                if (getC heck("altk eyPref"))  {
  695                    shor tCutKey +=  $("#altke yPref")[0] .value;
  696                    shor tCutKey +=  "+";
  697                }
  698                if (getC heck("shif tkeyPref") ) {
  699                    shor tCutKey +=  $("#shift keyPref")[ 0].value;
  700                    shor tCutKey +=  "+";
  701                }
  702                shortCut Key += get ("key3Pref ");
  703  
  704                return s hortCutKey ;
  705           }  catch (e)  {
  706                return " ";
  707           }
  708       }
  709  
  710       /**
  711        * Get  value for  given ele ment id
  712        * @pa ram {Type}  id 
  713        */
  714       functi on get(id)  {
  715           va r element  = document .getElemen tById(id);
  716           if  (element)  {
  717                if (elem ent.type = = "checkbo x") {
  718                    retu rn getChec k(id);
  719                } else i f (id.inde xOf('Color ') > -1) {
  720                    retu rn getColo rSpectrum( id);
  721                }
  722                return e lement.val ue;
  723           }
  724       }
  725  
  726       /**
  727        * Get  checked s tate for g iven check box id
  728        * @pa ram {Type}  id 
  729        */
  730       functi on getChec k(id) {
  731           re turn $("#"  + id)[0]. checked;
  732       }
  733  
  734       /**
  735        * Get  color for  given spe ctrum id
  736        * @pa ram {Type}  id 
  737        */
  738       functi on getColo rSpectrum( id) {
  739           re turn $("#"  + id).spe ctrum("get ").toRgbSt ring();
  740       }
  741  
  742       /**
  743        * Set  value for  given ele ment id
  744        * @pa ram {Type}  id 
  745        * @pa ram {Type}  value 
  746        */
  747       functi on set(id,  value) {
  748           va r element  = document .getElemen tById(id);
  749           if  (element)  {
  750                element. value = va lue;
  751           }
  752       }
  753  
  754       /**
  755        * Set  checked s tate for g iven check box id
  756        * @pa ram {Type}  id 
  757        * @pa ram {Type}  value 
  758        */
  759       functi on setChec k(id, valu e) {
  760           va r element  = document .getElemen tById(id);
  761           if  (element)  {
  762                element. checked =  value;
  763           }
  764       }
  765  
  766       /**
  767        * Con vert measu rement col lection to  design vi ew structu re
  768        * @pa ram {Type}  measureme ntStyleCol  
  769        */
  770       functi on setStyl eFromMeasu rementCol( measuremen tStyleCol)  {
  771           $. each(MT_Ty peCol, fun ction (key , value) {
  772                $.each(M T_EX_TypeC ol[value],  function  (key, valu e) {
  773                    if ( value == " LABEL") {
  774                         $.each(MT_ Lbl_Col, f unction (k ey, value_ ) {
  775                             setMea surementSt yle(measur ementStyle Col, value , value_);
  776                         });
  777                    } el se {
  778                         setMeasure mentStyle( measuremen tStyleCol,  value);
  779                    }
  780                });
  781           }) ;
  782       }
  783  
  784       /**
  785        * Set  measureme nt style t o controls  for given  measureme nt type
  786        * @pa ram {Type}  measureme ntStyleCol  
  787        * @pa ram {Type}  value 
  788        */
  789       functi on setMeas urementSty le(measure mentStyleC ol, id, su bType) {
  790           va r type = i d;
  791  
  792           if  (measurem entStyleCo l[id] == u ndefined)  {
  793                if (id = = "ASTROKE STYLE") {
  794                    type  = "LINE";
  795                } else i f (id == " MSTROKESTY LE") {
  796                    type  = "LENGTH ";
  797                } else i f (id == " ERSTROKEST YLE") {
  798                    type  = "ELLIPS E";
  799                } else i f (id == " HOUNSFIELD ") {
  800                    type  = "HOUNSF IELDELLIPS E";
  801                } else i f (id == " LABEL") {
  802                    type  = subType ;
  803                } else i f (id == " MA") {
  804                    type  = "MRL";
  805                } else i f (id == " MITRAL") {
  806                    type  = "MRL";
  807                } else i f (id == " AORTIC") {
  808                    type  = "ARL";
  809                } else {
  810                    type  = "LINE";
  811                }
  812           }
  813  
  814           if  (id == "L ABEL") {
  815                id = sub Type;
  816           }
  817  
  818           se t(id + "li neWidth",  measuremen tStyleCol[ type].styl eCol.lineW idth);
  819           se t(id + "ga ugeLength" , measurem entStyleCo l[type].st yleCol.gau geLength);
  820           se t(id + "ga ugeStyle",  measureme ntStyleCol [type].sty leCol.gaug eStyle);
  821           se tCheck(id  + "isFill" , measurem entStyleCo l[type].st yleCol.isF ill);
  822           se t(id + "ar cRadius",  measuremen tStyleCol[ type].styl eCol.arcRa dius);
  823           se t(id + "fo ntName", m easurement StyleCol[t ype].style Col.fontNa me);
  824           se t(id + "fo ntSize", m easurement StyleCol[t ype].style Col.fontSi ze);
  825           se tCheck(id  + "isBold" , measurem entStyleCo l[type].st yleCol.isB old);
  826           se tCheck(id  + "isItali c", measur ementStyle Col[type]. styleCol.i sItalic);
  827           se tCheck(id  + "isUnder lined", me asurementS tyleCol[ty pe].styleC ol.isUnder lined);
  828           se tCheck(id  + "isStrik eout", mea surementSt yleCol[typ e].styleCo l.isStrike out);
  829           se t(id + "pr ecision",  measuremen tStyleCol[ type].styl eCol.preci sion);
  830           se t(id + "me asureUnits ", measure mentStyleC ol[type].s tyleCol.me asurementU nits);
  831           se tSpectrumC olor(id +  "lineColor ", measure mentStyleC ol[type].s tyleCol.li neColor);
  832           se tSpectrumC olor(id +  "fillColor ", measure mentStyleC ol[type].s tyleCol.fi llColor);
  833           se tSpectrumC olor(id +  "textColor ", measure mentStyleC ol[type].s tyleCol.te xtColor);
  834       }
  835  
  836       /**
  837        * Con vert desig n view str ucture to  measuremen t collecti on
  838        * @pa ram {Type}   
  839        */
  840       functi on getMeas urementCol FromStyle( ) {
  841           va r measurem entStyleCo l = {};
  842           $. each(MT_PS _TypeCol,  function ( key, value ) {
  843                var styl eCol = {
  844                    line Width: get Measuremen tStyle("li neWidth",  value),
  845                    line Color: get Measuremen tStyle("li neColor",  value),
  846                    gaug eLength: g etMeasurem entStyle(" gaugeLengt h", value) ,
  847                    gaug eStyle: ge tMeasureme ntStyle("g augeStyle" , value),
  848                    isFi ll: getMea surementSt yle("isFil l", value) ,
  849                    fill Color: get Measuremen tStyle("fi llColor",  value),
  850                    arcR adius: get Measuremen tStyle("ar cRadius",  value),
  851                    text Color: get Measuremen tStyle("te xtColor",  value),
  852                    font Name: getM easurement Style("fon tName", va lue),
  853                    font Size: getM easurement Style("fon tSize", va lue),
  854                    isBo ld: getMea surementSt yle("isBol d", value) ,
  855                    isIt alic: getM easurement Style("isI talic", va lue),
  856                    isUn derlined:  getMeasure mentStyle( "isUnderli ned", valu e),
  857                    isSt rikeout: g etMeasurem entStyle(" isStrikeou t", value) ,
  858                    prec ision: get Measuremen tStyle("pr ecision",  value),
  859                    meas urementUni ts: getMea surementSt yle("measu reUnits",  value)
  860                }
  861  
  862                for (var  propName  in styleCo l) {
  863                    if ( styleCol[p ropName] = == undefin ed) {
  864                         delete sty leCol[prop Name];
  865                    }
  866                }
  867  
  868                measurem entStyleCo l[value] =  {
  869                    useD efault: tr ue,
  870                    styl eCol: styl eCol
  871                };
  872           }) ;
  873           re turn measu rementStyl eCol;
  874       }
  875  
  876       /**
  877        * Get  measureme nt style f rom contro ls for giv en measure ment type
  878        * @pa ram {Type}  style 
  879        * @pa ram {Type}  type 
  880        */
  881       functi on getMeas urementSty le(style,  type) {
  882           va r key = ge tEnumMT(ty pe);
  883           sw itch (styl e) {
  884                case "li neWidth":
  885                case "li neColor":
  886                case "pr ecision":
  887                case "me asureUnits ":
  888                    if ( key == "An notation")  {
  889                         type = "AS TROKESTYLE ";
  890                    } el se if (key  == "Measu rement") {
  891                         type = "MS TROKESTYLE ";
  892                    } el se if (key  == "Ellip se") {
  893                         type = "ER STROKESTYL E";
  894                    } el se if (key  == "hElli pse") {
  895                         type = "HO UNSFIELD";
  896                    } el se if (key  == "Mitra l") {
  897                         type = "MI TRAL";
  898                    } el se if (key  == "Aorti c") {
  899                         type = "AO RTIC";
  900                    } el se if (typ e.indexOf( 'LBL') > - 1) {
  901  
  902                    }
  903  
  904                    if ( style == " precision"  || style  == "measur eUnits") {
  905                         if (type = = "MITRAL"  || type = = "AORTIC" ) {
  906                             type =  "MA";
  907                         }
  908                    } el se if (key  == "hElli pse") {
  909                         type = "ER STROKESTYL E";
  910                    }
  911                    brea k;
  912                case "ga ugeStyle":
  913                case "ga ugeLength" :
  914                    if ( key == "An notation")  {
  915                         type = "LI NE";
  916                    } el se if (key  == "Measu rement") {
  917                         type = "LE NGTH";
  918                    } el se if (key  == "Mitra l" || key  == "Aortic ") {
  919                         type = "MA ";
  920                    }
  921                    brea k;
  922                case "is Fill":
  923                case "fi llColor":
  924                    if ( type == "T EXT") {
  925  
  926                    } el se if (key  == "Annot ation") {
  927                         type = "AR ROW";
  928                    } el se if (key  == "Ellip se" || key  == "hElli pse") {
  929                         type = "ER STROKESTYL E";
  930                    }
  931                    brea k;
  932                case "ar cRadius":
  933                    if ( type != "A NGLE" && t ype != "GL OBAL") {
  934                         return nul l;
  935                    }
  936                    brea k;
  937                case "te xtColor":
  938                case "fo ntName":
  939                case "fo ntSize":
  940                case "is Bold":
  941                case "is Italic":
  942                case "is Underlined ":
  943                case "is Strikeout" :
  944                    if ( type.index Of('LBL')  > -1) {
  945  
  946                    } el se if (typ e != "TEXT " && type  != "GLOBAL ") {
  947                         type = "LB LANNOTATIO N";
  948                    }
  949                    brea k;
  950                default:
  951                    retu rn null;
  952           }
  953           re turn get(t ype + styl e);
  954       }
  955  
  956       /**
  957        * Get  measureme nt categor y for give n measurem ent type
  958        * @pa ram {Type}  type 
  959        */
  960       functi on getEnum MT(type) {
  961           if  (type ==  "GLOBAL")  {
  962                return t ype;
  963           }
  964  
  965           if  (type ==  "TEXT" ||  type == "L INE" ||
  966                type ==  "ARROW" ||  type == " FREEHAND"  || type ==  "PEN") {
  967                return " Annotation ";
  968           }  else if (t ype == "LE NGTH" || t ype == "PO INT" || ty pe == "ANG LE" || typ e == "TRAC E") {
  969                return " Measuremen t";
  970           }  else if (t ype == "EL LIPSE" ||  type == "R ECT") {
  971                return " Ellipse";
  972           }  else if (t ype == "HO UNSFIELDEL LIPSE" ||  type == "H OUNSFIELDR ECT") {
  973                return " hEllipse";
  974           }  else if (t ype == "MG " || type  == "MRPV"  || type ==  "MRL" ||  type == "M VALT") {
  975                return " Mitral";
  976           }  else if (t ype == "AS PV" || typ e == "ARPV " || type  == "ARL")  {
  977                return " Aortic";
  978           }
  979       }
  980  
  981       /**
  982        * Set  color spe ctrum
  983        * @pa ram {Type}  id 
  984        * @pa ram {Type}  color 
  985        */
  986       functi on setSpec trumColor( id, color)  {
  987           va r element  = document .getElemen tById(id);
  988           if  (element)  {
  989                $("#" +  id).spectr um({
  990                    colo r: color,
  991                    show Alpha: tru e,
  992                    show PaletteOnl y: true,
  993                    togg lePaletteO nly: true,
  994                    togg lePaletteM oreText: ' more',
  995                    togg lePaletteL essText: ' less',
  996                    pale tte: [
  997                             ["#000 ", "#444",  "#666", " #999", "#c cc", "#eee ", "#f3f3f 3", "#fff" ],
  998                             ["#f00 ", "#f90",  "#ff0", " #0f0", "#0 ff", "#00f ", "#90f",  "#f0f"],
  999                             ["#f4c ccc", "#fc e5cd", "#f ff2cc", "# d9ead3", " #d0e0e3",  "#cfe2f3",  "#d9d2e9" , "#ead1dc "],
  1000                             ["#ea9 999", "#f9 cb9c", "#f fe599", "# b6d7a8", " #a2c4c9",  "#9fc5e8",  "#b4a7d6" , "#d5a6bd "],
  1001                             ["#e06 666", "#f6 b26b", "#f fd966", "# 93c47d", " #76a5af",  "#6fa8dc",  "#8e7cc3" , "#c27ba0 "],
  1002                             ["#c00 ", "#e6913 8", "#f1c2 32", "#6aa 84f", "#45 818e", "#3 d85c6", "# 674ea7", " #a64d79"],
  1003                             ["#900 ", "#b45f0 6", "#bf90 00", "#387 61d", "#13 4f5c", "#0 b5394", "# 351c75", " #741b47"],
  1004                             ["#600 ", "#783f0 4", "#7f60 00", "#274 e13", "#0c 343d", "#0 73763", "# 20124d", " #4c1130"]
  1005                         ]
  1006                });
  1007           }
  1008       }
  1009  
  1010       /**
  1011        * Get  row of ex isisting m odality
  1012        * @pa ram {Type}   
  1013        */
  1014       functi on isExist ingModalit y(modality ) {
  1015           //  Check whe ther the m odality is  already p resent and  update th e new sett ings. 
  1016           va r tdElemen t = null;
  1017           $( "#hpTableL ist").find ('tr').eac h(function  (i, el) {
  1018                tdData =  $(this).f ind('td');
  1019                if (tdDa ta.length  >= 4) {
  1020                    var  tdmodality  = tdData. eq(0).text ();
  1021                    if ( tdmodality  == modali ty) {
  1022                         tdElement  = tdData;
  1023                         return fal se;
  1024                    }
  1025                }
  1026           }) ;
  1027           re turn tdEle ment;
  1028       }
  1029  
  1030       /**
  1031        * To  update HP  table
  1032        * @pa ram {Type}   
  1033        */
  1034       functi on updateH PTable() {
  1035           va r data = { };
  1036           va r modality  = get('mo dality');
  1037           va r tdElemen t = isExis tingModali ty(modalit y);
  1038           da ta[modalit y] = {
  1039                modality : modality ,
  1040                rows: ge t('layoutR ows'),
  1041                columns:  get('layo utColumns' ),
  1042                zoomMode : get('zoo mModeValue s'),
  1043                useEmbed PdfViewer:  get('useE mbedPdfVie wer')
  1044           };
  1045           //  Add the n ew modalit y settings  
  1046           if  (!tdEleme nt) {
  1047                setDispl ayPreferen ce(data);
  1048           }  else {
  1049                tdElemen t.eq(1).ht ml(data[mo dality].ro ws);
  1050                tdElemen t.eq(2).ht ml(data[mo dality].co lumns);
  1051                tdElemen t.eq(3).ht ml(data[mo dality].zo omMode);
  1052           }
  1053  
  1054           if  (modality  == "Gener al") {
  1055                var valu e = $('#us eEmbedPdfV iewer')[0] .isGeneral  = data[mo dality].us eEmbedPdfV iewer;
  1056                $('#useE mbedPdfVie wer').val( value);
  1057           }  else if (m odality ==  "ECG") {
  1058                var valu e = $('#us eEmbedPdfV iewer')[0] .isECGPdf  = data[mod ality].use EmbedPdfVi ewer;
  1059                $('#useE mbedPdfVie wer').val( value);
  1060           }
  1061  
  1062           sh owOrHideHP Table(true );
  1063           on Submit('di splay');
  1064       }
  1065  
  1066       /**
  1067        * Edi t selected  HP Protoc ol
  1068        * @pa ram {Type}   
  1069        */
  1070       functi on addOrEd itHP(tdEle ment, acti on) {
  1071           va r useDefau lt = null;
  1072           va r modality  = null;
  1073           if  (action = = "edit")  {
  1074                useDefau lt = false ;
  1075           }  else if (a ction == " add") {
  1076                tdElemen t = isExis tingModali ty('US');
  1077                if (tdEl ement) {
  1078                    useD efault = f alse;
  1079                } else {
  1080                    useD efault = t rue;
  1081                }
  1082           }  else if (a ction == " selchange" ) {
  1083                if (tdEl ement) {
  1084                    useD efault = f alse;
  1085                } else {
  1086                    useD efault = t rue;
  1087                }
  1088           }
  1089  
  1090           if  (useDefau lt) {
  1091                modality  = 'US';
  1092                set('lay outRows',  '1');
  1093                set('lay outColumns ', '1');
  1094                set('zoo mModeValue s', '100%' );
  1095                $("#moda lity").pro p('disable d', false) ;
  1096           }  else {
  1097                modality  = tdEleme nt[0].inne rText;
  1098                set('lay outRows',  tdElement[ 1].innerTe xt);
  1099                set('lay outColumns ', tdEleme nt[2].inne rText);
  1100                set('zoo mModeValue s', tdElem ent[3].inn erText);
  1101                $("#moda lity").pro p('disable d', action  == "edit" );
  1102           }
  1103  
  1104           if  (modality  == "Gener al") {
  1105                var valu e = $('#us eEmbedPdfV iewer')[0] .isGeneral  == undefi ned ? "tru e" : $('#u seEmbedPdf Viewer')[0 ].isGenera l;
  1106                $('#useE mbedPdfVie wer').val( value);
  1107           }  else if (m odality ==  "ECG") {
  1108                var valu e = $('#us eEmbedPdfV iewer')[0] .isECGPdf  == undefin ed ? "true " : $('#us eEmbedPdfV iewer')[0] .isECGPdf;
  1109                $('#useE mbedPdfVie wer').val( value);
  1110           }
  1111  
  1112           if  (action ! = "selchan ge") {
  1113                showOrHi deHPTable( false);
  1114                set('mod ality', mo dality);
  1115  
  1116                if (moda lity == "G eneral" ||  modality  == "ECG")  {
  1117                    $("# useEmbedPD FViewer_Ro w").show() ;
  1118                } else {
  1119                    $("# useEmbedPD FViewer_Ro w").hide() ;
  1120                }
  1121           }
  1122       }
  1123  
  1124       /**
  1125        * Sho w or Hide  HP control s
  1126        * @pa ram {Type}   
  1127        */
  1128       functi on showOrH ideHPTable (isShow) {
  1129           if  (isShow)  {
  1130                $('#list HangingPro tocol').sh ow();
  1131                $('#addE ditHPTable ').hide();
  1132           }  else {
  1133                $('#list HangingPro tocol').hi de();
  1134                $('#addE ditHPTable ').show();
  1135                $("#moda lity").cha nge(functi on () {
  1136                    if ( this.value  == "Gener al" || thi s.value ==  "ECG") {
  1137                         if (this.v alue == "G eneral") {
  1138                             var va lue = $('# useEmbedPd fViewer')[ 0].isGener al == unde fined ? "t rue" : $(' #useEmbedP dfViewer') [0].isGene ral;
  1139                             $('#us eEmbedPdfV iewer').va l(value);
  1140                         } else if  (this.valu e == "ECG" ) {
  1141                             var va lue = $('# useEmbedPd fViewer')[ 0].isECGPd f == undef ined ? "tr ue" : $('# useEmbedPd fViewer')[ 0].isECGPd f;
  1142                             $('#us eEmbedPdfV iewer').va l(value);
  1143                         }
  1144                         $("#useEmb edPDFViewe r_Row").sh ow();
  1145                    } el se {
  1146                         $("#useEmb edPDFViewe r_Row").hi de();
  1147                    }
  1148                    addO rEditHP(is ExistingMo dality(thi s.value),  'selchange ');
  1149                });
  1150           }
  1151       }
  1152  
  1153       /**
  1154        * Del ete select ed HP Prot ocol
  1155        * @pa ram {Type}   
  1156        */
  1157       functi on deleteH P(row) {
  1158           $( row).close st('tr').r emove();
  1159  
  1160           va r modality  = $(row). closest('t r').find(' td').eq(0) .text();
  1161           if  (modality  == "ECG")  {
  1162                $('#useE mbedPdfVie wer')[0].i sECGPdf =  undefined;
  1163           }  else if (m odality ==  "General" ) {
  1164                $('#useE mbedPdfVie wer')[0].i sGeneral =  undefined ;
  1165           }
  1166           on Submit('di splay');
  1167       }
  1168  
  1169       /**
  1170        * Sub mit system  preferenc e
  1171        * @pa ram {Type}   
  1172        */
  1173       functi on onSubmi t(preferen ce) {
  1174           va r data = n ull;
  1175           sw itch (pref erence) {
  1176                case "ci ne":
  1177                    data  = getCine Preference ();
  1178                    brea k;
  1179                case "ec g":
  1180                    data  = getEcgP reference( );
  1181                    brea k;
  1182                case "an notation":
  1183                    data  = getAnno tationPref erence();
  1184                    brea k;
  1185                case "di splay":
  1186                    data  = {
  1187                         preference : getDispl ayPreferen ce()
  1188                    };
  1189                    brea k;
  1190                case "co pyattribut es":
  1191                    data  = getCopy Attributes Preference ();
  1192                    brea k;
  1193                case "lo g":
  1194                    data  = getLogP reference( );
  1195                    brea k;
  1196                default:
  1197                    retu rn;
  1198           }
  1199  
  1200           if  (preferen ce != "dis play") {
  1201                toggleBu tton(prefe rence, tru e);
  1202           }
  1203  
  1204           if  (preferen ce == "cin e") {
  1205                if (!isV alidCinePr eference(p reference) ) {
  1206                    retu rn;
  1207                }
  1208           }
  1209  
  1210           if  (preferen ce == "ann otation")  {
  1211                if (!isV alidAnnota tionPrefer ence(prefe rence)) {
  1212                    retu rn;
  1213                }
  1214           }
  1215  
  1216           if  (data) {
  1217                data.use Default =  true;
  1218                setSyste mPreferenc e(preferen ce, data);
  1219           }
  1220       }
  1221  
  1222       /**
  1223        * Res et system  preference
  1224        * @pa ram {Type}   
  1225        */
  1226       functi on onReset (preferenc e) {
  1227           $( "#Preferen ceAlert"). html("");
  1228           $( "#Preferen ceAlert"). hide();
  1229           $( "#Annotati onPreferen ceAlert"). html("");
  1230           $( "#Annotati onPreferen ceAlert"). hide();
  1231           re setPrefere nceValues( preference );
  1232       }
  1233  
  1234       /**
  1235        * loa d the syst em prefere nce
  1236        * @pa ram {Type}  preferenc e - Specif ies the pr eference
  1237        * @pa ram {Type}  loadFrom  - Specifie s the load ing type
  1238        */
  1239       functi on loadSys temPrefere nce(prefer ence, load From) {
  1240           tr y {
  1241                var pref erenceData ;
  1242                switch ( preference ) {
  1243                    case  "cine":
  1244                         preference Data = loa dFrom == " control" ?  getCinePr eference()  : cinePre ference;
  1245                         preference Data.useDe fault = tr ue;
  1246                         break;
  1247                    case  "ecg":
  1248                         preference Data = loa dFrom == " control" ?  getEcgPre ference()  : ecgPrefe rence;
  1249                         preference Data.useDe fault = tr ue;
  1250                         break;
  1251                    case  "annotati on":
  1252                         preference Data = loa dFrom == " control" ?  getAnnota tionPrefer ence() : a nnotationP reference;
  1253                         preference Data.useDe fault = tr ue;
  1254                         break;
  1255                    case  "display" :
  1256                         preference Data = loa dFrom == " control" ?  {
  1257                             prefer ence: getD isplayPref erence()
  1258                         } : displa yPreferenc e;
  1259                         preference Data.useDe fault = tr ue;
  1260                         break;
  1261                    case  "copyattr ibutes":
  1262                         preference Data = loa dFrom == " control" ?  getCopyAt tributesPr eference()  : copyAtt ributesPre ference;
  1263                         preference Data.useDe fault = tr ue;
  1264                         break;
  1265                    case  "log":
  1266                         preference Data = loa dFrom == " control" ?  getLogPre ference()  : logPrefe rence;
  1267                         preference Data.useDe fault = tr ue;
  1268                         break;
  1269                }
  1270  
  1271                return p referenceD ata;
  1272           }  catch (e)  {}
  1273       }
  1274  
  1275       /**
  1276        * upd ate the pr eference v alues
  1277        * @pa ram {Type}  preferenc e - Specif ies the pr eference
  1278        */
  1279       functi on updateP referenceV alues(pref erence) {
  1280           tr y {
  1281                switch ( preference ) {
  1282                    case  "cine":
  1283                         cinePrefer ence = get CinePrefer ence();
  1284                         cinePrefer ence.useDe fault = tr ue;
  1285                         break;
  1286                    case  "ecg":
  1287                         ecgPrefere nce = getE cgPreferen ce();
  1288                         ecgPrefere nce.useDef ault = tru e;
  1289                         break;
  1290                    case  "annotati on":
  1291                         annotation Preference  = getAnno tationPref erence();
  1292                         annotation Preference .useDefaul t = true;
  1293                         break;
  1294                    case  "display" :
  1295                         displayPre ference =  {
  1296                             prefer ence: getD isplayPref erence()
  1297                         };
  1298                         displayPre ference.us eDefault =  true;
  1299                         break;
  1300                    case  "copyattr ibutes":
  1301                         copyAttrib utesPrefer ence = get CopyAttrib utesPrefer ence();
  1302                         copyAttrib utesPrefer ence.useDe fault = tr ue;
  1303                         break;
  1304                    case  "log":
  1305                         logPrefere nce = getL ogPreferen ce();
  1306                         logPrefere nce.useDef ault = tru e;
  1307                         break;
  1308                }
  1309           }  catch (e)  {}
  1310       }
  1311  
  1312       /**
  1313        * Res et the pre ference va lues
  1314        * @pa ram {Type}  preferenc e - Specif ies the pr eference
  1315        */
  1316       functi on resetPr eferenceVa lues(prefe rence) {
  1317           tr y {
  1318                switch ( preference ) {
  1319                    case  "cine":
  1320                         setCinePre ference(ci nePreferen ce);
  1321                         break;
  1322                    case  "ecg":
  1323                         setEcgPref erence(ecg Preference );
  1324                         break;
  1325                    case  "annotati on":
  1326                         setAnnotat ionPrefere nce(annota tionPrefer ence);
  1327                         break;
  1328                    case  "display" :
  1329                         setDisplay Preference (displayPr eference.p reference) ;
  1330                         break;
  1331                    case  "copyattr ibutes":
  1332                         setCopyAtt ributesPre ference(co pyAttribut esPreferen ce);
  1333                         break;
  1334                    case  "log":
  1335                         setLogPref erence(log Preference );
  1336                         break;
  1337                }
  1338                toggleBu tton(prefe rence, tru e);
  1339           }  catch (e)  {}
  1340       }
  1341  
  1342       /**
  1343        * San ity check  in current  preferenc e window
  1344        * @pa ram {Type}  activePre fTab - Spe cifies the  active pr eference t ab
  1345        */
  1346       functi on sanityC heck(activ ePrefTab)  {
  1347           tr y {
  1348                var stor edData = l oadSystemP reference( activePref Tab, 'conf ig');
  1349                var curr entData =  loadSystem Preference (activePre fTab, 'con trol');
  1350                return ! Object.com pare(curre ntData, st oredData);
  1351           }  catch (e)  {}
  1352       }
  1353  
  1354       /**
  1355        * isD irtyCheck  in prefere nce window
  1356        * @pa ram {Type}  activePre fTab - Spe cifies the  active pr eference t ab
  1357        */
  1358       functi on isDirty Check(acti vePrefTab)  {
  1359           tr y {
  1360                var isDi rty = fals e;
  1361                isDirty  = sanityCh eck(active PrefTab);
  1362                toggleBu tton(activ ePrefTab,  isDirty ?  false : tr ue);
  1363           }  catch (e)  {}
  1364       }
  1365  
  1366       /**
  1367        * Tog gle the su bmit and r eset butto n
  1368        * @pa ram {Type}  preferenc e - Specif ies the pr eference
  1369        * @pa ram {Type}  state - S pecifies t he button  state
  1370        */
  1371       functi on toggleB utton(pref erence, st ate) {
  1372           tr y {
  1373                $('#dash board-' +  preference  + 'Tab-ap ply-btn'). prop('disa bled', sta te);
  1374                $('#dash board-' +  preference  + 'Tab-re set-btn'). prop('disa bled', sta te);
  1375           }  catch (e)  {}
  1376       }
  1377  
  1378       /**
  1379        * Dee p objects  comparisio n
  1380        */
  1381       Object .compare =  function  (obj1, obj 2) {
  1382           // Loop throu gh propert ies in obj ect 1
  1383           fo r (var p i n obj1) {
  1384                //Check  property e xists on b oth object s
  1385                if (obj1 .hasOwnPro perty(p) ! == obj2.ha sOwnProper ty(p)) ret urn false;
  1386  
  1387                switch ( typeof (ob j1[p])) {
  1388                    //De ep compare  objects
  1389                    case  'object':
  1390                         if (!Objec t.compare( obj1[p], o bj2[p])) r eturn fals e;
  1391                         break;
  1392                         //Compare  function c ode
  1393                    case  'function ':
  1394                         if (typeof  (obj2[p])  == 'undef ined' || ( p != 'comp are' && ob j1[p].toSt ring() !=  obj2[p].to String()))  return fa lse;
  1395                         break;
  1396                         //Compare  values
  1397                    defa ult:
  1398                         if ((typeo f obj1[p]  == "string ") && obj1 [p].indexO f('#') > - 1) {
  1399                             obj1[p ] = hexToR gb(obj1[p] );
  1400                         }
  1401                         if ((typeo f obj2[p]  == "string ") && obj2 [p].indexO f('#') > - 1) {
  1402                             obj2[p ] = hexToR gb(obj2[p] );
  1403                         }
  1404                         if (obj1[p ] != null  && obj2[p]  != null & & obj1[p]  != obj2[p] ) return f alse;
  1405                }
  1406           }
  1407  
  1408           // Check obje ct 2 for a ny extra p roperties
  1409           fo r (var p i n obj2) {
  1410                if (type of (obj1[p ]) == 'und efined') r eturn fals e;
  1411           }
  1412           re turn true;
  1413       };
  1414  
  1415       /**
  1416        * HEX  to RGB co nversion
  1417        * @pa ram {Type}  hex 
  1418        */
  1419       functi on hexToRg b(hex) {
  1420           //  Expand sh orthand fo rm (e.g. " 03F") to f ull form ( e.g. "0033 FF")
  1421           va r shorthan dRegex = / ^#?([a-f\d ])([a-f\d] )([a-f\d]) $/i;
  1422           he x = hex.re place(shor thandRegex , function  (m, r, g,  b) {
  1423                return r  + r + g +  g + b + b ;
  1424           }) ;
  1425  
  1426           va r result =  /^#?([a-f \d]{2})([a -f\d]{2})( [a-f\d]{2} )$/i.exec( hex);
  1427           re turn resul t ? "rgb("  + parseIn t(result[1 ], 16) + " , " + pars eInt(resul t[2], 16)  + ", " + p arseInt(re sult[3], 1 6) + ")" :  null;
  1428       }
  1429  
  1430       /**
  1431        * Is  valid cine  preferenc e or not
  1432        * @pa ram {Type}  prefActiv eTab - Spe cifies the  active ta b
  1433        */
  1434       functi on isValid CinePrefer ence(prefA ctiveTab)  {
  1435           tr y {
  1436                var pref erence = g etCinePref erence();
  1437                if (pref erence.fra mesToRepea t == "" ||  preferenc e.timesToR epeat == " " || prefe rence.idle Time == "" ) {
  1438                    $("# Preference Alert").ht ml('Value  should not  be empty' );
  1439                    $("# Preference Alert").sh ow();
  1440                    $('# dashboard- ' + prefAc tiveTab +  'Tab-reset -btn').pro p('disable d', false) ;
  1441                    retu rn false;
  1442                } else i f ((prefer ence.frame sToRepeat  < 1) || (5 00 < prefe rence.fram esToRepeat ) || (pref erence.tim esToRepeat  < 1) || ( 500 < pref erence.tim esToRepeat ) || (pref erence.idl eTime < 1)  || (500 <  preferenc e.idleTime )) {
  1443                    $("# Preference Alert").ht ml('Value  must be be tween 1 an d 500');
  1444                    $("# Preference Alert").sh ow();
  1445                    $('# dashboard- ' + prefAc tiveTab +  'Tab-reset -btn').pro p('disable d', false) ;
  1446                    retu rn false;
  1447                } else {
  1448                    $("# Preference Alert").ht ml("");
  1449                    $("# Preference Alert").hi de();
  1450                }
  1451  
  1452                return t rue;
  1453           }  catch (e)  {}
  1454       }
  1455  
  1456       /**
  1457        * Is  valid anno tation pre ference or  not
  1458        * @pa ram {Type}  prefActiv eTab - Spe cifies the  active ta b
  1459        */
  1460       functi on isValid Annotation Preference (prefActiv eTab) {
  1461           tr y {
  1462                var pref erence = g etAnnotati onPreferen ce();
  1463                if (pref erence.LIN E.styleCol .gaugeLeng th == "" | | preferen ce.LENGTH. styleCol.g augeLength  == "" ||  preference .ANGLE.sty leCol.arcR adius == " " || prefe rence.HOUN SFIELDRECT .styleCol. precision  == "" || p reference. MRPV.style Col.gaugeL ength == " " || prefe rence.MRPV .styleCol. precision  == "" || p reference. LENGTH.sty leCol.prec ision == " ") {
  1464                    $("# Annotation Preference Alert").ht ml('Value  should not  be empty' );
  1465                    $("# Annotation Preference Alert").sh ow();
  1466                    $('# dashboard- ' + prefAc tiveTab +  'Tab-reset -btn').pro p('disable d', false) ;
  1467                    retu rn false;
  1468                } else i f (prefere nce.LINE.s tyleCol.ga ugeLength  > 20 || pr eference.L ENGTH.styl eCol.gauge Length > 2 0 || prefe rence.MRPV .styleCol. gaugeLengt h > 20) {
  1469                    $("# Annotation Preference Alert").ht ml('GaugeL ength valu e must be  between 0  and 20');
  1470                    $("# Annotation Preference Alert").sh ow();
  1471                    $('# dashboard- ' + prefAc tiveTab +  'Tab-reset -btn').pro p('disable d', false) ;
  1472                    retu rn false;
  1473                } else i f ((prefer ence.ANGLE .styleCol. arcRadius  < 5 || pre ference.AN GLE.styleC ol.arcRadi us > 20))  {
  1474                    $("# Annotation Preference Alert").ht ml('ANGLE  arcRadius  value must  be betwee n 5 and 20 ');
  1475                    $("# Annotation Preference Alert").sh ow();
  1476                    $('# dashboard- ' + prefAc tiveTab +  'Tab-reset -btn').pro p('disable d', false) ;
  1477                    retu rn false;
  1478                } else i f (prefere nce.HOUNSF IELDRECT.s tyleCol.pr ecision >  14 || pref erence.MRP V.styleCol .precision  > 14 || p reference. LENGTH.sty leCol.prec ision > 14 ) {
  1479                    $("# Annotation Preference Alert").ht ml('Precis ion value  must be be tween 0 an d 14');
  1480                    $("# Annotation Preference Alert").sh ow();
  1481                    $('# dashboard- ' + prefAc tiveTab +  'Tab-reset -btn').pro p('disable d', false) ;
  1482                    retu rn false;
  1483                } else {
  1484                    $("# Annotation Preference Alert").ht ml("");
  1485                    $("# Annotation Preference Alert").hi de();
  1486                }
  1487  
  1488                return t rue;
  1489           }  catch (e)  {}
  1490       }
  1491  
  1492       dicomV iewer.syst emPreferen ces = {
  1493           ad dOrEditHP:  addOrEdit HP,
  1494           de leteHP: de leteHP,
  1495           up dateHPTabl e: updateH PTable,
  1496           sh owOrHideHP Table: sho wOrHideHPT able,
  1497           on Submit: on Submit,
  1498           on Reset: onR eset,
  1499           lo adAllPrefe rences: lo adAllPrefe rences,
  1500           is DirtyCheck : isDirtyC heck,
  1501           sa nityCheck:  sanityChe ck,
  1502           re setPrefere nceValues:  resetPref erenceValu es,
  1503           is ValidCineP reference:  isValidCi nePreferen ce,
  1504           is ValidAnnot ationPrefe rence: isV alidAnnota tionPrefer ence
  1505       }
  1506  
  1507       return  dicomView er;
  1508   }(dicomVie wer));
  1509   // Configu re all the  endpoints  of dashbo ard
  1510   var LOG_UR L = BASE_U RL + BASE_ LOG_URL +  "settings? Applicatio n=";
  1511   var LOG_FI LE_URL = B ASE_URL +  BASE_LOG_U RL + "file s?Applicat ion=";
  1512   var FILE_L IST_URL =  BASE_URL +  BASE_LOG_ URL + "eve nts?Applic ation=";
  1513   var HEADER S_TITLE_UR L = BASE_U RL + "dash /testdata/ " + TEST_D ATA;
  1514   var DASHBO RAD_STATUS _URL = BAS E_URL + "s tatus";
  1515  
  1516   var lastAp pliedLogLe vel;
  1517   var lastAp pliedRende rLogLevel;
  1518   var pageSi ze = 12;
  1519   var startI ndex = 0;
  1520   var lastSe lectedView erFileName ;
  1521   var lastSe lectedRend erFileName ;
  1522   var curren tSelectedF ileName;
  1523   var curren tSelectedP ageIndex =  0;
  1524   var curren tSelectedT imeStamp;
  1525   var prefer enceType =  ["cine",  "ecg", "an notation",  "display" , "copyatt ributes",  "log"];
  1526  
  1527   $(document ).ready(fu nction ()  {
  1528       $('#da shboard-vi ewer-log-s idebar').o n('click',  function  () {
  1529           $( '#sidebar' ).toggleCl ass('activ e');
  1530           if  ($(this)[ 0].classNa me === 'na vbar-btn d ashboard-l og-sidebar Collapse')  {
  1531                $('#dash board-view er-log-lef t-panel'). hide();
  1532                $('#dash board-view er-log-rig ht-panel') .show();
  1533           }  else {
  1534                $('#dash board-view er-log-lef t-panel'). show();
  1535                $('#dash board-view er-log-rig ht-panel') .hide();
  1536           }
  1537           $( this).togg leClass('a ctive');
  1538       });
  1539  
  1540       $('#da shboard-re nder-log-s idebar').o n('click',  function  () {
  1541           $( '#sidebar1 ').toggleC lass('acti ve');
  1542           if  ($(this)[ 0].classNa me === 'na vbar-btn d ashboard-l og-sidebar Collapse')  {
  1543                $('#dash board-rend er-log-lef t-panel'). hide();
  1544                $('#dash board-rend er-log-rig ht-panel') .show();
  1545           }  else {
  1546                $('#dash board-rend er-log-lef t-panel'). show();
  1547                $('#dash board-rend er-log-rig ht-panel') .hide();
  1548           }
  1549           $( this).togg leClass('a ctive');
  1550       });
  1551  
  1552       $('#da shboard-an notation-s idebar').o n('click',  function  () {
  1553           $( '#sidebar2 ').toggleC lass('acti ve');
  1554           if  ($(this)[ 0].classNa me === 'na vbar-btn d ashboard-l og-sidebar Collapse')  {
  1555                $('#dash board-anno tation-lef t-panel'). hide();
  1556                $('#dash board-anno tation-rig ht-panel') .show();
  1557           }  else {
  1558                $('#dash board-anno tation-lef t-panel'). show();
  1559                $('#dash board-anno tation-rig ht-panel') .hide();
  1560           }
  1561           $( this).togg leClass('a ctive');
  1562       });
  1563  
  1564       if (wi ndow.locat ion.search .indexOf(' studydetai ls') > 0)  {
  1565           va r newURl =  BASE_URL  + window.l ocation.se arch;
  1566           co nsole.log( "WINDOW LO CATION : "  + window. location.s earch);
  1567           va r validURL  = newURl. replace("/ ?", "/");
  1568           co nsole.log( "My New UR L : " + va lidURL);
  1569           la unchDetail URL(validU RL);
  1570       } else  {
  1571           co nsole.log( "Read base  URL { Bas e url } :  " + BASE_U RL);
  1572           lo adHeadersT itle();
  1573           $( "#headerSe lectBox"). change(fun ction () {
  1574                applyHea derTitle($ ("#headerS electBox o ption:sele cted").val ());
  1575           }) ;
  1576       }
  1577  
  1578       // Tab  settings
  1579       $('a[d ata-toggle ="tab"]'). on('shown. bs.tab', f unction (e ) {
  1580           va r target =  e.target. text;
  1581           if  (target = = "Configu ration") {
  1582                displayA nnotationP references ();
  1583           }
  1584       });
  1585  
  1586       $('#ci neTab').on ('change',  function  () {
  1587           di comViewer. systemPref erences.is DirtyCheck ("cine");
  1588       });
  1589  
  1590       $('#ec gTab').on( 'change',  function ( ) {
  1591           di comViewer. systemPref erences.is DirtyCheck ("ecg");
  1592       });
  1593  
  1594       $('#co pyAttrTab' ).on('chan ge', funct ion () {
  1595           di comViewer. systemPref erences.is DirtyCheck ("copyattr ibutes");
  1596       });
  1597  
  1598       $('#an notationTa b').on('ch ange', fun ction () {
  1599           di comViewer. systemPref erences.is DirtyCheck ("annotati on");
  1600       });
  1601  
  1602       $('#lo gTab').on( 'change',  function ( ) {
  1603           di comViewer. systemPref erences.is DirtyCheck ("log");
  1604       });
  1605  
  1606       $('#ti mepicker1' ).timepick er();
  1607       $('#ti mepicker2' ).timepick er();
  1608   });
  1609  
  1610   /**
  1611    * Load da shboard lo gin page w ith userna me and pas sword    
  1612    **/
  1613   /*function  doDashboa rLogin()
  1614   {
  1615     
  1616       var us ername = $ ('#usernam e').val();
  1617       var pa ssword = $ ('#passwor d').val();
  1618       
  1619       if(!is NullOrUnde fined(user name) && ! isNullOrUn defined(pa ssword) &&  username  != "" && p assword !=  "" )
  1620       {
  1621             if(usernam e == " AI " && passw ord == " AI ")
  1622           {
  1623                showDash boardHome( );
  1624                $('#dash board-home ').show();          
  1625           }
  1626           el se
  1627           {
  1628               alert("In valid user name and p assword. P lease try  again");
  1629               $('#usern ame').val( '');
  1630               $('#passw ord').val( '');
  1631           }    
  1632       }
  1633       else
  1634       {
  1635           al ert("Inval id usernam e and pass word. Plea se try aga in");
  1636       }
  1637       
  1638       
  1639       
  1640       $.ajax ({
  1641           ur l: "http:/ /localhost :64410/api /Emps_API_ /2",
  1642           ty pe: "GET",
  1643           ca che: false ,
  1644           co ntentType:  "applicat ion/json",
  1645           da taType: "j son",
  1646           he aders: { ' Authorizat ion': 'Bas ic ' + bto a(username  + ':' + p assword) }
  1647       }).don e(function  (data) {
  1648           if (data == t rue)
  1649           {
  1650                hideAndS howTopMenu ();
  1651                $('#dash board-home ').show();                  
  1652           }
  1653           el se
  1654           {
  1655                hideAndS howTopMenu ();
  1656                $('#dash board-logi n').show() ;        
  1657           }
  1658       }).err or(functio n (xhr, te xtStatus,  errorThrow n) {
  1659           al ert("Err "  + textSta tus + "    " + errorT hrown);
  1660       });
  1661   }
  1662   */
  1663  
  1664   /**
  1665    * Load da shboard ho me page 
  1666    **/
  1667   function s howDashboa rdHome() {
  1668       hideAn dShowTopMe nu();
  1669       $('#da shboard-ho me').show( );
  1670       $('#da shboard-to pmenu-logi n').show() ;
  1671   }
  1672  
  1673  
  1674   /**
  1675    * Load da shboard lo g page whi le clickin g on dashb oard logs  image
  1676    **/
  1677   function s howDashboa rdLogs() {
  1678       hideAn dShowTopMe nu();
  1679       $('#da shboard-to pmenu-logs -home').sh ow();
  1680       $('#da hsboard-to pmenu-home -nav').sho w();
  1681       $('#da shboard-lo g-home').s how();
  1682       dashbo ardDisplay ViewerLogL evel();
  1683       dashbo ardDisplay RenderLogL evel();
  1684   }
  1685  
  1686   /**
  1687    * Load da shboard vi ewer log p age while  clicking o n dashboar d logs ima ge
  1688    **/
  1689   function d ashboardDi splayViewe rLogLevel( ) {
  1690       $.ajax ({
  1691           ty pe: 'GET',
  1692           ur l: LOG_URL  + "VIEWER ",
  1693           da taType: 'j son',
  1694           as ync: true,
  1695           su ccess: fun ction (dat a) {
  1696                console. log("Dashb oard Log L evel Viewe r Url : "  + LOG_URL  + "VIEWER" );
  1697                if (!isN ullOrUndef ined(data) ) {
  1698                    $('# dashboard- viewer-sel ect-option ').val(dat a.logLevel );
  1699                    last AppliedLog Level = $( "#dashboar d-viewer-s elect-opti on option: selected") .val();
  1700                    $('# dashboard- viewer-app ly-btn').a ddClass('d isabled');
  1701                    dash boardDispl ayViewerLo gFiles();
  1702                }
  1703           },
  1704           er ror: funct ion (XMLHt tpRequest,  textStatu s, errorTh rown) {
  1705                console. log("The a jax error  occurred :  " + textS tatus);
  1706           }
  1707       });
  1708   }
  1709  
  1710   /**
  1711    * Load da shboard re nder log f iles page  while clic king on da shboard lo gs image
  1712    **/
  1713   function d ashboardDi splayRende rLogLevel( ) {
  1714       $.ajax ({
  1715           ty pe: 'GET',
  1716           ur l: LOG_URL  + "RENDER ",
  1717           da taType: 'j son',
  1718           as ync: true,
  1719           su ccess: fun ction (dat a) {
  1720                console. log("Dashb oard Log L evel rende r Url : "  + LOG_URL  + "RENDER" );
  1721                if (!isN ullOrUndef ined(data) ) {
  1722                    $('# dashboard- render-sel ect-option ').val(dat a.logLevel );
  1723                    last AppliedRen derLogLeve l = $("#da shboard-re nder-selec t-option o ption:sele cted").val ();
  1724                    $('# dashboard- render-app ly-btn').a ddClass('d isabled');
  1725                    dash boardDispl ayRenderLo gFiles();
  1726                }
  1727           },
  1728           er ror: funct ion (XMLHt tpRequest,  textStatu s, errorTh rown) {
  1729                console. log("The a jax error  occurred :  " + textS tatus);
  1730           }
  1731       });
  1732   }
  1733  
  1734   /**
  1735    * Load da shboard vi ewer log f iles page  while clic king on da shboard lo gs image
  1736    **/
  1737   function d ashboardDi splayViewe rLogFiles( ) {
  1738       var d  = new Date ();
  1739       var n  = d.getMil liseconds( );
  1740       var vi werCacheUr l = LOG_FI LE_URL + " VIEWER&_ca cheBust="  + n;
  1741       $.ajax ({
  1742           ty pe: 'GET',
  1743           ur l: viwerCa cheUrl,
  1744           da taType: 'j son',
  1745           as ync: true,
  1746           su ccess: fun ction (dat a) {
  1747                console. log("Dashb oard Log L evel Viewe r Url : "  + LOG_FILE _URL + "VI EWER");
  1748                if (!isN ullOrUndef ined(data) ) {
  1749                    var  fileListIn formation  = "";
  1750                    var  sliceFileN ame = "";
  1751                    if ( !isNullOrU ndefined(d ata.logFil eItems) &&  data.logF ileItems.l ength > 0)  {
  1752                         showDashbo ardViewerA ndRenderLo gFile(data .logFileIt ems[0].fil eName, dat a.applicat ion, data. logFileIte ms[0].time Stamp, sta rtIndex);
  1753                         $.each(dat a.logFileI tems, func tion (inde x, colData ) {
  1754                             sliceF ileName =  JSON.strin gify(colDa ta.fileNam e);
  1755                             fileLi stInformat ion += '<t r><td><a h ref="#" on click="sho wDashboard ViewerAndR enderLogFi le(\'' + s liceFileNa me.slice(1 , -1) + '\ ', \'' + d ata.applic ation + '\ ', \'' + c olData.tim eStamp + ' \', ' + st artIndex +  ')">' + c olData.fil eName + '( ' + colDat a.timeStam p + ')</a> </td><tr>' ;
  1756                         });
  1757                    }
  1758                }
  1759                $('#dash board-view er-list-fi les').html ('');
  1760                $('#dash board-view er-list-fi les').appe nd(fileLis tInformati on);
  1761           },
  1762           er ror: funct ion (XMLHt tpRequest,  textStatu s, errorTh rown) {
  1763                console. log("The a jax error  occurred :  " + textS tatus);
  1764           }
  1765       });
  1766   }
  1767  
  1768   /**
  1769    * Load da shboard re nder log f iles page  while clic king on da shboard lo gs image
  1770    **/
  1771   function d ashboardDi splayRende rLogFiles( ) {
  1772       var d  = new Date ();
  1773       var n  = d.getMil liseconds( );
  1774       var re nderCached Url = LOG_ FILE_URL +  "RENDER&_ cacheBust= " + n;
  1775       $.ajax ({
  1776           ty pe: 'GET',
  1777           ur l: renderC achedUrl,
  1778           da taType: 'j son',
  1779           as ync: true,
  1780           su ccess: fun ction (dat a) {
  1781                console. log("Dashb oard Log L evel Rende r Url : "  + LOG_FILE _URL + "RE NDER");
  1782                if (!isN ullOrUndef ined(data) ) {
  1783                    var  fileListIn formation  = "";
  1784                    var  sliceFileN ame = "";
  1785                    if ( !isNullOrU ndefined(d ata.logFil eItems) &&  data.logF ileItems.l ength > 0)  {
  1786                         showDashbo ardViewerA ndRenderLo gFile(data .logFileIt ems[0].fil eName, dat a.applicat ion, data. logFileIte ms[0].time Stamp, sta rtIndex);
  1787                         $.each(dat a.logFileI tems, func tion (inde x, colData ) {
  1788                             sliceF ileName =  JSON.strin gify(colDa ta.fileNam e);
  1789                             fileLi stInformat ion += '<t r><td><a h ref="#" on click="sho wDashboard ViewerAndR enderLogFi le(\'' + s liceFileNa me.slice(1 , -1) + '\ ', \'' + d ata.applic ation + '\ ', \'' + c olData.tim eStamp + ' \', ' + st artIndex +  ')">' + c olData.fil eName + '( ' + colDat a.timeStam p + ')</a> </td><tr>' ;
  1790                         });
  1791                    }
  1792                }
  1793                $('#dash board-rend er-list-fi les').html ('');
  1794                $('#dash board-rend er-list-fi les').appe nd(fileLis tInformati on);
  1795           },
  1796           er ror: funct ion (XMLHt tpRequest,  textStatu s, errorTh rown) {
  1797                console. log("The a jax error  occurred :  " + textS tatus);
  1798           }
  1799       });
  1800   }
  1801  
  1802   /**
  1803    * Load da shboard vi ewer and r ender log  content ba sed on 
  1804    * clickin g log file s from lef t panel
  1805    **/
  1806   function s howDashboa rdViewerAn dRenderLog File(fileN ame, appli cation, ti meStamp, p ageIndex)  {
  1807       curren tSelectedF ileName =  fileName;
  1808       curren tSelectedP ageIndex =  pageIndex ;
  1809       curren tSelectedT imeStamp =  timeStamp ;
  1810       pageIn dex = (pag eIndex < 0  ? 0 : pag eIndex);
  1811       var d  = new Date ();
  1812       var n  = d.getMil liseconds( );
  1813       var vi ewerRender CachedUrl  = FILE_LIS T_URL + ap plication  + "&LogFil eName=" +  fileName +  "&PageSiz e=" + page Size + "&P ageIndex="  + pageInd ex + "&_ca cheBust="  + n;
  1814  
  1815       if (ap plication  === 'RENDE R') {
  1816           $( '#dashboar d-render-l og-header- text').htm l(fileName  + "  ( "  + timeStam p + " )");
  1817           if  (currentS electedFil eName != l astSelecte dRenderFil eName) {
  1818                $('#dash board-rend er-log-hea der-text') .html('');
  1819                $('#dash board-rend er-log-hea der-text') .html(file Name + "   ( " + time Stamp + "  )");
  1820           }
  1821           la stSelected RenderFile Name = fil eName;
  1822  
  1823           $. ajax({
  1824                type: 'G ET',
  1825                url: vie werRenderC achedUrl,
  1826                dataType : 'json',
  1827                async: t rue,
  1828                success:  function  (data) {
  1829                    cons ole.log("D ashboard L og Level R ender Url  : " + FILE _LIST_URL  + applicat ion + "&Lo gFileName= " + fileNa me + "&Pag eSize=" +  pageSize +  "&PageInd ex=" + pag eIndex);
  1830                    if ( !isNullOrU ndefined(d ata)) {
  1831                         var fileLi stInformat ion = "";
  1832                         if (!isNul lOrUndefin ed(data.lo gEventItem s) && data .logEventI tems.lengt h > 0) {
  1833                             $('#da shboard-re nder-logs- table-body ').html('' );
  1834                             $.each (data.logE ventItems,  function  (index, co lData) {
  1835                                 fi leListInfo rmation +=  '<tr><td> ' + colDat a.timeStam p + '</td> <td>' + se tLogLevelL abel(colDa ta.level)  + '</td><t d>' + colD ata.messag e + '</td> <td class= "abbreviat ion">' + c olData.par ameters +  '</td><tr> ';
  1836                             });
  1837                         }
  1838                         if (data.m ore === tr ue) {
  1839                             //var  indexVal =  parseInt( pageIndex  - 1);
  1840                             $('#da shboard-re nder-logs- table-page nation').h tml('');
  1841                             $('#da shboard-re nder-logs- table-page nation').h tml('<butt on class=" btn btn-pr imary btn- sm disable d" type="b utton" id= "dashboard -render-lo g-previous -btn" oncl ick="showD ashboardVi ewerAndRen derLogFile (\'' + fil eName + '\ ', \'' + a pplication  + '\', \' ' + timeSt amp + '\', ' + parseI nt(pageInd ex - 1) +  ')">Previo us</button >&nbsp;&nb sp<button  class="btn  btn-prima ry btn-sm"  id="dashb oard-rende r-log-next -btn" type ="button"  onclick="s howDashboa rdViewerAn dRenderLog File(\'' +  fileName  + '\', \''  + applica tion + '\' , \'' + ti meStamp +  '\',' + pa rseInt(pag eIndex + 1 ) + ')">Ne xt</button >');
  1842  
  1843                             if (pa geIndex !=  0) {
  1844                                 $( '#dashboar d-render-l og-previou s-btn').re moveClass( 'disabled' );
  1845                             }
  1846                         } else {
  1847                             //$('# displayRen derPaginat ion').html ('');
  1848                             if (pa geIndex ==  0) {
  1849                                 $( '#dashboar d-render-l ogs-table- pagenation ').html('' );
  1850                             } else  {
  1851                                 $( '#dashboar d-render-l og-previou s-btn').re moveClass( 'disabled' );
  1852                                 $( '#dashboar d-render-l og-next-bt n').addCla ss('disabl ed');
  1853                             }
  1854                         }
  1855                    }
  1856                    $('# dashboard- render-log s-table-bo dy').appen d(fileList Informatio n);
  1857                },
  1858                error: f unction (X MLHttpRequ est, textS tatus, err orThrown)  {
  1859                    cons ole.log("T he ajax er ror occurr ed : " + t extStatus) ;
  1860                }
  1861           }) ;
  1862       } else  if (appli cation ===  'VIEWER')  {
  1863           $( '#dashboar d-viewer-l og-header- text').htm l(fileName  + "  ( "  + timeStam p + " )");
  1864           if  (currentS electedFil eName != l astSelecte dViewerFil eName) {
  1865                $('#dash board-view er-log-hea der-text') .html('');
  1866                $('#dash board-view er-log-hea der-text') .html(file Name + "   ( " + time Stamp + "  )");
  1867           }
  1868           la stSelected ViewerFile Name = fil eName;
  1869           $. ajax({
  1870                type: 'G ET',
  1871                url: vie werRenderC achedUrl,
  1872                dataType : 'json',
  1873                async: t rue,
  1874                success:  function  (data) {
  1875                    cons ole.log("D ashboard L og Level v iewer Url  : " + FILE _LIST_URL  + applicat ion + "&Lo gFileName= " + fileNa me + "&Pag eSize=" +  pageSize +  "&PageInd ex=" + pag eIndex);
  1876                    if ( !isNullOrU ndefined(d ata)) {
  1877                         var fileLi stInformat ion = "";
  1878                         if (!isNul lOrUndefin ed(data.lo gEventItem s) && data .logEventI tems.lengt h > 0) {
  1879                             $('#da shboard-vi ewer-logs- table-body ').html('' );
  1880                             $.each (data.logE ventItems,  function  (index, co lData) {
  1881                                 fi leListInfo rmation +=  '<tr><td> ' + colDat a.timeStam p + '</td> <td>' + se tLogLevelL abel(colDa ta.level)  + '</td><t d>' + colD ata.messag e + '</td> <td class= "abbreviat ion">' + c olData.par ameters +  '</td><tr> ';
  1882                             });
  1883                         }
  1884  
  1885                         if (data.m ore === tr ue) {
  1886                             $('#da shboard-vi ewer-logs- table-page nation').h tml('');
  1887                             $('#da shboard-vi ewer-logs- table-page nation').h tml('<butt on id="das hboardPrev iousLogBut ton" class ="btn btn- primary bt n-sm disab led" type= "button" o nclick="sh owDashboar dViewerAnd RenderLogF ile(\'' +  fileName +  '\', \''  + applicat ion + '\',  \'' + tim eStamp + ' \',' + par seInt(page Index - 1)  + ')">Pre vious</but ton>&nbsp; &nbsp<butt on  class= "btn btn-p rimary btn -sm" type= "button" i d="dashboa rdNextLogB utton" onc lick="show DashboardV iewerAndRe nderLogFil e(\'' + fi leName + ' \', \'' +  applicatio n + '\', \ '' + timeS tamp + '\' ,' + parse Int(pageIn dex + 1) +  ')">Next< /button>') ;
  1888  
  1889                             if (pa geIndex ==  0) {
  1890                                 $( '#dashboar dPreviousL ogButton') .addClass( 'disabled' );
  1891                             } else  {
  1892                                 $( '#dashboar dPreviousL ogButton') .removeCla ss('disabl ed');
  1893                             }
  1894                         } else {
  1895                             if (pa geIndex ==  0) {
  1896                                 /* $('#displa yPaginatio n').html(' ');*/
  1897                                 $( '#dashboar dPreviousL ogButton') .hide();
  1898                                 $( '#dashboar dNextLogBu tton').hid e();
  1899                             } else  {
  1900                                 $( '#dashboar dNextLogBu tton').add Class('dis abled');
  1901                                 $( '#dashboar dPreviousL ogButton') .removeCla ss('disabl ed');
  1902                             }
  1903                         }
  1904                    }
  1905                    $('# dashboard- viewer-log s-table-bo dy').appen d(fileList Informatio n);
  1906                },
  1907                error: f unction (X MLHttpRequ est, textS tatus, err orThrown)  {
  1908                    cons ole.log("T he ajax er ror occurr ed : " + t extStatus) ;
  1909                }
  1910           }) ;
  1911       }
  1912   }
  1913  
  1914  
  1915   function d ashboardRe freshLogFi le(applica tion) {
  1916       curren tSelectedP ageIndex =  (currentS electedPag eIndex < 0  ? 0 : cur rentSelect edPageInde x);
  1917       var d  = new Date ();
  1918       var n  = d.getMil liseconds( );
  1919       var vi ewerRender CachedUrl  = FILE_LIS T_URL + ap plication  + "&LogFil eName=" +  currentSel ectedFileN ame + "&Pa geSize=" +  pageSize  + "&PageIn dex=" + cu rrentSelec tedPageInd ex + "&_ca cheBust="  + n;
  1920       if (ap plication  === 'RENDE R') {
  1921           $( '#dashboar d-render-l og-header- text').htm l(currentS electedFil eName + "   ( " + cur rentSelect edTimeStam p + " )");
  1922           if  (currentS electedFil eName != l astSelecte dRenderFil eName) {
  1923                $('#dash board-rend er-log-hea der-text') .html('');
  1924                $('#dash board-rend er-log-hea der-text') .html(curr entSelecte dFileName  + "  ( " +  currentSe lectedTime Stamp + "  )");
  1925           }
  1926           la stSelected RenderFile Name = cur rentSelect edFileName ;
  1927           $. ajax({
  1928                type: 'G ET',
  1929                url: vie werRenderC achedUrl,
  1930                dataType : 'json',
  1931                async: t rue,
  1932                success:  function  (data) {
  1933                    cons ole.log("D ashboard L og Level R ender Url  : " + FILE _LIST_URL  + applicat ion + "&Lo gFileName= " + curren tSelectedF ileName +  "&PageSize =" + pageS ize + "&Pa geIndex="  + currentS electedPag eIndex);
  1934                    if ( !isNullOrU ndefined(d ata)) {
  1935                         var fileLi stInformat ion = "";
  1936                         if (!isNul lOrUndefin ed(data.lo gEventItem s) && data .logEventI tems.lengt h > 0) {
  1937                             $('#da shboard-re nder-logs- table-body ').html('' );
  1938                             $.each (data.logE ventItems,  function  (index, co lData) {
  1939                                 fi leListInfo rmation +=  '<tr><td> ' + colDat a.timeStam p + '</td> <td>' + se tLogLevelL abel(colDa ta.level)  + '</td><t d>' + colD ata.messag e + '</td> <td class= "abbreviat ion">' + c olData.par ameters +  '</td><tr> ';
  1940                             });
  1941                         }
  1942                         if (data.m ore === tr ue) {
  1943                             //var  indexVal =  parseInt( pageIndex  - 1);
  1944                             $('#da shboard-re nder-logs- table-page nation').h tml('');
  1945                             $('#da shboard-re nder-logs- table-page nation').h tml('<butt on class=" btn btn-pr imary btn- sm disable d" type="b utton" id= "dashboard -render-pr evious-btn " onclick= "showDashb oardViewer AndRenderL ogFile(\''  + current SelectedFi leName + ' \', \'' +  applicatio n + '\', \ '' + curre ntSelected TimeStamp  + '\',' +  parseInt(c urrentSele ctedPageIn dex - 1) +  ')">Previ ous</butto n>&nbsp;&n bsp<button  class="bt n btn-prim ary btn-sm " id="dash board-rend er-next-bt n" type="b utton" onc lick="show DashboardV iewerAndRe nderLogFil e(\'' + cu rrentSelec tedFileNam e + '\', \ '' + appli cation + ' \', \'' +  currentSel ectedTimeS tamp + '\' ,' + parse Int(curren tSelectedP ageIndex +  1) + ')"> Next</butt on>');
  1946  
  1947                             if (cu rrentSelec tedPageInd ex != 0) {
  1948                                 $( '#dashboar d-render-p revious-bt n').remove Class('dis abled');
  1949                             }
  1950                         } else {
  1951                             //$('# displayRen derPaginat ion').html ('');
  1952                             if (cu rrentSelec tedPageInd ex == 0) {
  1953                                 $( '#dashboar d-render-l ogs-table- pagenation ').html('' );
  1954                             } else  {
  1955                                 $( '#dashboar d-render-p revious-bt n').remove Class('dis abled');
  1956                                 $( '#dashboar d-render-n ext-btn'). addClass(' disabled') ;
  1957                             }
  1958                         }
  1959                    }
  1960                    $('# dashboard- render-log s-table-bo dy').appen d(fileList Informatio n);
  1961                },
  1962                error: f unction (X MLHttpRequ est, textS tatus, err orThrown)  {
  1963                    cons ole.log("T he ajax er ror occurr ed : " + t extStatus) ;
  1964                }
  1965           }) ;
  1966       } else  if (appli cation ===  'VIEWER')  {
  1967           $( '#dashboar d-viewer-l og-header- text').htm l(currentS electedFil eName + "   ( " + cur rentSelect edTimeStam p + " )");
  1968           if  (currentS electedFil eName != l astSelecte dViewerFil eName) {
  1969                $('#dash board-view er-log-hea der-text') .html('');
  1970                $('#dash board-view er-log-hea der-text') .html(curr entSelecte dFileName  + "  ( " +  currentSe lectedTime Stamp + "  )");
  1971           }
  1972           la stSelected ViewerFile Name = cur rentSelect edFileName ;
  1973           $. ajax({
  1974                type: 'G ET',
  1975                url: vie werRenderC achedUrl,
  1976                dataType : 'json',
  1977                async: t rue,
  1978                success:  function  (data) {
  1979                    cons ole.log("D ashboard L og Level V iewer Url  : " + FILE _LIST_URL  + applicat ion + "&Lo gFileName= " + curren tSelectedF ileName +  "&PageSize =" + pageS ize + "&Pa geIndex="  + currentS electedPag eIndex);
  1980                    if ( !isNullOrU ndefined(d ata)) {
  1981                         var fileLi stInformat ion = "";
  1982                         if (!isNul lOrUndefin ed(data.lo gEventItem s) && data .logEventI tems.lengt h > 0) {
  1983                             $('#da shboard-vi ewer-logs- table-body ').html('' );
  1984                             $.each (data.logE ventItems,  function  (index, co lData) {
  1985                                 fi leListInfo rmation +=  '<tr><td> ' + colDat a.timeStam p + '</td> <td>' + se tLogLevelL abel(colDa ta.level)  + '</td><t d>' + colD ata.messag e + '</td> <td class= "abbreviat ion">' + c olData.par ameters +  '</td><tr> ';
  1986                             });
  1987                         }
  1988  
  1989                         if (data.m ore === tr ue) {
  1990                             $('#da shboard-vi ewer-logs- table-page nation').h tml('');
  1991                             $('#da shboard-vi ewer-logs- table-page nation').h tml('<butt on id="das hboard-vie wer-prev-b tn" class= "btn btn-p rimary btn -sm disabl ed" type=" button" on click="sho wDashboard ViewerAndR enderLogFi le(\'' + c urrentSele ctedFileNa me + '\',  \'' + appl ication +  '\', \'' +  currentSe lectedTime Stamp + '\ ',' + pars eInt(curre ntSelected PageIndex  - 1) + ')" >Previous< /button>&n bsp;&nbsp< button  cl ass="btn b tn-primary  btn-sm" t ype="butto n" id="das hboard-vie wer-next-b tn" onclic k="showDas hboardView erAndRende rLogFile(\ '' + curre ntSelected FileName +  '\', \''  + applicat ion + '\',  \'' + cur rentSelect edTimeStam p + '\','  + parseInt (currentSe lectedPage Index + 1)  + ')">Nex t</button> ');
  1992  
  1993                             if (cu rrentSelec tedPageInd ex == 0) {
  1994                                 $( '#dashboar d-viewer-p rev-btn'). addClass(' disabled') ;
  1995                             } else  {
  1996                                 $( '#dashboar d-viewer-p rev-btn'). removeClas s('disable d');
  1997                             }
  1998                         } else {
  1999                             if (cu rrentSelec tedPageInd ex == 0) {
  2000                                 /* $('#displa yPaginatio n').html(' ');*/
  2001                                 $( '#dashboar d-viewer-p rev-btn'). hide();
  2002                                 $( '#dashboar d-viewer-n ext-btn'). hide();
  2003                             } else  {
  2004                                 $( '#dashboar d-viewer-n ext-btn'). addClass(' disabled') ;
  2005                                 $( '#dashboar d-viewer-p rev-btn'). removeClas s('disable d');
  2006                             }
  2007                         }
  2008                    }
  2009                    $('# dashboard- viewer-log s-table-bo dy').appen d(fileList Informatio n);
  2010                },
  2011                error: f unction (X MLHttpRequ est, textS tatus, err orThrown)  {
  2012                    cons ole.log("T he ajax er ror occurr ed : " + t extStatus) ;
  2013                }
  2014           }) ;
  2015       }
  2016   }
  2017  
  2018   /**
  2019    * set das hboard log  level act ion by pas sing logle vel while  clicking o n apply bu tton
  2020    **/
  2021   function d oDashboard ViewerAndR enderApply LogLevel(t ype) {
  2022       if (ty pe == "VIE WER") {
  2023           da shboardSet LogLevel(" VIEWER", $ ("#dashboa rd-viewer- select-opt ion option :selected" ).val());
  2024       } else  {
  2025           da shboardSet LogLevel(" RENDER", $ ("#dashboa rd-render- select-opt ion option :selected" ).val());
  2026       }
  2027   }
  2028  
  2029   /**
  2030    * set das hboard log  level act ion by pas sing logle vel while  clicking o n apply bu tton
  2031    **/
  2032   function d ashboardSe tLogLevel( type, logl evel) {
  2033       $.ajax ({
  2034           ty pe: 'POST' ,
  2035           ur l: LOG_URL  + type +  "&LogLevel =" + logle vel,
  2036           as ync: true,
  2037           ca che: false ,
  2038           su ccess: fun ction (dat a) {
  2039                console. log("Dashb oard Log L evel Url :  " + LOG_U RL + type) ;
  2040                if (type  == "VIEWE R") {
  2041                    $('# dashboard- viewer-sel ect-option ').val(log level);
  2042                    last AppliedLog Level = lo glevel;
  2043                    dash boardDispl ayViewerLo gFiles();
  2044                } else {
  2045                    $('# dashboard- render-sel ect-option ').val(log level);
  2046                    last AppliedRen derLogLeve l = loglev el;
  2047                    dash boardDispl ayRenderLo gFiles();
  2048                }
  2049           },
  2050           er ror: funct ion (XMLHt tpRequest,  textStatu s, errorTh rown) {
  2051                console. log("The a jax error  occurred :  " + textS tatus);
  2052           }
  2053       });
  2054   }
  2055  
  2056   /**
  2057    * set das hboard log  level act ion by pas sing logle vel
  2058    **/
  2059   function s etLogLevel Label(logL evel) {
  2060       var lo gLevelLabe l;
  2061       if (lo gLevel ===  'DEBUG')  {
  2062           lo gLevelLabe l = "<span  class='la bel label- primary'>"  + logLeve l + "</spa n";
  2063       } else  if (logLe vel === 'I NFO') {
  2064           lo gLevelLabe l = "<span  class='la bel label- success'>"  + logLeve l + "</spa n";
  2065       } else  if (logLe vel === 'W ARN') {
  2066           lo gLevelLabe l = "<span  class='la bel label- warning'>"  + logLeve l + "</spa n";
  2067       } else  if (logLe vel === 'E RROR') {
  2068           lo gLevelLabe l = "<span  class='la bel label- danger'>"  + logLevel  + "</span ";
  2069       } else  if (logLe vel === 'T RACE') {
  2070           lo gLevelLabe l = "<span  class='la bel label- info'>" +  logLevel +  "</span";
  2071       }
  2072       return  logLevelL abel;
  2073   }
  2074  
  2075   /**
  2076    * load da shboard vi ewer log w ith json f ormat
  2077    **/
  2078   $(document ).on("clic k", "#dash board-view er-log-tab le tbody t r", functi on (e) {
  2079       var pa ram = $(th is).find(" .abbreviat ion").html ();
  2080       if (!i sNullOrUnd efined(par am) && par am !== "")  {
  2081           $( "#dashboar d-viewer-l og-json-fo rmat").JSO NView(JSON .stringify (getJson(p aram)));
  2082       } else  {
  2083           co nsole.log( 'The param eter conta ins empty  string');
  2084           $( "#dashboar d-viewer-l og-json-fo rmat").htm l("The par ameter con tains empt y string") ;
  2085       }
  2086   });
  2087  
  2088   /**
  2089    * load da shboard re nder log w ith json f ormat
  2090    **/
  2091   $(document ).on("clic k", "#dash board-rend er-log-tab le tr", fu nction (e)  {
  2092       var pa ram = $(th is).find(" .abbreviat ion").html ();
  2093       if (!i sNullOrUnd efined(par am) && par am !== "")  {
  2094           $( "#dashboar d-render-l og-json-fo rmat").JSO NView(JSON .stringify (getJson(p aram)));
  2095       } else  {
  2096           co nsole.log( 'The param eter conta ins empty  string');
  2097           $( "#dashboar d-render-l og-json-fo rmat").htm l("The par ameter con tains empt y string") ;
  2098       }
  2099   });
  2100  
  2101  
  2102   function r emoveAllLo gFiles(typ e) {
  2103       $("#lo gViewerAnd RenderModa l").modal( );
  2104       if (ty pe == "VIE WER") {
  2105           $( '#btnRende rLog').hid e();
  2106           $( '#btnViewe rLog').sho w();
  2107       } else  {
  2108           $( '#btnViewe rLog').hid e();
  2109           $( '#btnRende rLog').sho w();
  2110       }
  2111   }
  2112  
  2113   function r emoveViewe rLogFile(t ype) {
  2114       if (ty pe == "VIE WER") {
  2115           $. ajax({
  2116                type: 'D ELETE',
  2117                url: LOG _FILE_URL  + type,
  2118                success:  function  (data) {
  2119                    $('# logViewerA ndRenderMo dal').moda l('hide');
  2120                    dash boardDispl ayViewerLo gFiles();
  2121                },
  2122                error: f unction (X MLHttpRequ est, textS tatus, err orThrown)  {
  2123                    cons ole.log("T he ajax er ror occurr ed : " + t extStatus) ;
  2124                }
  2125           }) ;
  2126       } else  {
  2127           $. ajax({
  2128                type: 'D ELETE',
  2129                url: LOG _FILE_URL  + type,
  2130                success:  function  (data) {
  2131                    $('# logViewerA ndRenderMo dal').moda l('hide');
  2132                    dash boardDispl ayRenderLo gFiles();
  2133                },
  2134                error: f unction (X MLHttpRequ est, textS tatus, err orThrown)  {
  2135                    cons ole.log("T he ajax er ror occurr ed : " + t extStatus) ;
  2136                }
  2137           }) ;
  2138       }
  2139   }
  2140  
  2141   function c learAllLog s(type) {
  2142       $("#cl earLogView erAndRende rModal").m odal();
  2143       if (ty pe == "VIE WER") {
  2144           $( '#btnClear RenderLog' ).hide();
  2145           $( '#btnClear ViewerLog' ).show();
  2146       } else  {
  2147           $( '#btnClear ViewerLog' ).hide();
  2148           $( '#btnClear RenderLog' ).show();
  2149       }
  2150   }
  2151  
  2152   function c learViewer LogFile(ty pe) {
  2153       if (ty pe == "VIE WER") {
  2154           $. ajax({
  2155                type: 'D ELETE',
  2156                url: LOG _FILE_URL  + type + " &LogFileNa me=" + las tSelectedV iewerFileN ame,
  2157                success:  function  (data) {
  2158                    $('# clearLogVi ewerAndRen derModal') .modal('hi de');
  2159                    dash boardDispl ayViewerLo gFiles();
  2160                },
  2161                error: f unction (X MLHttpRequ est, textS tatus, err orThrown)  {
  2162                    cons ole.log("T he ajax er ror occurr ed : " + t extStatus) ;
  2163                }
  2164           }) ;
  2165       } else  {
  2166           $. ajax({
  2167                type: 'D ELETE',
  2168                url: LOG _FILE_URL  + type + " &LogFileNa me=" + las tSelectedR enderFileN ame,
  2169                success:  function  (data) {
  2170                    $('# clearLogVi ewerAndRen derModal') .modal('hi de');
  2171                    dash boardDispl ayRenderLo gFiles();
  2172                },
  2173                error: f unction (X MLHttpRequ est, textS tatus, err orThrown)  {
  2174                    cons ole.log("T he ajax er ror occurr ed : " + t extStatus) ;
  2175                }
  2176           }) ;
  2177       }
  2178   }
  2179  
  2180  
  2181   /**
  2182    * Load da shboard se arch page  while clic king on da shboard se arch image
  2183    **/
  2184   function s howDashboa rdSearch()  {
  2185       hideAn dShowTopMe nu();
  2186       $('#da shboard-to pmenu-sear ch-home'). show();
  2187       $('#da hsboard-to pmenu-home -nav').sho w();
  2188       $('#da shboard-se arch-home' ).show();
  2189  
  2190   }
  2191  
  2192   /* 
  2193    * load al l the titl e of the h eaders in  select box  
  2194    */
  2195   function l oadHeaders Title() {
  2196       consol e.log("Rea der header  url : " +  HEADERS_T ITLE_URL);
  2197       $.ajax ({
  2198           ty pe: 'GET',
  2199           ur l: HEADERS _TITLE_URL ,
  2200           da taType: 'j son',
  2201           su ccess: fun ction (dat a) {
  2202                if (!isN ullOrUndef ined(data) ) {
  2203                    cons ole.log("T he length  of the hea der : " +  data.items .length);
  2204                    if ( !isNullOrU ndefined(d ata.items)  && data.i tems.lengt h > 0) {
  2205                         $.each(dat a.items, f unction (i ndex, colD ata) {
  2206                             $('#he aderSelect Box').appe nd('<optio n value="'  + colData .header.na me + '">'  + colData. title + '< /option>') ;
  2207                         });
  2208                    }
  2209                    appl yHeaderTit le($("#hea derSelectB ox option: selected") .val());
  2210                }
  2211           },
  2212           er ror: funct ion (XMLHt tpRequest,  textStatu s, errorTh rown) {
  2213                console. log("The a jax error  occurred :  " + textS tatus);
  2214           }
  2215       });
  2216   }
  2217  
  2218   /** 
  2219    *  select  header ti tle from t he select  box and cl ick on app ly button.  The follo wing code  will do th e action o f apply 
  2220    *  button  and displ ay headers  and body  text 
  2221    */
  2222   function a pplyHeader Title(opti onSelected Val) {
  2223       consol e.log("Sel ected Opti on Value :  " + optio nSelectedV al);
  2224       var he aderTitle  = $('#head erSelectBo x option:s elected'). html()
  2225       consol e.log("Hea der title  : " + head erTitle);
  2226       $.ajax ({
  2227           ty pe: 'GET',
  2228           ur l: HEADERS _TITLE_URL ,
  2229           da taType: 'j son',
  2230           su ccess: fun ction (dat a) {
  2231                console. log("Heade r title le ngth : " +  data.item s.length);
  2232                var head erVal = [] ;
  2233                for (i =  0; i < da ta.items.l ength; i++ ) {
  2234                    var  bashItems  = data.ite ms[i];
  2235                    if ( headerTitl e.trim() = = bashItem s.title) {
  2236                         if (!bashI tems.type)  {
  2237                             bashIt ems.type =  'STUDYQUE RY';
  2238                         }
  2239  
  2240                         $('#queryT ype').val( bashItems. type);
  2241                         if (bashIt ems.type = = 'STUDYQU ERY') {
  2242                             $('#re questUrl') .val(BASE_ URL + "stu dyquery");
  2243                             consol e.log("Dis playing st udy query  url : " +  BASE_URL +  "studyque ry");
  2244                         } else if  (bashItems .type == ' ROI') {
  2245                             $('#re questUrl') .val(BASE_ URL.replac e('viewer' , 'roi/sta tus'));
  2246                             consol e.log("Dis playing ro i status u rl : " + B ASE_URL.re place('vie wer', 'roi '));
  2247                         }
  2248  
  2249                         if (bashIt ems.header .name == o ptionSelec tedVal &&  bashItems. header.ite ms.length  > 0 || bas hItems.hea der.name ! = optionSe lectedVal  && bashIte ms.header. items.leng th > 0) {
  2250                             for (v ar i = 0;  i < bashIt ems.header .items.len gth; i++)  {
  2251                                 he aderVal.pu sh(bashIte ms.header. items[i].k ey + ":" +  bashItems .header.it ems[i].val ue);
  2252                             }
  2253                             $('#he aderText') .val(heade rVal);
  2254                         } else if  (bashItems .header.na me == opti onSelected Val && bas hItems.hea der.items. length ==  0) {
  2255                             for (v ar index =  0; index  < data.hea ders.lengt h; index++ ) {
  2256                                 if  (data.hea ders[index ].name ==  optionSele ctedVal) {
  2257                                      for (var  i = 0; i  < data.hea ders[index ].items.le ngth; i++)  {
  2258                                          head erVal.push (data.head ers[index] .items[i]. key + ":"  + data.hea ders[index ].items[i] .value);
  2259                                          head erVal.push ("\n");
  2260                                      }
  2261                                 }
  2262                             }
  2263                             $('#he aderText') .val(heade rVal.join( ' '));
  2264                         } else {
  2265                             consol e.log("The re is no i tem availa ble in thi s header") ;
  2266                         }
  2267                         $('#bodyTe xt').val(J SON.string ify(bashIt ems.body,  undefined,  4));
  2268                         return;
  2269                    }
  2270                }
  2271           }
  2272       });
  2273   }
  2274  
  2275   /**
  2276    * This me thod is us ed to fetc h all the  study info rmation ba sed on req uestUrl.Th e followin g informat ions are r ead from t he user.
  2277    */
  2278   function f etchStudyI nformation () {
  2279       var re questUrl =  $('#reque stUrl').va l();
  2280       var he aderTextVa l = $("#he aderText") .val();
  2281       var co ntents = $ ('#bodyTex t').val();
  2282       var qu eryType =  $('#queryT ype').val( );
  2283  
  2284       if (re questUrl = = null ||  requestUrl  == "") {
  2285           al ert("Reque st URL mus t not be n ull");
  2286           $( '#requestU rl').focus ();
  2287       } else  if (heade rTextVal = = null ||  headerText Val == "")  {
  2288           al ert("Heade rs must no t be null" );
  2289           $( '#headerTe xt').focus ();
  2290       } else  if (conte nts == nul l || conte nts == "")  {
  2291           al ert("Body  must not b e null");
  2292           $( '#bodyText ').focus() ;
  2293       } else  {
  2294           co nsole.log( requestUrl );
  2295           $( "#ajax_loa der").show ();
  2296           va r headerAr r = header TextVal.sp lit('\n');
  2297           va r headers  = {};
  2298           $. each(heade rArr, func tion (inde x, colData ) {
  2299                var head  = colData .split(':' );
  2300                if (head [0] !== '' ) {
  2301                    head ers[head[0 ].trim()]  = head[1]. trim();
  2302                }
  2303           }) ;
  2304  
  2305           if  (queryTyp e == 'STUD YQUERY') {
  2306                $.ajax({
  2307                    url:  requestUr l,
  2308                    data : contents .trim(),
  2309                    head ers: heade rs,
  2310                    meth od: 'POST' ,
  2311                    data Type: 'jso n',
  2312                    asyn c: true,
  2313                    succ ess: funct ion (data)  {
  2314                         // fetch a ll the pat ient and s tudy infor mation and  display i t
  2315                         if (!isNul lOrUndefin ed(data.pa tientICN))  {
  2316                             $('#pa tientICN') .html("Pat ientICN :  " + data.p atientICN) ;
  2317                         }
  2318  
  2319                         if (!isNul lOrUndefin ed(data.pa tientDFN))  {
  2320                             $('#pa tientDFN') .html("Pat ientDFN :  " + data.p atientDFN) ;
  2321                         }
  2322  
  2323                         if (!isNul lOrUndefin ed(data.si teNumber))  {
  2324                             $('#si teNumber') .html("Sit e Number :  " + data. siteNumber );
  2325                         }
  2326  
  2327                         if (!isNul lOrUndefin ed(data.au thSiteNumb er)) {
  2328                             $('#au thSiteNumb er').html( "AuthSiteN umber : "  + data.aut hSiteNumbe r);
  2329                         }
  2330  
  2331                         if (!isNul lOrUndefin ed(data.us erId)) {
  2332                             $('#us erId').htm l("User ID  : " + dat a.userId);
  2333                         }
  2334  
  2335                         if (!isNul lOrUndefin ed(data.au thSiteNumb er)) {
  2336                             $('#au thSiteNumb erVal').va l(data.aut hSiteNumbe r);
  2337                         }
  2338  
  2339                         if (data.s tudies &&  data.studi es.length  > 0 && !is NullOrUnde fined(data .studies[0 ].security Token)) {
  2340                             $('#se curityToke n').val(da ta.studies [0].securi tyToken);
  2341                             consol e.log("Tot al no of s tudies loa ded : " +  data.studi es.length) ;
  2342                         }
  2343  
  2344                         //Display  all the st udy inform ation in d ataTAble
  2345  
  2346                         var studyI nformation  = "";
  2347                         if (!isNul lOrUndefin ed(data))  {
  2348                             if (!i sNullOrUnd efined(dat a.studies)  && data.s tudies.len gth > 0) {
  2349                                 $. each(data. studies, f unction (i ndex, data Val) {
  2350                                      studyInf ormation + = '<tr><td  class="wr ap_words"> ' + dataVa l.groupIEN  + '</td>< td class=" wrap_words ">' + data Val.imageC ount + '</ td><td>' +  dataVal.s tudyId +
  2351                                          '</t d><td clas s="wrap_wo rds">' + d ataVal.eve nt + '</td ><td class ="wrap_wor ds">' + fo rmatDate(d ataVal.stu dyDate) +  '</td><td  class="wra p_words">'  + dataVal .procedure Descriptio n + '</td> <td class= "wrap_word s">' + dat aVal.speci altyDescri ption +
  2352                                          '</t d><td>' +
  2353                                          '<a  class="btn  btn-warni ng btn-sm"  onClick=" viewStudy( \'' + data Val.viewer Url + '\',  ' + index  + ')">Vie w</a>&nbsp ;' +
  2354                                          '<a  id="addToS ession_' +  index + ' " class="b tn btn-inf o btn-sm a ddToSessio n" onClick ="addToSes sion(\'' +  dataVal.c ontextId +  '\', \''  + dataVal. securityTo ken + '\', \'' + data Val.patien tICN + '\' ,\'' + dat aVal.patie ntDFN + '\ ',\'' + da taVal.site Number + ' \', \'' +  data.authS iteNumber  + '\')" st yle="displ ay: none"> Add</a>&nb sp;' +
  2355                                          '<a  href="#" c lass="btn  btn-primar y btn-sm"  onClick="l aunchManag eURL(\'' +  dataVal.m anageUrl +  '\')">Man age</a>&nb sp;' +
  2356                                          '<a  href="#" c lass="btn  btn-succes s btn-sm"  onClick="l aunchDetai lsURL(\''  + dataVal. detailsUrl  + '&inclu deImageDet ails=true'  + '\')">D etails</a> &nbsp;' +
  2357                                          '<a  href="#" c lass="btn  btn-primar y btn-sm"  onClick="l aunchRepor tURL(\'' +  dataVal.r eportUrl +  '\')">Rep ort</a>&nb sp;' +
  2358                                          '<a  class="btn  btn-dange r btn-sm"  onClick="l oadPurgeSt udy(\'' +  dataVal.vi ewerUrl +  '\',\'' +  dataVal.st udyId + '\ ')">Purge< /a>&nbsp;'  +
  2359                                          '</t d></tr>';
  2360                                 }) ;
  2361                             }
  2362                         }
  2363                         $('#patien tInformati on').hide( );
  2364                         $('#studyI nfoTable') .DataTable ().destroy ();
  2365                         $('#studyI nfo').html ('');
  2366                         $('#studyI nfo').appe nd(studyIn formation) ;
  2367                         // Display  data in t he dataTab le
  2368                         var table  = $('#stud yInfoTable ').DataTab le({
  2369                             "bDest roy": true ,
  2370                             "bAuto Width": fa lse,
  2371                             "bFilt er": true,
  2372                             "bSort ": true,
  2373                             "aaSor ting": [[0 ]],
  2374                             "lengt hMenu": [[ 5, 10, 15,  -1], [5,  10, 15, "A ll"]],
  2375                             "pageL ength": 5,
  2376                             "aoCol umns": [
  2377                                 {
  2378                                      "sWidth" : '1%',
  2379                                      "bSortab le": true
  2380                                 },
  2381                                 {
  2382                                      "sWidth" : '1%',
  2383                                      "bSortab le": true
  2384                                 },
  2385                                 {
  2386                                      "sWidth" : '15%',
  2387                                      "bSortab le": true
  2388                                 },
  2389                                 {
  2390                                      "sWidth" : '1%',
  2391                                      "bSortab le": true
  2392                                 },
  2393                                 {
  2394                                      "sWidth" : '5%',
  2395                                      "bSortab le": true
  2396                                 },
  2397                                 {
  2398                                      "sWidth" : '1%',
  2399                                      "bSortab le": true
  2400                                 },
  2401                                 {
  2402                                      "sWidth" : '5%',
  2403                                      "bSortab le": true
  2404                                 },
  2405                                 {
  2406                                      "sWidth" : '25%',
  2407                                      "bSortab le": false
  2408                                 }
  2409                                                       ]
  2410                         });
  2411                         $('#contai ner').css( 'display',  'block');
  2412                         table.colu mns.adjust ().draw();
  2413                         $("#ajax_l oader").hi de();
  2414                         $('#sudyIn formation' ).show();
  2415                    },
  2416                    erro r: functio n (xhr, st atus) {
  2417                         $("#ajax_l oader").hi de();
  2418                         alert("Con nection pr oblem with  Server");
  2419                    }
  2420                });
  2421           }  else if (q ueryType = = 'ROI') {
  2422                $.ajax({
  2423                    type : 'GET',
  2424                    url:  requestUr l,
  2425                    head ers: heade rs,
  2426                    data Type: 'jso n',
  2427                    succ ess: funct ion (data)  {
  2428                         console.lo g("Display  available  patient i nformation  length :"  + data.le ngth);
  2429                         //Display  all the pa tient info rmation in  dataTAble
  2430                         var patien tInformati on = "";
  2431                         if (!isNul lOrUndefin ed(data) & & data.len gth > 0) {
  2432                             $.each (data, fun ction (ind ex, colDat a) {
  2433                                 va r dicomRou ting = isN ullOrUndef ined(colDa ta.dicomRo uting) ? " " : colDat a.dicomRou ting;
  2434                                 pa tientInfor mation +=  '<tr><td>'  + colData .patientNa me + '</td ><td>' + c olData.ssN 4 + '</td> <td>' + co lData.pati entId + '< /td><td>'  + colData. status + ' </td><td>'  + colData .lastUpdat ed + '</td ><td>' + d icomRoutin g + '</td> </tr>';
  2435                             });
  2436                         }
  2437                         $('#sudyIn formation' ).hide();
  2438                         $('#patien tInfoTable ').DataTab le().destr oy();
  2439                         $('#patien tInfo').ht ml('');
  2440                         $('#patien tInfo').ap pend(patie ntInformat ion);
  2441                         // Display  data in t he dataTab le
  2442                         var table  = $('#pati entInfoTab le').DataT able({
  2443                             "bDest roy": true ,
  2444                             "bAuto Width": fa lse,
  2445                             "bFilt er": true,
  2446                             "bSort ": true,
  2447                             "aaSor ting": [[0 ]],
  2448                             "lengt hMenu": [[ 5, 10, 15,  -1], [5,  10, 15, "A ll"]],
  2449                             "pageL ength": 5,
  2450                             "aoCol umns": [
  2451                                 {
  2452                                      "sWidth" : '10%',
  2453                                      "bSortab le": true
  2454                                 },
  2455                                 {
  2456                                      "sWidth" : '10%',
  2457                                      "bSortab le": true
  2458                                 },
  2459                                 {
  2460                                      "sWidth" : '10%',
  2461                                      "bSortab le": true
  2462                                 },
  2463                                 {
  2464                                      "sWidth" : '10%',
  2465                                      "bSortab le": true
  2466                                 },
  2467                                 {
  2468                                      "sWidth" : '10%',
  2469                                      "bSortab le": true
  2470                                 },
  2471                                 {
  2472                                      "sWidth" : '10%',
  2473                                      "bSortab le": true
  2474                                 }
  2475                                                       ]
  2476                         });
  2477                         $('#contai ner').css( 'display',  'block');
  2478                         table.colu mns.adjust ().draw();
  2479                         $("#ajax_l oader").hi de();
  2480                         $('#patien tInformati on').show( );
  2481                    },
  2482                    erro r: functio n (xhr, st atus) {
  2483                         $("#ajax_l oader").hi de();
  2484                         alert("Con nection pr oblem with  Server");
  2485                    }
  2486                });
  2487           }
  2488       }
  2489   }
  2490  
  2491   // Load mo dal window  for purgi ng the stu dy 
  2492   function l oadPurgeSt udy(viewer Url, study Id) {
  2493       $("#pu rgeStudyMo dal").moda l();
  2494       $('#pu rgeStudyID ').html(st udyId);
  2495       $('#vi ewerURL'). val(viewer Url);
  2496       $('#st udyPurgeID ').val(stu dyId);
  2497   }
  2498  
  2499   // Purge a ction 
  2500   function p urgeStudy( ) {
  2501       var vi ewerUrl =  $('#viewer URL').val( );
  2502       var st udyId = $( '#studyPur geID').val ();
  2503  
  2504       var pu rgeUrl = v iewerUrl.r eplace("lo ader?", "c ontext?");
  2505  
  2506       $.ajax ({
  2507           ty pe: 'DELET E',
  2508           ur l: purgeUr l,
  2509           su ccess: fun ction (dat a) {
  2510                $("#purg eStudyModa l").modal( 'hide');
  2511                console. log("succe ssfully pu rged the c urrent stu dy");
  2512           },
  2513           er ror: funct ion (xhr,  status) {
  2514                $("#purg eStudyModa l").modal( 'hide');
  2515                alert("C onnection  problem wi th Server" );
  2516           }
  2517       });
  2518   }
  2519  
  2520   /**
  2521    * launch  the report  url in ne w tab
  2522    */
  2523   function l aunchRepor tURL(repor tUrl) {
  2524       consol e.log("Lau nch report  url :" +  reportUrl) ;
  2525       window .open(repo rtUrl);
  2526       return  false;
  2527   }
  2528  
  2529   function l aunchDetai lsURL(deta ilsUrl) {
  2530       var wi n = window .open(deta ilsUrl, '_ blank');
  2531       $.ajax ({
  2532           ty pe: 'GET',
  2533           ur l: details Url,
  2534           da taType: 'j son',
  2535           su ccess: fun ction (dat a) {
  2536                console. log(detail sUrl);
  2537                win.docu ment.write ('<html><h ead><title >' + detai lsUrl + '< /title><li nk rel="st ylesheet"  type="text /css" href ="../style /jquery.js onview.css "><script  type="text /javascrip t" src=".. /js/jquery -1.11.1.js "></script ><script t ype="text/ javascript " src="../ js/jquery. jsonview.j s"></scrip t></head>< body><div  id="conten t"></div>< script>$(" #content") .JSONView( ' + JSON.s tringify(d ata) + ')< /script>') ;
  2538                win.docu ment.write ('</body>< /html>');
  2539                win.focu s();
  2540           }
  2541       });
  2542   }
  2543  
  2544   function f ormatDate( date) {
  2545       var d  = new Date (date),
  2546           mo nth = '' +  (d.getMon th() + 1),
  2547           da y = '' + d .getDate() ,
  2548           ye ar = d.get FullYear() ;
  2549  
  2550       if (mo nth.length  < 2) mont h = '0' +  month;
  2551       if (da y.length <  2) day =  '0' + day;
  2552  
  2553       return  [year, mo nth, day]. join('-');
  2554   }
  2555  
  2556   /**
  2557    * launch  the manage  url in ne w tab
  2558    */
  2559   function l aunchManag eURL(manag eUrl) {
  2560       consol e.log("Lau nch manage  url :" +  manageUrl) ;
  2561       window .open(mana geUrl);
  2562       return  false;
  2563   }
  2564  
  2565   /**
  2566    * launch  the manage  url in ne w tab
  2567    */
  2568   function l aunchDetai lURL(detai lsUrl) {
  2569       consol e.log("Req uested det ails url : " + detail sUrl);
  2570       $('#he aderID').h ide();
  2571       $('#fo oterID').h ide();
  2572       $('#hr ID').hide( );
  2573       $('#ex Tab2').hid e();
  2574       $('#co nsole-log- div').hide ();
  2575       $('#su dyInformat ion').hide ();
  2576       $('#pa tientInfor mation').h ide();
  2577       $.ajax ({
  2578           ty pe: 'GET',
  2579           ur l: details Url,
  2580           da taType: 'j son',
  2581           su ccess: fun ction (dat a) {
  2582                console. log("Launc h the deta il url : "  + JSON.st ringify(da ta, undefi ned, 4));
  2583                $('#disp layDetailI nformation ').JSONVie w(data);
  2584                $('#disp layDetailI nformation ').show();
  2585           }
  2586       });
  2587  
  2588   }
  2589  
  2590   /** 
  2591    * Clickin g on this  should cal l the sess ion status  endpoint
  2592    * which w ill return  a list of  studies c urrently d isplayed a nd idle ti me. Place  a â€˜Remov e’ butto n next to  each displ ayed study  item.
  2593    * The stu dy list ca n be displ ayed eithe r in a pop up or as a n expandab le panel.  The sessio n status c all should  be as fol lows
  2594    */
  2595   function l oadStatusA ction() {
  2596       var se ssionId =  $('#sessio nId').val( );
  2597       var se curityToke n = $('#se curityToke n').val();
  2598       consol e.log("Rea ding the i nput from  the hidden  text box  as Session Id, Securi tyToken  :  " + sessi onId + ","  + securit yToken);
  2599       // GET  http://lo calhost:99 11/vix/vie wer/site/< authSiteNu mber>/sess ion/<sessi onId>/stat us
  2600       var st atusUrl =  BASE_URL +  "site/500 /session/"  + session Id + "/sta tus?Securi tyToken="  + security Token;
  2601       consol e.log("Fet ch study i nformation  from the  session fo llowing st atus url :  " + statu sUrl);
  2602  
  2603       $.ajax ({
  2604           ur l: statusU rl,
  2605           me thod: 'GET ',
  2606           da taType: 'j son',
  2607           as ync: true,
  2608           su ccess: fun ction (dat a) {
  2609                console. log("Statu s to sessi on studies  contextId s length : " + data.c ontextIds. length);
  2610                console. log("Statu s to sessi on studies  idle time  :" + data .idleTime) ;
  2611                $('#idle Time').htm l("Idle Ti me :" + da ta.idleTim e);
  2612                $('#stat usTable'). find('tbod y').empty( );
  2613                var stat usInformat ion = "";
  2614                $.each(d ata.contex tIds, func tion (inde x, colData ) {
  2615                    stat usInformat ion += '<t r><td>' +  colData +  '</td><td> ' +
  2616                         '<a class= "btn btn-d anger btn- sm" onClic k="removeF romSession (\'' + col Data + '\' )"><i clas s="glyphic on glyphic on-trash"> </i></butt on></td></ tr>';
  2617                });
  2618                $('#stat usTable'). append(sta tusInforma tion);
  2619                $("#myMo dal").moda l();
  2620           }
  2621       });
  2622   }
  2623  
  2624   /** 
  2625    * This me thod is us ed to laun ch particu lar study 
  2626    */
  2627   function v iewStudy(v iewerUrl,  index) {
  2628       var se ssionId =  $('#sessio nId').val( );
  2629       if (se ssionId ==  null || s essionId = = "") {
  2630           se ssionId =  GenRandom. Job();
  2631           $( '#sessionI d').val(se ssionId);
  2632           $( '#dispalyS ession').s how();
  2633       }
  2634       consol e.log("Rea ding the i nput from  the hidden  text box  as Session Id : " + s essionId);
  2635       var ur l = viewer Url + "&se ssionId="  + sessionI d;
  2636       consol e.log("Lau nch the Vi ewer url :  " + url);
  2637       window .open(url,  '_blank') ;
  2638       $('.ad dToSession ').css("di splay", "" );
  2639       $('#ad dToSession _' + index ).hide();
  2640   }
  2641  
  2642   /** 
  2643    * This me thod is us ed to add  study to s ession 
  2644    */
  2645   function a ddToSessio n(contextI d, securit yToken, pa tientICN,  patientDFN , siteNumb er, authSi teNumber)  {
  2646       var co ntextList  = [];
  2647       contex tList.push (contextId );
  2648       var co ntextIdLis t = JSON.s tringify(c ontextList );
  2649       consol e.log("Lis t all the  contextLis t : " + co ntextIdLis t);
  2650       var se ssionId =  $('#sessio nId').val( );
  2651       consol e.log("Rea ding the i nput from  the hidden  text box  : " + sess ionId);
  2652       var ad dContextUr l = BASE_U RL + "site /" + authS iteNumber  + "/sessio n/" + sess ionId + "/ context?Si teNumber="  + siteNum ber + "&Se curityToke n=" + secu rityToken  + "&AuthSi teNumber="  + authSit eNumber +  "&sessionI d=" + sess ionId;
  2653       if (pa tientICN ! = 'undefin ed')
  2654           ad dContextUr l = addCon textUrl +  "&PatientI CN=" + pat ientICN;
  2655       else
  2656           ad dContextUr l = addCon textUrl +  "&PatientD FN=" + pat ientDFN;
  2657  
  2658       consol e.log("Add  Context U RL { Conte xt URL } :  " + addCo ntextUrl);
  2659  
  2660       $.ajax ({
  2661           ty pe: 'POST' ,
  2662           ur l: addCont extUrl,
  2663           da ta: contex tIdList,
  2664           he aders: {
  2665                'Content -Type': 'a pplication /json',
  2666           },
  2667           da taType: 'j son',
  2668           su ccess: fun ction (dat a) {
  2669                console. log("succe ssfully po sted the a dd context  Url reque st to serv er");
  2670           }
  2671       });
  2672       $('#st atusBtn'). show();
  2673   }
  2674  
  2675   /**
  2676    * This me hod is use d to remov e the stud y from the  session 
  2677    */
  2678   function r emoveFromS ession(con textId) {
  2679       var co ntextList  = [];
  2680       contex tList.push (contextId );
  2681       var co ntextIdLis t = JSON.s tringify(c ontextList );
  2682       consol e.log("Lis t all the  contextLis t : " + co ntextIdLis t)
  2683       var se ssionId =  $('#sessio nId').val( );
  2684       var se curityToke n = $('#se curityToke n').val();
  2685       var au thSiteNumb er = $('#a uthSiteNum berVal').v al();
  2686       consol e.log("Rea ding the i nput from  the hidden  text box  as Securit yToken, Se ssionId, A uthSiteNum ber  : " +  securityT oken + ","  + session Id + "," +  authSiteN umber);
  2687       var re moveContex tUrl = BAS E_URL + "s ite/" + au thSiteNumb er + "/ses sion/" + s essionId +  "/context ?SecurityT oken=" + s ecurityTok en;
  2688       consol e.log("Rem ove Contex t url : "  + removeCo ntextUrl);
  2689  
  2690       $.ajax ({
  2691           ty pe: 'DELET E',
  2692           ur l: removeC ontextUrl,
  2693           da ta: contex tIdList,
  2694           he aders: {
  2695                'Content -Type': 'a pplication /json',
  2696           },
  2697           su ccess: fun ction (dat a) {
  2698                console. log("succe ssfully po sted the r emove cont ext Url re quest to s erver");
  2699           }
  2700       });
  2701   }
  2702  
  2703   /* Generat e random n umber for  adding ses sion id th e study */
  2704   var GenRan dom = {
  2705       Stored : [],
  2706       Job: f unction ()  {
  2707           // var newId  = Date.now ().toStrin g().substr (6); // or  use any m ethod that  you want  to achieve  this stri ng
  2708           va r newId =  generateGU ID();
  2709           if  (!this.Ch eck(newId) ) {
  2710                this.Sto red.push(n ewId);
  2711                return n ewId;
  2712           }
  2713           re turn this. Job();
  2714       },
  2715  
  2716       Check:  function  (id) {
  2717           fo r (var i =  0; i < th is.Stored. length; i+ +) {
  2718                if (this .Stored[i]  == id) re turn true;
  2719           }
  2720           re turn false ;
  2721       }
  2722   };
  2723  
  2724  
  2725   var genera teGUID = ( typeof (wi ndow.crypt o) != 'und efined' &&  typeof (w indow.cryp to.getRand omValues)  != 'undefi ned') ? fu nction ()  {
  2726           //  If we hav e a crypto graphicall y secure P RNG, use t hat
  2727           //  https://s tackoverfl ow.com/que stions/690 6916/colli sions-when -generatin g-uuids-in -javascrip t
  2728           va r buf = ne w Uint16Ar ray(8);
  2729           wi ndow.crypt o.getRando mValues(bu f);
  2730           va r S4 = fun ction (num ) {
  2731                var ret  = num.toSt ring(16);
  2732                while (r et.length  < 4) {
  2733                    ret  = "0" + re t;
  2734                }
  2735                return r et;
  2736           };
  2737           re turn (S4(b uf[0]) + S 4(buf[1])  + "-" + S4 (buf[2]) +  "-" + S4( buf[3]) +  "-" + S4(b uf[4]) + " -" + S4(bu f[5]) + S4 (buf[6]) +  S4(buf[7] ));
  2738       } :
  2739  
  2740       functi on () {
  2741           //  Otherwise , just use  Math.rand om
  2742           //  https://s tackoverfl ow.com/que stions/105 034/how-to -create-a- guid-uuid- in-javascr ipt/211752 3#2117523
  2743           re turn 'xxxx xxxx-xxxx- 4xxx-yxxx- xxxxxxxxxx xx'.replac e(/[xy]/g,  function  (c) {
  2744                var r =  Math.rando m() * 16 |  0,
  2745                    v =  c == 'x' ?  r : (r &  0x3 | 0x8) ;
  2746                return v .toString( 16);
  2747           }) ;
  2748       };
  2749  
  2750   function s howDashboa rdSystemPr eferences( ) {
  2751       initia lizePages( );
  2752       hideAn dShowTopMe nu();
  2753       displa yAnnotatio nPreferenc es();
  2754  
  2755       $('#da shboard-to pmenu-syst em-prefere nce-home') .show();
  2756       $('#da hsboard-to pmenu-home -nav').sho w();
  2757       $('#da shboard-sy stem-prefe rence-home ').show();
  2758   }
  2759  
  2760   /**
  2761    * Initial ize the pa ges
  2762    */
  2763   var isPage sInitializ ed = false ;
  2764  
  2765   function i nitializeP ages() {
  2766       if (!i sPagesInit ialized) {
  2767           //  Cine pref erence tab
  2768           $( '#cineTab' ).html('') ;
  2769           lo adCinePref erenceWind ow("Cine P references ");
  2770  
  2771           //  ECG prefe rence Tab
  2772           $( '#ecgTab') .html('');
  2773           lo adECGPrefe renceWindo w("ECG Pre ferences") ;
  2774  
  2775           //  Annotatio n preferen ce tab
  2776           ge tStrokeSty le("ASTROK ESTYLE");
  2777  
  2778           //  Display p reference  tab
  2779           $( '#displayT ab').html( '');
  2780           lo adDisplayP referenceW indow("Lay out Prefer ences");
  2781  
  2782           //  Copy attr ibutes pre ference ta b
  2783           $( '#copyAttr Tab').html ('');
  2784           lo adCopyAttr ibutePrefe renc("Copy  Attribute s Preferen ces");
  2785  
  2786           //  Log prefe rence tab
  2787           $( '#logTab') .html('');
  2788           lo adLogAttri butePrefer enc("Log A ttributes  Preference s");
  2789           $( '#logTab') .hide();
  2790  
  2791           is PagesIniti alized = t rue;
  2792           di comViewer. systemPref erences.lo adAllPrefe rences();
  2793       }
  2794   }
  2795  
  2796   function d isplayCine Preference s() {
  2797       $('#ci neTab').sh ow();
  2798       $('#an notationTa b').hide() ;
  2799       $('#ec gTab').hid e();
  2800       $('#di splayTab') .hide();
  2801       $('#co pyAttrTab' ).hide();
  2802       $('#lo gTab').hid e();
  2803  
  2804       $('#ci nePrefActi ve').addCl ass('tab-a ctive').re moveClass( 'panel-hea ding');
  2805       $('#an notaPrefAc tive').rem oveClass(' tab-active ').addClas s('panel-h eading');
  2806       $('#ec gPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  2807       $('#di sPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  2808       $('#co pyPrefActi ve').remov eClass('ta b-active') .addClass( 'panel-hea ding');
  2809       $('#lo gPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  2810  
  2811       $('#pr eferenceHe aderTitle' ).html('') ;
  2812       $('#pr eferenceHe aderTitle' ).append(" Cine Prefe rences");
  2813   }
  2814  
  2815   function d isplayLogP references () {
  2816       $('#ci neTab').hi de();
  2817       $('#an notationTa b').hide() ;
  2818       $('#ec gTab').hid e();
  2819       $('#di splayTab') .hide();
  2820       $('#co pyAttrTab' ).hide();
  2821       $('#lo gTab').sho w();
  2822  
  2823       $('#lo gPrefActiv e').addCla ss('tab-ac tive').rem oveClass(' panel-head ing');
  2824       $('#ci nePrefActi ve').remov eClass('ta b-active') .removeCla ss('panel- heading');
  2825       $('#an notaPrefAc tive').rem oveClass(' tab-active ').addClas s('panel-h eading');
  2826       $('#ec gPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  2827       $('#di sPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  2828       $('#co pyPrefActi ve').remov eClass('ta b-active') .addClass( 'panel-hea ding');
  2829  
  2830       $('#pr eferenceHe aderTitle' ).html('') ;
  2831       $('#pr eferenceHe aderTitle' ).append(" Log Prefer ences");
  2832   }
  2833  
  2834   function l oadCinePre ferenceWin dow(title)  {
  2835       var ci nePref = " ";
  2836  
  2837       cinePr ef += '<di v class="f orm-horizo ntal"><div  class="co l-md-12">< div class= "form-grou p"><label  for="cineM ode" class ="col-sm-3 "> Cine mo de</label> <div class ="col-sm-3 "><select  id="palyse lection" c lass="form -control"> <option va lue="Stack ">Stack</o ption><opt ion value= "Study">St udy</optio n></select ></div></d iv><div cl ass="form- group"><la bel for="r epeatCine"  class="co l-sm-3">Re peat cine  run</label ><div clas s="col-sm- 3"><input  type="numb er" id="ti mesToRepea t" name="t imesToRepe at" min="1 " max="500 " onkeypre ss="return  event.cha rCode >= 4 8 && event .charCode  <= 57" cla ss="form-c ontrol">(t imes)</div ></div><di v class="f orm-group" ><label fo r="numberO fFrames" c lass="col- sm-3">When  the numbe r of frame s in a cin e loop are  less than  or equal  to </label ><div clas s="col-sm- 3"><input  type="numb er" id="fr amesToRepe at" name=" framesToRe peat" min= "1" max="5 00" onkeyp ress="retu rn event.c harCode >=  48 && eve nt.charCod e <= 57" c lass="form -control"> </div></di v><div cla ss="form-g roup"><lab el for="lo oping" cla ss="col-sm -3">When l ooping thr ough a stu dy, pause  single fra me images  for</label ><div clas s="col-sm- 3"><input  type="numb er" id="id leTime" na me="idleTi me" min="1 " max="500 " onkeypre ss="return  event.cha rCode >= 4 8 && event .charCode  <= 57" cla ss="form-c ontrol">(s econds)</d iv></div>< div class= "col-md-3" > <div id= "dashboard -cine-load ing-icon"  style="mar gin-left:  -30px;disp lay: none" ><span cla ss="glyphi con glyphi con-refres h glyphico n-refresh- animate">< /span><spa n id="dash board-cine -loading-s tatus"></s pan> </div ></div><di v class="f orm-group" ><div clas s="col-md- 2"><button  type="but ton" class ="btn btn- sm btn-pri mary" id=" dashboard- cineTab-ap ply-btn" d isabled on click="dic omViewer.s ystemPrefe rences.onS ubmit(&quo t;cine&quo t;)">Apply </button>& nbsp;<butt on type="b utton" cla ss="btn bt n-sm btn-d efault" id ="dashboar d-cineTab- reset-btn"  disabled  onclick="d icomViewer .systemPre ferences.o nReset(&qu ot;cine&qu ot;)">Rese t</button> </div><div  class="co l-md-2"><d iv id="Pre ferenceAle rt" class= "alert ale rt-danger"  style="wi dth:300px; display: n one;font-s ize: 15px; " role="al ert"></div ></div>';
  2838  
  2839  
  2840       $('#ci neTab').ap pend(cineP ref);
  2841   }
  2842  
  2843   function d isplayEcgP references () {
  2844       $('#ec gTab').sho w();
  2845       $('#an notationTa b').hide() ;
  2846       $('#ci neTab').hi de();
  2847       $('#di splayTab') .hide();
  2848       $('#co pyAttrTab' ).hide();
  2849       $('#lo gTab').hid e();
  2850  
  2851       $('#ec gPrefActiv e').addCla ss('tab-ac tive').rem oveClass(' panel-head ing');
  2852       $('#ci nePrefActi ve').remov eClass('ta b-active') .addClass( 'panel-hea ding');
  2853       $('#an notaPrefAc tive').rem oveClass(' tab-active ').addClas s('panel-h eading');
  2854       $('#di sPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  2855       $('#co pyPrefActi ve').remov eClass('ta b-active') .addClass( 'panel-hea ding');
  2856       $('#lo gPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  2857  
  2858       $('#pr eferenceHe aderTitle' ).html('') ;
  2859       $('#pr eferenceHe aderTitle' ).append(" ECG Prefer ences");
  2860   }
  2861  
  2862   function l oadECGPref erenceWind ow(title)  {
  2863       var ec gPref = "" ;
  2864  
  2865       ecgPre f += '<div  id="ecgPr eferenceCo ntent"><fo rm class=" form-horiz ontal" rol e="form">< div class= "col-md-8" ><div clas s="form-gr oup"><labe l for="col umns" clas s="col-sm- 2 control- label">Lea d Type</la bel><div c lass="col- sm-4"><sel ect id="le dselection " onchange  = "change LeadType(t his.value) " class="f orm-contro l"><option  value="3x 4+1">3x4+1 </option>< option val ue="3x4+3" >3x4+3</op tion></sel ect></div> </div></di v></form>< div class= "col-md-5"  id="displ ayOne"><di v class="p anel panel -default"> <div class ="panel-he ading">3x4 +1</div> < div class= "panel-bod y" id="3x4 1"></div>< /div></div ><div clas s="col-md- 5" id="dis playThree"  style="di splay: non e"><div cl ass="panel  panel-def ault"><div  class="pa nel-headin g">3x4+3</ div><div c lass="pane l-body" st yle="margi n-left: -3 0px;"><div  class="co l-md-12">< div class= "form-grou p"><label  for="colum ns" class= "col-sm-5  control-la bel">First  Signal:</ div></div> <div class ="col-md-1 2"><div cl ass="form- group"><la bel for="c olumns" cl ass="col-s m-5 contro l-label">S econd Sign al:</label ><div clas s="col-sm- 8"><div id ="3x43_2"> </div></di v></div></ div><div c lass="col- md-12"><di v class="f orm-group" ><label fo r="columns " class="c ol-sm-5 co ntrol-labe l">Third S ignal:</la bel><div c lass="col- sm-8"><div  id="3x43_ 3"></div>< /div></div ></div></d iv></div>< /div><div  class="col -md-12"><d iv id="das hboard-ecg -loading-i con" style ="margin-l eft: -30px ;"><span c lass="glyp hicon glyp hicon-refr esh glyphi con-refres h-animate" ></span><s pan id="da shboard-ec g-loading- status"></ span></div ></div><di v class="f orm-group" ><div clas s="col-md- 2"><button  type="but ton" class ="btn btn- sm btn-pri mary" id=" dashboard- ecgTab-app ly-btn" di sabled onc lick="dico mViewer.sy stemPrefer ences.onSu bmit(&quot ;ecg&quot; )">Apply</ button>&nb sp;<button  type="but ton" class ="btn btn- sm btn-def ault" id=" dashboard- ecgTab-res et-btn" di sabled onc lick="dico mViewer.sy stemPrefer ences.onRe set(&quot; ecg&quot;) ">Reset</b utton></di v><div cla ss="col-md -2"></div> </div>';
  2866  
  2867       $('#ec gTab').app end(ecgPre f);
  2868   }
  2869  
  2870   function d isplayAnno tationPref erences()  {
  2871       $('#an notationTa b').show() ;
  2872       $('#ci neTab').hi de();
  2873       $('#ec gTab').hid e();
  2874       $('#di splayTab') .hide();
  2875       $('#co pyAttrTab' ).hide();
  2876       $('#lo gTab').hid e();
  2877  
  2878       $('#an notaPrefAc tive').add Class('tab -active'). removeClas s('panel-h eading');
  2879       $('#ci nePrefActi ve').remov eClass('ta b-active') .addClass( 'panel-hea ding');
  2880       $('#ec gPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  2881       $('#di sPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  2882       $('#co pyPrefActi ve').remov eClass('ta b-active') .addClass( 'panel-hea ding');
  2883       $('#lo gPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  2884  
  2885       $('#pr eferenceHe aderTitle' ).html('') ;
  2886       $('#pr eferenceHe aderTitle' ).append(" Annotation  Preferenc es");
  2887   }
  2888  
  2889   function g etStrokeSt yle(type)  {
  2890       var st orkeLine =  '<div cla ss="panel- body"><for m role="fo rm" class= "form-hori zontal"><d iv class=" form-group "><div cla ss="col-sm -2"> <labe l for="lin eWidth" st yle="margi n-top: 10p x;">Line W idth</labe l></div><d iv class=" col-sm-2"> ' + getLin eWidth(typ e) + '</di v><div cla ss="col-sm -2"> <labe l for="col or" style= "margin-to p: 10px;"> Color</lab el></div>< div class= "col-sm-2" > <input t ype="color " value="# 00FFFF" id ="' + type  + 'lineCo lor" class ="form-con trol"></di v></div></ form></div >';
  2891  
  2892       $('#st orkeStyleI D').append (storkeLin e);
  2893  
  2894       getGau geLength(" LINE");
  2895   }
  2896  
  2897   function g etGaugeLen gth(type)  {
  2898       var ga ugeLength  = '<div cl ass="panel -body" sty le="paddin g-top: 30p x !importa nt;">' + g etFieldSet Title("Lin e") + '<fo rm role="f orm" class ="form-hor izontal">< div class= "form-grou p"><div cl ass="col-s m-2"> <lab el for="ga ugeStyle"  style="mar gin-top: 1 0px;">Gaug e Style</l abel></div ><div clas s="col-sm- 2"> <selec t id="' +  type + 'ga ugeStyle"   class="fo rm-control  prefBtn"  style="min -width:40p x"><option  value="Li ne">Line</ option><op tion value ="Point">P oint</opti on></selec t></div><d iv class=" col-sm-2">    <label  for="gauge Length" st yle="margi n-top: 10p x;">Gauge  Length</la bel></div> <div class ="col-sm-2 "><input i d="' + typ e + 'gauge Length" ty pe="number " min="0"  max="20" o nkeypress= "return ev ent.charCo de >= 48 & & event.ch arCode <=  57" onkeyp ress="retu rn event.c harCode >=  48 && eve nt.charCod e <= 57" c lass=" for m-control" /></div><d iv class=" col-sm-2">  <label fo r="fill">< /label></d iv><div cl ass="col-s m-2"> <inp ut type="c heckbox" c lass="form -control"  style="dis play: none "></div></ div></form ></div>';
  2899  
  2900       $('#ga ugeLengthI D').append (gaugeLeng th);
  2901  
  2902       if (ty pe == "LIN E") {
  2903           $( '#gaugeLen gthID').hi de();
  2904       }
  2905  
  2906       getArr owFill("AR ROW");
  2907   }
  2908  
  2909   function g etArrowFil l(type) {
  2910       var ar rowFill =  '<div clas s="panel-b ody" style ="padding- top: 30px  !important ;">' + get FieldSetTi tle("Arrow ") + '<for m role="fo rm" class= "form-hori zontal"><d iv class=" form-group "><div cla ss="col-sm -2"> <labe l for="fil lColor" st yle="margi n-top: 10p x;">Fill C olor</labe l></div><d iv class=" col-sm-2">  <input ty pe="color"  id="' + t ype + 'fil lColor" va lue="#00FF FF" name=" fillColor"  class="fo rm-control "></div><d iv class=" col-sm-2">  <label fo r="fill" s tyle="marg in-top: 10 px;">Fill< /label></d iv><div cl ass="col-s m-2"> <inp ut type="c heckbox" i d="' + typ e + 'isFil l" class=" form-contr ol" style= "width: 35 px"></div> </div></fo rm></div>' ;
  2911  
  2912       $('#ar rowFillID' ).append(a rrowFill);
  2913  
  2914       getMea surement(" MSTROKESTY LE");
  2915   }
  2916  
  2917   function g etMeasurem ent(type)  {
  2918       var me asurement  = '<div cl ass="panel -body"><fo rm role="f orm" class ="form-hor izontal">< div class= "form-grou p"><div cl ass="col-s m-2"> <lab el for="li neWidth" c lass="labe l-align">L ine Width< /label></d iv><div cl ass="col-s m-2"> ' +  getLineWid th(type) +  '</div><d iv class=" col-sm-2">  <label fo r="color"  class="lab el-align"> Color</lab el></div>< div class= "col-sm-2" > <input t ype="color " value="# 00FFFF" id ="' + type  + 'lineCo lor" class ="form-con trol"></di v></div><d iv class=" form-group "><div cla ss="col-sm -2"> <labe l for="Pre cision" cl ass="label -align">Pr ecision</l abel></div ><div clas s="col-sm- 2"><input  type="numb er" id="'  + type + ' precision"  min="0" m ax="14" on keypress=" return eve nt.charCod e >= 48 &&  event.cha rCode <= 5 7" class=" form-contr ol"></div> <div class ="col-sm-2 "> <label  for="measu rementUnit s"class="l abel-align ">Measurem ent Units< /label></d iv><div cl ass="col-s m-2"><sele ct id="' +  type + 'm easureUnit s" class=" form-contr ol"><optio n value="i n">Inches< /option><o ption valu e="cm">Cen timeter</o ption><opt ion value= "mm">Milli meter</opt ion></sele ct></div>< /div></for m></div>';
  2919  
  2920       $('#me asurementL ineID').ap pend(measu rement);
  2921  
  2922       getMea surementGa ugeLength( "LENGTH");
  2923   }
  2924  
  2925   function g etMeasurem entGaugeLe ngth(type)  {
  2926       var me asurementG augeLength  = '<div c lass="pane l-body" st yle="paddi ng-top: 30 px !import ant;">' +  getFieldSe tTitle("Le ngth") + ' <form role ="form" cl ass="form- horizontal "><div cla ss="form-g roup"><div  class="co l-sm-2"> < label for= "gaugeStyl e" style=" margin-top : 10px;">G auge Style </label></ div><div c lass="col- sm-2"> <se lect id="'  + type +  'gaugeStyl e"  class= "form-cont rol prefBt n" style=" min-width: 40px"><opt ion value= "Line">Lin e</option> <option va lue="Point ">Point</o ption></se lect></div ><div clas s="col-sm- 2"><label  for="' + t ype + 'gau geLength"  style="mar gin-top: 1 0px;">Gaug e Length</ label></di v><div cla ss="col-sm -2"> <inpu t id="' +  type + 'ga ugeLength"  type="num ber" min=" 0" max="20 " onkeypre ss="return  event.cha rCode >= 4 8 && event .charCode  <= 57" cla ss=" form- control"/> </div></di v></form>< /div>';
  2927  
  2928       $('#me asurementG augeLength ID').appen d(measurem entGaugeLe ngth);
  2929  
  2930       getMea surementAn gle("ANGLE ");
  2931   }
  2932  
  2933   function g etMeasurem entAngle(t ype) {
  2934       var me asurementA ngle = '<d iv class=" panel-body " style="p adding-top : 30px !im portant;">  ' + getFi eldSetTitl e("Angle")  + '<form  role="form " class="f orm-horizo ntal"><div  class="fo rm-group"> <div class ="col-sm-2 "><label f or="' + ty pe + 'arcR adius" sty le="margin -top: 10px ;">Arc Rad ius</label ></div><di v class="c ol-sm-2">< input id=" ' + type +  'arcRadiu s" type="n umber" min ="5" max=" 20" onkeyp ress="retu rn event.c harCode >=  48 && eve nt.charCod e <= 57" c lass=" for m-control" /></div></ div></form ></div>';
  2935  
  2936       $('#me asurementA ngleID').a ppend(meas urementAng le);
  2937  
  2938       getEli pseRectLin e("ERSTROK ESTYLE");
  2939   }
  2940  
  2941   function g etElipseRe ctLine(typ e) {
  2942       var el ipseRectLi ne = ' <di v class="p anel-body" ><form rol e="form" c lass="form -horizonta l"><div cl ass="form- group"><di v class="c ol-sm-2">  <label for ="lineWidt h" class=" label-alig n">Line Wi dth</label ></div><di v class="c ol-sm-2">  ' + getLin eWidth(typ e) + ' </d iv><div cl ass="col-s m-2"> <lab el for="co lor" class ="label-al ign">Color </label></ div><div c lass="col- sm-2"> <in put type=" color" val ue="#00FFF F" id="' +  type + 'l ineColor"  class="for m-control" ></div></d iv><div cl ass="form- group"><di v class="c ol-sm-2">  <label for ="fillColo r" style=" margin-top : 10px;">F ill Color< /label></d iv><div cl ass="col-s m-2"><inpu t type="co lor" id="'  + type +  'fillColor " value="# 00FFFF" na me="fillCo lor" class ="form-con trol"></di v><div cla ss="col-sm -2"> <labe l for="fil l" style=" margin-top : 10px;">F ill</label ></div><di v class="c ol-sm-2">  <input typ e="checkbo x" id="' +  type + 'i sFill" cla ss="form-c ontrol" st yle="width : 35px"></ div></div> </form></d iv>';
  2943  
  2944       $('#el ipseRectLi neID').app end(elipse RectLine);
  2945  
  2946       getHou nsfield("H OUNSFIELD" );
  2947   }
  2948  
  2949   function g etHounsfie ld(type) {
  2950       var ho usnsfield  = '<div cl ass="panel -body" sty le="paddin g-top: 30p x !importa nt;"> ' +  getFieldSe tTitle("HO UNSFIELD")  + '<form  role="form " class="f orm-horizo ntal"><div  class="fo rm-group"> <div class ="col-sm-2 "> <label  for="Preci sion" clas s="label-a lign">Prec ision</lab el></div>< div class= "col-sm-2" > <input t ype="numbe r" id="' +  type + 'p recision"  min="0" ma x="14" onk eypress="r eturn even t.charCode  >= 48 &&  event.char Code <= 57 " class="f orm-contro l"></div>< div class= "col-sm-2" > <label f or="measur ementUnits "class="la bel-align" >Measureme nt Units</ label></di v><div cla ss="col-sm -2"> <sele ct id="' +  type + 'm easureUnit s" class=" form-contr ol"><optio n value="i n">Inches< /option><o ption valu e="cm">Cen timeter</o ption><opt ion value= "mm">Milli meter</opt ion></sele ct></div>< /div></for m></div>';
  2951  
  2952       $('#ho usnfieldID ').append( housnsfiel d);
  2953  
  2954       getMit ralLine("M A");
  2955   }
  2956  
  2957   function g etMitralLi ne(type) {
  2958       var mi tralAtro =  '<div cla ss="panel- body"><for m role="fo rm" class= "form-hori zontal"><d iv class=" form-group "><div cla ss="col-sm -2"><label  for="gaug eStyle" st yle="margi n-top: 10p x;">Gauge  Style</lab el></div>< div class= "col-sm-2" ><select i d="' + typ e + 'gauge Style"  cl ass="form- control pr efBtn" sty le="min-wi dth:40px"> <option va lue="Line" >Line</opt ion><optio n value="P oint">Poin t</option> </select>< /div><div  class="col -sm-2"><la bel for="'  + type +  'gaugeLeng th" style= "margin-to p: 10px;"> Gauge Leng th</label> </div><div  class="co l-sm-2"><i nput id="'  + type +  'gaugeLeng th" type=" number" mi n="0" max= "20" onkey press="ret urn event. charCode > = 48 && ev ent.charCo de <= 57"  class=" fo rm-control "/></div>< /div><div  class="for m-group">< div class= "col-sm-2" ><label fo r="Precisi on" class= "label-ali gn">Precis ion</label ></div><di v class="c ol-sm-2">< input type ="number"  id="' + ty pe + 'prec ision" min ="0" max=" 14" onkeyp ress="retu rn event.c harCode >=  48 && eve nt.charCod e <= 57" c lass="form -control"> </div><div  class="co l-sm-2"><l abel for=" measuremen tUnits"cla ss="label- align">Mea surement U nits</labe l></div><d iv class=" col-sm-2"> <select id ="' + type  + 'measur eUnits" cl ass="form- control">< option val ue="in">In ches</opti on><option  value="cm ">Centimet er</option ><option v alue="mm"> Millimeter </option>< /select></ div></div> </form></d iv>';
  2959  
  2960       $('#mi tralAortic ID').appen d(mitralAt ro);
  2961  
  2962       getMit ralWidth(" MITRAL");
  2963   }
  2964  
  2965   function g etMitralWi dth(type)  {
  2966       var mW idth = '<d iv class=" panel-body " style="p adding-top : 30px !im portant;">  ' + getFi eldSetTitl e("MITRAL" ) + '<form  role="for m" class=" form-horiz ontal"><di v class="f orm-group" ><div clas s="col-sm- 2"> <label  for="line Width" sty le="margin -top: 10px ;">Line Wi dth</label ></div><di v class="c ol-sm-2">  ' + getLin eWidth(typ e) + '</di v><div cla ss="col-sm -2"> <labe l for="col or" style= "margin-to p: 10px;"> Color</lab el></div>< div class= "col-sm-2" > <input t ype="color " value="# 00FFFF" id ="' + type  + 'lineCo lor" class ="form-con trol"></di v></div></ form></div >';
  2967  
  2968       $('#mi tralLineID ').append( mWidth);
  2969  
  2970       getAor ticWidth(" AORTIC");
  2971   }
  2972  
  2973   function g etAorticWi dth(type)  {
  2974       var mA orticWidth  = '<div c lass="pane l-body" st yle="paddi ng-top: 30 px !import ant;"> ' +  getFieldS etTitle("A ORTIC") +  '<form rol e="form" c lass="form -horizonta l"><div cl ass="form- group"><di v class="c ol-sm-2">  <label for ="lineWidt h" style=" margin-top : 10px;">L ine Width< /label></d iv><div cl ass="col-s m-2">' + g etLineWidt h(type) +  '</div><di v class="c ol-sm-2">  <label for ="color" s tyle="marg in-top: 10 px;">Color </label></ div><div c lass="col- sm-2"> <in put type=" color" val ue="#00FFF F" id="' +  type + 'l ineColor"  class="for m-control" ></div></d iv></form> </div>';
  2975  
  2976       $('#mi tralID').a ppend(mAor ticWidth);
  2977  
  2978       getTex t("TEXT");
  2979   }
  2980  
  2981   function g etText(typ e) {
  2982       var te xt = '<div  class="pa nel-body">  <form rol e="form" c lass="form -horizonta l"><div cl ass="form- group"><di v class="c ol-sm-2">  <label for ="fontName " style="m argin-top:  10px;">Fo nt Name</l abel></div ><div clas s="col-sm- 2"> ' + ge tFontName( type) + '  </div><div  class="co l-sm-2"> < label for= "fontSize"  style="ma rgin-top:  10px;">Fon t Size</la bel></div> <div class ="col-sm-2 "> ' + get FontSize(t ype) + ' < /div><div  class="col -sm-2"> <l abel for=" textColor"  style="ma rgin-top:  10px;">Fon t Color</l abel></div ><div clas s="col-sm- 2"> <input  type="col or" id="'  + type + ' textColor"  value="#0 0FFFF" cla ss="form-c ontrol"></ div></div> <div class ="form-gro up"><div c lass="col- sm-2"> <la bel for="'  + type +  'isFill" c lass="labe l-align">F ill</label ></div><di v class="c ol-sm-2">  <input typ e="checkbo x"  id="'  + type + ' isFill" cl ass="form- control fo rm-input-s tyle"></di v><div cla ss="col-sm -2"> <labe l for="' +  type + 'f illColor"  class="lab el-align"> Fill Color </label></ div><div c lass="col- sm-2"> <in put type=" color" val ue="#00FFF F"  id="'  + type + ' fillColor"  class="fo rm-control "></div></ div><div c lass="form -group"> '  + getFont Attr(type)  + ' </div ></form></ div></div> ';
  2983  
  2984       $('#fo ntText').a ppend(text );
  2985  
  2986       getLab elAnnotati on("LBLANN OTATION");
  2987   }
  2988  
  2989   function g etLabelAnn otation(ty pe) {
  2990       var lb lAnnotatio n = '<div  class="pan el-body">< form role= "form" cla ss="form-h orizontal" ><div clas s="form-gr oup"><div  class="col -sm-2"> <l abel for=" fontName"  style="mar gin-top: 1 0px;">Font  Name</lab el></div>< div class= "col-sm-2" > ' + getF ontName(ty pe) + '</d iv><div cl ass="col-s m-2"> <lab el for="fo ntSize" st yle="margi n-top: 10p x;">Font S ize</label ></div><di v class="c ol-sm-2">  ' + getFon tSize(type ) + '</div > <div cla ss="col-sm -2"> <labe l for="tex tColor" st yle="margi n-top: 10p x;">Font C olor</labe l></div><d iv class=" col-sm-2">  <input ty pe="color"  id="' + t ype + 'tex tColor" va lue="#00FF FF" class= "form-cont rol"></div ></div><di v class="f orm-group" >' + getFo ntAttr(typ e) + '</di v></form>< /div>';
  2991  
  2992       $('#la belAnnotat ionID').ap pend(lblAn notation);
  2993  
  2994       getLab elOverlay( "LBLOVERLA Y");
  2995   }
  2996  
  2997   function g etLabelOve rlay(type)  {
  2998       var lb lOverlay =  '<div cla ss="panel- body"><for m role="fo rm" class= "form-hori zontal"><d iv class=" form-group "><div cla ss="col-sm -2"> <labe l for="fon tName" sty le="margin -top: 10px ;">Font Na me</label> </div><div  class="co l-sm-2"> '  + getFont Name(type)  + '</div> <div class ="col-sm-2 "> <label  for="fontS ize" style ="margin-t op: 10px;" >Font Size </label></ div><div c lass="col- sm-2"> ' +  getFontSi ze(type) +  '</div> < div class= "col-sm-2" > <label f or="textCo lor" style ="margin-t op: 10px;" >Font Colo r</label>< /div><div  class="col -sm-2"> <i nput type= "color" id ="' + type  + 'textCo lor" value ="#00FFFF"  class="fo rm-control "></div></ div><div c lass="form -group">'  + getFontA ttr(type)  + '</div>< /form></di v>';
  2999  
  3000       $('#la belOverlay ID').appen d(lblOverl ay);
  3001  
  3002       getLab elOrientat ion("LBLOR IENTATION" );
  3003   }
  3004  
  3005   function g etLabelOri entation(t ype) {
  3006       var lb lOrientati on = '<div  class="pa nel-body"> <form role ="form" cl ass="form- horizontal "><div cla ss="form-g roup"><div  class="co l-sm-2"> < label for= "fontName"  style="ma rgin-top:  10px;">Fon t Name</la bel></div> <div class ="col-sm-2 "> ' + get FontName(t ype) + '</ div><div c lass="col- sm-2"> <la bel for="f ontSize" s tyle="marg in-top: 10 px;">Font  Size</labe l></div><d iv class=" col-sm-2">  ' + getFo ntSize(typ e) + '</di v> <div cl ass="col-s m-2"> <lab el for="te xtColor" s tyle="marg in-top: 10 px;">Font  Color</lab el></div>< div class= "col-sm-2" > <input t ype="color " id="' +  type + 'te xtColor" v alue="#00F FFF" class ="form-con trol"></di v></div><d iv class=" form-group ">' + getF ontAttr(ty pe) + '</d iv></form> </div>';
  3007  
  3008       $('#la belOrienta tionID').a ppend(lblO rientation );
  3009  
  3010       getLab elScoutRul er("LBLSCO UT");
  3011   }
  3012  
  3013   function g etLabelSco utRuler(ty pe) {
  3014       var lb lScoutRule  = '<div c lass="pane l-body" st yle="paddi ng-top: 30 px !import ant;">' +  getFieldSe tTitle("SC OUT") + '< form role= "form" cla ss="form-h orizontal" ><div clas s="form-gr oup"><div  class="col -sm-2"> <l abel for=" lineWidth"  style="ma rgin-top:  10px;">Lin e Width</l abel></div ><div clas s="col-sm- 2">' + get LineWidth( type) + '< /div><div  class="col -sm-2"> <l abel for=" color" sty le="margin -top: 10px ;">Color</ label></di v><div cla ss="col-sm -2"> <inpu t type="co lor" value ="#00FFFF"  id="' + t ype + 'lin eColor" cl ass="form- control">< /div></div ></form></ div>';
  3015  
  3016       $('#la belScoutRu lerID').ap pend(lblSc outRule);
  3017  
  3018       getLab elRuler("L BLRULER");
  3019   }
  3020  
  3021   function g etLabelRul er(type) {
  3022       var lb lRule = '< div class= "panel-bod y" style=" padding-to p: 30px !i mportant;" >' + getFi eldSetTitl e("RULER")  + '<form  role="form " class="f orm-horizo ntal"><div  class="fo rm-group"> <div class ="col-sm-2 "> <label  for="lineW idth" styl e="margin- top: 10px; ">Line Wid th</label> </div><div  class="co l-sm-2">'  + getLineW idth(type)  + '</div> <div class ="col-sm-2 "> <label  for="color " style="m argin-top:  10px;">Co lor</label ></div><di v class="c ol-sm-2">  <input typ e="color"  value="#00 FFFF" id=" ' + type +  'lineColo r" class=" form-contr ol"></div> </div></fo rm></div>' ;
  3023  
  3024       $('#la belRulerID ').append( lblRule);
  3025   }
  3026  
  3027   function g etFontName (type) {
  3028       return  '<select  id="' + ty pe + 'font Name" clas s="form-co ntrol"><op tion value ="Arial">A rial</opti on><option  value="Ar ial Black" >Arial Bla ck</option > <option  value="Boo k Antiqua" >Book Anti qua</optio n><option  value="Cal ibri">Cali bri</optio n><option  value="Com ic Sans MS ">Comic Sa ns MS</opt ion><optio n value="C ourier">Co urier</opt ion><optio n value="C ursive">Cu rsive</opt ion><optio n value="F antasy">Fa ntasy </op tion><opti on value=" Georgia">G eorgia</op tion><opti on value=" Garamond"> Garamond</ option><op tion value ="Helvetic a">Helveti ca</option ><option v alue="Impa ct">Impact  </option> <option va lue="Lucid a Sans Uni code">Luci da Sans Un icode </op tion><opti on value=" Lucida Con sole">Luci da Console  </option> <option va lue="Monos pace">Mono space</opt ion><optio n value="P alatino Li notype">Pa latino Lin otype</opt ion><optio n value="s ans-serif" >Sans-seri f</option> <option va lue="Times  New Roman ">Times Ne w Roman</o ption><opt ion value= "Tahoma">T ahoma </op tion><opti on value=" Verdana">V erdana </o ption></se lect>';
  3029   }
  3030  
  3031   function g etFontSize (type) {
  3032       return  '<select  id="' + ty pe + 'font Size" clas s="form-co ntrol"><op tion value ="6">5</op tion><opti on value=" 7">7</opti on><option  value="8" >8</option ><option v alue="9">9 </option>< option val ue="10">10 </option>< option val ue="11">11 </option>< option val ue="12">12 </option>< option val ue="13">13 </option>< option val ue="14">14 </option>< option val ue="16">16 </option>< option val ue="18">18 </option>< option val ue="20">20 </option>< option val ue="22">22 </option>< option val ue="24">24 </option>< option val ue="26">26 </option>< option val ue="28">28 </option>< /select>';
  3033   }
  3034  
  3035   function g etFontAttr (type) {
  3036       var di splay = "b lock";
  3037       if (ty pe == "LBL ORIENTATIO N" || type  == "LBLOV ERLAY") {
  3038           di splay = "n one";
  3039       }
  3040  
  3041       return  '<div cla ss="col-sm -2"> <labe l for="' +  type + 'i sBold" cla ss="label- align">Bol d</label>< /div><div  class="col -sm-2"> <i nput type= "checkbox"   id="' +  type + 'is Bold" clas s="form-co ntrol form -input-sty le"></div> <div class ="col-sm-2 "> <label  for="' + t ype + 'isI talic" cla ss="label- align">Ita lic</label ></div><di v class="c ol-sm-2">< input type ="checkbox "  id="' +  type + 'i sItalic" c lass="form -control f orm-input- style"></d iv></div>< div class= "form-grou p" style=" display:'  + display  + '"><div  class="col -sm-2"> <l abel for=" ' + type +  'isUnderl ined" clas s="label-a lign">Unde rline</lab el></div>< div class= "col-sm-2" ><input ty pe="checkb ox"  id="'  + type +  'isUnderli ned" class ="form-con trol form- input-styl e"></div>< div class= "col-sm-2" > <label f or="' + ty pe + 'isSt rikeout" c lass="labe l-align">S trikeout</ label></di v><div cla ss="col-sm -2"> <inpu t type="ch eckbox"  i d="' + typ e + 'isStr ikeout" cl ass="form- control fo rm-input-s tyle"></di v>';
  3042   }
  3043  
  3044   function g etLineWidt h(type) {
  3045       return  '<select  id="' + ty pe + 'line Width" cla ss="form-c ontrol"><o ption valu e="1">1</o ption><opt ion value= "2">2</opt ion><optio n value="3 ">3</optio n><option  value="4"> 4</option> <option va lue="5">5< /option><o ption valu e="6">6</o ption><opt ion value= "7">7</opt ion><optio n value="8 ">8</optio n><option  value="9"> 9</option> <option va lue="10">1 0</option> <option va lue="11">1 1</option> <option va lue="12">1 2</option> <option va lue="13">1 3</option> <option va lue="14">1 4</option> </select>' ;
  3046   }
  3047  
  3048   function g etFieldSet Title(titl e) {
  3049       return  '<h5 clas s="text-on -pannel">< strong cla ss="text-u ppercase">  ' + title  + ' </str ong></h5>' ;
  3050   }
  3051  
  3052   function d isplayLayo utPreferen ces() {
  3053       $('#di splayTab') .show();
  3054       $('#an notationTa b').hide() ;
  3055       $('#ci neTab').hi de();
  3056       $('#ec gTab').hid e();
  3057       $('#co pyAttrTab' ).hide();
  3058       $('#lo gTab').hid e();
  3059  
  3060       $('#di sPrefActiv e').addCla ss('tab-ac tive').rem oveClass(' panel-head ing');
  3061       $('#ci nePrefActi ve').remov eClass('ta b-active') .addClass( 'panel-hea ding');
  3062       $('#ec gPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  3063       $('#an notaPrefAc tive').rem oveClass(' tab-active ').addClas s('panel-h eading');
  3064       $('#co pyPrefActi ve').remov eClass('ta b-active') .addClass( 'panel-hea ding');
  3065       $('#lo gPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  3066  
  3067       $('#pr eferenceHe aderTitle' ).html('') ;
  3068       $('#pr eferenceHe aderTitle' ).append(" Layout Pre ferences") ;
  3069   }
  3070  
  3071   function l oadDisplay Preference Window(tit le) {
  3072       var hp List = "";
  3073  
  3074       hpList  += '<div  id="addEdi tHPTable"  style="dis play: none "><form cl ass="form- horizontal " role="fo rm"><div c lass="col- md-12"><di v class="f orm-group" ><label fo r="modalit y" class=" col-sm-2 c ontrol-lab el">Modali ty</label> <div class ="col-sm-3 "><select  id="modali ty" class= "form-cont rol"><opti on value=" US">US</op tion><opti on value=" MR">MR</op tion><opti on value=" CR">CR</op tion><opti on value=" XA">XA</op tion><opti on value=" CT">CT</op tion><opti on value=" ECG">ECG</ option><op tion value ="NM">NM</ option><op tion value ="SR">SR</ option><op tion value ="MG">MG</ option><op tion value ="DOC">DOC </option>< option val ue="DX">DX </option>< option val ue="OT">OT </option>< option val ue="SC">SC </option>< option val ue="PT">PT </option>< option val ue="RF">RF </option>< option val ue="ES">ES </option>< option val ue="XC">XC </option>< option val ue="Genera l">General </option>< /select></ div></div> <div class ="form-gro up"><label  for="rows " class="c ol-sm-2 co ntrol-labe l">Rows</l abel><div  class="col -sm-3"><se lect id="l ayoutRows"  class="fo rm-control "><option  value="1"> 1</option> <option va lue="2">2< /option><o ption valu e="3">3</o ption></se lect></div ></div><di v class="f orm-group" ><label fo r="layoutC olumns" cl ass="col-s m-2 contro l-label">C olumns</la bel><div c lass="col- sm-3"><sel ect id="la youtColumn s" class=" form-contr ol"><optio n value="1 ">1</optio n><option  value="2"> 2</option> <option va lue="3">3< /option></ select></d iv></div>< div class= "form-grou p"><label  for="zoomM odeValues"  class="co l-sm-2 con trol-label ">Initial  Zoom</labe l><div cla ss="col-sm -3"><selec t id="zoom ModeValues " class="f orm-contro l"><option  value="10 0%" id="0_ zoom">100% </option>< option val ue="Fit-to -window" i d="1_zoom" >Fit-to-wi ndow</opti on><option  value="Fi t-width-to -window" i d="2_zoom" >Fit-width -to-window </option>< option val ue="Fit-he ight-to-wi ndow" id=" 3_zoom">Fi t-height-t o-window</ option></s elect></di v></div><d iv class=" form-group " id ="use EmbedPDFVi ewer_Row"  style="dis play: none "><label f or="useEmb edPdfViewe r" class=" col-sm-2 c ontrol-lab el">Use Br owser PDF  Plugin</la bel><div c lass="col- sm-3"><sel ect id="us eEmbedPdfV iewer" cla ss="form-c ontrol"><o ption valu e="true" i d="useEmbe dPDFViewer _true">tru e</option> <option va lue="false " id="useE mbedPDFVie wer_false" >false</op tion></sel ect></div> </div><div  class="fo rm-group"> <div class ="col-md-2 "></div><d iv class=" col-md-2"> <button ty pe="button " class="b tn btn-sm  btn-primar y" id="das hboard-dis playTab-su bmit-btn"  onclick="d icomViewer .systemPre ferences.u pdateHPTab le()">Subm it</button >&nbsp;<bu tton type= "button" c lass="btn  btn-sm btn -default"  id="dashbo ard-displa yTab-cance l-btn" onc lick="dico mViewer.sy stemPrefer ences.show OrHideHPTa ble(true)" >Cancel</b utton></di v><div cla ss="col-md -2"></div> ';
  3075  
  3076       $('#di splayTab') .append(hp List);
  3077  
  3078       hpList  = '<br/>< div id="li stHangingP rotocol">< table id=" hpTableLis t" class=" table tabl e-bordered "><thead>< tr><th>Mod ality</th> <th>Rows</ th><th>Col umns</th>< th>Zoom Mo de</th><th  align="le ft">Action </th></tr> </thead></ table><div  id="dashb oard-displ ay-loading -icon" sty le="margin -bottom: - 27px;displ ay: none"> <span clas s="glyphic on glyphic on-refresh  glyphicon -refresh-a nimate"></ span> <spa n id="dash board-disp lay-loadin g-status"> </span></d iv><button  type="but ton" class ="btn btn- sm btn-pri mary pull- right" onc lick="dico mViewer.sy stemPrefer ences.addO rEditHP(un defined, & quot;add&q uot;)">Add </button>< /div>';
  3079  
  3080       $('#di splayTab') .append(hp List);
  3081   }
  3082  
  3083   function d isplayCopy AttributeP references () {
  3084       $('#co pyAttrTab' ).show();
  3085       $('#an notationTa b').hide() ;
  3086       $('#ci neTab').hi de();
  3087       $('#ec gTab').hid e();
  3088       $('#di splayTab') .hide();
  3089       $('#lo gTab').hid e();
  3090  
  3091       $('#co pyPrefActi ve').addCl ass('tab-a ctive').re moveClass( 'panel-hea ding');
  3092       $('#ci nePrefActi ve').remov eClass('ta b-active') .addClass( 'panel-hea ding');
  3093       $('#ec gPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  3094       $('#an notaPrefAc tive').rem oveClass(' tab-active ').addClas s('panel-h eading');
  3095       $('#di sPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  3096       $('#lo gPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  3097  
  3098       $('#pr eferenceHe aderTitle' ).html('') ;
  3099       $('#pr eferenceHe aderTitle' ).append(" Copy Attri butes Pref erences");
  3100   }
  3101  
  3102   function l oadCopyAtt ributePref erenc(titl e) {
  3103       var co pyAttr = " ";
  3104       var ar rCopyAttr  = ["Window  Level", " Brightness  and Contr ast", "Sca le", "Inve rt", "Orie ntation",  "Pan"];
  3105       var aC heckbox =  "";
  3106       for (v ar i = 0;  i < arrCop yAttr.leng th; i++) {
  3107           if  (arrCopyA ttr[i] ==  'Pan') {
  3108                aCheckbo x += '<div  class="ch eckbox" st yle="displ ay:none">< input id=" ' + arrCop yAttr[i].r eplace(/\s |\and/g, " ").toLower Case() + ' " type="ch eckbox" ch ecked><lab el for="'  + arrCopyA ttr[i].rep lace(/\s|\ and/g, "") .toLowerCa se() + '"> ' + arrCop yAttr[i] +  '</label> </div>';
  3109           }  else {
  3110                aCheckbo x += '<div  class="ch eckbox"><i nput id="'  + arrCopy Attr[i].re place(/\s| \and/g, "" ).toLowerC ase() + '"  type="che ckbox" che cked><labe l for="' +  arrCopyAt tr[i].repl ace(/\s|\a nd/g, ""). toLowerCas e() + '">'  + arrCopy Attr[i] +  ' </label> </div>';
  3111           }
  3112       }
  3113       if (aC heckbox !=  undefined ) {
  3114           co pyAttr +=  '<div clas s="row"><d iv class=" col-md-4"> </div><div  class="co l-md-4">'  + aCheckbo x + '</div ><div clas s="col-md- 4"></div>< /div><div  class="for m-group">< div class= "col-md-4" ><div id=" dashboard- copyattr-l oading-ico n" style=" display: n one"><span  class="gl yphicon gl yphicon-re fresh glyp hicon-refr esh-animat e"></span>  <span id= "dashboard -copyattr- loading-st atus"></sp an></div>< /div><div  class="col -md-4"><bu tton type= "button" c lass="btn  btn-sm btn -primary"   id="dashb oard-copya ttributesT ab-apply-b tn" disabl ed onclick ="dicomVie wer.system Preference s.onSubmit (&quot;cop yattribute s&quot;)"> Apply</but ton>&nbsp; <button ty pe="button " class="b tn btn-sm  btn-defaul t" id="das hboard-cop yattribute sTab-reset -btn" disa bled oncli ck="dicomV iewer.syst emPreferen ces.onRese t(&quot;co pyattribut es&quot;)" >Reset</bu tton></div ><div clas s="col-md- 4"></div>' ;
  3115           $( '#copyAttr Tab').appe nd(copyAtt r)
  3116       }
  3117   }
  3118  
  3119   function l oadLogAttr ibutePrefe renc(title ) {
  3120       var ci nePref = " ";
  3121  
  3122       cinePr ef += '<di v class="f orm-horizo ntal"><div  class="co l-md-12">< div class= "form-grou p"><label  for="logLe vel" class ="col-sm-3 "> Log lev el</label> <div class ="col-sm-3 "><select  id="logLev elPref" cl ass="form- control">< option val ue="Trace" >Trace</op tion><opti on value=" Debug">Deb ug</option ><option v alue="Info ">Info</op tion><opti on value=" Warn">Warn </option>< option val ue="Error" >Error</op tion><opti on value=" None">None </option>< /select></ div></div> ';
  3123  
  3124       cinePr ef += '<di v class="f orm-group" ><label fo r="LineLim it" class= "col-sm-3" >Line limi t</label>< div class= "col-sm-3" ><input ty pe="number " id="line LimitPref"  value="10 00" name=" logLineLim it" min="5 00" max="2 000" onkey press="ret urn event. charCode > = 48 && ev ent.charCo de <= 57"  onchange=" document.g etElementB yId(&quot; lineLimitP ref&quot;) .value =(t his.value  &lt; 500 ?  500 : (th is.value & gt; 2000 ?  2000 : th is.value)) " class="f orm-contro l"></div>< /div>';
  3125  
  3126       cinePr ef += '<di v class="f orm-group" ><label fo r="ctrlkey Pref" clas s="col-sm- 3">Shortcu t key</lab el><div cl ass="col-s m-3"><inpu t type="ch eckbox" va lue="CTRL"  id="ctrlk eyPref" ch ecked><lab el for="ct rlkeyPref" >CTRL</lab el></div>< /div>';
  3127  
  3128       cinePr ef += '<di v class="f orm-group" ><div clas s="col-sm- 3"></div>< div class= "col-sm-3" ><input ty pe="checkb ox" value= "ALT" id=" altkeyPref "><label f or="altkey Pref">ALT< /label></d iv></div>' ;
  3129  
  3130       cinePr ef += '<di v class="f orm-group" ><div clas s="col-sm- 3"></div>< div class= "col-sm-3" ><input ty pe="checkb ox" value= "SHIFT" id ="shiftkey Pref"><lab el for="sh iftkeyPref ">SHIFT</l abel></div ></div>';
  3131  
  3132       cinePr ef += '<di v class="f orm-group" ><div clas s="col-sm- 3"></div>< div class= "col-sm-3" ><select i d="key3Pre f" class=" form-contr ol"><optio n value="A ">A</optio n><option  value="B"> B</option> <option va lue="C">C< /option><o ption valu e="D">D</o ption><opt ion value= "E">E</opt ion><optio n value="F ">F</optio n><option  value="G"> G</option> <option va lue="H">H< /option><o ption sele cted value ="I">I</op tion><opti on value=" J">J</opti on><option  value="K" >K</option ><option v alue="L">L </option>< option val ue="M">M</ option><op tion value ="N">N</op tion><opti on value=" O">O</opti on><option  value="P" >P</option ><option v alue="Q">Q </option>< option val ue="R">R</ option><op tion value ="S">S</op tion><opti on value=" T">T</opti on><option  value="U" >U</option ><option v alue="V">V </option>< option val ue="W">W</ option><op tion value ="X">X</op tion><opti on value=" Y">Y</opti on><option  value="Z" >Z</option ></select> </div></di v>';
  3133  
  3134       cinePr ef += '<di v class="f orm-group" ><div clas s="col-md- 4"><div id ="dashboar d-log-load ing-icon"  style="dis play: none "><span cl ass="glyph icon glyph icon-refre sh glyphic on-refresh -animate"> </span> <s pan id="da shboard-lo g-loading- status"></ span></div ></div><di v class="c ol-md-4 pu ll-right"> <button ty pe="button " class="b tn btn-sm  btn-primar y"  id="da shboard-lo gTab-apply -btn" disa bled oncli ck="dicomV iewer.syst emPreferen ces.onSubm it(&quot;l og&quot;)" >Apply</bu tton>&nbsp ;<button t ype="butto n" class=" btn btn-sm  btn-defau lt" id="da shboard-lo gTab-reset -btn" disa bled oncli ck="dicomV iewer.syst emPreferen ces.onRese t(&quot;lo g&quot;)"> Reset</but ton></div> <div class ="col-md-4 "></div></ div></div> </div>';
  3135  
  3136       $('#lo gTab').app end(cinePr ef);
  3137   }
  3138  
  3139   function d isplayHead erTitle(ti tle) {
  3140       return  '<div cla ss="header -text-alig n"><h4 cla ss="text-c enter">' +  title + ' </h4></div >';
  3141   }
  3142  
  3143   function g enerateSto rkeValue(i d) {
  3144       var st rokeValue  = "";
  3145       for (v ar i = 1;  i < 15; i+ +) {
  3146           st rokeValue  += "<optio n value='"  + i + "'> " + i + "< /option>";
  3147       }
  3148  
  3149       return  strokeVal ue;
  3150   }
  3151  
  3152   function c hangeLeadT ype(value)  {
  3153       if (va lue == "3x 4+1") {
  3154           $( '#displayO ne').show( );
  3155           $( '#displayT hree').hid e();
  3156       } else  {
  3157           $( '#displayO ne').hide( );
  3158           $( '#displayT hree').sho w();
  3159       }
  3160   }
  3161  
  3162  
  3163   /**
  3164    * Load da shboard ca che page w hile click ing on das hboard cac he image
  3165    **/
  3166   function s howDashboa rdCache()  {
  3167       hideAn dShowTopMe nu();
  3168       $('#da shboard-to pmenu-cach e-home').s how();
  3169       $('#da hsboard-to pmenu-home -nav').sho w();
  3170       $('#da shboard-ca che-home') .show();
  3171   }
  3172  
  3173   /**
  3174    * Load da shboard st atus page  while clic king on da shboard st atus image
  3175    **/
  3176   function s howDashboa rdStatus()  {
  3177       hideAn dShowTopMe nu();
  3178       $('#da shboard-to pmenu-stat us-home'). show();
  3179       $('#da hsboard-to pmenu-home -nav').sho w();
  3180       $('#da shboard-st atus-home' ).show();
  3181       getDas hboardRend erAndViewe rStatus();
  3182   }
  3183  
  3184   /**
  3185    * Get das hboard ren der and vi ewer statu s informat ion
  3186    * and dis play it in  status pa ge 
  3187    **/
  3188   function g etDashboar dRenderAnd ViewerStat us() {
  3189       $.ajax ({
  3190           ur l: DASHBOR AD_STATUS_ URL,
  3191           me thod: 'GET ',
  3192           da taType: 'j son',
  3193           as ync: true,
  3194           su ccess: fun ction (dat a) {
  3195                var stat usViewerIn formation  = "";
  3196                var stat usRenderIn formation  = "";
  3197                if (!isN ullOrUndef ined(data) ) {
  3198                    $('# dashboard- status-vie wer-table- body').htm l('');
  3199                    $('# dashboard- status-ren der-table- body').htm l('');
  3200                    $.ea ch(data, f unction (i ndex, colD ata) {
  3201                         var render Str = inde x.replace( 'rENDER',  'RENDER');
  3202                         if (render Str.indexO f('RENDER' ) !== -1)  {
  3203                             status RenderInfo rmation +=  '<tr><td> ' + index. replace('r ENDER.', ' ') + '</td ><td>' + c olData + ' </td></tr> ';
  3204                         } else {
  3205                             status ViewerInfo rmation +=  '<tr><td> ' + index. replace('v IEWER.', ' ') + '</td ><td>' + c olData + ' </td></tr> ';
  3206                         }
  3207                    });
  3208                } else {
  3209                    stat usRenderIn formation  = 'There i s no rende r status i nformation  available ';
  3210                    stat usViewerIn formation  = 'There i s no viewe r status i nformation  available ';
  3211                }
  3212                $('#dash board-stat us-viewer- table-body ').append( statusView erInformat ion);
  3213                $('#dash board-stat us-render- table-body ').append( statusRend erInformat ion);
  3214           }
  3215       });
  3216   }
  3217  
  3218   /**
  3219    * Display  dashboard  menu base d on hide  and show a ction
  3220    **/
  3221   function h ideAndShow TopMenu()  {
  3222       $('#da shboard-lo gin').hide ();
  3223       $('#da shboard-ho me').hide( );
  3224       $('#da shboard-lo g-home').h ide();
  3225       $('#da shboard-se arch-home' ).hide();
  3226       $('#da shboard-ca che-home') .hide();
  3227       $('#da shboard-sy stem-prefe rence-home ').hide();
  3228       $('#da shboard-to pmenu-logi n').hide() ;
  3229       $('#da shboard-st atus-home' ).hide();
  3230  
  3231  
  3232       $('#da shboard-to pmenu-logs -home').hi de();
  3233       $('#da hsboard-to pmenu-home -nav').hid e();
  3234       $('#da shboard-to pmenu-sear ch-home'). hide();
  3235       $('#da shboard-to pmenu-cach e-home').h ide();
  3236       $('#da shboard-to pmenu-syst em-prefere nce-home') .hide();
  3237       $('#da shboard-to pmenu-stat us-home'). hide();
  3238   }
  3239  
  3240   /**
  3241    * Check t he if a va lue is nul l or undef ined
  3242    **/
  3243   function i sNullOrUnd efined(obj ) {
  3244       if (ob j === unde fined || o bj === nul l) {
  3245           re turn true;
  3246       }
  3247       return  false;
  3248   }
  3249  
  3250   /**
  3251    * Convert  the xml t ext into j son value
  3252    **/
  3253   function x mlToJson(x ml) {
  3254       // Cre ate the re turn objec t
  3255       var ob j = {};
  3256  
  3257       if (xm l.nodeType  == 1) { / / element
  3258           //  do attrib utes
  3259           if  (xml.attr ibutes.len gth > 0) {
  3260                obj["att ributes"]  = {};
  3261                for (var  j = 0; j  < xml.attr ibutes.len gth; j++)  {
  3262                    var  attribute  = xml.attr ibutes.ite m(j);
  3263                    obj[ "attribute s"][attrib ute.nodeNa me] = attr ibute.node Value;
  3264                }
  3265           }
  3266       } else  if (xml.n odeType ==  3) { // t ext
  3267           ob j = xml.no deValue;
  3268       }
  3269  
  3270       // do  children
  3271       // If  just one t ext node i nside
  3272       if (xm l.hasChild Nodes() &&  xml.child Nodes.leng th === 1 & & xml.chil dNodes[0]. nodeType = == 3) {
  3273           ob j = xml.ch ildNodes[0 ].nodeValu e;
  3274       } else  if (xml.h asChildNod es()) {
  3275           fo r (var i =  0; i < xm l.childNod es.length;  i++) {
  3276                var item  = xml.chi ldNodes.it em(i);
  3277                var node Name = ite m.nodeName ;
  3278                if (node Name != "# comment")  {
  3279                    if ( typeof (ob j[nodeName ]) == "und efined") {
  3280                         obj[nodeNa me] = xmlT oJson(item );
  3281                    } el se {
  3282                         if (typeof  (obj[node Name].push ) == "unde fined") {
  3283                             var ol d = obj[no deName];
  3284                             obj[no deName] =  [];
  3285                             obj[no deName].pu sh(old);
  3286                         }
  3287                         obj[nodeNa me].push(x mlToJson(i tem));
  3288                    }
  3289                }
  3290           }
  3291       }
  3292  
  3293       return  obj;
  3294   }
  3295  
  3296   /**
  3297    * Get the  value as  JSON Forma te by pass ing the pa ram
  3298    **/
  3299   function g etJson(par am) {
  3300       try {
  3301           va r formatte dParams =  {};
  3302           va r params =  JSON.pars e(param);
  3303           $. each(param s, functio n (key, va lue) {
  3304                if (Obje ct.prototy pe.toStrin g.call(val ue) == '[o bject Stri ng]') {
  3305                    if ( value.star tsWith("[{ ") || valu e.startsWi th("{")) {
  3306                         formattedP arams[key]  = getJson (value);
  3307                    } el se if (val ue.startsW ith("<"))  {
  3308                         value = va lue.replac e('<!--',  '<');
  3309                         value = va lue.replac e('?-->',  '?>');
  3310                         value = va lue.replac e(new RegE xp('<img>' , 'g'), '' );
  3311  
  3312                         var xmlDoc ;
  3313                         if (window .DOMParser ) {
  3314                             var pa rser = new  DOMParser ();
  3315                             xmlDoc  = parser. parseFromS tring(valu e, "text/x ml");
  3316                             xmlCon tent = new  XMLSerial izer().ser ializeToSt ring(xmlDo c);
  3317                         } else {
  3318                             xmlDoc  = new Act iveXObject ("Microsof t.XMLDOM") ;
  3319                             xmlDoc .async = f alse;
  3320                             xmlDoc .loadXML(v alue);
  3321                         }
  3322  
  3323                         formattedP arams[key]  = getJson (JSON.stri ngify(xmlT oJson(xmlD oc)));
  3324                    } el se {
  3325                         formattedP arams[key]  = value;
  3326                    }
  3327                } else i f (Object. prototype. toString.c all(value)  == '[obje ct Object] ') {
  3328                    form attedParam s[key] = g etJson(JSO N.stringif y(value));
  3329                } else i f (Object. prototype. toString.c all(value)  == '[obje ct Array]' ) {
  3330                    valu e.forEach( function ( item, inde x) {
  3331                         if (Object .prototype .toString. call(item)  == '[obje ct Object] ') {
  3332                             value[ index] = g etJson(JSO N.stringif y(item));
  3333                         }
  3334                    });
  3335                    form attedParam s[key] = v alue;
  3336                } else {
  3337                    form attedParam s[key] = v alue;
  3338                }
  3339           }) ;
  3340  
  3341           re turn forma ttedParams ;
  3342       } catc h (e) {}
  3343  
  3344       return  param;
  3345   }
  3346  
  3347   /**
  3348    * Is dirt y check
  3349    * @param  {Type} cur rentActive Tab - Spec ifies the  current pr eference t ab
  3350    */
  3351   function i sDirty(cur rentActive Tab) {
  3352       try {
  3353           va r previous ActiveTab  = $(".tab- active")[0 ].id;
  3354           if  (previous ActiveTab  !== "disPr efActive")  {
  3355                if (dico mViewer.sy stemPrefer ences.sani tyCheck(ge tActiveTab Preference ())) {
  3356                    $("# preference SaveModal" ).val(curr entActiveT ab);
  3357                    $('# preference SaveModal' ).modal();
  3358                } else {
  3359                    sele ctPreferen ces(curren tActiveTab );
  3360                }
  3361           }  else {
  3362                selectPr eferences( currentAct iveTab);
  3363           }
  3364       } catc h (e) {}
  3365   }
  3366  
  3367   /**
  3368    * Get the  active ta b preferen ce
  3369    * @param  {Type}  
  3370    */
  3371   function g etActiveTa bPreferenc e() {
  3372       try {
  3373           va r activePr efTab = $( ".tab-acti ve")[0].id ;
  3374           va r preferen ce;
  3375           sw itch (acti vePrefTab)  {
  3376                case "ci nePrefActi ve":
  3377                    pref erence = " cine";
  3378                    brea k;
  3379                case "ec gPrefActiv e":
  3380                    pref erence = " ecg";
  3381                    brea k;
  3382                case "an notaPrefAc tive":
  3383                    pref erence = " annotation ";
  3384                    brea k;
  3385                case "di sPrefActiv e":
  3386                    pref erence = " display";
  3387                    brea k;
  3388                case "co pyPrefActi ve":
  3389                    pref erence = " copyattrib utes";
  3390                    brea k;
  3391                case "lo gPrefActiv e":
  3392                    pref erence = " log";
  3393                    brea k;
  3394           }
  3395  
  3396           re turn prefe rence;
  3397       } catc h (e) {}
  3398   }
  3399  
  3400   /**
  3401    * Apply t he changes
  3402    * @param  {Type}  
  3403    */
  3404   function a pplyChange s() {
  3405       var ac tivePrefTa b = getAct iveTabPref erence();
  3406       if (ac tivePrefTa b == "cine ") {
  3407           if  (!dicomVi ewer.syste mPreferenc es.isValid CinePrefer ence(activ ePrefTab))  {
  3408                dicomVie wer.system Preference s.resetPre ferenceVal ues(active PrefTab);
  3409                $("#pref erenceSave Modal").mo dal('hide' );
  3410                selectPr eferences( $("#prefer enceSaveMo dal").val( ));
  3411                return;
  3412           }
  3413       } else  if (activ ePrefTab = = "annotat ion") {
  3414           if  (!dicomVi ewer.syste mPreferenc es.isValid Annotation Preference (activePre fTab)) {
  3415                dicomVie wer.system Preference s.resetPre ferenceVal ues(active PrefTab);
  3416                $("#pref erenceSave Modal").mo dal('hide' );
  3417                selectPr eferences( $("#prefer enceSaveMo dal").val( ));
  3418                return;
  3419           }
  3420       }
  3421       dicomV iewer.syst emPreferen ces.onSubm it(activeP refTab);
  3422       $("#pr eferenceSa veModal"). modal('hid e');
  3423       select Preference s($("#pref erenceSave Modal").va l());
  3424   }
  3425  
  3426   /**
  3427    * Revert  the change s
  3428    * @param  {Type}  
  3429    */
  3430   function r evertChang es() {
  3431       dicomV iewer.syst emPreferen ces.resetP referenceV alues(getA ctiveTabPr eference() );
  3432       select Preference s($("#pref erenceSave Modal").va l());
  3433   }
  3434  
  3435   /**
  3436    * Select  the prefer ences
  3437    * @param  {Type} act ivePrefTab  - Specifi es the act ive prefer ence tab
  3438    */
  3439   function s electPrefe rences(act ivePrefTab ) {
  3440       try {
  3441           sw itch (acti vePrefTab)  {
  3442                case "ci nePrefActi ve":
  3443                    disp layCinePre ferences() ;
  3444                    brea k;
  3445                case "ec gPrefActiv e":
  3446                    disp layEcgPref erences();
  3447                    brea k;
  3448                case "an notaPrefAc tive":
  3449                    disp layAnnotat ionPrefere nces();
  3450                    brea k;
  3451                case "di sPrefActiv e":
  3452                    disp layLayoutP references ();
  3453                    brea k;
  3454                case "co pyPrefActi ve":
  3455                    disp layCopyAtt ributePref erences();
  3456                    brea k;
  3457                case "lo gPrefActiv e":
  3458                    disp layLogPref erences();
  3459                    brea k;
  3460           }
  3461       } catc h (e) {}
  3462   }
  3463  
  3464   /**
  3465    * Display  the prefe rences
  3466    * @param  {Type} act ivePrefTab  - Specifi es the act ive prefer ence tab
  3467    */
  3468   function d isplayPref erences(ac tivePrefTa b) {
  3469       try {
  3470           $( "#Preferen ceAlert"). html("");
  3471           $( "#Preferen ceAlert"). hide();
  3472           $( "#Annotati onPreferen ceAlert"). html("");
  3473           $( "#Annotati onPreferen ceAlert"). hide();
  3474           va r aPrefere nceType =  getActiveT abPreferen ce();
  3475           if  ($.inArra y(aPrefere nceType, p referenceT ype) != -1 ) {
  3476                isDirty( activePref Tab);
  3477           }  else {
  3478                selectPr eferences( activePref Tab);
  3479           }
  3480       } catc h (e) {}
  3481   }