Page MenuHomec4science

branch-ul.component.ts
No OneTemporary

File Metadata

Created
Mon, Jun 30, 08:02

branch-ul.component.ts

import { Component, OnInit } from '@angular/core';
import 'jquery-ui/ui/widgets/sortable';
import * as $ from 'jquery';
import { Router } from '@angular/router';
import { Hl } from '../hl';
import { Title } from '@angular/platform-browser';
@Component({
selector: 'app-branch-ul',
templateUrl: './branch-ul.component.html',
styleUrls: ['./branch-ul.component.css']
})
export class BranchUlComponent implements OnInit {
firstObj: String;
firstObj_full: String;
firstObj_best: Number;
firstObj_worst: Number;
firstObj_unit: String;
secondObj : String;
secondObj_full : String;
secondObj_best : Number;
secondObj_worst : Number;
secondObj_unit: String;
thirdObj : String;
thirdObj_full : String;
thirdObj_best : Number;
thirdObj_worst : Number;
thirdObj_unit : String;
forthObj : String;
forthObj_full : String;
forthObj_best : Number;
forthObj_worst : Number;
forthObj_unit : String;
constructor(private router: Router, private hl: Hl, private title: Title) { }
nextrate(){
var itemOrder = $('#sortable').sortable("toArray");
// console.log(itemOrder);
// Save data to sessionStorage
sessionStorage.setItem('branchul', JSON.stringify(itemOrder));
// Get saved data from sessionStorage
//var data = sessionStorage.getItem('key');
var data1 = JSON.parse(sessionStorage.getItem('branch1'));
var data2 = JSON.parse(sessionStorage.getItem('branch2'));
var data3 = JSON.parse(sessionStorage.getItem('branch3'));
var data4 = JSON.parse(sessionStorage.getItem('branch4'));
var item = [];
if (data1[0] == String(this.hl.heirarchyList[0].objName)){
item.push("0");
}else{
item.push("1");
}
if (data2[0] == String(this.hl.heirarchyList[2].objName)){
item.push("2");
}else if(data2[0] == String(this.hl.heirarchyList[3].objName)){
item.push("3");
}else{
item.push("4");
}
if (data3[0] == String(this.hl.heirarchyList[5].objName)){
item.push("5");
}else if(data3[0] == String(this.hl.heirarchyList[6].objName)){
item.push("6");
}else{
item.push("7");
}
if (data4[0] == String(this.hl.heirarchyList[8].objName)){
item.push("8");
}else{
item.push("9");
}
sessionStorage.setItem('branchulhigh', JSON.stringify(item));
this.router.navigateByUrl('/survey-v1/branch-ul/rate');
}
ngOnInit() {
this.title.setTitle('Survey v1');
var data1 = JSON.parse(sessionStorage.getItem('branch1'));
var data2 = JSON.parse(sessionStorage.getItem('branch2'));
var data3 = JSON.parse(sessionStorage.getItem('branch3'));
var data4 = JSON.parse(sessionStorage.getItem('branch4'));
if (data1[0] == String(this.hl.heirarchyList[0].objName)){
this.firstObj = this.hl.heirarchyList[0].objName;
this.firstObj_full = this.hl.heirarchyList[0].objFull;
this.firstObj_best = this.hl.heirarchyList[0].best;
this.firstObj_worst = this.hl.heirarchyList[0].worst;
this.firstObj_unit = this.hl.heirarchyList[0].unit;
}else{
this.firstObj = this.hl.heirarchyList[1].objName;
this.firstObj_full = this.hl.heirarchyList[1].objFull;
this.firstObj_best = this.hl.heirarchyList[1].best;
this.firstObj_worst = this.hl.heirarchyList[1].worst;
this.firstObj_unit = this.hl.heirarchyList[1].unit;
}
if (data2[0] == String(this.hl.heirarchyList[2].objName)){
this.secondObj = this.hl.heirarchyList[2].objName;
this.secondObj_full = this.hl.heirarchyList[2].objFull;
this.secondObj_best = this.hl.heirarchyList[2].best;
this.secondObj_worst = this.hl.heirarchyList[2].worst;
this.secondObj_unit = this.hl.heirarchyList[2].unit;
}
else if(data2[0] == String(this.hl.heirarchyList[3].objName)){
this.secondObj = this.hl.heirarchyList[3].objName;
this.secondObj_full = this.hl.heirarchyList[3].objFull;
this.secondObj_best = this.hl.heirarchyList[3].best;
this.secondObj_worst = this.hl.heirarchyList[3].worst;
this.secondObj_unit = this.hl.heirarchyList[3].unit;
}else{
this.secondObj = this.hl.heirarchyList[4].objName;
this.secondObj_full = this.hl.heirarchyList[4].objFull;
this.secondObj_best = this.hl.heirarchyList[4].best;
this.secondObj_worst = this.hl.heirarchyList[4].worst;
this.secondObj_unit = this.hl.heirarchyList[4].unit;
}
if (data3[0] == String(this.hl.heirarchyList[5].objName)){
this.thirdObj = this.hl.heirarchyList[5].objName;
this.thirdObj_full = this.hl.heirarchyList[5].objFull;
this.thirdObj_best = this.hl.heirarchyList[5].best;
this.thirdObj_worst = this.hl.heirarchyList[5].worst;
this.thirdObj_unit = this.hl.heirarchyList[5].unit;
}else if(data3[0] == String(this.hl.heirarchyList[6].objName)){
this.thirdObj = this.hl.heirarchyList[6].objName;
this.thirdObj_full = this.hl.heirarchyList[6].objFull;
this.thirdObj_best = this.hl.heirarchyList[6].best;
this.thirdObj_worst = this.hl.heirarchyList[6].worst;
this.thirdObj_unit = this.hl.heirarchyList[6].unit;
}else{
this.thirdObj = this.hl.heirarchyList[7].objName;
this.thirdObj_full = this.hl.heirarchyList[7].objFull;
this.thirdObj_best = this.hl.heirarchyList[7].best;
this.thirdObj_worst = this.hl.heirarchyList[7].worst;
this.thirdObj_unit = this.hl.heirarchyList[7].unit;
}
if (data4[0] == String(this.hl.heirarchyList[8].objName)){
this.forthObj = this.hl.heirarchyList[8].objName;
this.forthObj_full = this.hl.heirarchyList[8].objFull;
this.forthObj_best = this.hl.heirarchyList[8].best;
this.forthObj_worst = this.hl.heirarchyList[8].worst;
this.forthObj_unit = this.hl.heirarchyList[8].unit;
}else{
this.forthObj = this.hl.heirarchyList[9].objName;
this.forthObj_full = this.hl.heirarchyList[9].objFull;
this.forthObj_best = this.hl.heirarchyList[9].best;
this.forthObj_worst = this.hl.heirarchyList[9].worst;
this.forthObj_unit = this.hl.heirarchyList[9].unit;
}
$('#sortable').sortable();
}
}

Event Timeline