$(document).ready(function() {
    $('#id_request_div').show();
    $('#id_response_div').hide();
    $('.tabcontent').hide();
    $('#view1').show();
    $('#tab1').attr('checked', true); //No I18N

    var loadVisualizer = function() {
        var visualizerData = null;
        var viewCreationTime = null;
        var visualizerTarget = '#workspc'; //No I18N
        var visualizerMode = 'GCP_VISUALIZER_EDIT_MODE'; //No I18N
        var deployment = 'PRODUCT_DEPLOYMENT'; //No I18N
        var zoomLevel = 1;
        var viewData = null;
        var viewTitle = $('#viewTitle').val();
		
		var visualizerLeftPanelData = {
            "monitors": {
                
                "Api": {
                    "type": "Api",
                    "name": "Api",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/api.svg width='40px' height='40px'\>",
                    "displayName": "Api",
                    "classList": "Api isSmall smallnode"
                },
                "Ccm": {
                    "type": "Ccm",
                    "name": "Ccm",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/c-c-m.svg width='40px' height='40px'\>",
                    "displayName": "C c m",
                    "classList": "C-c-m isSmall smallnode"
                },
                "Cm": {
                    "type": "Cm",
                    "name": "Cm",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/c-m.svg width='40px' height='40px'\>",
                    "displayName": "C-m",
                    "classList": "C-m isSmall smallnode"
                },
                "C-role": {
                    "type": "C-role",
                    "name": "C-role",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/c-role.svg width='40px' height='40px'\>",
                    "displayName": "C-role",
                    "classList": "C-role isSmall smallnode"
                },
                "Cm": {
                    "type": "Cm",
                    "name": "Cm",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/cm.svg width='40px' height='40px'\>",
                    "displayName": "Cm",
                    "classList": "Cm isSmall smallnode"
                },
                "Controlplane": {
                    "type": "Controlplane",
                    "name": "Controlplane",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/control-plane.svg width='40px' height='40px'\>",
                    "displayName": "Control plane",
                    "classList": "Control-plane isSmall smallnode"
                },
                "Crb": {
                    "type": "Crb",
                    "name": "Crb",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/crb.svg width='40px' height='40px'\>",
                    "displayName": "Crb",
                    "classList": "Crb isSmall smallnode"
                },
                "Crd": {
                    "type": "Crd",
                    "name": "Crd",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/crd.svg width='40px' height='40px'\>",
                    "displayName": "Crd",
                    "classList": "Crd isSmall smallnode"
                },
                "Cronjob": {
                    "type": "Cronjob",
                    "name": "Cronjob",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/cronjob.svg width='40px' height='40px'\>",
                    "displayName": "Cronjob",
                    "classList": "Cronjob isSmall smallnode"
                },
                "Deploy": {
                    "type": "Deploy",
                    "name": "Deploy",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/deploy.svg width='40px' height='40px'\>",
                    "displayName": "Deploy",
                    "classList": "Deploy isSmall smallnode"
                },
                "Ds": {
                    "type": "Ds",
                    "name": "Ds",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/ds.svg width='40px' height='40px'\>",
                    "displayName": "Ds",
                    "classList": "Ds isSmall smallnode"
                },
                "Ep": {
                    "type": "Ep",
                    "name": "Ep",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/ep.svg width='40px' height='40px'\>",
                    "displayName": "Ep",
                    "classList": "Ep isSmall smallnode"
                },
                "Etcd": {
                    "type": "Etcd",
                    "name": "Etcd",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/etcd.svg width='40px' height='40px'\>",
                    "displayName": "Etcd",
                    "classList": "Etcd isSmall smallnode"
                },
                "Group": {
                    "type": "Group",
                    "name": "Group",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/group.svg width='40px' height='40px'\>",
                    "displayName": "Group",
                    "classList": "Group isSmall smallnode"
                },
                "Hpa": {
                    "type": "Hpa",
                    "name": "Hpa",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/hpa.svg width='40px' height='40px'\>",
                    "displayName": "Hpa",
                    "classList": "Hpa isSmall smallnode"
                },
                "Ing": {
                    "type": "Ing",
                    "name": "Ing",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/ing.svg width='40px' height='40px'\>",
                    "displayName": "Ing",
                    "classList": "Ing isSmall smallnode"
                },
                "Job": {
                    "type": "Job",
                    "name": "Job",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/job.svg width='40px' height='40px'\>",
                    "displayName": "Job",
                    "classList": "Job isSmall smallnode"
                },
                "Kproxy": {
                    "type": "Kproxy",
                    "name": "Kproxy",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/k-proxy.svg width='40px' height='40px'\>",
                    "displayName": "K-proxy",
                    "classList": "K-proxy isSmall smallnode"
                },
                "Kubelet": {
                    "type": "Kubelet",
                    "name": "Kubelet",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/kubelet.svg width='40px' height='40px'\>",
                    "displayName": "Kubelet",
                    "classList": "Kubelet isSmall smallnode"
                },
                "Limits": {
                    "type": "Limits",
                    "name": "Limits",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/limits.svg width='40px' height='40px'\>",
                    "displayName": "Limits",
                    "classList": "Limits isSmall smallnode"
                },
                "Netpol": {
                    "type": "Netpol",
                    "name": "Netpol",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/netpol.svg width='40px' height='40px'\>",
                    "displayName": "Netpol",
                    "classList": "Netpol isSmall smallnode"
                },
                "Node": {
                    "type": "Node",
                    "name": "Node",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/node.svg width='40px' height='40px'\>",
                    "displayName": "Node",
                    "classList": "Node isSmall smallnode"
                },
                "Ns": {
                    "type": "Ns",
                    "name": "Ns",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/ns.svg width='40px' height='40px'\>",
                    "displayName": "Ns",
                    "classList": "Ns isSmall smallnode"
                },
                "Pod": {
                    "type": "Pod",
                    "name": "Pod",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/pod.svg width='40px' height='40px'\>",
                    "displayName": "Pod",
                    "classList": "Pod isSmall smallnode"
                },
                "Psp": {
                    "type": "Psp",
                    "name": "Psp",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/psp.svg width='40px' height='40px'\>",
                    "displayName": "Psp",
                    "classList": "Psp isSmall smallnode"
                },
                "Pv": {
                    "type": "Pv",
                    "name": "Pv",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/pv.svg width='40px' height='40px'\>",
                    "displayName": "Pv",
                    "classList": "Pv isSmall smallnode"
                },
                "Pvc": {
                    "type": "Pvc",
                    "name": "Pvc",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/pvc.svg width='40px' height='40px'\>",
                    "displayName": "Pvc",
                    "classList": "Pvc isSmall smallnode"
                },
                "Quota": {
                    "type": "Quota",
                    "name": "Quota",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/quota.svg width='40px' height='40px'\>",
                    "displayName": "Quota",
                    "classList": "Quota isSmall smallnode"
                },
                "Rb": {
                    "type": "Rb",
                    "name": "Rb",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/rb.svg width='40px' height='40px'\>",
                    "displayName": "Rb",
                    "classList": "Rb isSmall smallnode"
                },
                "Role": {
                    "type": "Role",
                    "name": "Role",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/role.svg width='40px' height='40px'\>",
                    "displayName": "Role",
                    "classList": "Role isSmall smallnode"
                },
                "Rs": {
                    "type": "Rs",
                    "name": "Rs",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/rs.svg width='40px' height='40px'\>",
                    "displayName": "Rs",
                    "classList": "Rs isSmall smallnode"
                },
                "Sa": {
                    "type": "Sa",
                    "name": "Sa",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/sa.svg width='40px' height='40px'\>",
                    "displayName": "Sa",
                    "classList": "Sa isSmall smallnode"
                },
                "Sc": {
                    "type": "Sc",
                    "name": "Sc",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/sc.svg width='40px' height='40px'\>",
                    "displayName": "Sc",
                    "classList": "Sc isSmall smallnode"
                },
                "Sched": {
                    "type": "Sched",
                    "name": "Sched",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/sched.svg width='40px' height='40px'\>",
                    "displayName": "Sched",
                    "classList": "Sched isSmall smallnode"
                },
                "Secret": {
                    "type": "Secret",
                    "name": "Secret",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/secret.svg width='40px' height='40px'\>",
                    "displayName": "Secret",
                    "classList": "Secret isSmall smallnode"
                },
                "Sts": {
                    "type": "Sts",
                    "name": "Sts",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/sts.svg width='40px' height='40px'\>",
                    "displayName": "Sts",
                    "classList": "Sts isSmall smallnode"
                },
                "Svc": {
                    "type": "Svc",
                    "name": "Svc",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/svc.svg width='40px' height='40px'\>",
                    "displayName": "Svc",
                    "classList": "Svc isSmall smallnode"
                },
                "User": {
                    "type": "User",
                    "name": "User",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/user.svg width='40px' height='40px'\>",
                    "displayName": "User",
                    "classList": "User isSmall smallnode"
                },
                "Vol": {
                    "type": "Vol",
                    "name": "Vol",
                    "class": " drag-source ",
                    "svg": "<img src=" +imagesUrl+"tools/kubernetes/vol.svg width='40px' height='40px'\>",
                    "displayName": "Vol",
                    "classList": "Vol isSmall smallnode"
                }
            },
            "monitor_groups": {}
        };
		
		
        if (visualizerData) {
            viewData = visualizerData.viewData;
            viewTitle = visualizerData.viewTitle;
            if (visualizerData.zoomLevel) {
                zoomLevel = visualizerData.zoomLevel;
            }
            if (visualizerData.viewTitle) {
                viewTitle = visualizerData.viewTitle;
                $('#viewTitle').val(viewTitle);
            }

        } else {

            viewData = {
                "view": {
                    "DC1": {
                        "css": {
                            "top": "auto",
                            "left": "auto",
                            "position": "relative",
                            "float": "none",
                            "width": "100000px",
                            "height": "100000px"
                        },
                        "connections": [],
                        "className": "DataCenter",
                        "id": "DC1",
                        "data": {
                            "state": "up",
                            "rtime": "0.25ms",
                            "dn": "",
                            "tt": "NA"
                        },
                        "droppableId": null
                    }
                },
                "viewOrder": ["DC1"]
            }; //No I18N
        }
        Visualizer.init(visualizerTarget, viewData, visualizerLeftPanelData, visualizerMode, deployment, viewCreationTime, viewTitle);

        ZoomUtil.init('.drawBoard', zoomLevel); //No I18N

         var items = $('.inWS',$('#workspc'));

              for(var l=0;l<items.length;l++)
              {
                  var $node = $(items[l]);
                  if(l==0){
                      continue;
                  }
                  var nodename = $node.attr("id").split('_')[0];
                  var nodeId = $node.attr("id");
                  classNames = Visualizer.nodeList[nodename].class;
                  var Iconcontent = '<div class="'+ classNames +'"><span class="path1"></span><span class="path2"></span><span class="path3"></span><span class="path4"></span><span class="path5"></span><span class="path6"></span></div> <div class="close" data-toggle="tooltip" title="Remove Node"><span class="icon-cross"></span></div>';
                  $node.append(Iconcontent);

              }
    }();
});