25. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 10/18/2018 2:01:24 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

25.1 Files compared

# Location File Last Modified
1 VIX_SIV_v3_0_patch_201_build_8.zip\v3.0_patch_201_build_8\common\ZFViewerServices\ViewerRender-2.2.6841.19565.zip\VIX.Viewer.Service\Viewer\js\dash dash.js Mon Sep 24 17:06:26 2018 UTC
2 VIX_SIV_v3_0_patch_201_build_8.zip\v3.0_patch_201_build_8\common\ZFViewerServices\ViewerRender-2.2.6841.19565.zip\VIX.Viewer.Service\Viewer\js\dash dash.js Wed Oct 17 14:53:00 2018 UTC

25.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 3 7454
Changed 2 4
Inserted 0 0
Removed 0 0

25.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

25.4 Active regular expressions

No regular expressions were active.

25.5 Comparison detail

  1   /**
  2    * Admin P references  file
  3    */
  4  
  5   var dicomV iewer = (f unction(di comViewer)  {
  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 : " Info",
  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, value ) {
  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           {
  130                if (defa ultAnnotat ionPrefere nce === un defined ||  defaultAn notationPr eference = == null) {
  131                    defa ultAnnotat ionPrefere nce = {};
  132                }
  133                var meas urementSty le = {
  134                    useD efault: us eDefault,
  135                    styl eCol: styl eCol
  136                };
  137                
  138                defaultA nnotationP reference[ "" + type  + ""] = me asurementS tyle;
  139           }
  140           ca tch(e)
  141           {  }
  142       }
  143  
  144       /**
  145        * Sen d study qu ery reques t to get S ecurityTok en, AuthSi teNumber a nd SiteNum ber
  146        * @pa ram {Type}   
  147        */ 
  148       functi on studyQu eryRequest () {
  149           
  150       }
  151  
  152       /**
  153        *Set  the defaul t layout p reference  by modalit y
  154        */
  155       functi on setDefa ultLayoutP references ByModality (modality)  {
  156           tr y
  157           {
  158                if (defa ultDisplay Preference  === undef ined || de faultDispl ayPreferen ce === nul l) {
  159                    defa ultDisplay Preference  = {};
  160                }
  161                sysDispl ayPreferen ce["" + mo dality + " "] = {
  162                    moda lity: moda lity,
  163                    rows : 1,
  164                    colu mns: 1,
  165                    zoom Mode: '100 %',
  166                    useE mbedPdfVie wer: "fals e"
  167                };
  168                defaultD isplayPref erence = {
  169                    pref erence: sy sDisplayPr eference,
  170                    useD efault: tr ue
  171                };
  172           }
  173           ca tch(e)
  174           {  }
  175       }
  176       
  177       /**
  178        * upd ate the sy stem prefe rence load ing status
  179        * @pa ram {Type}  preferenc e - Specif ies the pr eference t ype
  180        * @pa ram {Type}  preferenc eData - Sp ecifies th e preferen ce data
  181        */ 
  182       var pr eferenceLo adingStatu s = [];
  183       functi on updateP referenceL oadingStat us(prefere nce, prefe renceData,  isUpdate)  {
  184           tr y
  185           {
  186                var load ingStatus  = {};
  187                var disp layText =  preference  + " syste m preferen ces.";
  188                if(!pref erenceLoad ingStatus[ preference ]) {
  189                    load ingStatus 
  190                    {
  191                         status: (i sUpdate ?  " Sending  " : " Fetc hing ") +  displayTex t,
  192                         canDisplay : true,
  193                         isSuccess:  true,
  194                         preference : preferen ce
  195                    };
  196                    pref erenceLoad ingStatus[ preference ] = loadin gStatus;
  197                } else {
  198                    load ingStatus  = preferen ceLoadingS tatus[pref erence];
  199                    load ingStatus. status = ( isUpdate ?  "Updated  " : " Appl ied ") + d isplayText ;
  200                    load ingStatus. canDisplay  = false;
  201                    if ( !preferenc eData) {
  202                         loadingSta tus.isSucc ess = fals e;
  203                         loadingSta tus.status  = "Failed  to " + (i sUpdate ?  "update "  : "fetch " ) + displa yText + "  Restoring  to default ";
  204                    }
  205                }
  206  
  207                switch(p reference)
  208                {
  209                    case  "cine":
  210                         showAndHid eStatus("d ashboard-c ine-loadin g-status",  "dashboar d-cine-loa ding-icon" , loadingS tatus);
  211                         break;
  212                    case  "ecg":
  213                          showAndHi deStatus(" dashboard- ecg-loadin g-status",  "dashboar d-ecg-load ing-icon",  loadingSt atus);
  214                         break;
  215                    case  "annotati on":
  216                         showAndHid eStatus("d ashboard-a nnotation- loading-st atus", "da shboard-an notation-l oading-ico n", loadin gStatus);
  217                         break;
  218                    case  "display" :
  219                         showAndHid eStatus("d ashboard-d isplay-loa ding-statu s", "dashb oard-displ ay-loading -icon", lo adingStatu s);
  220                         break;
  221                    case  "copyattr ibutes":
  222                         showAndHid eStatus("d ashboard-c opyattr-lo ading-stat us", "dash board-copy attr-loadi ng-icon",  loadingSta tus);
  223                         break;
  224                    case  "log":
  225                         showAndHid eStatus("d ashboard-l og-loading -status",  "dashboard -log-loadi ng-icon",  loadingSta tus);
  226                         break;
  227                    defa ult:
  228                         console.lo g("Unsuppo rted prefe rence type : " + pref erence);
  229                         break;
  230                }
  231           }
  232           ca tch(e)
  233           {  }
  234       }
  235       
  236       /**
  237        * Sho w and hide  dashboard  status ba sed on fol lowing par am
  238        */
  239       functi on showAnd HideStatus (statusId,  iconId, l oadingStat us) {
  240           $( '#'+iconId ).show();
  241           $( '#'+status Id).html(' ');
  242           $( '#'+status Id).html(l oadingStat us.status) ;
  243  
  244           if (loadingSt atus.isSuc cess && !l oadingStat us.canDisp lay) {
  245                $('#'+st atusId).re moveClass( 'dashboard -status-fa il-style') ;
  246                $('#'+st atusId).ad dClass('da shboard-st atus-succe ss-style') ;
  247           }  else if(!l oadingStat us.isSucce ss) {
  248                $('#'+st atusId).re moveClass( 'dashboard -status-su ccess-styl e');
  249                $('#'+st atusId).ad dClass('da shboard-st atus-fail- style');       
  250           }
  251  
  252           if (!loadingS tatus.canD isplay) {
  253                setTimeo ut(functio n(){ 
  254                    $('# '+iconId). hide();
  255                    if(p referenceL oadingStat us[loading Status.pre ference]){
  256                         delete pre ferenceLoa dingStatus [loadingSt atus.prefe rence];
  257                         $('#'+stat usId).remo veClass('d ashboard-s tatus-fail -style');
  258                         $('#'+stat usId).remo veClass('d ashboard-s tatus-succ ess-style' );
  259                    }
  260                }, 2000) ;  
  261           }
  262       }
  263  
  264       /**
  265        * Upd ate the sy stem prefe rences 
  266        * @pa ram {Type}  preferenc e - Specif ies the pr eference t ype
  267        * @pa ram {Type}  preferenc eData - Sp ecifies th e preferen ce data
  268        */ 
  269       functi on updateS ystemPrefe rences(pre ference, p referenceD ata) {
  270           tr y
  271           {
  272                updatePr eferenceLo adingStatu s(preferen ce, prefer enceData);
  273  
  274                switch(p reference)
  275                {
  276                    case  "cine":
  277                         if (!prefe renceData)  {
  278                             prefer enceData =  defaultCi nePreferen ce;
  279                         }
  280                         setCinePre ference(pr eferenceDa ta);
  281                         cinePrefer ence = pre ferenceDat a;
  282                         break;
  283                    case  "ecg":
  284                         if (!prefe renceData)  {
  285                             prefer enceData =  defaultEc gPreferenc e;
  286                         }
  287                         setEcgPref erence(pre ferenceDat a);
  288                         ecgPrefere nce = pref erenceData ;
  289                         break;
  290                    case  "annotati on":
  291                         if (!prefe renceData)  {
  292                             prefer enceData =  defaultAn notationPr eference;
  293                         }
  294                         setAnnotat ionPrefere nce(prefer enceData);
  295                         annotation Preference  = prefere nceData;
  296                         break;
  297                    case  "display" :
  298                         if (!prefe renceData)  {
  299                             prefer enceData =  defaultDi splayPrefe rence;
  300                         }
  301                         setDisplay Preference (preferenc eData.pref erence);
  302                         displayPre ference =  preference Data;
  303                         break;
  304                    case  "copyattr ibutes":
  305                         if (!prefe renceData)  {
  306                             prefer enceData =  defaultCo pyAttribut esPreferen ce;
  307                         }
  308                         setCopyAtt ributesPre ference(pr eferenceDa ta);
  309                         copyAttrib utesPrefer ence = pre ferenceDat a;
  310                         break;
  311                    case  "log":
  312                         if (!prefe renceData)  {
  313                             prefer enceData =  defaultLo gPreferenc e;
  314                         }
  315                         setLogPref erence(pre ferenceDat a);
  316                         logPrefere nce = pref erenceData ;
  317                         break;
  318                    defa ult:
  319                         console.lo g("Unsuppo rted prefe rence type : " + pref erence);
  320                         break;
  321                 }
  322           }
  323           ca tch(e)
  324           {  }
  325       }
  326  
  327       /**
  328        * Loa d all pref ernces
  329        */ 
  330       functi on loadAll Preference s() {
  331           pr eferenceLo adingStatu s = [];
  332           lo adPreferen ce("annota tion", tru e);
  333           lo adPreferen ce("displa y", true);
  334           lo adPreferen ce("copyat tributes",  true);
  335           lo adPreferen ce("cine",  true);
  336           lo adPreferen ce("log",  true);
  337       }
  338  
  339       /**
  340        * Set  system pr eference t o controls
  341        * @pa ram {Type}  preferenc
  342        */ 
  343       functi on loadPre ference(pr eference,  runAsAsync ) {
  344           va r t0 = Dat e.now();
  345           co nsole.log( "info: loa dPreferenc e - start" );
  346  
  347           tr y
  348           {
  349                // updat e the pref erence loa ding statu s
  350                updatePr eferenceLo adingStatu s(preferen ce);
  351  
  352                $.ajax
  353                (
  354                    {
  355                         url: getPr efUrl(pref erence),
  356                         cache: fal se,
  357                         async : (r unAsAsync  == true ?  true : fal se)
  358                    }
  359                )
  360                .done(fu nction(dat a) {
  361                    upda teSystemPr eferences( preference , JSON.par se(data));
  362                })
  363                .fail(fu nction(dat a) {
  364                    upda teSystemPr eferences( preference , null);
  365                })
  366                .error(f unction(xh r, status)  {
  367                    upda teSystemPr eferences( preference , null);
  368                    cons ole.log("e rror : " +  xhr.statu sText + "\ nFailed to  load the  system pre ference fr om server" );
  369                });
  370           }
  371           ca tch(e) {
  372                console. log("error : loadPref erence" +  e.message) ;
  373           }
  374           fi nally {
  375                console. log("info  : loadPref erence - e nd" + (Dat e.now() -  t0));
  376           }
  377       }
  378  
  379       /**
  380        * Get  request u rl for spe cified pre ference
  381        * @pa ram {Type}  preferenc
  382        */ 
  383       functi on getPref Url(prefer ence) {
  384           va r requestU rl = null;
  385           sw itch(prefe rence) {
  386                    case  "cine":
  387                    requ estUrl = g etCineUrl( );
  388                    brea k;
  389                case "ec g":
  390                    requ estUrl = g etEcgUrl() ;
  391                    brea k;
  392                case "an notation":
  393                    requ estUrl = g etMeasurem entPrefUrl ();
  394                    brea k;
  395                case "di splay":
  396                    requ estUrl = g etSettings Url();
  397                    brea k;
  398                case "co pyattribut es":
  399                    requ estUrl = g etCopyAttr ibUrl();
  400                    brea k;
  401                case "lo g":
  402                    requ estUrl = g etLogUrl() ;
  403                    brea k;
  404                default:
  405                    retu rn null;
  406           }
  407           re turn reque stUrl;
  408       }
  409  
  410       /**
  411        * Cin e Url
  412        */ 
  413       functi on getCine Url() {
  414           re turn BASE_ URL+"dict/ SYS/cine?S ecurityTok en=" + SEC URITY_TOKE N;
  415       }
  416  
  417       /**
  418        * Ecg  Url
  419        */ 
  420       functi on getEcgU rl() {
  421           re turn BASE_ URL+"dict/ SYS/ecg?Se curityToke n=" + SECU RITY_TOKEN ;
  422       }
  423  
  424       /**
  425        * Cop yAttribute s Url
  426        */ 
  427       functi on getCopy AttribUrl( ) {
  428           re turn BASE_ URL+"dict/ SYS/copyat tributes?S ecurityTok en=" + SEC URITY_TOKE N;
  429       }
  430  
  431       /**
  432        * Log  Url
  433        */ 
  434       functi on getLogU rl() {
  435           re turn BASE_ URL+"dict/ SYS/log?Se curityToke n=" + SECU RITY_TOKEN ;
  436       }
  437  
  438       /**
  439        * Set tings Url  (Hanging P rotocol)
  440        */ 
  441       functi on getSett ingsUrl()  {
  442           re turn BASE_ URL+"dict/ SYS/layout s?Security Token=" +  SECURITY_T OKEN;
  443       }
  444  
  445        /**
  446        * Mea surement p references  Url
  447        */ 
  448       functi on getMeas urementPre fUrl() {
  449           re turn BASE_ URL + "dic t/SYS/mpre f?Security Token=" +  SECURITY_T OKEN;
  450       }
  451  
  452       /**
  453        * Pra se html te xt
  454        * @pa ram {Type}  id 
  455        */ 
  456       functi on parseHT MLText(id)  {
  457           re turn $(id) .html().sp lit(':')[1 ].trim();
  458       }
  459  
  460       /**
  461        * Set  system pr eference f rom viewer  service
  462        * @pa ram {Type}  preferenc
  463        * @pa ram {Type}  data 
  464        */ 
  465       functi on setSyst emPreferen ce(prefere nce, data)  {
  466           va r requestU rl = getPr efUrl(pref erence);
  467           va r t0 = Dat e.now();
  468           co nsole.log( "info: set SystemPref erence - s tart");
  469  
  470           tr y {
  471  
  472                // updat e the pref erence loa ding statu s
  473                updatePr eferenceLo adingStatu s(preferen ce, undefi ned, true) ;
  474  
  475                $.ajax
  476                (
  477                    {
  478                         type: 'POS T',
  479                         url: reque stUrl,
  480                         data: JSON .stringify (data),
  481                         beforeSend : function (xhr) {
  482                             xhr.ov errideMime Type("text /plain; ch arset=x-us er-defined ");
  483                         }
  484                    }
  485                )
  486                .success (function( data) {
  487                    upda tePreferen ceValues(p reference) ;
  488                    upda tePreferen ceLoadingS tatus(pref erence, {} , true);
  489                })
  490                .fail(fu nction(dat a) {
  491                    upda tePreferen ceLoadingS tatus(pref erence, un defined, t rue);
  492                })
  493                .error(f unction(xh r, status)  {
  494                         var descri ption = xh r.statusTe xt + "\nFa iled to sa ve the sys tem prefer ence to se rver";
  495                         console.lo g("error :  " + descr iption);
  496                });
  497           }
  498           ca tch(e) {
  499                console. log("error  : " + e.m essage);
  500           }
  501           fi nally {
  502                console. log("info  : setSyste mPreferenc e - end" +  (Date.now () - t0));
  503           }
  504       }
  505  
  506       /**
  507        * Set  cine pref erence to  controls
  508        * @pa ram {Type}  preferenc
  509        */ 
  510       functi on setCine Preference (data) {
  511           se t('palysel ection', d ata.palyse lection);
  512           se t('timesTo Repeat', d ata.timesT oRepeat);
  513           se t('framesT oRepeat',  data.frame sToRepeat) ;
  514           se t('idleTim e', data.i dleTime);
  515       }
  516  
  517       /**
  518        * Get  cine pref erence fro m controls
  519        * 
  520        */ 
  521       functi on getCine Preference () {
  522           va r preferen ce = {
  523                palysele ction: get ('palysele ction'),
  524                timesToR epeat: get ('timesToR epeat'),
  525                framesTo Repeat: ge t('framesT oRepeat'),
  526                idleTime : get('idl eTime')
  527           };
  528           re turn prefe rence;
  529       }
  530  
  531       /**
  532        * Set  ecg prefe rence to c ontrols
  533        * @pa ram {Type}  preferenc
  534        */ 
  535       functi on setEcgP reference( data) {
  536           se t('ledsele ction', da ta.leadTyp e);
  537           se t('3x43one ',data.fir stSignal);
  538           se t('3x43two ',data.sec ondSignal) ;
  539           se t('3x43thr ee',data.t hirdSignal );
  540           se t('3x41Val ue',data.s ignalValue );
  541           $( '#ledselec tion').cha nge();
  542       }
  543  
  544       /**
  545        * Get  ecg prefe rence from  controls
  546        * 
  547        */ 
  548       functi on getEcgP reference( ) {
  549           va r preferen ce = {
  550                leadType : get('led selection' ),
  551                firstSig nal: get(' 3x43one'),
  552                secondSi gnal: get( '3x43two') ,
  553                thirdSig nal: get(' 3x43three' ),
  554                signalVa lue: get(' 3x41Value' )
  555           };
  556           re turn prefe rence;
  557       }
  558  
  559       /**
  560        * Set  annotatio n preferen ce to cont rols
  561        * @pa ram {Type}  preferenc
  562        */ 
  563       functi on setAnno tationPref erence(dat a) {
  564           se tStyleFrom Measuremen tCol(data) ;
  565       }
  566  
  567       /**
  568        * Get  annotatio n preferen ce from co ntrols
  569        * 
  570        */ 
  571       functi on getAnno tationPref erence() {
  572           re turn getMe asurementC olFromStyl e();
  573       }
  574  
  575       /**
  576        * Set  display p reference  to control s
  577        * @pa ram {Type}  preferenc
  578        */ 
  579       functi on setDisp layPrefere nce(data)  {
  580           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>'
  581  
  582           va r tr = nul l;
  583           $. each(data,  function( key, value ) {
  584                if (key  == "useDef ault") {
  585                    retu rn;
  586                }
  587                tr = $(' <tr/>');
  588                tr.appen d("<td>" +  value.mod ality + "< /td>");
  589                tr.appen d("<td>" +  value.row s + "</td> ");
  590                tr.appen d("<td>" +  value.col umns + "</ td>");
  591                tr.appen d("<td>" +  value.zoo mMode + "< /td>");
  592                tr.appen d("<td sty le='paddin g: 0px'>"  + tdAction  + "</td>" );
  593                $("#hpTa bleList"). append(tr) ;
  594  
  595                if (key  == 'ECG')  {
  596                    $('# useEmbedPd fViewer')[ 0].isECGPd f = value. useEmbedPd fViewer;
  597                } else i f (key ==  'General')  {
  598                    $('# useEmbedPd fViewer')[ 0].isGener al = value .useEmbedP dfViewer;
  599                } 
  600           }) ;
  601  
  602           $( '#useEmbed PdfViewer' ).val("tru e");
  603       }
  604  
  605       /**
  606        * Get  display p reference  from contr ols
  607        * 
  608        */ 
  609       functi on getDisp layPrefere nce() {
  610           va r preferen ce = {};
  611  
  612           $( "#hpTableL ist").find ('tr').eac h(function  (i, el) {
  613                tdData =  $(this).f ind('td');
  614                if (tdDa ta.length  >= 4) {
  615                    var  tdmodality  = tdData. eq(0).text ();
  616  
  617                    var  isUseEmbed PdfViewer   = true;
  618                    if(t dmodality  == "Genera l") {
  619                         isUseEmbed PdfViewer  = $('#useE mbedPdfVie wer')[0].i sGeneral;
  620                    } el se if(tdmo dality ==  "ECG") {
  621                         isUseEmbed PdfViewer  = $('#useE mbedPdfVie wer')[0].i sECGPdf;
  622                    }
  623  
  624                    pref erence[""  + tdmodali ty + ""] =  {
  625                         modality:  tdmodality ,
  626                         rows: tdDa ta.eq(1).t ext(),
  627                         columns: t dData.eq(2 ).text(),
  628                         zoomMode:  tdData.eq( 3).text(),
  629                         useEmbedPd fViewer: i sUseEmbedP dfViewer
  630                    };
  631                }
  632           }) ;
  633  
  634           re turn prefe rence;
  635       }
  636  
  637       /**
  638        * Set  copy attr ibutes pre ference to  controls
  639        * @pa ram {Type}  preferenc
  640        */ 
  641       functi on setCopy Attributes Preference (data) {
  642           se tCheck('wi ndowlevel' , data.win dowLevel);
  643           se tCheck('br ightnessco ntrast', d ata.bright nessContra st);
  644           se tCheck('sc ale', data .scale);
  645           se tCheck('in vert', dat a.invert);
  646           se tCheck('or ientation' , data.ori entation);
  647           se tCheck('pa n', data.p an);
  648       }
  649  
  650       /**
  651        * Set  copy attr ibutes pre ference to  controls
  652        * @pa ram {Type}  preferenc
  653        */ 
  654       functi on setLogP reference( data) {
  655           se t('logLeve lPref', da ta.logLeve l);
  656           se t('lineLim itPref', d ata.lineLi mit);
  657           se tLogPrefer enceKey(da ta.keys);
  658       }
  659  
  660       /**
  661        * Par se and set  the short cut key to  the contr ol
  662        * @pa ram {strin g}   value     shortc ut key
  663        */
  664       functi on setLogP referenceK ey (value)  {
  665           tr y
  666           {
  667                if(!valu e) {
  668                    retu rn;
  669                }
  670  
  671                var spli tValue = v alue.split ("+");
  672  
  673                value.in dexOf("CTR L") > -1 ?  setCheck( "ctrlkeyPr ef" ,true)  : setChec k("ctrlkey Pref" ,fal se);
  674                value.in dexOf("ALT ") > -1 ?  setCheck(" altkeyPref " ,true) :  setCheck( "altkeyPre f" ,false) ;
  675                value.in dexOf("SHI FT") > -1  ? setCheck ("shiftkey Pref" ,tru e) : setCh eck("shift keyPref" , false);
  676                set("key 3Pref", sp litValue[s plitValue. length-1]) ;
  677           }
  678           ca tch(e)
  679           {  }
  680       }
  681  
  682       /**
  683        * Get  copy attr ibutes pre ference fr om control s
  684        * 
  685        */ 
  686       functi on getCopy Attributes Preference () {
  687           va r preferen ce = {
  688                windowLe vel: getCh eck('windo wlevel'),
  689                brightne ssContrast : getCheck ('brightne sscontrast '),
  690                scale: g etCheck('s cale'),
  691                invert:  getCheck(' invert'),
  692                orientat ion: getCh eck('orien tation'),
  693                pan: get Check('pan ')
  694           };
  695           re turn prefe rence;
  696       }
  697  
  698       /**
  699        * Get  copy attr ibutes pre ference fr om control s
  700        * 
  701        */ 
  702       functi on getLogP reference( ) {
  703           va r preferen ce = {
  704                logLevel : get('log LevelPref' ),
  705                lineLimi t: get('li neLimitPre f'),
  706                keys: ge tLogPrefer enceKey()
  707           };
  708           re turn prefe rence;
  709       }
  710  
  711       /**
  712        * Get  and forma t the shor tcut key f rom contro l
  713        * @re turns {str ing} Shotc ut key
  714        */
  715       functi on getLogP referenceK ey () {
  716           tr y
  717           {
  718                var shor tCutKey =  "";
  719                if(getCh eck("ctrlk eyPref")){
  720                    shor tCutKey =  $("#ctrlke yPref")[0] .value;
  721                    shor tCutKey +=  "+" ;
  722                }
  723                if(getCh eck("altke yPref")){
  724                    shor tCutKey +=  $("#altke yPref")[0] .value;
  725                    shor tCutKey +=  "+" ;
  726                }
  727                if(getCh eck("shift keyPref")) {
  728                    shor tCutKey +=  $("#shift keyPref")[ 0].value;
  729                    shor tCutKey +=  "+" ;
  730                }
  731                shortCut Key += get ("key3Pref ");
  732  
  733                return s hortCutKey ;
  734           }
  735           ca tch(e)
  736           { 
  737                return " ";
  738           }
  739       }
  740  
  741       /**
  742        * Get  value for  given ele ment id
  743        * @pa ram {Type}  id 
  744        */ 
  745       functi on get(id)  {
  746           va r element  = document .getElemen tById(id);
  747           if (element)  {
  748                if (elem ent.type = = "checkbo x") {
  749                    retu rn getChec k(id);
  750                } else i f (id.inde xOf('Color ') > -1) {
  751                    retu rn getColo rSpectrum( id);
  752                }
  753                return e lement.val ue;
  754           }
  755       }
  756  
  757       /**
  758        * Get  checked s tate for g iven check box id
  759        * @pa ram {Type}  id 
  760        */ 
  761       functi on getChec k(id) {
  762           re turn $("#"  + id)[0]. checked;
  763       }
  764  
  765       /**
  766        * Get  color for  given spe ctrum id
  767        * @pa ram {Type}  id 
  768        */ 
  769       functi on getColo rSpectrum( id) {
  770           re turn $("#"  + id).spe ctrum("get ").toRgbSt ring();
  771       }
  772  
  773       /**
  774        * Set  value for  given ele ment id
  775        * @pa ram {Type}  id 
  776        * @pa ram {Type}  value 
  777        */ 
  778       functi on set(id,  value) {
  779           va r element  = document .getElemen tById(id);
  780           if (element)  {
  781                element. value = va lue;
  782           }
  783       }
  784  
  785       /**
  786        * Set  checked s tate for g iven check box id
  787        * @pa ram {Type}  id 
  788        * @pa ram {Type}  value 
  789        */ 
  790       functi on setChec k(id, valu e) {
  791           va r element  = document .getElemen tById(id);
  792           if (element)  {
  793                element. checked =  value;
  794           }
  795       }
  796  
  797       /**
  798        * Con vert measu rement col lection to  design vi ew structu re
  799        * @pa ram {Type}  measureme ntStyleCol  
  800        */ 
  801       functi on setStyl eFromMeasu rementCol( measuremen tStyleCol)  {
  802           $. each(MT_Ty peCol, fun ction(key,  value) {
  803                $.each(M T_EX_TypeC ol[value],  function( key, value ) {
  804                    if ( value == " LABEL") {
  805                         $.each(MT_ Lbl_Col, f unction(ke y, value_)  {
  806                             setMea surementSt yle(measur ementStyle Col, value , value_);
  807                         });
  808                    } el se {
  809                         setMeasure mentStyle( measuremen tStyleCol,  value);
  810                    }
  811                });
  812           }) ;
  813       }
  814  
  815       /**
  816        * Set  measureme nt style t o controls  for given  measureme nt type
  817        * @pa ram {Type}  measureme ntStyleCol  
  818        * @pa ram {Type}  value 
  819        */ 
  820       functi on setMeas urementSty le(measure mentStyleC ol, id, su bType) {
  821           va r type = i d;
  822  
  823           if  (measurem entStyleCo l[id] == u ndefined)  {
  824                if (id = = "ASTROKE STYLE") {
  825                    type  = "LINE";
  826                } else i f (id == " MSTROKESTY LE") {
  827                    type  = "LENGTH ";
  828                } else i f (id == " ERSTROKEST YLE") {
  829                    type  = "ELLIPS E";
  830                } else i f (id == " HOUNSFIELD ") {
  831                    type  = "HOUNSF IELDELLIPS E";
  832                } else i f (id == " LABEL") {
  833                    type  = subType ;
  834                } else i f (id == " MA") {
  835                    type  = "MRL";
  836                } else i f (id == " MITRAL") {
  837                    type  = "MRL";
  838                } else i f (id == " AORTIC") {
  839                    type  = "ARL";
  840                } else {
  841                    type  = "LINE";
  842                }
  843           }
  844  
  845           if  (id == "L ABEL") {
  846                id = sub Type;
  847           }
  848  
  849           se t(id + "li neWidth",  measuremen tStyleCol[ type].styl eCol.lineW idth);
  850           se t(id + "ga ugeLength" , measurem entStyleCo l[type].st yleCol.gau geLength);
  851           se t(id + "ga ugeStyle",  measureme ntStyleCol [type].sty leCol.gaug eStyle);
  852           se tCheck(id  + "isFill" , measurem entStyleCo l[type].st yleCol.isF ill);
  853           se t(id + "ar cRadius",  measuremen tStyleCol[ type].styl eCol.arcRa dius);
  854           se t(id + "fo ntName", m easurement StyleCol[t ype].style Col.fontNa me);
  855           se t(id + "fo ntSize", m easurement StyleCol[t ype].style Col.fontSi ze);
  856           se tCheck(id  + "isBold" , measurem entStyleCo l[type].st yleCol.isB old);
  857           se tCheck(id  + "isItali c", measur ementStyle Col[type]. styleCol.i sItalic);
  858           se tCheck(id  + "isUnder lined", me asurementS tyleCol[ty pe].styleC ol.isUnder lined);
  859           se tCheck(id  + "isStrik eout", mea surementSt yleCol[typ e].styleCo l.isStrike out);
  860           se t(id + "pr ecision",  measuremen tStyleCol[ type].styl eCol.preci sion);
  861           se t(id + "me asureUnits ", measure mentStyleC ol[type].s tyleCol.me asurementU nits);
  862           se tSpectrumC olor(id +  "lineColor ", measure mentStyleC ol[type].s tyleCol.li neColor);
  863           se tSpectrumC olor(id +  "fillColor ", measure mentStyleC ol[type].s tyleCol.fi llColor);
  864           se tSpectrumC olor(id +  "textColor ", measure mentStyleC ol[type].s tyleCol.te xtColor);
  865       }
  866       
  867       /**
  868        * Con vert desig n view str ucture to  measuremen t collecti on
  869        * @pa ram {Type}   
  870        */ 
  871       functi on getMeas urementCol FromStyle( ) {
  872           va r measurem entStyleCo l = {};
  873           $. each(MT_PS _TypeCol,  function(k ey, value)  {
  874                var styl eCol = {
  875                    line Width: get Measuremen tStyle("li neWidth",  value),
  876                    line Color: get Measuremen tStyle("li neColor",  value),
  877                    gaug eLength: g etMeasurem entStyle(" gaugeLengt h", value) ,
  878                    gaug eStyle: ge tMeasureme ntStyle("g augeStyle" , value),
  879                    isFi ll: getMea surementSt yle("isFil l", value) ,
  880                    fill Color: get Measuremen tStyle("fi llColor",  value),
  881                    arcR adius: get Measuremen tStyle("ar cRadius",  value),
  882                    text Color: get Measuremen tStyle("te xtColor",  value),
  883                    font Name: getM easurement Style("fon tName", va lue),
  884                    font Size: getM easurement Style("fon tSize", va lue),
  885                    isBo ld: getMea surementSt yle("isBol d", value) ,
  886                    isIt alic: getM easurement Style("isI talic", va lue),
  887                    isUn derlined:  getMeasure mentStyle( "isUnderli ned", valu e),
  888                    isSt rikeout: g etMeasurem entStyle(" isStrikeou t", value) ,
  889                    prec ision: get Measuremen tStyle("pr ecision",  value),
  890                    meas urementUni ts: getMea surementSt yle("measu reUnits",  value)
  891                }
  892  
  893                for (var  propName  in styleCo l) {
  894                    if ( styleCol[p ropName] = == undefin ed) {
  895                         delete sty leCol[prop Name];
  896                    }
  897                }
  898  
  899                measurem entStyleCo l[value] =  { 
  900                    useD efault: tr ue,
  901                    styl eCol: styl eCol
  902                };
  903           }) ;
  904           re turn measu rementStyl eCol;
  905       }
  906  
  907       /**
  908        * Get  measureme nt style f rom contro ls for giv en measure ment type
  909        * @pa ram {Type}  style 
  910        * @pa ram {Type}  type 
  911        */ 
  912       functi on getMeas urementSty le(style,  type) {
  913           va r key = ge tEnumMT(ty pe);
  914           sw itch(style ) {
  915                case "li neWidth":
  916                case "li neColor":
  917                case "pr ecision":
  918                case "me asureUnits ":
  919                    if ( key == "An notation")  {
  920                         type = "AS TROKESTYLE ";
  921                    } el se if (key  == "Measu rement") {
  922                         type = "MS TROKESTYLE ";
  923                    } el se if (key  == "Ellip se") {
  924                         type = "ER STROKESTYL E";
  925                    } el se if (key  == "hElli pse") {
  926                         type = "HO UNSFIELD";
  927                    } el se if (key  == "Mitra l") {
  928                         type = "MI TRAL";
  929                    } el se if (key  == "Aorti c") {
  930                         type = "AO RTIC";
  931                    } el se if (typ e.indexOf( 'LBL') > - 1) {
  932  
  933                    }
  934  
  935                    if ( style == " precision"  || style  == "measur eUnits") {
  936                         if (type = = "MITRAL"  || type = = "AORTIC" ) {
  937                             type =  "MA";
  938                         }
  939                    } el se if (key  == "hElli pse") {
  940                         type = "ER STROKESTYL E";
  941                    }
  942                    brea k;
  943                case "ga ugeStyle":
  944                case "ga ugeLength" :
  945                    if ( key == "An notation")  {
  946                         type = "LI NE";
  947                    } el se if (key  == "Measu rement") {
  948                         type = "LE NGTH";
  949                    } el se if (key  == "Mitra l" || key  == "Aortic ") {
  950                         type = "MA ";
  951                    }
  952                    brea k;
  953                case "is Fill":
  954                case "fi llColor":
  955                    if ( type == "T EXT") {
  956                        
  957                    } el se if (key  == "Annot ation") {
  958                         type = "AR ROW";
  959                    } el se if (key  == "Ellip se" || key  == "hElli pse") {
  960                         type = "ER STROKESTYL E";
  961                    }
  962                    brea k;
  963                case "ar cRadius":
  964                    if ( type != "A NGLE" && t ype != "GL OBAL") {
  965                         return nul l;
  966                    }
  967                    brea k;
  968                case "te xtColor":
  969                case "fo ntName":
  970                case "fo ntSize":
  971                case "is Bold":
  972                case "is Italic":
  973                case "is Underlined ":
  974                case "is Strikeout" :
  975                    if ( type.index Of('LBL')  > -1) {
  976  
  977                    } el se if (typ e != "TEXT " && type  != "GLOBAL ") {
  978                         type = "LB LANNOTATIO N";
  979                    }
  980                    brea k;
  981                default:
  982                    retu rn null;
  983           }
  984           re turn get(t ype + styl e);
  985       }
  986  
  987       /**
  988        * Get  measureme nt categor y for give n measurem ent type
  989        * @pa ram {Type}  type 
  990        */ 
  991       functi on getEnum MT(type) {
  992           if  (type ==  "GLOBAL")  {
  993                return t ype;
  994           }
  995  
  996           if  (type ==  "TEXT" ||  type == "L INE" 
  997                                ||  type == "A RROW" || t ype == "FR EEHAND" ||  type == " PEN") {
  998                return " Annotation ";
  999           }  else if (t ype == "LE NGTH" || t ype == "PO INT" || ty pe == "ANG LE" || typ e == "TRAC E") {
  1000                return " Measuremen t";
  1001           }  else if (t ype == "EL LIPSE" ||  type == "R ECT") {
  1002                return " Ellipse";
  1003           }  else if (t ype == "HO UNSFIELDEL LIPSE" ||  type == "H OUNSFIELDR ECT") {
  1004                return " hEllipse";
  1005           }  else if (t ype == "MG " || type  == "MRPV"  || type ==  "MRL" ||  type == "M VALT") {
  1006                return " Mitral";
  1007           }  else if (t ype == "AS PV" || typ e == "ARPV " || type  == "ARL")  {
  1008                return " Aortic";
  1009           }
  1010       }
  1011  
  1012       /**
  1013        * Set  color spe ctrum
  1014        * @pa ram {Type}  id 
  1015        * @pa ram {Type}  color 
  1016        */ 
  1017       functi on setSpec trumColor( id, color)  {
  1018           va r element  = document .getElemen tById(id);
  1019           if  (element)  {
  1020                $("#" +  id).spectr um
  1021                (
  1022                    {
  1023                         color: col or,
  1024                         showAlpha:  true,
  1025                         showPalett eOnly: tru e,
  1026                         togglePale tteOnly: t rue,
  1027                         togglePale tteMoreTex t: 'more',
  1028                         togglePale tteLessTex t: 'less',
  1029                         palette: [
  1030                             ["#000 ","#444"," #666","#99 9","#ccc", "#eee","#f 3f3f3","#f ff"],
  1031                             ["#f00 ","#f90"," #ff0","#0f 0","#0ff", "#00f","#9 0f","#f0f" ],
  1032                             ["#f4c ccc","#fce 5cd","#fff 2cc","#d9e ad3","#d0e 0e3","#cfe 2f3","#d9d 2e9","#ead 1dc"],
  1033                             ["#ea9 999","#f9c b9c","#ffe 599","#b6d 7a8","#a2c 4c9","#9fc 5e8","#b4a 7d6","#d5a 6bd"],
  1034                             ["#e06 666","#f6b 26b","#ffd 966","#93c 47d","#76a 5af","#6fa 8dc","#8e7 cc3","#c27 ba0"],
  1035                             ["#c00 ","#e69138 ","#f1c232 ","#6aa84f ","#45818e ","#3d85c6 ","#674ea7 ","#a64d79 "],
  1036                             ["#900 ","#b45f06 ","#bf9000 ","#38761d ","#134f5c ","#0b5394 ","#351c75 ","#741b47 "],
  1037                             ["#600 ","#783f04 ","#7f6000 ","#274e13 ","#0c343d ","#073763 ","#20124d ","#4c1130 "]
  1038                         ]
  1039                    }
  1040                );
  1041           }
  1042       }
  1043  
  1044       /**
  1045        * Get  row of ex isisting m odality
  1046        * @pa ram {Type}   
  1047        */ 
  1048       functi on isExist ingModalit y(modality ) {
  1049           //  Check whe ther the m odality is  already p resent and  update th e new sett ings. 
  1050           va r tdElemen t = null;
  1051           $( "#hpTableL ist").find ('tr').eac h(function  (i, el) {
  1052                tdData =  $(this).f ind('td');
  1053                if (tdDa ta.length  >= 4) {
  1054                    var  tdmodality  = tdData. eq(0).text ();
  1055                    if ( tdmodality  == modali ty) {
  1056                         tdElement  = tdData;
  1057                         return fal se;
  1058                    }
  1059                }
  1060           }) ;
  1061           re turn tdEle ment;
  1062       }
  1063  
  1064       /**
  1065        * To  update HP  table
  1066        * @pa ram {Type}   
  1067        */ 
  1068       functi on updateH PTable() {
  1069           va r data = { };
  1070           va r modality  = get('mo dality');
  1071           va r tdElemen t = isExis tingModali ty(modalit y);
  1072           da ta[modalit y] = {
  1073                modality : modality ,
  1074                rows: ge t('layoutR ows'),
  1075                columns:  get('layo utColumns' ),
  1076                zoomMode : get('zoo mModeValue s'),
  1077                useEmbed PdfViewer:  get('useE mbedPdfVie wer')
  1078           };
  1079           //  Add the n ew modalit y settings  
  1080           if  (!tdEleme nt) {
  1081                setDispl ayPreferen ce(data);
  1082           }  else {
  1083                tdElemen t.eq(1).ht ml(data[mo dality].ro ws);
  1084                tdElemen t.eq(2).ht ml(data[mo dality].co lumns);
  1085                tdElemen t.eq(3).ht ml(data[mo dality].zo omMode);
  1086           }
  1087  
  1088           if (modality  == "Genera l") {
  1089                var valu e = $('#us eEmbedPdfV iewer')[0] .isGeneral  = data[mo dality].us eEmbedPdfV iewer;
  1090                $('#useE mbedPdfVie wer').val( value);
  1091           }  else if(mo dality ==  "ECG") {
  1092                var valu e = $('#us eEmbedPdfV iewer')[0] .isECGPdf  = data[mod ality].use EmbedPdfVi ewer;
  1093                $('#useE mbedPdfVie wer').val( value);
  1094           }
  1095  
  1096           sh owOrHideHP Table(true );
  1097           on Submit('di splay');
  1098       }
  1099  
  1100       /**
  1101        * Edi t selected  HP Protoc ol
  1102        * @pa ram {Type}   
  1103        */ 
  1104       functi on addOrEd itHP(tdEle ment, acti on) {
  1105           va r useDefau lt = null;
  1106           va r modality  = null;
  1107           if  (action = = "edit")  {
  1108                useDefau lt = false ;
  1109           }  else if (a ction == " add") {
  1110                tdElemen t = isExis tingModali ty('US');
  1111                if (tdEl ement) {
  1112                    useD efault = f alse;
  1113                } else {
  1114                    useD efault = t rue;
  1115                }
  1116           }  else if (a ction == " selchange" ) {
  1117                if (tdEl ement) {
  1118                    useD efault = f alse;
  1119                } else {
  1120                    useD efault = t rue;
  1121                }
  1122           }
  1123  
  1124           if  (useDefau lt) {
  1125                modality  = 'US';
  1126                set('lay outRows',  '1');
  1127                set('lay outColumns ', '1');
  1128                set('zoo mModeValue s', '100%' );
  1129                $("#moda lity").pro p('disable d', false) ;
  1130           }  else {
  1131                modality  = tdEleme nt[0].inne rText;
  1132                set('lay outRows',  tdElement[ 1].innerTe xt);
  1133                set('lay outColumns ', tdEleme nt[2].inne rText);
  1134                set('zoo mModeValue s', tdElem ent[3].inn erText);
  1135                $("#moda lity").pro p('disable d', action  == "edit" );
  1136           }
  1137  
  1138           if (modality  == "Genera l") {
  1139                var valu e = $('#us eEmbedPdfV iewer')[0] .isGeneral  == undefi ned ? "tru e" : $('#u seEmbedPdf Viewer')[0 ].isGenera l;
  1140                $('#useE mbedPdfVie wer').val( value);
  1141           }  else if(mo dality ==  "ECG") {
  1142                var valu e = $('#us eEmbedPdfV iewer')[0] .isECGPdf  == undefin ed ? "true " : $('#us eEmbedPdfV iewer')[0] .isECGPdf;
  1143                $('#useE mbedPdfVie wer').val( value);
  1144           }
  1145  
  1146           if  (action ! = "selchan ge") {
  1147                showOrHi deHPTable( false);
  1148                set('mod ality', mo dality);
  1149                
  1150                if(modal ity == "Ge neral" ||  modality = = "ECG") {
  1151                    $("# useEmbedPD FViewer_Ro w").show() ;
  1152                } else {
  1153                    $("# useEmbedPD FViewer_Ro w").hide() ;
  1154                }
  1155           }
  1156       }
  1157  
  1158       /**
  1159        * Sho w or Hide  HP control s
  1160        * @pa ram {Type}   
  1161        */ 
  1162       functi on showOrH ideHPTable (isShow) {
  1163           if  (isShow)  {
  1164                $('#list HangingPro tocol').sh ow();
  1165                $('#addE ditHPTable ').hide();
  1166           }  else {
  1167                $('#list HangingPro tocol').hi de();
  1168                $('#addE ditHPTable ').show();
  1169                $("#moda lity").cha nge(functi on () {
  1170                    if(t his.value  == "Genera l" || this .value ==  "ECG") {
  1171                         if(this.va lue == "Ge neral") {
  1172                             var va lue = $('# useEmbedPd fViewer')[ 0].isGener al == unde fined ? "t rue" : $(' #useEmbedP dfViewer') [0].isGene ral;
  1173                             $('#us eEmbedPdfV iewer').va l(value);
  1174                         } else if( this.value  == "ECG")  {
  1175                             var va lue = $('# useEmbedPd fViewer')[ 0].isECGPd f == undef ined ? "tr ue" : $('# useEmbedPd fViewer')[ 0].isECGPd f;
  1176                             $('#us eEmbedPdfV iewer').va l(value);
  1177                         }
  1178                         $("#useEmb edPDFViewe r_Row").sh ow();
  1179                    } el se {
  1180                         $("#useEmb edPDFViewe r_Row").hi de();
  1181                    }
  1182                    addO rEditHP(is ExistingMo dality(thi s.value),  'selchange ');
  1183                });
  1184           }
  1185       }
  1186  
  1187       /**
  1188        * Del ete select ed HP Prot ocol
  1189        * @pa ram {Type}   
  1190        */ 
  1191       functi on deleteH P(row) {
  1192           $( row).close st('tr').r emove();
  1193  
  1194           va r modality  = $(row). closest('t r').find(' td').eq(0) .text();
  1195           if (modality  == "ECG"){
  1196                $('#useE mbedPdfVie wer')[0].i sECGPdf =  undefined;
  1197           }  else if(mo dality ==  "General")  {
  1198                $('#useE mbedPdfVie wer')[0].i sGeneral =  undefined ;
  1199           }
  1200           on Submit('di splay');
  1201       }
  1202  
  1203       /**
  1204        * Sub mit system  preferenc e
  1205        * @pa ram {Type}   
  1206        */ 
  1207       functi on onSubmi t(preferen ce) {
  1208           va r data = n ull;
  1209           sw itch(prefe rence) {
  1210                    case  "cine":
  1211                    data  = getCine Preference ();
  1212                    brea k;
  1213                case "ec g":
  1214                    data  = getEcgP reference( );
  1215                    brea k;
  1216                case "an notation":
  1217                    data  = getAnno tationPref erence();
  1218                    brea k;
  1219                case "di splay":
  1220                    data  = {
  1221                         preference : getDispl ayPreferen ce()
  1222                    };
  1223                    brea k;
  1224                case "co pyattribut es":
  1225                    data  = getCopy Attributes Preference ();
  1226                    brea k;
  1227                case "lo g":
  1228                    data  = getLogP reference( );
  1229                    brea k;
  1230                default:
  1231                    retu rn;
  1232           }
  1233  
  1234           if (preferenc e != "disp lay") {
  1235                toggleBu tton(prefe rence, tru e);
  1236           }
  1237  
  1238           if (preferenc e == "cine ") {
  1239                if(!isVa lidCinePre ference(pr eference))  {
  1240                    retu rn;
  1241                }
  1242           }
  1243  
  1244           if (preferenc e == "anno tation") {
  1245                if(!isVa lidAnnotat ionPrefere nce(prefer ence)) {
  1246                    retu rn;
  1247                }
  1248           }
  1249  
  1250           if  (data) {
  1251                data.use Default =  true;
  1252                setSyste mPreferenc e(preferen ce, data);
  1253           }
  1254       }
  1255  
  1256       /**
  1257        * Res et system  preference
  1258        * @pa ram {Type}   
  1259        */ 
  1260       functi on onReset (preferenc e) {
  1261           $( "#Preferen ceAlert"). html("");
  1262           $( "#Preferen ceAlert"). hide();
  1263           $( "#Annotati onPreferen ceAlert"). html("");
  1264           $( "#Annotati onPreferen ceAlert"). hide();
  1265           re setPrefere nceValues( preference );
  1266       }
  1267  
  1268       /**
  1269        * loa d the syst em prefere nce
  1270        * @pa ram {Type}  preferenc e - Specif ies the pr eference
  1271        * @pa ram {Type}  loadFrom  - Specifie s the load ing type
  1272        */ 
  1273       functi on loadSys temPrefere nce(prefer ence, load From) {
  1274           tr y {
  1275                var pref erenceData ;
  1276                switch(p reference)  {
  1277                    case  "cine":
  1278                         preference Data = loa dFrom == " control" ?  getCinePr eference()  : cinePre ference;
  1279                         preference Data.useDe fault = tr ue;
  1280                         break;
  1281                    case  "ecg":
  1282                         preference Data = loa dFrom == " control" ?  getEcgPre ference()  : ecgPrefe rence;
  1283                         preference Data.useDe fault = tr ue;
  1284                         break;
  1285                    case  "annotati on":
  1286                         preference Data = loa dFrom == " control" ?  getAnnota tionPrefer ence() : a nnotationP reference;
  1287                         preference Data.useDe fault = tr ue;
  1288                         break;
  1289                    case  "display" :
  1290                         preference Data = loa dFrom == " control" ?  { prefere nce : getD isplayPref erence()}  : displayP reference;
  1291                         preference Data.useDe fault = tr ue;
  1292                         break;
  1293                    case  "copyattr ibutes":
  1294                         preference Data = loa dFrom == " control" ?  getCopyAt tributesPr eference()  : copyAtt ributesPre ference;
  1295                         preference Data.useDe fault = tr ue;
  1296                         break;
  1297                    case  "log":
  1298                         preference Data = loa dFrom == " control" ?  getLogPre ference()  : logPrefe rence;
  1299                         preference Data.useDe fault = tr ue;
  1300                         break;
  1301                }
  1302  
  1303                return p referenceD ata;
  1304           }
  1305           ca tch(e)
  1306           {  }
  1307       }
  1308  
  1309       /**
  1310        * upd ate the pr eference v alues
  1311        * @pa ram {Type}  preferenc e - Specif ies the pr eference
  1312        */ 
  1313       functi on updateP referenceV alues(pref erence) {
  1314           tr y {
  1315                switch(p reference)  {
  1316                    case  "cine":
  1317                         cinePrefer ence = get CinePrefer ence();
  1318                         cinePrefer ence.useDe fault = tr ue;
  1319                         break;
  1320                    case  "ecg":
  1321                         ecgPrefere nce = getE cgPreferen ce();
  1322                         ecgPrefere nce.useDef ault = tru e;
  1323                         break;
  1324                    case  "annotati on":
  1325                         annotation Preference  = getAnno tationPref erence();
  1326                         annotation Preference .useDefaul t = true;
  1327                         break;
  1328                    case  "display" :
  1329                         displayPre ference =  { preferen ce : getDi splayPrefe rence()};
  1330                         displayPre ference.us eDefault =  true;
  1331                         break;
  1332                    case  "copyattr ibutes":
  1333                         copyAttrib utesPrefer ence = get CopyAttrib utesPrefer ence();
  1334                         copyAttrib utesPrefer ence.useDe fault = tr ue;
  1335                         break;
  1336                    case  "log":
  1337                         logPrefere nce = getL ogPreferen ce();
  1338                         logPrefere nce.useDef ault = tru e;
  1339                         break;
  1340                }
  1341           }
  1342           ca tch(e)
  1343           {  }
  1344       }
  1345       
  1346       /**
  1347        * Res et the pre ference va lues
  1348        * @pa ram {Type}  preferenc e - Specif ies the pr eference
  1349        */ 
  1350       functi on resetPr eferenceVa lues(prefe rence) {
  1351           tr y {
  1352                switch(p reference)  {
  1353                    case  "cine":
  1354                         setCinePre ference(ci nePreferen ce);
  1355                         break;
  1356                    case  "ecg":
  1357                         setEcgPref erence(ecg Preference );
  1358                         break;
  1359                    case  "annotati on":
  1360                         setAnnotat ionPrefere nce(annota tionPrefer ence);
  1361                         break;
  1362                    case  "display" :
  1363                         setDisplay Preference (displayPr eference.p reference) ;
  1364                         break;
  1365                    case  "copyattr ibutes":
  1366                         setCopyAtt ributesPre ference(co pyAttribut esPreferen ce);
  1367                         break;
  1368                    case  "log":
  1369                         setLogPref erence(log Preference );
  1370                         break;
  1371                                  }
  1372                toggleBu tton(prefe rence, tru e);
  1373           }
  1374           ca tch(e)
  1375           {  }
  1376       }
  1377  
  1378       /**
  1379        * San ity check  in current  preferenc e window
  1380        * @pa ram {Type}  activePre fTab - Spe cifies the  active pr eference t ab
  1381        */ 
  1382       functi on sanityC heck(activ ePrefTab)  {
  1383           tr y {
  1384                var stor edData = l oadSystemP reference( activePref Tab, 'conf ig');
  1385                var curr entData =  loadSystem Preference (activePre fTab, 'con trol');
  1386                return ! Object.com pare(curre ntData, st oredData);
  1387           }
  1388           ca tch(e)
  1389           {  }
  1390       }
  1391  
  1392       /**
  1393        * isD irtyCheck  in prefere nce window
  1394        * @pa ram {Type}  activePre fTab - Spe cifies the  active pr eference t ab
  1395        */ 
  1396       functi on isDirty Check(acti vePrefTab)  {
  1397           tr y {
  1398                var isDi rty = fals e;
  1399                isDirty  = sanityCh eck(active PrefTab);
  1400                toggleBu tton(activ ePrefTab,  isDirty ?  false : tr ue);
  1401           }
  1402           ca tch(e)
  1403           {  }
  1404       }
  1405  
  1406       /**
  1407        * Tog gle the su bmit and r eset butto n
  1408        * @pa ram {Type}  preferenc e - Specif ies the pr eference
  1409        * @pa ram {Type}  state - S pecifies t he button  state
  1410        */ 
  1411       functi on toggleB utton(pref erence, st ate) {
  1412           tr y {
  1413                $('#dash board-' +  preference  + 'Tab-ap ply-btn'). prop('disa bled', sta te);
  1414                $('#dash board-' +  preference  + 'Tab-re set-btn'). prop('disa bled', sta te);
  1415           }
  1416           ca tch(e)
  1417           {  }
  1418       }
  1419  
  1420       /**
  1421        * Dee p objects  comparisio n
  1422        */ 
  1423       Object .compare =  function  (obj1, obj 2) {
  1424           // Loop throu gh propert ies in obj ect 1
  1425           fo r (var p i n obj1) {
  1426                //Check  property e xists on b oth object s
  1427                if (obj1 .hasOwnPro perty(p) ! == obj2.ha sOwnProper ty(p)) ret urn false;
  1428  
  1429                switch ( typeof (ob j1[p])) {
  1430                         //Deep com pare objec ts
  1431                    case  'object':
  1432                         if (!Objec t.compare( obj1[p], o bj2[p])) r eturn fals e;
  1433                         break;
  1434                         //Compare  function c ode
  1435                    case  'function ':
  1436                         if (typeof  (obj2[p])  == 'undef ined' || ( p != 'comp are' && ob j1[p].toSt ring() !=  obj2[p].to String()))  return fa lse;
  1437                         break;
  1438                         //Compare  values
  1439                    defa ult:
  1440                         if ((typeo f obj1[p]  == "string ") && obj1 [p].indexO f('#') > - 1) {
  1441                             obj1[p ] = hexToR gb(obj1[p] );
  1442                         }
  1443                         if ((typeo f obj2[p]  == "string ") && obj2 [p].indexO f('#') > - 1) {
  1444                             obj2[p ] = hexToR gb(obj2[p] );
  1445                         }
  1446                         if (obj1[p ] != null  && obj2[p]  != null & & obj1[p]  != obj2[p] ) return f alse;
  1447                                          }
  1448           }
  1449  
  1450           // Check obje ct 2 for a ny extra p roperties
  1451           fo r (var p i n obj2) {
  1452                if (type of (obj1[p ]) == 'und efined') r eturn fals e;
  1453           }
  1454           re turn true;
  1455       };
  1456       
  1457       /**
  1458        * HEX  to RGB co nversion
  1459        * @pa ram {Type}  hex 
  1460        */ 
  1461       functi on hexToRg b(hex) {
  1462           //  Expand sh orthand fo rm (e.g. " 03F") to f ull form ( e.g. "0033 FF")
  1463           va r shorthan dRegex = / ^#?([a-f\d ])([a-f\d] )([a-f\d]) $/i;
  1464           he x = hex.re place(shor thandRegex , function (m, r, g,  b) {
  1465                return r  + r + g +  g + b + b ;
  1466           }) ;
  1467  
  1468           va r result =  /^#?([a-f \d]{2})([a -f\d]{2})( [a-f\d]{2} )$/i.exec( hex);
  1469           re turn resul t ? "rgb("  + parseIn t(result[1 ], 16) + " , " + pars eInt(resul t[2], 16)  + ", " + p arseInt(re sult[3], 1 6) +")" :  null;
  1470       }
  1471  
  1472       /**
  1473        * Is  valid cine  preferenc e or not
  1474        * @pa ram {Type}  prefActiv eTab - Spe cifies the  active ta b
  1475        */ 
  1476       functi on isValid CinePrefer ence(prefA ctiveTab)  {
  1477           tr y {
  1478                var pref erence = g etCinePref erence();
  1479                if(prefe rence.fram esToRepeat  == "" ||  preference .timesToRe peat == ""  || prefer ence.idleT ime == "")
  1480                {
  1481                    $("# Preference Alert").ht ml('Value  should not  be empty' );
  1482                    $("# Preference Alert").sh ow();
  1483                    $('# dashboard- ' + prefAc tiveTab +  'Tab-reset -btn').pro p('disable d', false) ;
  1484                    retu rn false;
  1485                } else i f ((prefer ence.frame sToRepeat  < 1 ) || ( 500 < pref erence.fra mesToRepea t) ||(pref erence.tim esToRepeat  < 1 ) ||  (500 < pre ference.ti mesToRepea t) || (pre ference.id leTime < 1  ) || (500  < prefere nce.idleTi me)) {
  1486                    $("# Preference Alert").ht ml('Value  must be be tween 1 an d 500');
  1487                    $("# Preference Alert").sh ow();
  1488                    $('# dashboard- ' + prefAc tiveTab +  'Tab-reset -btn').pro p('disable d', false) ;
  1489                    retu rn false;
  1490                } else {
  1491                    $("# Preference Alert").ht ml("");
  1492                    $("# Preference Alert").hi de();
  1493                }
  1494  
  1495                return t rue;
  1496           }
  1497           ca tch(e)
  1498           {  }
  1499       }
  1500  
  1501       /**
  1502        * Is  valid anno tation pre ference or  not
  1503        * @pa ram {Type}  prefActiv eTab - Spe cifies the  active ta b
  1504        */ 
  1505       functi on isValid Annotation Preference (prefActiv eTab) {
  1506           tr y {
  1507                var pref erence = g etAnnotati onPreferen ce();
  1508                if(prefe rence.LINE .styleCol. gaugeLengt h == "" ||  preferenc e.LENGTH.s tyleCol.ga ugeLength  ==  "" ||  preference .ANGLE.sty leCol.arcR adius == " " || prefe rence.HOUN SFIELDRECT .styleCol. precision  == "" || p reference. MRPV.style Col.gaugeL ength  ==  "" || pref erence.MRP V.styleCol .precision  == "" ||  preference .LENGTH.st yleCol.pre cision ==  "") {
  1509                    $("# Annotation Preference Alert").ht ml('Value  should not  be empty' );
  1510                    $("# Annotation Preference Alert").sh ow();
  1511                    $('# dashboard- ' + prefAc tiveTab +  'Tab-reset -btn').pro p('disable d', false) ;
  1512                    retu rn false;
  1513                } else i f(preferen ce.LINE.st yleCol.gau geLength >  20 || pre ference.LE NGTH.style Col.gaugeL ength > 20  || prefer ence.MRPV. styleCol.g augeLength  > 20) {
  1514                    $("# Annotation Preference Alert").ht ml('GaugeL ength valu e must be  between 0  and 20');
  1515                    $("# Annotation Preference Alert").sh ow();
  1516                    $('# dashboard- ' + prefAc tiveTab +  'Tab-reset -btn').pro p('disable d', false) ;
  1517                    retu rn false;
  1518                } else i f((prefere nce.ANGLE. styleCol.a rcRadius <  5 || pref erence.ANG LE.styleCo l.arcRadiu s > 20) )  {
  1519                    $("# Annotation Preference Alert").ht ml('ANGLE  arcRadius  value must  be betwee n 5 and 20 ');
  1520                    $("# Annotation Preference Alert").sh ow();
  1521                    $('# dashboard- ' + prefAc tiveTab +  'Tab-reset -btn').pro p('disable d', false) ;
  1522                    retu rn false;
  1523                } else i f(preferen ce.HOUNSFI ELDRECT.st yleCol.pre cision > 1 4 ||  pref erence.MRP V.styleCol .precision  > 14 || p reference. LENGTH.sty leCol.prec ision > 14 ) {
  1524                    $("# Annotation Preference Alert").ht ml('Precis ion value  must be be tween 0 an d 14');
  1525                    $("# Annotation Preference Alert").sh ow();
  1526                    $('# dashboard- ' + prefAc tiveTab +  'Tab-reset -btn').pro p('disable d', false) ;
  1527                    retu rn false;
  1528                } else {
  1529                    $("# Annotation Preference Alert").ht ml("");
  1530                    $("# Annotation Preference Alert").hi de();
  1531                }
  1532                
  1533                return t rue;
  1534           }
  1535           ca tch(e)
  1536           {  }
  1537       }
  1538  
  1539       dicomV iewer.syst emPreferen ces = {
  1540           ad dOrEditHP:  addOrEdit HP,
  1541           de leteHP: de leteHP,
  1542           up dateHPTabl e: updateH PTable,
  1543           sh owOrHideHP Table: sho wOrHideHPT able,
  1544           on Submit: on Submit,
  1545           on Reset: onR eset,
  1546           lo adAllPrefe rences: lo adAllPrefe rences,
  1547           is DirtyCheck : isDirtyC heck,
  1548           sa nityCheck:  sanityChe ck,
  1549           re setPrefere nceValues:  resetPref erenceValu es,
  1550           is ValidCineP reference  : isValidC inePrefere nce,
  1551           is ValidAnnot ationPrefe rence : is ValidAnnot ationPrefe rence
  1552       }
  1553  
  1554       return  dicomView er;
  1555   } (dicomVi ewer));
  1556   // Configu re all the  endpoints  of dashbo ard
  1557   var LOG_UR L = BASE_U RL + BASE_ LOG_URL +  "settings? Applicatio n=";
  1558   var LOG_FI LE_URL = B ASE_URL +  BASE_LOG_U RL + "file s?Applicat ion=";
  1559   var FILE_L IST_URL =  BASE_URL +  BASE_LOG_ URL + "eve nts?Applic ation=";
  1560   var HEADER S_TITLE_UR L = BASE_U RL + "dash /testdata/ " + TEST_D ATA;
  1561   var DASHBO RAD_STATUS _URL = BAS E_URL + "s tatus";
  1562  
  1563   var lastAp pliedLogLe vel;
  1564   var lastAp pliedRende rLogLevel;
  1565   var pageSi ze = 12;
  1566   var startI ndex = 0;
  1567   var lastSe lectedView erFileName ;
  1568   var lastSe lectedRend erFileName ;
  1569   var curren tSelectedF ileName;
  1570   var curren tSelectedP ageIndex =  0;
  1571   var curren tSelectedT imeStamp;
  1572   var prefer enceType =  ["cine",  "ecg", "an notation",  "display" , "copyatt ributes"," log"];
  1573     
  1574     $(docume nt).ready( function ( ) {
  1575         $('# dashboard- viewer-log -sidebar') .on('click ', functio n () {
  1576              $('#sideba r').toggle Class('act ive');
  1577              if ($(this )[0].class Name === ' navbar-btn  dashboard -log-sideb arCollapse ') {
  1578                  $('#da shboard-vi ewer-log-l eft-panel' ).hide();
  1579                  $('#da shboard-vi ewer-log-r ight-panel ').show();
  1580              } else {
  1581                     $(' #dashboard -viewer-lo g-left-pan el').show( );
  1582                     $(' #dashboard -viewer-lo g-right-pa nel').hide ();
  1583              }
  1584              $(this).to ggleClass( 'active');
  1585         });
  1586         
  1587       $('#da shboard-re nder-log-s idebar').o n('click',  function  () {
  1588              $('#sideba r1').toggl eClass('ac tive');
  1589              if ($(this )[0].class Name === ' navbar-btn  dashboard -log-sideb arCollapse ') {
  1590                  $('#da shboard-re nder-log-l eft-panel' ).hide();
  1591                  $('#da shboard-re nder-log-r ight-panel ').show();
  1592              } else {
  1593                  $('#da shboard-re nder-log-l eft-panel' ).show();
  1594                  $('#da shboard-re nder-log-r ight-panel ').hide();
  1595              }
  1596              $(this).to ggleClass( 'active');
  1597        });
  1598         
  1599          $(' #dashboard -annotatio n-sidebar' ).on('clic k', functi on () {
  1600              $('#sideba r2').toggl eClass('ac tive');
  1601              if ($(this )[0].class Name === ' navbar-btn  dashboard -log-sideb arCollapse ') {
  1602                  $('#da shboard-an notation-l eft-panel' ).hide();
  1603                  $('#da shboard-an notation-r ight-panel ').show();
  1604              } else {
  1605                  $('#da shboard-an notation-l eft-panel' ).show();
  1606                  $('#da shboard-an notation-r ight-panel ').hide();
  1607              }
  1608              $(this).to ggleClass( 'active');
  1609         });
  1610  
  1611         if(w indow.loca tion.searc h.indexOf( 'studydeta ils') > 0)  {
  1612              var newURl  = BASE_UR L + window .location. search;
  1613              console.lo g("WINDOW  LOCATION :  " + windo w.location .search );
  1614              var validU RL = newUR l.replace( "/?", "/") ;
  1615              console.lo g("My New  URL : " +  validURL);
  1616              launchDeta ilURL(vali dURL);
  1617         } el se {
  1618              console.lo g("Read ba se URL { B ase url }  : " + BASE _URL);
  1619              loadHeader sTitle();
  1620              $("#header SelectBox" ).change(f unction ()  {
  1621                  applyH eaderTitle ($("#heade rSelectBox  option:se lected" ). val());
  1622              });
  1623       }
  1624         
  1625         // T ab setting s
  1626         $('a [data-togg le="tab"]' ).on('show n.bs.tab',  function  (e) {
  1627              var target  = e.targe t.text;
  1628              if (target  == "Confi guration")  {
  1629                  displa yAnnotatio nPreferenc es();
  1630              }
  1631         });
  1632  
  1633         $('# cineTab'). on('change ', functio n() {
  1634              dicomViewe r.systemPr eferences. isDirtyChe ck("cine") ;
  1635         });
  1636  
  1637         $('# ecgTab').o n('change' , function () {
  1638              dicomViewe r.systemPr eferences. isDirtyChe ck("ecg");
  1639         });
  1640  
  1641         $('# copyAttrTa b').on('ch ange', fun ction() {
  1642              dicomViewe r.systemPr eferences. isDirtyChe ck("copyat tributes") ;
  1643         });
  1644  
  1645         $('# annotation Tab').on(' change', f unction()  {
  1646              dicomViewe r.systemPr eferences. isDirtyChe ck("annota tion");
  1647         });
  1648  
  1649         $('# logTab').o n('change' , function () {
  1650              dicomViewe r.systemPr eferences. isDirtyChe ck("log");
  1651         });
  1652  
  1653          $(' #timepicke r1').timep icker();
  1654          $(' #timepicke r2').timep icker();
  1655    });
  1656  
  1657   /**
  1658    * Load da shboard lo gin page w ith userna me and pas sword    
  1659    **/
  1660   /*function  doDashboa rLogin()
  1661   {
  1662     
  1663       var us ername = $ ('#usernam e').val();
  1664       var pa ssword = $ ('#passwor d').val();
  1665       
  1666       if(!is NullOrUnde fined(user name) && ! isNullOrUn defined(pa ssword) &&  username  != "" && p assword !=  "" )
  1667       {
  1668             if(usernam e == " AI " && passw ord == " AI ")
  1669           {
  1670                showDash boardHome( );
  1671                $('#dash board-home ').show();          
  1672           }
  1673           el se
  1674           {
  1675               alert("In valid user name and p assword. P lease try  again");
  1676               $('#usern ame').val( '');
  1677               $('#passw ord').val( '');
  1678           }    
  1679       }
  1680       else
  1681       {
  1682           al ert("Inval id usernam e and pass word. Plea se try aga in");
  1683       }
  1684       
  1685       
  1686       
  1687       $.ajax ({
  1688             url: "http ://localho st: PORT /api/Emps_ API_/2",
  1689           ty pe: "GET",
  1690           ca che: false ,
  1691           co ntentType:  "applicat ion/json",
  1692           da taType: "j son",
  1693           he aders: { ' Authorizat ion': 'Bas ic ' + bto a(username  + ':' + p assword) }
  1694       }).don e(function  (data) {
  1695           if (data == t rue)
  1696           {
  1697                hideAndS howTopMenu ();
  1698                $('#dash board-home ').show();                  
  1699           }
  1700           el se
  1701           {
  1702                hideAndS howTopMenu ();
  1703                $('#dash board-logi n').show() ;        
  1704           }
  1705       }).err or(functio n (xhr, te xtStatus,  errorThrow n) {
  1706           al ert("Err "  + textSta tus + "    " + errorT hrown);
  1707       });
  1708   }
  1709   */
  1710  
  1711   /**
  1712    * Load da shboard ho me page 
  1713    **/
  1714   function s howDashboa rdHome()
  1715   {
  1716       hideAn dShowTopMe nu();
  1717       $('#da shboard-ho me').show( );
  1718       $('#da shboard-to pmenu-logi n').show() ;
  1719   }
  1720  
  1721  
  1722   /**
  1723    * Load da shboard lo g page whi le clickin g on dashb oard logs  image
  1724    **/
  1725   function s howDashboa rdLogs()
  1726   {
  1727       hideAn dShowTopMe nu();
  1728       $('#da shboard-to pmenu-logs -home').sh ow();
  1729       $('#da hsboard-to pmenu-home -nav').sho w();
  1730       $('#da shboard-lo g-home').s how();  
  1731       dashbo ardDisplay ViewerLogL evel();
  1732       dashbo ardDisplay RenderLogL evel();
  1733   }
  1734  
  1735   /**
  1736    * Load da shboard vi ewer log p age while  clicking o n dashboar d logs ima ge
  1737    **/
  1738   function d ashboardDi splayViewe rLogLevel( )
  1739   {
  1740       $.ajax ({
  1741           ty pe: 'GET',
  1742           ur l: LOG_URL  + "VIEWER ",
  1743           da taType: 'j son',
  1744           as ync : true ,
  1745           su ccess: fun ction(data )
  1746           {
  1747                console. log("Dashb oard Log L evel Viewe r Url : "  +  LOG_URL  + "VIEWER ");
  1748                if(!isNu llOrUndefi ned(data))
  1749                {
  1750                    $('# dashboard- viewer-sel ect-option ').val(dat a.logLevel );
  1751                    last AppliedLog Level = $( "#dashboar d-viewer-s elect-opti on option: selected"  ).val();
  1752                    $('# dashboard- viewer-app ly-btn').a ddClass('d isabled');
  1753                    dash boardDispl ayViewerLo gFiles();
  1754                }
  1755           },
  1756           er ror: funct ion(XMLHtt pRequest,  textStatus , errorThr own) {
  1757                console. log("The a jax error  occurred :  " + textS tatus);
  1758           }} );
  1759   }
  1760  
  1761   /**
  1762    * Load da shboard re nder log f iles page  while clic king on da shboard lo gs image
  1763    **/
  1764   function d ashboardDi splayRende rLogLevel( ) {
  1765       $.ajax ({
  1766       type:  'GET',
  1767       url: L OG_URL + " RENDER",
  1768       dataTy pe: 'json' ,
  1769       async  : true,
  1770       succes s: functio n(data)
  1771       {
  1772           co nsole.log( "Dashboard  Log Level  render Ur l : " +  L OG_URL + " RENDER");
  1773           if (!isNullOr Undefined( data))
  1774           {
  1775                $('#dash board-rend er-select- option').v al(data.lo gLevel);
  1776                lastAppl iedRenderL ogLevel =  $("#dashbo ard-render -select-op tion optio n:selected " ).val();
  1777                $('#dash board-rend er-apply-b tn').addCl ass('disab led');
  1778                dashboar dDisplayRe nderLogFil es();
  1779           }
  1780       },
  1781       error:  function( XMLHttpReq uest, text Status, er rorThrown)  {
  1782           co nsole.log( "The ajax  error occu rred : " +  textStatu s);
  1783       }});
  1784   }
  1785  
  1786   /**
  1787    * Load da shboard vi ewer log f iles page  while clic king on da shboard lo gs image
  1788    **/
  1789   function d ashboardDi splayViewe rLogFiles( )
  1790   {
  1791       var d  = new Date ();
  1792       var n  = d.getMil liseconds( );
  1793       var vi werCacheUr l = LOG_FI LE_URL + " VIEWER&_ca cheBust="+ n;
  1794       $.ajax ({
  1795           ty pe: 'GET',
  1796           ur l: viwerCa cheUrl,
  1797           da taType: 'j son',
  1798           as ync : true ,
  1799           su ccess: fun ction(data )
  1800           {
  1801                console. log("Dashb oard Log L evel Viewe r Url : "  +  LOG_FIL E_URL + "V IEWER");
  1802                if(!isNu llOrUndefi ned(data))
  1803                {
  1804                    var  fileListIn formation  = "";
  1805                    var  sliceFileN ame = "";
  1806                    if(! isNullOrUn defined(da ta.logFile Items) &&  data.logFi leItems.le ngth > 0)
  1807                    {
  1808                         showDashbo ardViewerA ndRenderLo gFile(data .logFileIt ems[0].fil eName, dat a.applicat ion, data. logFileIte ms[0].time Stamp, sta rtIndex);
  1809                         $.each(dat a.logFileI tems, func tion( inde x, colData  ){
  1810                             sliceF ileName =  JSON.strin gify(colDa ta.fileNam e);
  1811                             fileLi stInformat ion += '<t r><td><a h ref="#" on click="sho wDashboard ViewerAndR enderLogFi le(\''+ sl iceFileNam e.slice(1,  -1) +'\',  \''+ data .applicati on +'\', \ ''+ colDat a.timeStam p +'\', '+  startInde x +')">'+  colData.fi leName + ' ('+ colDat a.timeStam p +')</a>< /td><tr>';  
  1812                         });
  1813                    }
  1814                }
  1815                $('#dash board-view er-list-fi les').html ('');
  1816                $('#dash board-view er-list-fi les').appe nd(fileLis tInformati on);
  1817           },
  1818           er ror: funct ion(XMLHtt pRequest,  textStatus , errorThr own) {
  1819                console. log("The a jax error  occurred :  " + textS tatus);
  1820           }} );
  1821   }
  1822  
  1823   /**
  1824    * Load da shboard re nder log f iles page  while clic king on da shboard lo gs image
  1825    **/
  1826   function d ashboardDi splayRende rLogFiles(
  1827   {
  1828       var d  = new Date ();
  1829       var n  = d.getMil liseconds( );
  1830       var re nderCached Url = LOG_ FILE_URL +  "RENDER&_ cacheBust= "+n;
  1831       $.ajax ({
  1832       type:  'GET',
  1833       url: r enderCache dUrl,
  1834       dataTy pe: 'json' ,
  1835       async  : true,
  1836       succes s: functio n(data)
  1837       {
  1838           co nsole.log( "Dashboard  Log Level  Render Ur l : " +  L OG_FILE_UR L + "RENDE R");
  1839           if (!isNullOr Undefined( data))
  1840           {
  1841                var file ListInform ation = "" ;
  1842                var slic eFileName  = "";
  1843                if(!isNu llOrUndefi ned(data.l ogFileItem s) && data .logFileIt ems.length  > 0)
  1844                {
  1845                    show DashboardV iewerAndRe nderLogFil e(data.log FileItems[ 0].fileNam e, data.ap plication,  data.logF ileItems[0 ].timeStam p, startIn dex);
  1846                    $.ea ch(data.lo gFileItems , function ( index, c olData ){
  1847                         sliceFileN ame = JSON .stringify (colData.f ileName);
  1848                         fileListIn formation  += '<tr><t d><a href= "#" onclic k="showDas hboardView erAndRende rLogFile(\ ''+ sliceF ileName.sl ice(1, -1)  +'\', \'' + data.app lication + '\', \''+  colData.ti meStamp +' \', '+ sta rtIndex +' )">'+ colD ata.fileNa me + '('+  colData.ti meStamp +' )</a></td> <tr>'; 
  1849                    });
  1850                }
  1851           }
  1852           $( '#dashboar d-render-l ist-files' ).html('') ;
  1853           $( '#dashboar d-render-l ist-files' ).append(f ileListInf ormation);
  1854       },
  1855       error:  function( XMLHttpReq uest, text Status, er rorThrown)  {
  1856           co nsole.log( "The ajax  error occu rred : " +  textStatu s);
  1857       }});
  1858   }
  1859  
  1860   /**
  1861    * Load da shboard vi ewer and r ender log  content ba sed on 
  1862    * clickin g log file s from lef t panel
  1863    **/
  1864   function s howDashboa rdViewerAn dRenderLog File(fileN ame, appli cation, ti meStamp, p ageIndex) 
  1865   {
  1866       curren tSelectedF ileName =  fileName;
  1867       curren tSelectedP ageIndex =  pageIndex ;
  1868       curren tSelectedT imeStamp =  timeStamp ;
  1869       pageIn dex = (pag eIndex < 0  ? 0 : pag eIndex);
  1870        var d  = new Dat e();
  1871        var n  = d.getMi lliseconds ();
  1872        var v iewerRende rCachedUrl  = FILE_LI ST_URL + a pplication  + "&LogFi leName=" +  fileName  + "&PageSi ze="+ page Size +"&Pa geIndex="  + pageInde x + "&_cac heBust="+n ;
  1873       
  1874       if(app lication = == 'RENDER ')
  1875       {
  1876          $(' #dashboard -render-lo g-header-t ext').html (fileName  + "  ( "+  timeStamp  + " )");
  1877           if (currentSe lectedFile Name != la stSelected RenderFile Name)
  1878           {
  1879               $('#dashb oard-rende r-log-head er-text'). html('');
  1880               $('#dashb oard-rende r-log-head er-text'). html(fileN ame + "  (  "+ timeSt amp + " )" );        
  1881           }
  1882          las tSelectedR enderFileN ame = file Name;
  1883          
  1884          $.a jax({
  1885           ty pe: 'GET',
  1886           ur l: viewerR enderCache dUrl,
  1887           da taType: 'j son',
  1888           as ync : true ,
  1889           su ccess: fun ction(data )
  1890           {
  1891                console. log("Dashb oard Log L evel Rende r Url : "  +  FILE_LI ST_URL + a pplication  + "&LogFi leName=" +  fileName  + "&PageSi ze="+ page Size +"&Pa geIndex="  + pageInde x);
  1892                if(!isNu llOrUndefi ned(data))
  1893                {
  1894                    var  fileListIn formation  = "";
  1895                    if(! isNullOrUn defined(da ta.logEven tItems) &&  data.logE ventItems. length > 0 )
  1896                    {
  1897                         $('#dashbo ard-render -logs-tabl e-body').h tml('');
  1898                         $.each(dat a.logEvent Items, fun ction( ind ex, colDat a ){
  1899                             fileLi stInformat ion += '<t r><td>'+ c olData.tim eStamp +'< /td><td>'+  setLogLev elLabel(co lData.leve l) +'</td> <td>'+ col Data.messa ge +'</td> <td class= "abbreviat ion">'+ co lData.para meters +'< /td><tr>';   
  1900                         });   
  1901                    }
  1902                    if(d ata.more = == true)
  1903                    {
  1904                         //var inde xVal = par seInt(page Index - 1) ;
  1905                         $('#dashbo ard-render -logs-tabl e-pagenati on').html( '');
  1906                         $('#dashbo ard-render -logs-tabl e-pagenati on').html( '<button c lass="btn  btn-primar y btn-sm d isabled" t ype="butto n" id="das hboard-ren der-log-pr evious-btn " onclick= "showDashb oardViewer AndRenderL ogFile(\'' + fileName  +'\', \'' + applicat ion +'\',  \''+ timeS tamp +'\', '+ parseIn t(pageInde x - 1) +') ">Previous </button>& nbsp;&nbsp <button cl ass="btn b tn-primary  btn-sm" i d="dashboa rd-render- log-next-b tn" type=" button" on click="sho wDashboard ViewerAndR enderLogFi le(\''+ fi leName +'\ ', \''+ ap plication  +'\', \''+  timeStamp  +'\','+ p arseInt(pa geIndex +  1) +')">Ne xt</button >');
  1907                        
  1908                         if(pageInd ex != 0)
  1909                         {
  1910                             $('#da shboard-re nder-log-p revious-bt n').remove Class('dis abled');
  1911                         }
  1912                    }els e
  1913                    {
  1914                         //$('#disp layRenderP agination' ).html('') ;
  1915                         if(pageInd ex == 0)
  1916                         {
  1917                             $('#da shboard-re nder-logs- table-page nation').h tml('');
  1918                         }else{
  1919                             $('#da shboard-re nder-log-p revious-bt n').remove Class('dis abled');
  1920                             $('#da shboard-re nder-log-n ext-btn'). addClass(' disabled') ;
  1921                         }
  1922                    }
  1923                }
  1924                $('#dash board-rend er-logs-ta ble-body') .append(fi leListInfo rmation);
  1925           },
  1926           er ror: funct ion(XMLHtt pRequest,  textStatus , errorThr own) {
  1927                console. log("The a jax error  occurred :  " + textS tatus);
  1928           }} );      
  1929       } 
  1930       else i f(applicat ion === 'V IEWER')
  1931       {
  1932           $( '#dashboar d-viewer-l og-header- text').htm l(fileName  + "  ( "+  timeStamp  + " )");    
  1933           if (currentSe lectedFile Name != la stSelected ViewerFile Name)
  1934           {
  1935               $('#dashb oard-viewe r-log-head er-text'). html('');
  1936               $('#dashb oard-viewe r-log-head er-text'). html(fileN ame + "  (  "+ timeSt amp + " )" );     
  1937           }     
  1938          las tSelectedV iewerFileN ame = file Name;
  1939          $.a jax({
  1940           ty pe: 'GET',
  1941           ur l: viewerR enderCache dUrl,
  1942           da taType: 'j son',
  1943           as ync : true ,
  1944           su ccess: fun ction(data )
  1945           {
  1946                console. log("Dashb oard Log L evel viewe r Url : "  +  FILE_LI ST_URL + a pplication  + "&LogFi leName=" +  fileName  + "&PageSi ze="+ page Size +"&Pa geIndex="  + pageInde x);
  1947                if(!isNu llOrUndefi ned(data))
  1948                {
  1949                    var  fileListIn formation  = "";
  1950                    if(! isNullOrUn defined(da ta.logEven tItems) &&  data.logE ventItems. length > 0 )
  1951                    {
  1952                       $ ('#dashboa rd-viewer- logs-table -body').ht ml('');
  1953                       $ .each(data .logEventI tems, func tion( inde x, colData  ){
  1954                             fileLi stInformat ion += '<t r><td>'+ c olData.tim eStamp +'< /td><td>'+  setLogLev elLabel(co lData.leve l) +'</td> <td>'+ col Data.messa ge +'</td> <td class= "abbreviat ion">'+ co lData.para meters +'< /td><tr>';   
  1955                         });
  1956                    }
  1957                   
  1958                    if(d ata.more = == true)
  1959                    {
  1960                         $('#dashbo ard-viewer -logs-tabl e-pagenati on').html( '');
  1961                         $('#dashbo ard-viewer -logs-tabl e-pagenati on').html( '<button i d="dashboa rdPrevious LogButton"  class="bt n btn-prim ary btn-sm  disabled"  type="but ton" oncli ck="showDa shboardVie werAndRend erLogFile( \''+ fileN ame +'\',  \''+ appli cation +'\ ', \''+ ti meStamp +' \','+ pars eInt(pageI ndex - 1)+ ')">Previo us</button >&nbsp;&nb sp<button   class="bt n btn-prim ary btn-sm " type="bu tton" id=" dashboardN extLogButt on" onclic k="showDas hboardView erAndRende rLogFile(\ ''+ fileNa me +'\', \ ''+ applic ation +'\' , \''+ tim eStamp +'\ ','+ parse Int(pageIn dex + 1) + ')">Next</ button>');
  1962                     
  1963                         if(pageInd ex == 0)
  1964                         {
  1965                             $('#da shboardPre viousLogBu tton').add Class('dis abled');
  1966                         }
  1967                         else{
  1968                             $('#da shboardPre viousLogBu tton').rem oveClass(' disabled') ;
  1969                         }
  1970                    }
  1971                    else
  1972                    {
  1973                         if(pageInd ex == 0)
  1974                         {
  1975                             /*$('# displayPag ination'). html('');* /
  1976                             $('#da shboardPre viousLogBu tton').hid e();
  1977                              $('#d ashboardNe xtLogButto n').hide() ;
  1978                         }
  1979                         else
  1980                         {
  1981                             $('#da shboardNex tLogButton ').addClas s('disable d');
  1982                             $('#da shboardPre viousLogBu tton').rem oveClass(' disabled')
  1983                         }
  1984                    }
  1985                }
  1986                $('#dash board-view er-logs-ta ble-body') .append(fi leListInfo rmation);
  1987           },
  1988           er ror: funct ion(XMLHtt pRequest,  textStatus , errorThr own) {
  1989                console. log("The a jax error  occurred :  " + textS tatus);
  1990           }} );       
  1991       }
  1992   }
  1993  
  1994  
  1995   function d ashboardRe freshLogFi le(applica tion)
  1996   {
  1997       curren tSelectedP ageIndex =  (currentS electedPag eIndex < 0  ? 0 : cur rentSelect edPageInde x);
  1998        var d  = new Dat e();
  1999        var n  = d.getMi lliseconds ();
  2000        var v iewerRende rCachedUrl  = FILE_LI ST_URL + a pplication  + "&LogFi leName=" +  currentSe lectedFile Name + "&P ageSize="+  pageSize  +"&PageInd ex=" + cur rentSelect edPageInde x + "&_cac heBust="+n ;
  2001       if(app lication = == 'RENDER ')
  2002       {
  2003           $( '#dashboar d-render-l og-header- text').htm l(currentS electedFil eName + "   ( "+ curr entSelecte dTimeStamp  + " )");
  2004           if (currentSe lectedFile Name != la stSelected RenderFile Name)
  2005           {
  2006              $('#dashbo ard-render -log-heade r-text').h tml('');
  2007              $('#dashbo ard-render -log-heade r-text').h tml(curren tSelectedF ileName +  "  ( "+ cu rrentSelec tedTimeSta mp + " )") ;                          
  2008           }
  2009          las tSelectedR enderFileN ame = curr entSelecte dFileName;
  2010          $.a jax({
  2011           ty pe: 'GET',
  2012           ur l: viewerR enderCache dUrl,
  2013           da taType: 'j son',
  2014           as ync : true ,
  2015           su ccess: fun ction(data )
  2016           {
  2017                console. log("Dashb oard Log L evel Rende r Url : "  +  FILE_LI ST_URL + a pplication  + "&LogFi leName=" +  currentSe lectedFile Name + "&P ageSize="+  pageSize  +"&PageInd ex=" + cur rentSelect edPageInde x);
  2018                if(!isNu llOrUndefi ned(data))
  2019                {
  2020                    var  fileListIn formation  = "";
  2021                    if(! isNullOrUn defined(da ta.logEven tItems) &&  data.logE ventItems. length > 0 )
  2022                    {
  2023                         $('#dashbo ard-render -logs-tabl e-body').h tml('');
  2024                         $.each(dat a.logEvent Items, fun ction( ind ex, colDat a ){
  2025                             fileLi stInformat ion += '<t r><td>'+ c olData.tim eStamp +'< /td><td>'+  setLogLev elLabel(co lData.leve l) +'</td> <td>'+ col Data.messa ge +'</td> <td class= "abbreviat ion">'+ co lData.para meters +'< /td><tr>';   
  2026                         });   
  2027                    }
  2028                    if(d ata.more = == true)
  2029                    {
  2030                         //var inde xVal = par seInt(page Index - 1) ;
  2031                         $('#dashbo ard-render -logs-tabl e-pagenati on').html( '');
  2032                         $('#dashbo ard-render -logs-tabl e-pagenati on').html( '<button c lass="btn  btn-primar y btn-sm d isabled" t ype="butto n" id="das hboard-ren der-previo us-btn" on click="sho wDashboard ViewerAndR enderLogFi le(\''+ cu rrentSelec tedFileNam e +'\', \' '+ applica tion +'\',  \''+ curr entSelecte dTimeStamp  +'\','+ p arseInt(cu rrentSelec tedPageInd ex - 1) +' )">Previou s</button> &nbsp;&nbs p<button c lass="btn  btn-primar y btn-sm"  id="dashbo ard-render -next-btn"  type="but ton" oncli ck="showDa shboardVie werAndRend erLogFile( \''+ curre ntSelected FileName + '\', \''+  applicatio n +'\', \' '+ current SelectedTi meStamp +' \','+ pars eInt(curre ntSelected PageIndex  + 1) +')"> Next</butt on>');
  2033                        
  2034                         if(current SelectedPa geIndex !=  0)
  2035                         {
  2036                             $('#da shboard-re nder-previ ous-btn'). removeClas s('disable d');
  2037                         }
  2038                    }els e
  2039                    {
  2040                         //$('#disp layRenderP agination' ).html('') ;
  2041                         if(current SelectedPa geIndex ==  0)
  2042                         {
  2043                             $('#da shboard-re nder-logs- table-page nation').h tml('');
  2044                         }else{
  2045                             $('#da shboard-re nder-previ ous-btn'). removeClas s('disable d');
  2046                             $('#da shboard-re nder-next- btn').addC lass('disa bled');
  2047                         }
  2048                    }
  2049                }
  2050                $('#dash board-rend er-logs-ta ble-body') .append(fi leListInfo rmation);
  2051           },
  2052           er ror: funct ion(XMLHtt pRequest,  textStatus , errorThr own) {
  2053                console. log("The a jax error  occurred :  " + textS tatus);
  2054           }} );  
  2055       }
  2056       else i f(applicat ion === 'V IEWER')
  2057       {
  2058          $(' #dashboard -viewer-lo g-header-t ext').html (currentSe lectedFile Name + "   ( "+ curre ntSelected TimeStamp  + " )");
  2059           if (currentSe lectedFile Name != la stSelected ViewerFile Name)
  2060           {
  2061              $('#dashbo ard-viewer -log-heade r-text').h tml('');
  2062              $('#dashbo ard-viewer -log-heade r-text').h tml(curren tSelectedF ileName +  "  ( "+ cu rrentSelec tedTimeSta mp + " )") ;               
  2063           }
  2064          las tSelectedV iewerFileN ame = curr entSelecte dFileName;
  2065          $.a jax({
  2066           ty pe: 'GET',
  2067           ur l: viewerR enderCache dUrl,
  2068           da taType: 'j son',
  2069           as ync : true ,
  2070           su ccess: fun ction(data )
  2071           {
  2072                console. log("Dashb oard Log L evel Viewe r Url : "  +  FILE_LI ST_URL + a pplication  + "&LogFi leName=" +  currentSe lectedFile Name + "&P ageSize="+  pageSize  +"&PageInd ex=" + cur rentSelect edPageInde x);
  2073                if(!isNu llOrUndefi ned(data))
  2074                {
  2075                    var  fileListIn formation  = "";
  2076                    if(! isNullOrUn defined(da ta.logEven tItems) &&  data.logE ventItems. length > 0 )
  2077                    {
  2078                       $ ('#dashboa rd-viewer- logs-table -body').ht ml('');
  2079                       $ .each(data .logEventI tems, func tion( inde x, colData  ){
  2080                             fileLi stInformat ion += '<t r><td>'+ c olData.tim eStamp +'< /td><td>'+  setLogLev elLabel(co lData.leve l) +'</td> <td>'+ col Data.messa ge +'</td> <td class= "abbreviat ion">'+ co lData.para meters +'< /td><tr>';   
  2081                         });
  2082                    }
  2083                   
  2084                    if(d ata.more = == true)
  2085                    {
  2086                         $('#dashbo ard-viewer -logs-tabl e-pagenati on').html( '');
  2087                         $('#dashbo ard-viewer -logs-tabl e-pagenati on').html( '<button i d="dashboa rd-viewer- prev-btn"  class="btn  btn-prima ry btn-sm  disabled"  type="butt on" onclic k="showDas hboardView erAndRende rLogFile(\ ''+ curren tSelectedF ileName +' \', \''+ a pplication  +'\', \'' + currentS electedTim eStamp +'\ ','+ parse Int(curren tSelectedP ageIndex -  1)+')">Pr evious</bu tton>&nbsp ;&nbsp<but ton  class ="btn btn- primary bt n-sm" type ="button"  id="dashbo ard-viewer -next-btn"  onclick=" showDashbo ardViewerA ndRenderLo gFile(\''+  currentSe lectedFile Name +'\',  \''+ appl ication +' \', \''+ c urrentSele ctedTimeSt amp +'\',' + parseInt (currentSe lectedPage Index + 1)  +')">Next </button>' );
  2088                     
  2089                         if(current SelectedPa geIndex ==  0)
  2090                         {
  2091                             $('#da shboard-vi ewer-prev- btn').addC lass('disa bled');
  2092                         }
  2093                         else{
  2094                             $('#da shboard-vi ewer-prev- btn').remo veClass('d isabled');
  2095                         }
  2096                    }
  2097                    else
  2098                    {
  2099                         if(current SelectedPa geIndex ==  0)
  2100                         {
  2101                             /*$('# displayPag ination'). html('');* /
  2102                             $('#da shboard-vi ewer-prev- btn').hide ();
  2103                              $('#d ashboard-v iewer-next -btn').hid e();
  2104                         }
  2105                         else
  2106                         {
  2107                             $('#da shboard-vi ewer-next- btn').addC lass('disa bled');
  2108                             $('#da shboard-vi ewer-prev- btn').remo veClass('d isabled');  
  2109                         }
  2110                    }
  2111                }
  2112                $('#dash board-view er-logs-ta ble-body') .append(fi leListInfo rmation);
  2113           },
  2114           er ror: funct ion(XMLHtt pRequest,  textStatus , errorThr own) {
  2115                console. log("The a jax error  occurred :  " + textS tatus);
  2116           }} );  
  2117       }
  2118   }
  2119  
  2120   /**
  2121    * set das hboard log  level act ion by pas sing logle vel while  clicking o n apply bu tton
  2122    **/
  2123   function d oDashboard ViewerAndR enderApply LogLevel(t ype) 
  2124   {
  2125       if (ty pe == "VIE WER") 
  2126       {
  2127           da shboardSet LogLevel(" VIEWER", $ ("#dashboa rd-viewer- select-opt ion option :selected" ).val());
  2128       }
  2129       else 
  2130       {
  2131           da shboardSet LogLevel(" RENDER", $ ("#dashboa rd-render- select-opt ion option :selected" ).val());
  2132       }
  2133   }
  2134  
  2135   /**
  2136    * set das hboard log  level act ion by pas sing logle vel while  clicking o n apply bu tton
  2137    **/
  2138   function d ashboardSe tLogLevel( type, logl evel) {
  2139       $.ajax ({
  2140       type:  'POST',
  2141       url: L OG_URL + t ype + "&Lo gLevel=" +  loglevel,
  2142       async:  true,
  2143       cache:  false,
  2144       succes s: functio n(data)
  2145       {
  2146           co nsole.log( "Dashboard  Log Level  Url : " +   LOG_URL  + type);
  2147           if  (type ==  "VIEWER")  {
  2148                $('#dash board-view er-select- option').v al(logleve l);
  2149                lastAppl iedLogLeve l = loglev el;
  2150                dashboar dDisplayVi ewerLogFil es();
  2151           }  else {
  2152                $('#dash board-rend er-select- option').v al(logleve l);
  2153                lastAppl iedRenderL ogLevel =  loglevel;
  2154                dashboar dDisplayRe nderLogFil es();
  2155           }
  2156       },
  2157       error:  function( XMLHttpReq uest, text Status, er rorThrown)  {
  2158           co nsole.log( "The ajax  error occu rred : " +  textStatu s);
  2159       }});
  2160   }
  2161  
  2162   /**
  2163    * set das hboard log  level act ion by pas sing logle vel
  2164    **/
  2165   function s etLogLevel Label(logL evel)
  2166   {
  2167       var lo gLevelLabe l;
  2168       if(log Level ===  'DEBUG')
  2169       {
  2170           lo gLevelLabe l = "<span  class='la bel label- primary'>"  + logLeve l + "</spa n";
  2171       }
  2172       else i f(logLevel  === 'INFO ')
  2173       {
  2174           lo gLevelLabe l = "<span  class='la bel label- success'>"  + logLeve l + "</spa n";
  2175       }
  2176       else i f(logLevel  === 'WARN ')
  2177       {  
  2178           lo gLevelLabe l = "<span  class='la bel label- warning'>"  + logLeve l + "</spa n";
  2179       }
  2180       else i f(logLevel  === 'ERRO R')
  2181       { 
  2182           lo gLevelLabe l = "<span  class='la bel label- danger'>"  + logLevel  + "</span ";
  2183       }
  2184       else i f(logLevel  === 'TRAC E')
  2185       {
  2186           lo gLevelLabe l = "<span  class='la bel label- info'>" +  logLevel +  "</span";
  2187       }
  2188       return  logLevelL abel;
  2189   }
  2190  
  2191   /**
  2192    * load da shboard vi ewer log w ith json f ormat
  2193    **/
  2194   $(document ).on("clic k", "#dash board-view er-log-tab le tbody t r", functi on(e) {
  2195       var pa ram = $(th is).find(" .abbreviat ion").html ();   
  2196       if(!is NullOrUnde fined(para m) &&  par am !== "")
  2197       {
  2198           $( "#dashboar d-viewer-l og-json-fo rmat").JSO NView(JSON .stringify (getJson(p aram)));
  2199       }
  2200       else
  2201       {
  2202           co nsole.log( 'The param eter conta ins empty  string');
  2203           $( "#dashboar d-viewer-l og-json-fo rmat").htm l("The par ameter con tains empt y string") ;
  2204       }
  2205   });
  2206  
  2207   /**
  2208    * load da shboard re nder log w ith json f ormat
  2209    **/
  2210   $(document ).on("clic k", "#dash board-rend er-log-tab le tr", fu nction(e)  {
  2211       var pa ram = $(th is).find(" .abbreviat ion").html ();  
  2212       if(!is NullOrUnde fined(para m) &&  par am !== "")
  2213       {
  2214           $( "#dashboar d-render-l og-json-fo rmat").JSO NView(JSON .stringify (getJson(p aram)));
  2215       }
  2216       else
  2217       {
  2218           co nsole.log( 'The param eter conta ins empty  string');
  2219           $( "#dashboar d-render-l og-json-fo rmat").htm l("The par ameter con tains empt y string") ;
  2220       }
  2221   });
  2222  
  2223  
  2224   function r emoveAllLo gFiles(typ e)
  2225   {
  2226        $("#l ogViewerAn dRenderMod al").modal (); 
  2227       if(typ e == "VIEW ER")
  2228       {
  2229          $(' #btnRender Log').hide ();
  2230          $(' #btnViewer Log').show ();
  2231       }
  2232       else
  2233       {
  2234          $(' #btnViewer Log').hide ();
  2235          $(' #btnRender Log').show ();
  2236       } 
  2237   }
  2238    
  2239   function r emoveViewe rLogFile(t ype)
  2240   {
  2241       if(typ e == "VIEW ER")
  2242       {
  2243           $. ajax({
  2244                type: 'D ELETE',
  2245                url: LOG _FILE_URL  + type,
  2246                success:  function( data)
  2247                {
  2248                    $('# logViewerA ndRenderMo dal').moda l('hide');
  2249                     das hboardDisp layViewerL ogFiles();
  2250                }, error : function (XMLHttpRe quest, tex tStatus, e rrorThrown
  2251                {
  2252                    cons ole.log("T he ajax er ror occurr ed : " + t extStatus) ;
  2253                }
  2254           }) ;  
  2255       }
  2256       else
  2257       {
  2258          $.a jax({
  2259                type: 'D ELETE',
  2260                url: LOG _FILE_URL  + type,
  2261                success:  function( data)
  2262                {
  2263                    $('# logViewerA ndRenderMo dal').moda l('hide');
  2264                    dash boardDispl ayRenderLo gFiles();
  2265                }, error : function (XMLHttpRe quest, tex tStatus, e rrorThrown
  2266                {
  2267                    cons ole.log("T he ajax er ror occurr ed : " + t extStatus) ;
  2268                }
  2269           }) ;   
  2270       }
  2271   }
  2272       
  2273   function c learAllLog s(type)
  2274   {
  2275       $("#cl earLogView erAndRende rModal").m odal(); 
  2276       if(typ e == "VIEW ER")
  2277       {
  2278           $( '#btnClear RenderLog' ).hide();
  2279           $( '#btnClear ViewerLog' ).show();
  2280       }
  2281       else
  2282       {
  2283           $( '#btnClear ViewerLog' ).hide();
  2284           $( '#btnClear RenderLog' ).show();
  2285       }   
  2286   }
  2287       
  2288   function c learViewer LogFile(ty pe)
  2289   {
  2290       if(typ e == "VIEW ER")
  2291       {
  2292           $. ajax({
  2293                type: 'D ELETE',
  2294                url: LOG _FILE_URL  + type + " &LogFileNa me=" + las tSelectedV iewerFileN ame,
  2295                success:  function( data)
  2296                {
  2297                    $('# clearLogVi ewerAndRen derModal') .modal('hi de');
  2298                     das hboardDisp layViewerL ogFiles();
  2299                }, error : function (XMLHttpRe quest, tex tStatus, e rrorThrown
  2300                {
  2301                    cons ole.log("T he ajax er ror occurr ed : " + t extStatus) ;
  2302                }
  2303           }) ;  
  2304       }
  2305       else
  2306       {
  2307          $.a jax({
  2308                type: 'D ELETE',
  2309                url: LOG _FILE_URL  + type + " &LogFileNa me=" + las tSelectedR enderFileN ame,
  2310                success:  function( data)
  2311                {
  2312                    $('# clearLogVi ewerAndRen derModal') .modal('hi de');
  2313                    dash boardDispl ayRenderLo gFiles();
  2314                }, error : function (XMLHttpRe quest, tex tStatus, e rrorThrown
  2315                {
  2316                    cons ole.log("T he ajax er ror occurr ed : " + t extStatus) ;
  2317                }
  2318           }) ;   
  2319       }
  2320   }
  2321  
  2322  
  2323   /**
  2324    * Load da shboard se arch page  while clic king on da shboard se arch image
  2325    **/
  2326   function s howDashboa rdSearch()
  2327   {
  2328       hideAn dShowTopMe nu();
  2329       $('#da shboard-to pmenu-sear ch-home'). show();
  2330       $('#da hsboard-to pmenu-home -nav').sho w(); 
  2331       $('#da shboard-se arch-home' ).show();
  2332  
  2333   }
  2334       
  2335   /* 
  2336    * load al l the titl e of the h eaders in  select box  
  2337    */
  2338   function l oadHeaders Title()
  2339   {
  2340       consol e.log("Rea der header  url : " +  HEADERS_T ITLE_URL);
  2341       $.ajax ({
  2342           ty pe: 'GET',
  2343           ur l: HEADERS _TITLE_URL ,
  2344           da taType: 'j son',
  2345           su ccess: fun ction(data )
  2346           {
  2347                if(!isNu llOrUndefi ned(data))
  2348                {
  2349                    cons ole.log("T he length  of the hea der : " +  data.items .length);
  2350                    if(! isNullOrUn defined(da ta.items)  && data.it ems.length  > 0)
  2351                    {
  2352                          $.each(da ta.items,  function(  index, col Data ){
  2353                               $('# headerSele ctBox').ap pend( '<op tion value ="'+ colDa ta.header. name +'">' + colData. title +'</ option>' ) ;
  2354                          });         
  2355                    }
  2356                     app lyHeaderTi tle($("#he aderSelect Box option :selected"  ).val());
  2357                } 
  2358           },  error: fu nction(XML HttpReques t, textSta tus, error Thrown) 
  2359           {
  2360                console. log("The a jax error  occurred :  " + textS tatus);
  2361           }
  2362       });  
  2363   }
  2364  
  2365   /** 
  2366    *  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 
  2367    *  button  and displ ay headers  and body  text 
  2368    */
  2369   function a pplyHeader Title(opti onSelected Val)
  2370   {
  2371       consol e.log("Sel ected Opti on Value :  " + optio nSelectedV al);
  2372       var he aderTitle  = $('#head erSelectBo x option:s elected'). html()
  2373       consol e.log("Hea der title  : " + head erTitle);
  2374       $.ajax ({
  2375           ty pe: 'GET',
  2376           ur l: HEADERS _TITLE_URL ,
  2377           da taType: 'j son',
  2378           su ccess: fun ction(data )
  2379           {
  2380                console. log("Heade r title le ngth : " +  data.item s.length);
  2381                var head erVal = [] ;
  2382                for (i =  0; i < da ta.items.l ength; i++ )
  2383                {
  2384                    var  bashItems  = data.ite ms[i];
  2385                    if(h eaderTitle .trim() ==  bashItems .title)
  2386                    {
  2387                         if(!bashIt ems.type)  {
  2388                             bashIt ems.type =  'STUDYQUE RY';
  2389                         }
  2390  
  2391                                               $('#queryT ype').val( bashItems. type);
  2392                                               if(bashIte ms.type ==  'STUDYQUE RY')
  2393                                               {
  2394                                                       $( '#requestU rl').val(B ASE_URL +  "studyquer y");
  2395                                                       co nsole.log( "Displayin g study qu ery url :  " + BASE_U RL + "stud yquery");
  2396                                               }else if(b ashItems.t ype == 'RO I')
  2397                                               {
  2398                                                       $( '#requestU rl').val(B ASE_URL.re place('vie wer', 'roi /status')) ;
  2399                                                       co nsole.log( "Displayin g roi stat us url : "  + BASE_UR L.replace( 'viewer',  'roi'));                  
  2400                                               }
  2401  
  2402                         if(bashIte ms.header. name == op tionSelect edVal &&   bashItems. header.ite ms.length  > 0 || bas hItems.hea der.name ! = optionSe lectedVal  && bashIte ms.header. items.leng th > 0)
  2403                         {
  2404                             for (v ar i = 0;  i < bashIt ems.header .items.len gth;i++)
  2405                             {
  2406                                 he aderVal.pu sh(bashIte ms.header. items[i].k ey + ":" +  bashItems .header.it ems[i].val ue);
  2407                             }
  2408                             $('#he aderText') .val(heade rVal);
  2409                         }
  2410                         else if(ba shItems.he ader.name  == optionS electedVal  &&  bashI tems.heade r.items.le ngth == 0)
  2411                         {
  2412                             for(va r index=0;  index < d ata.header s.length;  index++)
  2413                             {
  2414                                 if (data.head ers[index] .name == o ptionSelec tedVal)
  2415                                 {
  2416                                      for (var  i = 0; i  < data.hea ders[index ].items.le ngth; i++)
  2417                                      {
  2418                                          head erVal.push (data.head ers[index] .items[i]. key + ":"  + data.hea ders[index ].items[i] .value);
  2419                                          head erVal.push ("\n");         
  2420                                      }
  2421                                 }        
  2422                             }
  2423                             $('#he aderText') .val(heade rVal.join( ' '));
  2424                         }
  2425                         else
  2426                         {
  2427                             consol e.log("The re is no i tem availa ble in thi s header") ;
  2428                         }
  2429                                               $('#bodyTe xt').val(J SON.string ify(bashIt ems.body,  undefined,  4));
  2430                         return ;
  2431                    }
  2432                }
  2433           }
  2434       });
  2435   }
  2436  
  2437   /**
  2438    * 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.
  2439    */
  2440   function f etchStudyI nformation ()
  2441   {
  2442       var re questUrl =  $('#reque stUrl').va l();
  2443       var he aderTextVa l = $("#he aderText") .val();
  2444       var co ntents = $ ('#bodyTex t').val();
  2445           va r queryTyp e = $('#qu eryType'). val();
  2446       
  2447       if(req uestUrl ==  null || r equestUrl= ="")
  2448       {
  2449           al ert("Reque st URL mus t not be n ull");
  2450           $( '#requestU rl').focus ();
  2451       }
  2452       else i f(headerTe xtVal == n ull || hea derTextVal  == "")
  2453       {
  2454           al ert("Heade rs must no t be null" );
  2455           $( '#headerTe xt').focus ();
  2456       }
  2457       else i f(contents  == null | | contents  == "")
  2458       {
  2459           al ert("Body  must not b e null");
  2460           $( '#bodyText ').focus() ;
  2461       }
  2462       else
  2463       {
  2464                    cons ole.log(re questUrl);
  2465           $( "#ajax_loa der").show ();
  2466           va r headerAr r = header TextVal.sp lit('\n');
  2467           va r headers  = {};
  2468           $. each(heade rArr, func tion(index , colData) {
  2469                var head  = colData .split(':' );
  2470                if (head [0] !== ''
  2471                {
  2472                    head ers[head[0 ].trim()]  = head[1]. trim();
  2473                }
  2474           }) ;
  2475           
  2476                    if(q ueryType = = 'STUDYQU ERY')
  2477                    {
  2478                             $.ajax ({
  2479                                      url: req uestUrl,
  2480                                      data: co ntents.tri m(),
  2481                                      headers:  headers,
  2482                                      method:  'POST',
  2483                                      dataType : 'json',
  2484                                      async: t rue,
  2485                                      success:  function( data)
  2486                                      {
  2487                                               // fetch a ll the pat ient and s tudy infor mation and  display i t
  2488                                               if(!isNull OrUndefine d(data.pat ientICN))
  2489                                               {
  2490                                                       $( '#patientI CN').html( "PatientIC N : " + da ta.patient ICN);        
  2491                                               }
  2492  
  2493                         if(!isNull OrUndefine d(data.pat ientDFN))
  2494                                               {
  2495                                                       $( '#patientD FN').html( "PatientDF N : " + da ta.patient DFN);
  2496                                               }
  2497  
  2498                         if(!isNull OrUndefine d(data.sit eNumber))
  2499                                               {
  2500                                                       $( '#siteNumb er').html( "Site Numb er : " + d ata.siteNu mber);
  2501                                               }
  2502  
  2503                         if(!isNull OrUndefine d(data.aut hSiteNumbe r))
  2504                                               {
  2505                                                       $( '#authSite Number').h tml("AuthS iteNumber  : " + data .authSiteN umber);
  2506                                               }
  2507  
  2508                         if(!isNull OrUndefine d(data.use rId))
  2509                                               {
  2510                                                       $( '#userId') .html("Use r ID : " +  data.user Id);
  2511                                               }
  2512  
  2513                         if(!isNull OrUndefine d(data.aut hSiteNumbe r))
  2514                                               {
  2515                                                       $( '#authSite NumberVal' ).val(data .authSiteN umber);
  2516                                               }
  2517  
  2518                         if(data.st udies && d ata.studie s.length >  0 && !isN ullOrUndef ined(data. studies[0] .securityT oken))
  2519                                               {
  2520                                                       $( '#security Token').va l(data.stu dies[0].se curityToke n);
  2521                             consol e.log("Tot al no of s tudies loa ded : " +  data.studi es.length) ;
  2522                                               }
  2523  
  2524                                               //Display  all the st udy inform ation in d ataTAble
  2525  
  2526                                               var studyI nformation  = "";
  2527                         if(!isNull OrUndefine d(data))
  2528                         {
  2529                             if( !i sNullOrUnd efined(dat a.studies)  && data.s tudies.len gth > 0)
  2530                             {
  2531                                 $. each(data. studies, f unction(in dex, dataV al){
  2532                                      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 +
  2533                                          '</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 +
  2534                                          '</t d><td>' +
  2535                                          '<a  class="btn  btn-warni ng btn-sm"  onClick=" viewStudy( \''+ dataV al.viewerU rl +'\', ' + index +' )">View</a >&nbsp;' +
  2536                                          '<a  id="addToS ession_'+  index +'"  class="btn  btn-info  btn-sm add ToSession"  onClick=" addToSessi on(\''+ da taVal.cont extId +'\' , \''+ dat aVal.secur ityToken + '\',\''+ d ataVal.pat ientICN +' \',\''+ da taVal.pati entDFN +'\ ',\''+ dat aVal.siteN umber +'\' , \'' + da ta.authSit eNumber +  '\')" styl e="display : none">Ad d</a>&nbsp ;' +
  2537                                          '<a  href="#" c lass="btn  btn-primar y btn-sm"  onClick="l aunchManag eURL(\''+  dataVal.ma nageUrl +' \')">Manag e</a>&nbsp ;' +
  2538                                          '<a  href="#" c lass="btn  btn-succes s btn-sm"  onClick="l aunchDetai lsURL(\''  + dataVal. detailsUrl  + '\')">D etail</a>& nbsp;' +
  2539                                          '<a  href="#" c lass="btn  btn-primar y btn-sm"  onClick="l aunchRepor tURL(\'' +  dataVal.r eportUrl +  '\')">Rep ort</a>&nb sp;' +
  2540                                          '<a  class="btn  btn-dange r btn-sm"  onClick="l oadPurgeSt udy(\''+ d ataVal.vie werUrl +'\ ',\'' + da taVal.stud yId + '\') ">Purge</a >&nbsp;' +
  2541                                          '</t d></tr>';
  2542                                 }) ;
  2543                             }
  2544                         }
  2545                         $('#patien tInformati on').hide( );
  2546                         $('#studyI nfoTable') .DataTable ().destroy ();
  2547                         $('#studyI nfo').html ('');
  2548                                               $('#studyI nfo').appe nd(studyIn formation) ;
  2549                                               // Display  data in t he dataTab le
  2550                                               var table  = $('#stud yInfoTable ').DataTab le({
  2551                                                       "b Destroy":  true,
  2552                                                       "b AutoWidth" : false,
  2553                                                       "b Filter": t rue,
  2554                                                       "b Sort": tru e,
  2555                                                       "a aSorting":  [[0]],
  2556                             "lengt hMenu": [  [5, 10, 15 , -1], [5,  10, 15, " All"] ],
  2557                             "pageL ength": 5,
  2558                                                       "a oColumns":  [
  2559                                                                { "s Width": '1 %', "bSort able": tru e },
  2560                                                                { "s Width": '1 %', "bSort able": tru e },
  2561                                                                { "s Width": '1 5%', "bSor table": tr ue },
  2562                                                                { "s Width": '1 %', "bSort able": tru e },
  2563                                 {  "sWidth":  '5%', "bSo rtable": t rue },
  2564                                                                { "s Width": '1 %', "bSort able": tru e },
  2565                                                                { "s Width": '5 %', "bSort able": tru e },
  2566                                                                { "s Width": '2 5%', "bSor table": fa lse }
  2567                                                       ]
  2568                                               });
  2569                                               $('#contai ner').css(  'display' , 'block'  );
  2570                                               table.colu mns.adjust ().draw();
  2571                         $("#ajax_l oader").hi de();
  2572                                               $('#sudyIn formation' ).show();
  2573                                      },
  2574                    erro r : functi on(xhr, st atus) {
  2575                         $("#ajax_l oader").hi de();
  2576                         alert("Con nection pr oblem with  Server");
  2577                    }
  2578                             });      
  2579                    }
  2580                    else  if(queryT ype == 'RO I')
  2581                    {
  2582                             $.ajax ({
  2583                                      type: 'G ET',
  2584                                      url: req uestUrl,
  2585                                      headers:  headers,
  2586                                      dataType : 'json',
  2587                                      success:  function( data)
  2588                                      {
  2589                                               console.lo g("Display  available  patient i nformation  length :"  + data.le ngth);
  2590                                               //Display  all the pa tient info rmation in  dataTAble
  2591                                               var patien tInformati on = "";
  2592                         if(!isNull OrUndefine d(data) &&  data.leng th > 0)
  2593                         {
  2594                             $.each (data, fun ction(inde x, colData ){
  2595                                 va r dicomRou ting = isN ullOrUndef ined(colDa ta.dicomRo uting) ? " " : colDat a.dicomRou ting;
  2596                                 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>';
  2597                             });
  2598                         }
  2599                                               $('#sudyIn formation' ).hide();
  2600                         $('#patien tInfoTable ').DataTab le().destr oy();
  2601                         $('#patien tInfo').ht ml('');
  2602                                               $('#patien tInfo').ap pend(patie ntInformat ion);
  2603                                               // Display  data in t he dataTab le
  2604                                               var table  = $('#pati entInfoTab le').DataT able({
  2605                                                       "b Destroy":  true,
  2606                                                       "b AutoWidth" : false,
  2607                                                       "b Filter": t rue,
  2608                                                       "b Sort": tru e,
  2609                                                       "a aSorting":  [[0]],
  2610                             "lengt hMenu": [  [5, 10, 15 , -1], [5,  10, 15, " All"] ],
  2611                             "pageL ength": 5,
  2612                                                       "a oColumns":  [
  2613                                                                { "s Width": '1 0%', "bSor table": tr ue },
  2614                                                                { "s Width": '1 0%', "bSor table": tr ue },
  2615                                                                { "s Width": '1 0%', "bSor table": tr ue },
  2616                                                                { "s Width": '1 0%', "bSor table": tr ue },
  2617                                                                { "s Width": '1 0%', "bSor table": tr ue },
  2618                                                                { "s Width": '1 0%', "bSor table": tr ue }
  2619                                                       ]
  2620                                               });
  2621                                               $('#contai ner').css(  'display' , 'block'  );
  2622                                               table.colu mns.adjust ().draw();
  2623                         $("#ajax_l oader").hi de();
  2624                                               $('#patien tInformati on').show( );
  2625                                      },
  2626                    erro r : functi on(xhr, st atus) {
  2627                         $("#ajax_l oader").hi de();
  2628                         alert("Con nection pr oblem with  Server");
  2629                    }
  2630                             });                       
  2631                    }
  2632       }
  2633   }
  2634  
  2635   // Load mo dal window  for purgi ng the stu dy 
  2636   function l oadPurgeSt udy(viewer Url, study Id)
  2637   {
  2638       $("#pu rgeStudyMo dal").moda l(); 
  2639       $('#pu rgeStudyID ').html(st udyId);
  2640       $('#vi ewerURL'). val(viewer Url);
  2641       $('#st udyPurgeID ').val(stu dyId);
  2642   }
  2643  
  2644   // Purge a ction 
  2645   function p urgeStudy( )
  2646   {
  2647       var vi ewerUrl =  $('#viewer URL').val( );
  2648       var st udyId = $( '#studyPur geID').val ();
  2649       
  2650       var pu rgeUrl = v iewerUrl.r eplace("lo ader?", "c ontext?");
  2651       
  2652        $.aja x({
  2653           ty pe: 'DELET E',
  2654           ur l: purgeUr l,
  2655           su ccess: fun ction(data )
  2656           {
  2657               $("#purge StudyModal ").modal(' hide'); 
  2658               console.l og("succes sfully pur ged the cu rrent stud y");
  2659           },
  2660           er ror : func tion(xhr,  status){
  2661                $("#purg eStudyModa l").modal( 'hide'); 
  2662                alert("C onnection  problem wi th Server" );
  2663           }
  2664        });
  2665   }
  2666  
  2667   /**
  2668    * launch  the report  url in ne w tab
  2669    */
  2670   function l aunchRepor tURL(repor tUrl) {
  2671       consol e.log("Lau nch report  url :" +  reportUrl) ;
  2672       window .open(repo rtUrl);
  2673       return  false;
  2674   }
  2675  
  2676   function l aunchDetai lsURL(deta ilsUrl)
  2677   {
  2678       var wi n = window .open(deta ilsUrl, '_ blank');
  2679       $.ajax ({
  2680           ty pe: 'GET',
  2681           ur l: details Url,
  2682           da taType: 'j son',
  2683           su ccess: fun ction(data )
  2684           {
  2685                console. log(detail sUrl);
  2686                win.docu ment.write ('<html><h ead><title >' + detai lsUrl +  ' </title><l ink rel="s tylesheet"  type="tex t/css" hre f="../styl e/jquery.j sonview.cs s"><script  type="tex t/javascri pt" src=". ./js/jquer y-1.11.1.j s"></scrip t><script  type="text /javascrip t" src=".. /js/jquery .jsonview. js"></scri pt></head> <body><div  id="conte nt"></div> <script>$( "#content" ).JSONView (' + JSON. stringify( data) + ') </script>' );
  2687                win.docu ment.write ('</body>< /html>');
  2688                win.focu s();
  2689           }
  2690       });
  2691   }
  2692       
  2693   function f ormatDate( date) 
  2694   {
  2695       var d  = new Date (date),
  2696           mo nth = '' +  (d.getMon th() + 1),
  2697           da y = '' + d .getDate() ,
  2698           ye ar = d.get FullYear() ;
  2699  
  2700       if (mo nth.length  < 2) mont h = '0' +  month;
  2701       if (da y.length <  2) day =  '0' + day;
  2702  
  2703       return  [year, mo nth, day]. join('-');
  2704   }
  2705       
  2706   /**
  2707    * launch  the manage  url in ne w tab
  2708    */
  2709   function l aunchManag eURL(manag eUrl)
  2710   {
  2711       consol e.log("Lau nch manage  url :" +  manageUrl) ;
  2712       window .open(mana geUrl);
  2713       return  false;
  2714   }
  2715  
  2716   /**
  2717    * launch  the manage  url in ne w tab
  2718    */
  2719   function l aunchDetai lURL(detai lsUrl)
  2720   {
  2721       consol e.log("Req uested det ails url : " + detail sUrl);
  2722       $('#he aderID').h ide();
  2723       $('#fo oterID').h ide();
  2724       $('#hr ID').hide( );
  2725       $('#ex Tab2').hid e();
  2726       $('#co nsole-log- div').hide ();
  2727       $('#su dyInformat ion').hide ();
  2728       $('#pa tientInfor mation').h ide();
  2729       $.ajax ({
  2730           ty pe: 'GET',
  2731           ur l: details Url,
  2732           da taType: 'j son',
  2733           su ccess: fun ction(data )
  2734           {
  2735                console. log("Launc h the deta il url : "  + JSON.st ringify(da ta, undefi ned, 4));
  2736                $('#disp layDetailI nformation ').JSONVie w(data);
  2737                $('#disp layDetailI nformation ').show();
  2738           }
  2739       });
  2740  
  2741   }
  2742  
  2743   /** 
  2744    * Clickin g on this  should cal l the sess ion status  endpoint
  2745    * 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.
  2746    * 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
  2747    */
  2748   function l oadStatusA ction()
  2749   {
  2750       var se ssionId =  $('#sessio nId').val( );
  2751       var se curityToke n = $('#se curityToke n').val();
  2752       consol e.log("Rea ding the i nput from  the hidden  text box  as Session Id, Securi tyToken  :  " + sessi onId + ","  + securit yToken);
  2753       // GET  http://lo calhost:99 11/vix/vie wer/site/< authSiteNu mber>/sess ion/<sessi onId>/stat us
  2754       var st atusUrl =  BASE_URL +  "site/500 /session/" + sessionI d + "/stat us?Securit yToken=" +  securityT oken;
  2755       consol e.log("Fet ch study i nformation  from the  session fo llowing st atus url :  " + statu sUrl);
  2756       
  2757       $.ajax ({
  2758           ur l: statusU rl,
  2759           me thod: 'GET ',
  2760           da taType: 'j son',
  2761           as ync: true,
  2762           su ccess: fun ction(data )
  2763           {
  2764                console. log("Statu s to sessi on studies  contextId s length : " + data.c ontextIds. length);
  2765                console. log("Statu s to sessi on studies  idle time  :" + data .idleTime) ;
  2766                $('#idle Time').htm l("Idle Ti me :" + da ta.idleTim e);
  2767                $('#stat usTable'). find('tbod y').empty( );
  2768                var stat usInformat ion = "";
  2769                $.each(d ata.contex tIds, func tion(index , colData) {
  2770                   statu sInformati on += '<tr ><td>' + c olData + ' </td><td>'  +
  2771                    '<a  class="btn  btn-dange r btn-sm"  onClick="r emoveFromS ession(\'' + colData  +'\')"><i  class="gly phicon gly phicon-tra sh"></i></ button></t d></tr>';
  2772                });
  2773                $('#stat usTable'). append(sta tusInforma tion);
  2774                $("#myMo dal").moda l();
  2775           }
  2776       });
  2777   }
  2778  
  2779   /** 
  2780    * This me thod is us ed to laun ch particu lar study 
  2781    */
  2782   function v iewStudy(v iewerUrl,  index)
  2783   {
  2784       var se ssionId =  $('#sessio nId').val( );
  2785       if(ses sionId ==  null || se ssionId ==  "")
  2786       {
  2787           se ssionId =  GenRandom. Job();
  2788           $( '#sessionI d').val(se ssionId);
  2789           $( '#dispalyS ession').s how();
  2790       }
  2791       consol e.log("Rea ding the i nput from  the hidden  text box  as Session Id : " + s essionId);
  2792       var ur l = viewer Url + "&se ssionId="  + sessionI d;
  2793       consol e.log("Lau nch the Vi ewer url :  " + url);
  2794       window .open(url,  '_blank') ;
  2795       $('.ad dToSession ').css("di splay", "" );
  2796       $('#ad dToSession _'+ index) .hide();
  2797   }
  2798  
  2799   /** 
  2800    * This me thod is us ed to add  study to s ession 
  2801    */
  2802   function a ddToSessio n(contextI d, securit yToken, pa tientICN,  patientDFN , siteNumb er, authSi teNumber)
  2803   {
  2804       var co ntextList  = [];
  2805       contex tList.push (contextId );
  2806       var co ntextIdLis t = JSON.s tringify(c ontextList );
  2807       consol e.log("Lis t all the  contextLis t : " + co ntextIdLis t);
  2808       var se ssionId =  $('#sessio nId').val( );
  2809       consol e.log("Rea ding the i nput from  the hidden  text box  : " + sess ionId);
  2810       var ad dContextUr l = BASE_U RL + "site /" + authS iteNumber  + "/sessio n/"+ sessi onId + "/c ontext?Sit eNumber="+  siteNumbe r + "&Secu rityToken= "+ securit yToken +"& AuthSiteNu mber=" + a uthSiteNum ber + "&se ssionId="+  sessionId ;
  2811       if (pa tientICN ! = 'undefin ed') 
  2812           ad dContextUr l = addCon textUrl +  "&PatientI CN="+ pati entICN;
  2813       else
  2814           ad dContextUr l = addCon textUrl +  "&PatientD FN="+ pati entDFN;
  2815  
  2816       consol e.log("Add  Context U RL { Conte xt URL } :  " + addCo ntextUrl);
  2817       
  2818       $.ajax ({
  2819           ty pe: 'POST' ,
  2820           ur l: addCont extUrl,
  2821           da ta: contex tIdList,
  2822           he aders: 
  2823           {
  2824                'Content -Type': 'a pplication /json',
  2825           },
  2826           da taType: 'j son',
  2827           su ccess: fun ction(data )
  2828           {
  2829                console. log("succe ssfully po sted the a dd context  Url reque st to serv er");
  2830           }
  2831       });
  2832       $('#st atusBtn'). show();
  2833   }
  2834  
  2835   /**
  2836    * This me hod is use d to remov e the stud y from the  session 
  2837    */
  2838   function r emoveFromS ession(con textId)
  2839   {
  2840        var c ontextList  = [];
  2841        conte xtList.pus h(contextI d);
  2842        var c ontextIdLi st = JSON. stringify( contextLis t);
  2843        conso le.log("Li st all the  contextLi st : " + c ontextIdLi st)
  2844        var s essionId =  $('#sessi onId').val ();
  2845        var s ecurityTok en = $('#s ecurityTok en').val() ;
  2846        var a uthSiteNum ber = $('# authSiteNu mberVal'). val();
  2847        conso le.log("Re ading the  input from  the hidde n text box  as Securi tyToken, S essionId,  AuthSiteNu mber  : "  + security Token + ", " + sessio nId + ","  + authSite Number);
  2848        var r emoveConte xtUrl = BA SE_URL + " site/" + a uthSiteNum ber + "/se ssion/"+ s essionId +  "/context ?SecurityT oken="+ se curityToke n;
  2849        conso le.log("Re move Conte xt url : "  + removeC ontextUrl) ;
  2850       
  2851        $.aja x({
  2852           ty pe: 'DELET E',
  2853           ur l: removeC ontextUrl,
  2854           da ta: contex tIdList,
  2855           he aders: 
  2856           {
  2857                'Content -Type': 'a pplication /json',
  2858           },
  2859           su ccess: fun ction(data )
  2860           {
  2861               console.l og("succes sfully pos ted the re move conte xt Url req uest to se rver");
  2862           }
  2863        });
  2864   }
  2865  
  2866   /* Generat e random n umber for  adding ses sion id th e study */
  2867   var GenRan dom =  {
  2868       Stored : [],
  2869       Job: f unction()
  2870       {
  2871           // var newId  = Date.now ().toStrin g().substr (6); // or  use any m ethod that  you want  to achieve  this stri ng
  2872           va r newId =  generateGU ID();
  2873           if ( !this.Ch eck(newId)  )
  2874           {
  2875                this.Sto red.push(n ewId);
  2876                return n ewId;
  2877           }
  2878           re turn this. Job();
  2879       },
  2880  
  2881       Check:  function( id)
  2882       {
  2883           fo r( var i =  0; i < th is.Stored. length; i+ + )
  2884           {
  2885                if( this .Stored[i]  == id ) r eturn true ;
  2886           }
  2887           re turn false ;
  2888       }
  2889   };
  2890           
  2891  
  2892   var genera teGUID = ( typeof(win dow.crypto ) != 'unde fined' &&  typeof(win dow.crypto .getRandom Values) !=  'undefine d') ? func tion() 
  2893   {
  2894       // If  we have a  cryptograp hically se cure PRNG,  use that
  2895       // htt ps://stack overflow.c om/questio ns/6906916 /collision s-when-gen erating-uu ids-in-jav ascript
  2896       var bu f = new Ui nt16Array( 8);
  2897       window .crypto.ge tRandomVal ues(buf);
  2898       var S4  = functio n(num) 
  2899       {
  2900           va r ret = nu m.toString (16);
  2901           wh ile(ret.le ngth < 4)
  2902           {
  2903                ret = "0 "+ret;
  2904           }
  2905           re turn ret;
  2906       };
  2907       return  (S4(buf[0 ])+S4(buf[ 1])+"-"+S4 (buf[2])+" -"+S4(buf[ 3])+"-"+S4 (buf[4])+" -"+S4(buf[ 5])+S4(buf [6])+S4(bu f[7]));
  2908   }:
  2909  
  2910   function()  
  2911   {
  2912       // Oth erwise, ju st use Mat h.random
  2913       // htt ps://stack overflow.c om/questio ns/105034/ how-to-cre ate-a-guid -uuid-in-j avascript/ 2117523#21 17523
  2914       return  'xxxxxxxx -xxxx-4xxx -yxxx-xxxx xxxxxxxx'. replace(/[ xy]/g, fun ction(c) 
  2915       {
  2916           va r r = Math .random()* 16|0, v =  c == 'x' ?  r : (r&0x 3|0x8);
  2917           re turn v.toS tring(16);
  2918       });
  2919   };
  2920  
  2921   function s howDashboa rdSystemPr eferences( )
  2922   {
  2923       initia lizePages( );
  2924       hideAn dShowTopMe nu();
  2925       displa yAnnotatio nPreferenc es();
  2926  
  2927       $('#da shboard-to pmenu-syst em-prefere nce-home') .show();
  2928       $('#da hsboard-to pmenu-home -nav').sho w(); 
  2929       $('#da shboard-sy stem-prefe rence-home ').show();
  2930   }
  2931  
  2932   /**
  2933    * Initial ize the pa ges
  2934    */ 
  2935   var isPage sInitializ ed = false ;
  2936   function i nitializeP ages() {
  2937       if(!is PagesIniti alized) {
  2938           //  Cine pref erence tab
  2939           $( '#cineTab' ).html('') ;
  2940           lo adCinePref erenceWind ow("Cine P references ");
  2941  
  2942           //  ECG prefe rence Tab
  2943           $( '#ecgTab') .html('');
  2944           lo adECGPrefe renceWindo w("ECG Pre ferences") ;
  2945  
  2946           //  Annotatio n preferen ce tab
  2947           ge tStrokeSty le("ASTROK ESTYLE");
  2948  
  2949           //  Display p reference  tab
  2950           $( '#displayT ab').html( '');
  2951           lo adDisplayP referenceW indow("Lay out Prefer ences");
  2952  
  2953           //  Copy attr ibutes pre ference ta b
  2954           $( '#copyAttr Tab').html ('');
  2955           lo adCopyAttr ibutePrefe renc("Copy  Attribute s Preferen ces");
  2956  
  2957           //  Log prefe rence tab
  2958           $( '#logTab') .html('');
  2959           lo adLogAttri butePrefer enc("Log A ttributes  Preference s");
  2960           $( '#logTab') .hide();
  2961  
  2962           is PagesIniti alized = t rue;
  2963           di comViewer. systemPref erences.lo adAllPrefe rences();
  2964       }
  2965   }
  2966  
  2967   function d isplayCine Preference s()
  2968   {
  2969       $('#ci neTab').sh ow();
  2970       $('#an notationTa b').hide() ;
  2971       $('#ec gTab').hid e();
  2972       $('#di splayTab') .hide();
  2973       $('#co pyAttrTab' ).hide();
  2974       $('#lo gTab').hid e();
  2975       
  2976       $('#ci nePrefActi ve').addCl ass('tab-a ctive').re moveClass( 'panel-hea ding');
  2977       $('#an notaPrefAc tive').rem oveClass(' tab-active ').addClas s('panel-h eading');
  2978       $('#ec gPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  2979       $('#di sPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  2980       $('#co pyPrefActi ve').remov eClass('ta b-active') .addClass( 'panel-hea ding');
  2981       $('#lo gPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  2982  
  2983       $('#pr eferenceHe aderTitle' ).html('') ;
  2984       $('#pr eferenceHe aderTitle' ).append(" Cine Prefe rences");
  2985   }
  2986  
  2987   function d isplayLogP references ()
  2988   {
  2989       $('#ci neTab').hi de();
  2990       $('#an notationTa b').hide() ;
  2991       $('#ec gTab').hid e();
  2992       $('#di splayTab') .hide();
  2993       $('#co pyAttrTab' ).hide();
  2994       $('#lo gTab').sho w();
  2995  
  2996       $('#lo gPrefActiv e').addCla ss('tab-ac tive').rem oveClass(' panel-head ing');
  2997       $('#ci nePrefActi ve').remov eClass('ta b-active') .removeCla ss('panel- heading');
  2998       $('#an notaPrefAc tive').rem oveClass(' tab-active ').addClas s('panel-h eading');
  2999       $('#ec gPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  3000       $('#di sPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  3001       $('#co pyPrefActi ve').remov eClass('ta b-active') .addClass( 'panel-hea ding');
  3002  
  3003       $('#pr eferenceHe aderTitle' ).html('') ;
  3004       $('#pr eferenceHe aderTitle' ).append(" Log Prefer ences");
  3005   }
  3006  
  3007   function l oadCinePre ferenceWin dow(title)
  3008   {
  3009       var ci nePref = " "; 
  3010       
  3011       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>';
  3012       
  3013       
  3014       $('#ci neTab').ap pend(cineP ref);
  3015   }
  3016       
  3017   function d isplayEcgP references ()
  3018   {
  3019       $('#ec gTab').sho w();
  3020       $('#an notationTa b').hide() ;
  3021       $('#ci neTab').hi de();
  3022       $('#di splayTab') .hide();
  3023       $('#co pyAttrTab' ).hide();
  3024       $('#lo gTab').hid e();
  3025       
  3026       $('#ec gPrefActiv e').addCla ss('tab-ac tive').rem oveClass(' panel-head ing');
  3027       $('#ci nePrefActi ve').remov eClass('ta b-active') .addClass( 'panel-hea ding');
  3028       $('#an notaPrefAc tive').rem oveClass(' tab-active ').addClas s('panel-h eading');
  3029       $('#di sPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  3030       $('#co pyPrefActi ve').remov eClass('ta b-active') .addClass( 'panel-hea ding');
  3031       $('#lo gPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  3032       
  3033       $('#pr eferenceHe aderTitle' ).html('') ;
  3034       $('#pr eferenceHe aderTitle' ).append(" ECG Prefer ences");
  3035   }
  3036  
  3037   function l oadECGPref erenceWind ow(title)
  3038   {
  3039       var ec gPref = ""
  3040       
  3041       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>';
  3042       
  3043       $('#ec gTab').app end(ecgPre f);
  3044   }
  3045       
  3046   function d isplayAnno tationPref erences()
  3047   {
  3048       $('#an notationTa b').show() ;
  3049       $('#ci neTab').hi de();
  3050       $('#ec gTab').hid e();
  3051       $('#di splayTab') .hide();
  3052       $('#co pyAttrTab' ).hide();
  3053       $('#lo gTab').hid e();
  3054       
  3055       $('#an notaPrefAc tive').add Class('tab -active'). removeClas s('panel-h eading');
  3056       $('#ci nePrefActi ve').remov eClass('ta b-active') .addClass( 'panel-hea ding');
  3057       $('#ec gPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  3058       $('#di sPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  3059       $('#co pyPrefActi ve').remov eClass('ta b-active') .addClass( 'panel-hea ding');
  3060       $('#lo gPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  3061  
  3062       $('#pr eferenceHe aderTitle' ).html('') ;
  3063       $('#pr eferenceHe aderTitle' ).append(" Annotation  Preferenc es");
  3064   }
  3065       
  3066   function g etStrokeSt yle(type)
  3067   {
  3068       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"> '+ getLine Width(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 +' lineColor"  class="fo rm-control "></div></ div></form ></div>';
  3069       
  3070       $('#st orkeStyleI D').append (storkeLin e);
  3071       
  3072       getGau geLength(" LINE");
  3073   }
  3074  
  3075   function g etGaugeLen gth(type)
  3076   {
  3077       var ga ugeLength  = '<div cl ass="panel -body" sty le="paddin g-top: 30p x !importa nt;">'+ ge tFieldSetT itle("Line ") +'<form  role="for m" class=" form-horiz ontal"><di v class="f orm-group" ><div clas s="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  id="' + ty pe + 'gaug eStyle"  c lass="form -control p refBtn" st yle="min-w idth:40px" ><option v alue="Line ">Line</op tion><opti on value=" Point">Poi nt</option ></select> </div><div  class="co l-sm-2">    <label fo r="gaugeLe ngth" styl e="margin- top: 10px; ">Gauge Le ngth</labe l></div><d iv class=" col-sm-2"> <input id= "'+ type + 'gaugeLeng th" type=" number" mi n="0" max= "20" onkey press="ret urn event. charCode > = 48 && ev ent.charCo de <= 57"  onkeypress ="return e vent.charC ode >= 48  && event.c harCode <=  57" class =" form-co ntrol"/></ div><div c lass="col- sm-2"> <la bel for="f ill"></lab el></div>< div class= "col-sm-2" > <input t ype="check box" class ="form-con trol" styl e="display : none"></ div></div> </form></d iv>';
  3078       
  3079       $('#ga ugeLengthI D').append (gaugeLeng th);
  3080       
  3081       getArr owFill("AR ROW");
  3082   }
  3083       
  3084   function g etArrowFil l(type)
  3085   {
  3086       var ar rowFill =  '<div clas s="panel-b ody" style ="padding- top: 30px  !important ;">'+ getF ieldSetTit le("Arrow" ) +'<form  role="form " class="f orm-horizo ntal"><div  class="fo rm-group"> <div class ="col-sm-2 "> <label  for="fillC olor" styl e="margin- top: 10px; ">Fill Col or</label> </div><div  class="co l-sm-2"> < input type ="color" i d="'+ type  +'fillCol or" value= "#00FFFF"  name="fill Color" cla ss="form-c ontrol"></ div><div c lass="col- sm-2"> <la bel for="f ill" style ="margin-t op: 10px;" >Fill</lab el></div>< div class= "col-sm-2" > <input t ype="check box" id="' + type +'i sFill" cla ss="form-c ontrol" st yle="width : 35px"></ div></div> </form></d iv>';
  3087       
  3088       $('#ar rowFillID' ).append(a rrowFill);
  3089       
  3090       getMea surement(" MSTROKESTY LE");
  3091   }
  3092    
  3093   function g etMeasurem ent(type)
  3094   {
  3095       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"> '+ g etLineWidt h(type) +' </div><div  class="co l-sm-2"> < label for= "color" cl ass="label -align">Co lor</label ></div><di v class="c ol-sm-2">  <input typ e="color"  value="#00 FFFF" id=" '+ type +' lineColor"  class="fo rm-control "></div></ div><div c lass="form -group"><d iv 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="'+ typ e +'precis ion" min=" 0" max="14 " onkeypre ss="return  event.cha rCode >= 4 8 && event .charCode  <= 57" cla ss="form-c ontrol"></ div><div c lass="col- sm-2"> <la bel for="m easurement Units"clas s="label-a lign">Meas urement Un its</label ></div><di v class="c ol-sm-2">< select id= "'+ type + 'measureUn its" class ="form-con trol"><opt ion value= "in">Inche s</option> <option va lue="cm">C entimeter< /option><o ption valu e="mm">Mil limeter</o ption></se lect></div ></div></f orm></div> ';
  3096       
  3097       $('#me asurementL ineID').ap pend(measu rement);
  3098       
  3099       getMea surementGa ugeLength( "LENGTH");
  3100   }
  3101       
  3102   function g etMeasurem entGaugeLe ngth(type)
  3103   {
  3104       var me asurementG augeLength  = '<div c lass="pane l-body" st yle="paddi ng-top: 30 px !import ant;">'+ g etFieldSet Title("Len gth") +'<f orm role=" form" clas s="form-ho rizontal"> <div class ="form-gro up"><div c lass="col- sm-2"> <la bel for="g augeStyle"  style="ma rgin-top:  10px;">Gau ge Style</ label></di v><div cla ss="col-sm -2"> <sele ct id="' +  type + 'g augeStyle"   class="f orm-contro l prefBtn"  style="mi n-width:40 px"><optio n value="L ine">Line< /option><o ption valu e="Point"> Point</opt ion></sele ct></div>< div class= "col-sm-2" ><label fo r="'+ type  +'gaugeLe ngth" styl e="margin- top: 10px; ">Gauge Le ngth</labe l></div><d iv class=" col-sm-2">  <input id ="'+ type  +'gaugeLen gth" type= "number" m in="0" max ="20" onke ypress="re turn event .charCode  >= 48 && e vent.charC ode <= 57"  class=" f orm-contro l"/></div> </div></fo rm></div>' ;
  3105       
  3106       $('#me asurementG augeLength ID').appen d(measurem entGaugeLe ngth);
  3107       
  3108       getMea surementAn gle("ANGLE ");
  3109   }
  3110       
  3111   function g etMeasurem entAngle(t ype)
  3112   {
  3113       var me asurementA ngle = '<d iv class=" panel-body " style="p adding-top : 30px !im portant;">  '+ getFie ldSetTitle ("Angle")  +'<form ro le="form"  class="for m-horizont al"><div c lass="form -group"><d iv class=" col-sm-2"> <label for ="'+ type  +'arcRadiu s" style=" margin-top : 10px;">A rc Radius< /label></d iv><div cl ass="col-s m-2"><inpu t id="'+ t ype +'arcR adius" typ e="number"  min="5" m ax="20" on keypress=" return eve nt.charCod e >= 48 &&  event.cha rCode <= 5 7" class="  form-cont rol"/></di v></div></ form></div >';
  3114       
  3115        $('#m easurement AngleID'). append(mea surementAn gle);
  3116       
  3117       getEli pseRectLin e("ERSTROK ESTYLE");
  3118   }
  3119    
  3120   function g etElipseRe ctLine(typ e)
  3121   {
  3122       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) +' </di v><div cla ss="col-sm -2"> <labe l for="col or" class= "label-ali gn">Color< /label></d iv><div cl ass="col-s m-2"> <inp ut type="c olor" valu e="#00FFFF " id="'+ t ype +'line Color" cla ss="form-c ontrol"></ div></div> <div class ="form-gro up"><div c lass="col- sm-2"> <la bel for="f illColor"  style="mar gin-top: 1 0px;">Fill  Color</la bel></div> <div class ="col-sm-2 "><input t ype="color " id="'+ t ype +'fill Color" val ue="#00FFF F" name="f illColor"  class="for m-control" ></div><di v class="c ol-sm-2">  <label for ="fill" st yle="margi n-top: 10p x;">Fill</ label></di v><div cla ss="col-sm -2"> <inpu t type="ch eckbox" id ="'+ type  +'isFill"  class="for m-control"  style="wi dth: 35px" ></div></d iv></form> </div>';
  3123       
  3124       $('#el ipseRectLi neID').app end(elipse RectLine);
  3125       
  3126       getHou nsfield("H OUNSFIELD" );
  3127   }
  3128  
  3129   function g etHounsfie ld(type)
  3130   {
  3131       var ho usnsfield  = '<div cl ass="panel -body" sty le="paddin g-top: 30p x !importa nt;"> '+ g etFieldSet Title("HOU NSFIELD")  +'<form ro le="form"  class="for m-horizont al"><div c lass="form -group"><d iv 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 typ e="number"  id="'+ ty pe +'preci sion" min= "0" max="1 4" onkeypr ess="retur n event.ch arCode >=  48 && even t.charCode  <= 57" cl ass="form- control">< /div><div  class="col -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 i d="'+ type  +'measure Units" cla ss="form-c ontrol"><o ption valu e="in">Inc hes</optio n><option  value="cm" >Centimete r</option> <option va lue="mm">M illimeter< /option></ select></d iv></div>< /form></di v>';    
  3132       
  3133      $('#hou snfieldID' ).append(h ousnsfield );
  3134       
  3135       getMit ralLine("M A");
  3136   }
  3137  
  3138   function g etMitralLi ne(type)
  3139   {
  3140       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 +'g augeLength " style="m argin-top:  10px;">Ga uge Length </label></ div><div c lass="col- sm-2"><inp ut id="'+  type +'gau geLength"  type="numb er" min="0 " max="20"  onkeypres s="return  event.char Code >= 48  && event. charCode < = 57" clas s=" form-c ontrol"/>< /div></div ><div clas s="form-gr oup"><div  class="col -sm-2"><la bel for="P recision"  class="lab el-align"> Precision< /label></d iv><div cl ass="col-s m-2"><inpu t type="nu mber" 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 f or="measur ementUnits "class="la bel-align" >Measureme nt Units</ label></di v><div cla ss="col-sm -2"><selec t id="'+ t ype +'meas ureUnits"  class="for m-control" ><option v alue="in"> Inches</op tion><opti on value=" cm">Centim eter</opti on><option  value="mm ">Millimet er</option ></select> </div></di v></form>< /div>';
  3141  
  3142       $('#mi tralAortic ID').appen d(mitralAt ro);
  3143       
  3144       getMit ralWidth(" MITRAL");
  3145   }
  3146       
  3147   function g etMitralWi dth(type)
  3148   {
  3149       var mW idth = '<d iv class=" panel-body " style="p adding-top : 30px !im portant;">  '+ getFie ldSetTitle ("MITRAL")  +'<form r ole="form"  class="fo rm-horizon tal"><div  class="for m-group">< div class= "col-sm-2" > <label f or="lineWi dth" style ="margin-t op: 10px;" >Line Widt h</label>< /div><div  class="col -sm-2"> '+  getLineWi dth(type)  +'</div><d iv class=" col-sm-2">  <label fo r="color"  style="mar gin-top: 1 0px;">Colo r</label>< /div><div  class="col -sm-2"> <i nput type= "color" va lue="#00FF FF" id="'+  type +'li neColor" c lass="form -control"> </div></di v></form>< /div>';
  3150       
  3151       $('#mi tralLineID ').append( mWidth);
  3152       
  3153       getAor ticWidth(" AORTIC");
  3154   }
  3155       
  3156   function g etAorticWi dth(type)
  3157   {
  3158       var mA orticWidth  = '<div c lass="pane l-body" st yle="paddi ng-top: 30 px !import ant;"> '+  getFieldSe tTitle("AO RTIC") +'< 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">'+ getL ineWidth(t ype) +'</d iv><div cl ass="col-s m-2"> <lab el for="co lor" style ="margin-t op: 10px;" >Color</la bel></div> <div class ="col-sm-2 "> <input  type="colo r" value=" #00FFFF" i d="'+ type  +'lineCol or" class= "form-cont rol"></div ></div></f orm></div> ';
  3159       
  3160       $('#mi tralID').a ppend(mAor ticWidth);
  3161       
  3162       getTex t("TEXT");
  3163   }
  3164       
  3165   function g etText(typ e)
  3166   {
  3167       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"> '+ 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">  '+ getFon tSize(type ) +' </div ><div clas s="col-sm- 2"> <label  for="text Color" sty le="margin -top: 10px ;">Font Co lor</label ></div><di v class="c ol-sm-2">  <input typ e="color"  id="'+ typ e +'textCo lor" value ="#00FFFF"  class="fo rm-control "></div></ div><div c lass="form -group"><d iv class=" col-sm-2">  <label fo r="'+ type  +'isFill"  class="la bel-align" >Fill</lab el></div>< div class= "col-sm-2" > <input t ype="check box"  id=" '+ type +' isFill" cl ass="form- control fo rm-input-s tyle"></di v><div cla ss="col-sm -2"> <labe l for="'+  type +'fil lColor" cl ass="label -align">Fi ll Color</ label></di v><div cla ss="col-sm -2"> <inpu t type="co lor" value ="#00FFFF"   id="'+ t ype +'fill Color" cla ss="form-c ontrol"></ div></div> <div class ="form-gro up"> '+ ge tFontAttr( type) +' < /div></for m></div></ div>';
  3168       
  3169       $('#fo ntText').a ppend(text );
  3170       
  3171       getLab elAnnotati on("LBLANN OTATION");
  3172   }
  3173  
  3174   function g etLabelAnn otation(ty pe)
  3175   {
  3176       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" > '+ getFo ntName(typ e) +'</div ><div clas s="col-sm- 2"> <label  for="font Size" styl e="margin- top: 10px; ">Font Siz e</label>< /div><div  class="col -sm-2"> '+  getFontSi ze(type) + '</div> <d iv class=" col-sm-2">  <label fo r="textCol or" style= "margin-to p: 10px;"> Font Color </label></ div><div c lass="col- sm-2"> <in put type=" color" id= "'+ type + 'textColor " value="# 00FFFF" cl ass="form- control">< /div></div ><div clas s="form-gr oup">'+ ge tFontAttr( type) +'</ div></form ></div>';
  3177       
  3178       $('#la belAnnotat ionID').ap pend(lblAn notation);
  3179       
  3180       getLab elOverlay( "LBLOVERLA Y");
  3181   }
  3182  
  3183   function g etLabelOve rlay(type)
  3184   {
  3185       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"> ' + getFontN ame(type)  +'</div><d iv class=" col-sm-2">  <label fo r="fontSiz e" style=" margin-top : 10px;">F ont Size</ label></di v><div cla ss="col-sm -2"> '+ ge tFontSize( type) +'</ 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 +'te xtColor" v alue="#00F FFF" class ="form-con trol"></di v></div><d iv class=" form-group ">'+ getFo ntAttr(typ e) +'</div ></form></ div>';
  3186       
  3187       $('#la belOverlay ID').appen d(lblOverl ay);
  3188       
  3189       getLab elOrientat ion("LBLOR IENTATION" );
  3190   }
  3191  
  3192   function g etLabelOri entation(t ype)
  3193   {
  3194       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 "> '+ getF ontName(ty pe) +'</di v><div cla ss="col-sm -2"> <labe l for="fon tSize" sty le="margin -top: 10px ;">Font Si ze</label> </div><div  class="co l-sm-2"> ' + getFontS ize(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  +'textColo r" value=" #00FFFF" c lass="form -control"> </div></di v><div cla ss="form-g roup">'+ g etFontAttr (type) +'< /div></for m></div>';
  3195       
  3196       $('#la belOrienta tionID').a ppend(lblO rientation );
  3197       
  3198       getLab elScoutRul er("LBLSCO UT");
  3199   }
  3200  
  3201   function g etLabelSco utRuler(ty pe)
  3202   {
  3203       var lb lScoutRule  = '<div c lass="pane l-body" st yle="paddi ng-top: 30 px !import ant;">'+ g etFieldSet Title("SCO UT") +'<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" s tyle="marg in-top: 10 px;">Line  Width</lab el></div>< div class= "col-sm-2" >'+ getLin eWidth(typ e) +'</div ><div clas s="col-sm- 2"> <label  for="colo r" style=" margin-top : 10px;">C olor</labe l></div><d iv class=" col-sm-2">  <input ty pe="color"  value="#0 0FFFF" id= "'+ type + 'lineColor " class="f orm-contro l"></div>< /div></for m></div>';
  3204       
  3205       $('#la belScoutRu lerID').ap pend(lblSc outRule);
  3206       
  3207       getLab elRuler("L BLRULER");
  3208   }
  3209  
  3210   function g etLabelRul er(type)
  3211   {
  3212      var lbl Rule = '<d iv class=" panel-body " style="p adding-top : 30px !im portant;"> '+ getFiel dSetTitle( "RULER") + '<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">'+ ge tLineWidth (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="'+ ty pe +'lineC olor" clas s="form-co ntrol"></d iv></div>< /form></di v>';
  3213       
  3214       $('#la belRulerID ').append( lblRule);
  3215   }
  3216       
  3217   function g etFontName (type)
  3218   {
  3219       return  '<select  id="'+ typ e +'fontNa me" class= "form-cont rol"><opti on value=" Arial">Ari al</option ><option v alue="Aria l Black">A rial Black </option>  <option va lue="Book  Antiqua">B ook Antiqu a</option> <option va lue="Calib ri">Calibr i</option> <option va lue="Comic  Sans MS"> Comic Sans  MS</optio n><option  value="Cou rier">Cour ier</optio n><option  value="Cur sive">Curs ive</optio n><option  value="Fan tasy">Fant asy </opti on><option  value="Ge orgia">Geo rgia</opti on><option  value="Ga ramond">Ga ramond</op tion><opti on value=" Helvetica" >Helvetica </option>< option val ue="Impact ">Impact < /option><o ption valu e="Lucida  Sans Unico de">Lucida  Sans Unic ode </opti on><option  value="Lu cida Conso le">Lucida  Console < /option><o ption valu e="Monospa ce">Monosp ace</optio n><option  value="Pal atino Lino type">Pala tino Linot ype</optio n><option  value="san s-serif">S ans-serif< /option><o ption valu e="Times N ew Roman"> Times New  Roman</opt ion><optio n value="T ahoma">Tah oma </opti on><option  value="Ve rdana">Ver dana </opt ion></sele ct>';
  3220   }
  3221       
  3222   function g etFontSize (type)
  3223   {
  3224       return  '<select  id="'+ typ e +'fontSi ze" class= "form-cont rol"><opti on value=" 6">5</opti on><option  value="7" >7</option ><option v alue="8">8 </option>< option val ue="9">9</ option><op tion value ="10">10</ option><op tion value ="11">11</ option><op tion value ="12">12</ option><op tion value ="13">13</ option><op tion value ="14">14</ option><op tion value ="16">16</ option><op tion value ="18">18</ option><op tion value ="20">20</ option><op tion value ="22">22</ option><op tion value ="24">24</ option><op tion value ="26">26</ option><op tion value ="28">28</ option></s elect>';
  3225   }
  3226       
  3227   function g etFontAttr (type)
  3228   {
  3229       return  '<div cla ss="col-sm -2"> <labe l for="'+  type +'isB old" class ="label-al ign">Bold< /label></d iv><div cl ass="col-s m-2"> <inp ut type="c heckbox"   id="'+ typ e +'isBold " class="f orm-contro l form-inp ut-style"> </div><div  class="co l-sm-2"> < label for= "'+ type + 'isItalic"  class="la bel-align" >Italic</l abel></div ><div clas s="col-sm- 2"><input  type="chec kbox"  id= "'+ type + 'isItalic"  class="fo rm-control  form-inpu t-style">< /div></div ><div clas s="form-gr oup"><div  class="col -sm-2"> <l abel for=" '+ type +' isUnderlin ed" class= "label-ali gn">Underl ine</label ></div><di v class="c ol-sm-2">< input type ="checkbox "  id="'+  type +'isU nderlined"  class="fo rm-control  form-inpu t-style">< /div><div  class="col -sm-2"> <l abel for=" '+ type +' isStrikeou t" class=" label-alig n">Strikeo ut</label> </div><div  class="co l-sm-2"> < input type ="checkbox "  id="'+  type +'isS trikeout"  class="for m-control  form-input -style"></ div>';
  3230   }
  3231  
  3232   function g etLineWidt h(type)
  3233   {
  3234       return  '<select  id="'+ typ e +'lineWi dth" class ="form-con trol"><opt ion value= "1">1</opt ion><optio n value="2 ">2</optio n><option  value="3"> 3</option> <option va lue="4">4< /option><o ption valu e="5">5</o ption><opt ion value= "6">6</opt ion><optio n value="7 ">7</optio n><option  value="8"> 8</option> <option va lue="9">9< /option><o ption valu e="10">10< /option><o ption valu e="11">11< /option><o ption valu e="12">12< /option><o ption valu e="13">13< /option><o ption valu e="14">14< /option></ select>';
  3235   }
  3236       
  3237   function g etFieldSet Title(titl e)
  3238   {
  3239       return  '<h5 clas s="text-on -pannel">< strong cla ss="text-u ppercase">  '+ title  +' </stron g></h5>';
  3240   }
  3241       
  3242   function d isplayLayo utPreferen ces()
  3243   {
  3244       $('#di splayTab') .show();
  3245       $('#an notationTa b').hide() ;
  3246       $('#ci neTab').hi de();
  3247       $('#ec gTab').hid e();
  3248       $('#co pyAttrTab' ).hide();
  3249       $('#lo gTab').hid e();
  3250       
  3251       $('#di sPrefActiv e').addCla ss('tab-ac tive').rem oveClass(' panel-head ing');
  3252       $('#ci nePrefActi ve').remov eClass('ta b-active') .addClass( 'panel-hea ding');
  3253       $('#ec gPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  3254       $('#an notaPrefAc tive').rem oveClass(' tab-active ').addClas s('panel-h eading');
  3255       $('#co pyPrefActi ve').remov eClass('ta b-active') .addClass( 'panel-hea ding');
  3256       $('#lo gPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  3257       
  3258       $('#pr eferenceHe aderTitle' ).html('') ;
  3259       $('#pr eferenceHe aderTitle' ).append(" Layout Pre ferences") ;
  3260   }
  3261  
  3262   function l oadDisplay Preference Window(tit le)
  3263   {
  3264       var hp List = "";
  3265  
  3266       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> ';
  3267       
  3268       $('#di splayTab') .append(hp List);
  3269       
  3270       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>';
  3271  
  3272       $('#di splayTab') .append(hp List);
  3273   }
  3274       
  3275   function d isplayCopy AttributeP references ()
  3276   {
  3277       $('#co pyAttrTab' ).show();
  3278       $('#an notationTa b').hide() ;
  3279       $('#ci neTab').hi de();
  3280       $('#ec gTab').hid e();
  3281       $('#di splayTab') .hide();
  3282       $('#lo gTab').hid e();
  3283       
  3284       $('#co pyPrefActi ve').addCl ass('tab-a ctive').re moveClass( 'panel-hea ding');
  3285       $('#ci nePrefActi ve').remov eClass('ta b-active') .addClass( 'panel-hea ding');
  3286       $('#ec gPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  3287       $('#an notaPrefAc tive').rem oveClass(' tab-active ').addClas s('panel-h eading');
  3288       $('#di sPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  3289       $('#lo gPrefActiv e').remove Class('tab -active'). addClass(' panel-head ing');
  3290  
  3291       $('#pr eferenceHe aderTitle' ).html('') ;
  3292       $('#pr eferenceHe aderTitle' ).append(" Copy Attri butes Pref erences");
  3293   }
  3294       
  3295   function l oadCopyAtt ributePref erenc(titl e)
  3296   {
  3297       var co pyAttr ="" ;
  3298       var ar rCopyAttr  = ["Window  Level", " Brightness  and Contr ast", "Sca le", "Inve rt", "Orie ntation"," Pan"];
  3299       var aC heckbox =  "";
  3300       for(va r i = 0; i  < arrCopy Attr.lengt h; i++)
  3301       {
  3302           if (arrCopyAt tr[i] == ' Pan')
  3303           {
  3304                 aCheckb ox += '<di v class="c heckbox" s tyle="disp lay:none"> <input id= "' + arrCo pyAttr[i]. replace(/\ s|\and/g,  "").toLowe rCase() +  '" type="c heckbox" c hecked><la bel for="'  + arrCopy Attr[i].re place(/\s| \and/g, "" ).toLowerC ase() + '" >'+ arrCop yAttr[i] + '</label>< /div>';         
  3305           }
  3306           el se
  3307           {
  3308                 aCheckb ox += '<di v class="c heckbox">< 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() + '"> '+ arrCopy Attr[i] +'  </label>< /div>';     
  3309           }
  3310       }
  3311       if(aCh eckbox !=  undefined)
  3312       {
  3313           co pyAttr +=  '<div clas s="row"><d iv class=" col-md-4"> </div><div  class="co l-md-4">'+  aCheckbox  +'</div>< div class= "col-md-4" ></div></d iv><div cl ass="form- group"><di v class="c ol-md-4">< div id="da shboard-co pyattr-loa ding-icon"  style="di splay: non e"><span c lass="glyp hicon glyp hicon-refr esh glyphi con-refres h-animate" ></span> < span id="d ashboard-c opyattr-lo ading-stat us"></span ></div></d iv><div cl ass="col-m d-4"><butt on type="b utton" cla ss="btn bt n-sm btn-p rimary"  i d="dashboa rd-copyatt ributesTab -apply-btn " disabled  onclick=" dicomViewe r.systemPr eferences. onSubmit(& quot;copya ttributes& quot;)">Ap ply</butto n>&nbsp;<b utton type ="button"  class="btn  btn-sm bt n-default"  id="dashb oard-copya ttributesT ab-reset-b tn" disabl ed onclick ="dicomVie wer.system Preference s.onReset( &quot;copy attributes &quot;)">R eset</butt on></div>< div class= "col-md-4" ></div>';
  3314           $( '#copyAttr Tab').appe nd(copyAtt r)
  3315       }
  3316   }
  3317  
  3318   function l oadLogAttr ibutePrefe renc(title )
  3319   {
  3320       var ci nePref = " "; 
  3321  
  3322       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> ';
  3323  
  3324       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>';
  3325  
  3326       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>';
  3327  
  3328       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>' ;
  3329  
  3330       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>';
  3331  
  3332       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>';
  3333  
  3334       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>';
  3335  
  3336       $('#lo gTab').app end(cinePr ef);
  3337   }
  3338  
  3339   function d isplayHead erTitle(ti tle)
  3340   {
  3341      return  '<div clas s="header- text-align "><h4 clas s="text-ce nter">'+ t itle +'</h 4></div>';
  3342   }
  3343       
  3344   function g enerateSto rkeValue(i d)
  3345   {
  3346       var st rokeValue  = "";
  3347       for(va r i = 1; i  < 15; i++ )
  3348       {
  3349           st rokeValue  += "<optio n value='" + i +"'>"  + i + "</o ption>";
  3350       }
  3351  
  3352       return  strokeVal ue;
  3353   }
  3354       
  3355   function c hangeLeadT ype(value)
  3356   {
  3357       if(val ue == "3x4 +1")
  3358       {
  3359           $( '#displayO ne').show( );
  3360           $( '#displayT hree').hid e();
  3361       }
  3362       else
  3363       {
  3364           $( '#displayO ne').hide( );
  3365           $( '#displayT hree').sho w();
  3366       }
  3367   }
  3368  
  3369  
  3370   /**
  3371    * Load da shboard ca che page w hile click ing on das hboard cac he image
  3372    **/
  3373   function s howDashboa rdCache()
  3374   {
  3375       hideAn dShowTopMe nu();
  3376       $('#da shboard-to pmenu-cach e-home').s how();
  3377       $('#da hsboard-to pmenu-home -nav').sho w();
  3378       $('#da shboard-ca che-home') .show();
  3379   }
  3380  
  3381   /**
  3382    * Load da shboard st atus page  while clic king on da shboard st atus image
  3383    **/
  3384   function s howDashboa rdStatus()
  3385   {
  3386       hideAn dShowTopMe nu();
  3387       $('#da shboard-to pmenu-stat us-home'). show();
  3388       $('#da hsboard-to pmenu-home -nav').sho w();
  3389       $('#da shboard-st atus-home' ).show();
  3390       getDas hboardRend erAndViewe rStatus();
  3391   }
  3392  
  3393   /**
  3394    * Get das hboard ren der and vi ewer statu s informat ion
  3395    * and dis play it in  status pa ge 
  3396    **/
  3397   function g etDashboar dRenderAnd ViewerStat us()
  3398   {
  3399       $.ajax ({
  3400           ur l: DASHBOR AD_STATUS_ URL,
  3401           me thod: 'GET ',
  3402           da taType: 'j son',
  3403           as ync: true,
  3404           su ccess: fun ction(data )
  3405           {
  3406                var stat usViewerIn formation  = "";
  3407                var stat usRenderIn formation  = "";
  3408                if(!isNu llOrUndefi ned(data))
  3409                {
  3410                    $('# dashboard- status-vie wer-table- body').htm l('');
  3411                    $('# dashboard- status-ren der-table- body').htm l('');
  3412                    $.ea ch(data, f unction(in dex, colDa ta){
  3413                         var render Str = inde x.replace( 'rENDER',' RENDER');
  3414                         if(renderS tr.indexOf ('RENDER')  !== -1)
  3415                         {
  3416                            statusR enderInfor mation +=  '<tr><td>'  + index.r eplace('rE NDER.','')  + '</td>< td>' + col Data + '</ td></tr>';    
  3417                         }
  3418                         else
  3419                         {
  3420                             status ViewerInfo rmation +=  '<tr><td> ' + index. replace('v IEWER.','' ) + '</td> <td>' + co lData + '< /td></tr>' ;         
  3421                        
  3422                    }); 
  3423                }
  3424                else
  3425                {
  3426                    stat usRenderIn formation  = 'There i s no rende r status i nformation  available ';
  3427                    stat usViewerIn formation  = 'There i s no viewe r status i nformation  available ';
  3428                }
  3429                $('#dash board-stat us-viewer- table-body ').append( statusView erInformat ion);  
  3430                $('#dash board-stat us-render- table-body ').append( statusRend erInformat ion);    
  3431           }
  3432       });
  3433   }
  3434  
  3435   /**
  3436    * Display  dashboard  menu base d on hide  and show a ction
  3437    **/
  3438   function h ideAndShow TopMenu()
  3439   {
  3440       $('#da shboard-lo gin').hide ();
  3441       $('#da shboard-ho me').hide( ); 
  3442       $('#da shboard-lo g-home').h ide();
  3443       $('#da shboard-se arch-home' ).hide();
  3444       $('#da shboard-ca che-home') .hide();
  3445       $('#da shboard-sy stem-prefe rence-home ').hide();
  3446       $('#da shboard-to pmenu-logi n').hide() ;
  3447       $('#da shboard-st atus-home' ).hide();
  3448       
  3449       
  3450       $('#da shboard-to pmenu-logs -home').hi de();
  3451       $('#da hsboard-to pmenu-home -nav').hid e();
  3452       $('#da shboard-to pmenu-sear ch-home'). hide();
  3453       $('#da shboard-to pmenu-cach e-home').h ide();
  3454       $('#da shboard-to pmenu-syst em-prefere nce-home') .hide();
  3455       $('#da shboard-to pmenu-stat us-home'). hide();
  3456   }
  3457  
  3458   /**
  3459    * Check t he if a va lue is nul l or undef ined
  3460    **/
  3461   function i sNullOrUnd efined(obj
  3462   {
  3463       if (ob j === unde fined || o bj === nul l) 
  3464       {
  3465           re turn true;
  3466       }
  3467       return  false;
  3468   }
  3469  
  3470   /**
  3471    * Convert  the xml t ext into j son value
  3472    **/
  3473   function x mlToJson(x ml) 
  3474   {
  3475       // Cre ate the re turn objec t
  3476       var ob j = {};
  3477  
  3478       if (xm l.nodeType  == 1) 
  3479       { // e lement
  3480           //  do attrib utes
  3481           if  (xml.attr ibutes.len gth > 0) 
  3482           {
  3483                obj["att ributes"]  = {};
  3484                for (var  j = 0; j  < xml.attr ibutes.len gth; j++) 
  3485                {
  3486                    var  attribute  = xml.attr ibutes.ite m(j);
  3487                    obj[ "attribute s"][attrib ute.nodeNa me] = attr ibute.node Value;
  3488                }
  3489           }
  3490       }
  3491       else i f (xml.nod eType == 3
  3492       { // t ext
  3493           ob j = xml.no deValue;
  3494       }
  3495  
  3496       // do  children
  3497       // If  just one t ext node i nside
  3498       if (xm l.hasChild Nodes() &&  xml.child Nodes.leng th === 1 & & xml.chil dNodes[0]. nodeType = == 3) 
  3499       {
  3500           ob j = xml.ch ildNodes[0 ].nodeValu e;
  3501       }
  3502       else i f (xml.has ChildNodes ()) 
  3503       {
  3504           fo r(var i =  0; i < xml .childNode s.length;  i++)
  3505           {
  3506                var item  = xml.chi ldNodes.it em(i);
  3507                var node Name = ite m.nodeName ;
  3508                if(nodeN ame != "#c omment") 
  3509                {
  3510                    if ( typeof(obj [nodeName] ) == "unde fined") 
  3511                    {
  3512                         obj[nodeNa me] = xmlT oJson(item );
  3513                    } 
  3514                    else
  3515                    {
  3516                         if (typeof (obj[nodeN ame].push)  == "undef ined") 
  3517                         {
  3518                             var ol d = obj[no deName];
  3519                             obj[no deName] =  [];
  3520                             obj[no deName].pu sh(old);
  3521                         }
  3522                         obj[nodeNa me].push(x mlToJson(i tem));
  3523                    }
  3524                }
  3525           }
  3526       }
  3527  
  3528       return  obj;
  3529   }
  3530  
  3531   /**
  3532    * Get the  value as  JSON Forma te by pass ing the pa ram
  3533    **/
  3534   function g etJson(par am) {
  3535       try
  3536       {
  3537           va r formatte dParams =  {};
  3538           va r params =  JSON.pars e(param);
  3539           $. each(param s, functio n(key, val ue) {
  3540                if(Objec t.prototyp e.toString .call(valu e) == '[ob ject Strin g]') {
  3541                    if(v alue.start sWith("[{" ) || value .startsWit h("{")) {
  3542                         formattedP arams [key ] = getJso n(value);
  3543                    } el se if(valu e.startsWi th("<")) {
  3544                         value = va lue.replac e('<!--',  '<');
  3545                         value = va lue.replac e('?-->',  '?>');
  3546                         value = va lue.replac e(new RegE xp('<img>' , 'g'), '' );
  3547  
  3548                         var xmlDoc ;
  3549                         if (window .DOMParser ) {
  3550                             var pa rser = new  DOMParser ();
  3551                             xmlDoc  = parser. parseFromS tring(valu e,"text/xm l");
  3552                             xmlCon tent = new  XMLSerial izer().ser ializeToSt ring(xmlDo c);
  3553                         } else {
  3554                             xmlDoc  = new Act iveXObject ("Microsof t.XMLDOM") ;
  3555                             xmlDoc .async = f alse;
  3556                             xmlDoc .loadXML(v alue);
  3557                         }
  3558  
  3559                         formattedP arams [key ] = getJso n(JSON.str ingify(xml ToJson(xml Doc)));
  3560                    } el se {
  3561                         formattedP arams [key ] = value;
  3562                    }
  3563                } else i f(Object.p rototype.t oString.ca ll(value)  == '[objec t Object]' ) {
  3564                    form attedParam s [key] =  getJson(JS ON.stringi fy(value)) ;
  3565                } else i f(Object.p rototype.t oString.ca ll(value)  == '[objec t Array]')  {
  3566                    valu e.forEach( function(i tem, index ) {
  3567                         if(Object. prototype. toString.c all(item)  == '[objec t Object]' )
  3568                         {
  3569                             value[ index] = g etJson(JSO N.stringif y(item));
  3570                         }
  3571                    });
  3572                    form attedParam s [key] =  value;
  3573                } else {
  3574                    form attedParam s [key] =  value;
  3575                }
  3576           }) ;
  3577  
  3578           re turn forma ttedParams ;
  3579       }
  3580       catch( e)
  3581       { }
  3582  
  3583       return  param;
  3584   }
  3585  
  3586   /**
  3587    * Is dirt y check
  3588    * @param  {Type} cur rentActive Tab - Spec ifies the  current pr eference t ab
  3589    */ 
  3590   function i sDirty(cur rentActive Tab) {
  3591       try {
  3592           va r previous ActiveTab  = $(".tab- active")[0 ].id;
  3593           if (previousA ctiveTab ! == "disPre fActive")  {
  3594                if(dicom Viewer.sys temPrefere nces.sanit yCheck(get ActiveTabP reference( ))) {
  3595                    $("# preference SaveModal" ).val(curr entActiveT ab);
  3596                    $('# preference SaveModal' ).modal();
  3597                } else {
  3598                    sele ctPreferen ces(curren tActiveTab );
  3599                }
  3600           }  else {
  3601                selectPr eferences( currentAct iveTab);
  3602           }
  3603       }
  3604       catch( e)
  3605       { }
  3606   }
  3607  
  3608   /**
  3609    * Get the  active ta b preferen ce
  3610    * @param  {Type}  
  3611    */ 
  3612   function g etActiveTa bPreferenc e() {
  3613       try {
  3614           va r activePr efTab = $( ".tab-acti ve")[0].id ;
  3615           va r preferen ce;
  3616           sw itch(activ ePrefTab)  {
  3617                case "ci nePrefActi ve":
  3618                    pref erence = " cine";
  3619                    brea k;
  3620                case "ec gPrefActiv e":
  3621                    pref erence = " ecg";
  3622                    brea k;
  3623                case "an notaPrefAc tive":
  3624                    pref erence = " annotation ";
  3625                    brea k;
  3626                case "di sPrefActiv e":
  3627                    pref erence = " display";
  3628                    brea k;
  3629                case "co pyPrefActi ve":
  3630                    pref erence = " copyattrib utes";
  3631                    brea k;
  3632                case "lo gPrefActiv e":
  3633                    pref erence = " log";
  3634                    brea k;
  3635           }
  3636  
  3637           re turn prefe rence;
  3638       }
  3639       catch( e)
  3640       { }
  3641   }
  3642  
  3643   /**
  3644    * Apply t he changes
  3645    * @param  {Type}  
  3646    */ 
  3647   function a pplyChange s() {
  3648       var ac tivePrefTa b = getAct iveTabPref erence();
  3649       if(act ivePrefTab  == "cine" ) {
  3650           if (!dicomVie wer.system Preference s.isValidC inePrefere nce(active PrefTab))  {
  3651                dicomVie wer.system Preference s.resetPre ferenceVal ues(active PrefTab);
  3652                $("#pref erenceSave Modal").mo dal('hide' );
  3653                selectPr eferences( $("#prefer enceSaveMo dal").val( ));
  3654                return;
  3655           }
  3656       } else  if(active PrefTab ==  "annotati on") {
  3657           if (!dicomVie wer.system Preference s.isValidA nnotationP reference( activePref Tab)) {
  3658                dicomVie wer.system Preference s.resetPre ferenceVal ues(active PrefTab);
  3659                $("#pref erenceSave Modal").mo dal('hide' );
  3660                selectPr eferences( $("#prefer enceSaveMo dal").val( ));
  3661                return;
  3662           }
  3663       }
  3664       dicomV iewer.syst emPreferen ces.onSubm it(activeP refTab);
  3665       $("#pr eferenceSa veModal"). modal('hid e');
  3666       select Preference s($("#pref erenceSave Modal").va l());
  3667   }
  3668  
  3669   /**
  3670    * Revert  the change s
  3671    * @param  {Type}  
  3672    */ 
  3673   function r evertChang es() {
  3674       dicomV iewer.syst emPreferen ces.resetP referenceV alues(getA ctiveTabPr eference() );
  3675       select Preference s($("#pref erenceSave Modal").va l());
  3676   }
  3677  
  3678   /**
  3679    * Select  the prefer ences
  3680    * @param  {Type} act ivePrefTab  - Specifi es the act ive prefer ence tab
  3681    */ 
  3682   function s electPrefe rences(act ivePrefTab ) {
  3683       try {
  3684           sw itch(activ ePrefTab)  {
  3685                case "ci nePrefActi ve":
  3686                    disp layCinePre ferences() ;
  3687                    brea k;
  3688                case "ec gPrefActiv e":
  3689                    disp layEcgPref erences();
  3690                    brea k;
  3691                case "an notaPrefAc tive":
  3692                    disp layAnnotat ionPrefere nces();
  3693                    brea k;
  3694                case "di sPrefActiv e":
  3695                    disp layLayoutP references ();
  3696                    brea k;
  3697                case "co pyPrefActi ve":
  3698                    disp layCopyAtt ributePref erences();
  3699                    brea k;
  3700                case "lo gPrefActiv e":
  3701                    disp layLogPref erences();
  3702                    brea k;
  3703           }
  3704       }
  3705       catch( e)
  3706       { }
  3707   }
  3708  
  3709   /**
  3710    * Display  the prefe rences
  3711    * @param  {Type} act ivePrefTab  - Specifi es the act ive prefer ence tab
  3712    */ 
  3713   function d isplayPref erences(ac tivePrefTa b) {
  3714       try {
  3715           $( "#Preferen ceAlert"). html("");
  3716           $( "#Preferen ceAlert"). hide();
  3717           $( "#Annotati onPreferen ceAlert"). html("");
  3718           $( "#Annotati onPreferen ceAlert"). hide();
  3719           va r aPrefere nceType =  getActiveT abPreferen ce();
  3720           if ( $.inArra y(aPrefere nceType, p referenceT ype) != -1 ) {
  3721                isDirty( activePref Tab);
  3722           }  else {
  3723                selectPr eferences( activePref Tab);
  3724           }
  3725       }
  3726       catch( e)
  3727       { }
  3728   }
  3729