<!DOCTYPE html>
<html lang="en" ng-app="appice" xmlns:ng="http://angularjs.org" id="ng-app">
<!--<![endif]-->
<head>
	<meta charset="utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<link rel="shortcut icon" href="assets/img/icon-title.png" type="image/png">
	<title> <%= serverName %> | Dashboard</title>
	<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
	<meta content="appICE-User Details Page" name="description" />
	<meta content="Semusi Technologies Private Limited" name="author" />

	<style>
		.fa-2x {
			font-size: 1em !important;
		}
		a{
			cursor: pointer;
		}
	</style>
	<!-- ================== Begin PreLoaded JS and CSS ================== -->
	
	<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700" crossorigin="anonymous">
	<link href="<%= cdnUrl %>/assets/bundle/plugins/css/global-libs.css" rel="stylesheet"/>
	 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css" integrity="sha256-VBrFgheoreGl4pKmWgZh3J23pJrhNlSUOBek+8Z2Gv0=" crossorigin="anonymous">
	<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/bundle/plugins/global-libs.js"></script>
	<script nonce="<%=nonce%>" type="text/javascript" src="<%= cdnUrl %>/scripts/angular-module.js"></script>
	<script nonce="<%=nonce%>" language="javascript" type="text/javascript" src="/javascripts/utils/appiceEncode.js"></script>
	<script nonce="<%=nonce%>" language="javascript" type="text/javascript" src="/javascripts/utils/appiceRandom.js"></script>
	<script nonce="<%=nonce%>" src="assets/plugins/jquery/sha256.min.js"></script>

	<!-- ================== END PreLoaded JS and CSS ================== -->
	<%if(action=='aud' || action=='funnels' || action == 'insideapp'){%>
		<link href="/assets/plugins/select2/select2.css" rel="stylesheet" />
		<link href="<%= cdnUrl %>/assets/plugins/dropdownchecklist/multiple-select.css" rel="stylesheet">
		<link href="<%= cdnUrl %>/assets/plugins/bootstrap-datepicker/css/datepicker.css" rel="stylesheet" />
	<link rel="stylesheet" href="<%= cdnUrl %>/assets/plugins/bootstrap-multiselect/bootstrap-multiselect.css" integrity="sha256-7stu7f6AB+1rx5IqD8I+XuIcK4gSnpeGeSjqsODU+Rk=" crossorigin="anonymous">
	<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/bootstrap-multiselect/bootstrap-multiselect.min.js" integrity="sha256-qoj3D1oB1r2TAdqKTYuWObh01rIVC1Gmw9vWp1+q5xw=" crossorigin="anonymous"></script>
	<%}%>
	<%if(action == 'audiencesegment' ||  action =='push' || action=="campaigns" || action=="camp" || action=="transactionalCampaigns"){%>
	<!-- ================== BEGIN PAGE LEVEL STYLE for Audience Segments================== -->
	<link href="<%= cdnUrl %>/assets/plugins/bootstrap-wizard/css/bwizard.min.css" rel="stylesheet" />
	<link href="<%= cdnUrl %>/assets/plugins/bootstrap-datepicker/css/datepicker.css" rel="stylesheet" />
	<link href="<%= cdnUrl %>/assets/plugins/DataTables/css/data-table.css" rel="stylesheet" />
	<link href="<%= cdnUrl %>/assets/plugins/bootstrap-switch/css/bootstrap-switch.css" rel="stylesheet">
	<link href="assets/css/campaigns.css" rel="stylesheet">
	<link href="<%= cdnUrl %>/assets/plugins/bootstrap-daterangepicker/daterangepicker-bs3.css" rel="stylesheet">

	<!-- ================== END PAGE LEVEL STYLE ================== -->
	<%}%>
	<!-- <%if(action=="sessionSetting"){%>
		 ================== BEGIN PAGE LEVEL STYLE for Audience Segments================== 
		<link href="<%= cdnUrl %>/assets/plugins/DataTables/css/data-table.css" rel="stylesheet" />
		<link href="<%= cdnUrl %>/assets/plugins/bootstrap-sweetalert/sweetalert.css" rel="stylesheet">
		 ================== END PAGE LEVEL STYLE ================== 
	<%}%> -->
	<%if(action=="displaypref"){%>
		<link rel="stylesheet" href="/assets/css/displaypref.css">
	<%}%>
	<%if(action == 'createAudSegment' || action == 'editSegment'){%>
		<link rel="stylesheet" href="<%= cdnUrl %>/assets/plugins/ionicons/css/ionicons.min.css">
		<link href="<%= cdnUrl %>/assets/plugins/bootstrap-tagsinput/bootstrap-tagsinput.css" rel="stylesheet">
		<link href="<%= cdnUrl %>/assets/plugins/jquery-tag-it/css/jquery.tagit.css" rel="stylesheet">
	<%}%>
	<%if(action == 'otherapps'){%>
		<link href="<%= cdnUrl %>/assets/plugins/bootstrap-daterangepicker/daterangepicker-bs3.css" rel="stylesheet">
	<%}%>
	<% if(action=="camp") { %>
		<link href="/assets/plugins/select2/select2.css" rel="stylesheet" />
		<link href="<%= cdnUrl %>/assets/plugins/bootstrap-wizard/css/bwizard.min.css" rel="stylesheet" />
		<link href="<%= cdnUrl %>/assets/plugins/bootstrap-switch/css/bootstrap-switch.css" rel="stylesheet">
		<link href="<%= cdnUrl %>/assets/plugins/bootstrap-datepicker/css/datepicker.css" rel="stylesheet" />
		<link href="<%= cdnUrl %>/assets/plugins/DataTables/css/data-table.css" rel="stylesheet" />
		<link href="/assets/plugins/editor/jquery-te-1.4.0.css" rel="stylesheet" />
		<link href="assets/css/campaigns.css" rel="stylesheet">
	<% } %>
	<% if(action=="createchatbot" || action == 'insides' || action=="transactionalCampaigns") { %>
		<link href="<%= cdnUrl %>/assets/plugins/bootstrap-datepicker/css/datepicker.css" rel="stylesheet" />
		<link href="<%= cdnUrl %>/assets/plugins/bootstrap-switch/css/bootstrap-switch.css" rel="stylesheet">
		<link rel="stylesheet" type="text/css" href="/assets/plugins/cohort/cohort.min.css" />
		<link href="<%= cdnUrl %>/assets/plugins/bootstrap-daterangepicker/daterangepicker-bs3.css" rel="stylesheet">
		<link href="<%= cdnUrl %>/assets/plugins/bootstrap-wizard/css/bwizard.min.css" rel="stylesheet" />
		<link href="<%= cdnUrl %>/assets/plugins/DataTables/css/data-table.css" rel="stylesheet" />
	<% } %>
	<%if(action == 'allusers' ||  action=='uploads' || action =='push' || action == 'appsetting'){%>
		<link href="<%= cdnUrl %>/assets/plugins/bootstrap-switch/css/bootstrap-switch.css" rel="stylesheet">
		<link rel="stylesheet" href="<%= cdnUrl %>/assets/plugins/DataTables/css/jquery.dataTables.min.css">
		<link rel="stylesheet" href="<%= cdnUrl %>/assets/plugins/ionicons/css/ionicons.min.css">
	<%}%>
	<%if(action == 'olduninstalls'){%>
		<link href="<%= cdnUrl %>/assets/plugins/bootstrap-switch/css/bootstrap-switch.css" rel="stylesheet">
	<%}%>

	<%if(action=='usage' ){%>
		<link href="<%= cdnUrl %>/assets/plugins/bootstrap-daterangepicker/daterangepicker-bs3.css" rel="stylesheet">
		<link href="<%= cdnUrl %>/assets/plugins/bootstrap-switch/css/bootstrap-switch.css" rel="stylesheet">
		<link rel="stylesheet" href="<%= cdnUrl %>/assets/plugins/DataTables/css/jquery.dataTables.min.css">
		<link href="<%= cdnUrl %>/assets/plugins/DataTables/css/data-table.css" rel="stylesheet" />
	<%}%>

	<%if(action == 'customevents' || action=='aud' || action == 'insideapp'){%>
		<link href="<%= cdnUrl %>/assets/plugins/dropdownchecklist/multiple-select.css" rel="stylesheet">
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/js/chart_2.8.min.js"></script>
		<link href="<%= cdnUrl %>/assets/plugins/bootstrap-datepicker/css/datepicker.css" rel="stylesheet" />
		<link href="<%= cdnUrl %>/assets/plugins/bootstrap-daterangepicker/daterangepicker-bs3.css" rel="stylesheet">
		<link href="<%= cdnUrl %>/assets/plugins/bootstrap-switch/css/bootstrap-switch.css" rel="stylesheet">
		<link rel="stylesheet" href="<%= cdnUrl %>/assets/plugins/DataTables/css/jquery.dataTables.min.css">
		<link href="<%= cdnUrl %>/assets/plugins/bootstrap-sweetalert/sweetalert.css" rel="stylesheet">
		<style>
			.fa-arrow-up{
				color: green!important;
				font-size: 17px !important;
			}
			.fa-arrow-down{
				color: red!important;
				font-size: 17px !important;
			}
		</style>
	<%}%>
	<%if(action == 'installs' || action == 'uninstalls'){%>
	
		<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" integrity="sha256-1EoySeK+BS1oPHtY0DiQk3GZsFamMTvXrgg0KBpwotY=" crossorigin="anonymous">
		<link href="<%= cdnUrl %>/assets/anychart/fonts/css/anychart-font.min.css" rel="stylesheet" >
		<link href="<%= cdnUrl %>/assets/anychart/css/anychart-ui.min.css" rel="stylesheet" >
		<link href="<%= cdnUrl %>/assets/plugins/bootstrap-daterangepicker/daterangepicker-bs3.css" rel="stylesheet">
		<link href="<%= cdnUrl %>/assets/plugins/DataTables/css/data-table.css" rel="stylesheet" />

		<style>
			.fa-arrow-up{
				color: green!important;
				font-size: 17px !important;
			}
			.fa-arrow-down{
				color: red!important;
				font-size: 17px !important;
			}
		</style>
	<%}%>
	<%if(action=='dashboard' || action=='insight'){%>
		<link href="/assets/css/custom-dashboard.css" rel="stylesheet" id="theme" />
		<link href="/assets/bundle/plugins/css/dashboard-libs.css" rel="stylesheet" />
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/bundle/plugins/anychart+cohort-libs.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/anychart/anychart-cartesian.min.js" integrity="sha256-igUXQrtcIhmTTuVWyZ80YF48rwbwT9Z5sBebD2qcsGs=" crossorigin="anonymous"></script>
	<%}%>
	<%if(action=='createapp' || (action== false && !userOfApps.length)){%>
		<link href="<%= cdnUrl %>/assets/plugins/bootstrap-wizard/css/bwizard.min.css" rel="stylesheet" />
	<%}%>
	<%if(action == 'users'){%>
		<link href="<%= cdnUrl %>/assets/plugins/bootstrap-daterangepicker/daterangepicker-bs3.css" rel="stylesheet">
		<link href="<%= cdnUrl %>/assets/plugins/DataTables/css/data-table.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="<%= cdnUrl %>/assets/plugins/timeline/jquery.timeline.css" />
		<link rel="stylesheet" href="/assets/css/screenshot-player/devices.css">
		<link rel="stylesheet" href="/assets/css/screenshot-player/player.css">
	<%}%>
	<% if(action=="analytics" || action =="aidql") { %>
		<link href="<%= cdnUrl %>/assets/plugins/bootstrap-datepicker/css/datepicker.css" rel="stylesheet" />
		<link href="/assets/plugins/select2/select2.css" rel="stylesheet" />
		<link href="/assets/plugins/jstree-viwer/jquery.json-view.css" rel="stylesheet" type="text/css">
	<% } %>
</head>
<body>
	<style>
		#load{
		width:100%;
		height:100%;
		position:fixed;
		z-index:9999;
		/* for now no image/gif is passed  so a blackish screen will appear on loading */
		background:url("<%= cdnUrl %>/assets/img/loading-buffering.gif") no-repeat center center rgba(0,0,0,0.25)
	}
	</style>
<!-- Loader Screen -->
<div id="load" style="visibility:hidden;"></div>
<!-- PopUp Message about Session Closure --> 

<div id="logoutmodalwarning" class="modal fade"> 
	<div class="modal-dialog"> 
		<div class="modal-content"> 
			<div class="modal-header"> 
				<h5 class="modal-title">Warning</h5> 
			</div> 
			<div class="modal-body"> 
				<p>Due to inactivity. Your session will be closed in 2 minute</p> 
				<a href="dashboard"> 
					<button type="submit" class="btn btn-primary">Click Here to continue the Session</button> 
				</a> 
			</div> 
		</div> 
	</div> 
</div> 

<!-- PopUp message end -->
	 <div id="overlay"></div>
	 						  <!-- Alert Warning Box -->
	<div class="alert alert-danger fade in m-b-15" style="position:relative;z-index:1021;display:none;" id='message'>
		<strong id="messagebox"></strong>
		<span class="close" onclick="closeMessage('message');">&times;</span>
	</div>
	 									 <!-- Success Box -->
	<div class="alert alert-success fade in m-b-15" style="position:relative;z-index:1021;display:none;" id='messagesucess'>
		<strong id="messageboxsucess"></strong>
		<span class="close" onclick="closeMessage('messagesucess');">&times;</span>
	</div>
	 									 <!-- Info Box -->
	  <div class="alert alert-info fade in m-b-15" style="position:relative;z-index:1021;display:none;" id='messageInfo'>
		<strong id="messageboxInfo"></strong>
		<span class="close" >&times;</span>
	</div>
	<!-- begin #page-loader -->
	<div id="page-loader" class="fade in"><span class="spinner"></span></div>
	<!-- end #page-loader -->
	<!-- begin #page-container -->
	<div id="page-container" class="fade page-sidebar-fixed page-header-fixed">
		<!-- begin #header -->
		<div id="header" class="header navbar navbar-default navbar-fixed-top">
			<!-- begin container-fluid -->
			<div class="container-fluid">
				<!-- begin mobile sidebar expand / collapse button -->
				<div class="navbar-header">
					<a href="" class="navbar-brand"><!-- <span class="navbar-logo"></span> <%= serverName %> Admin -->
					<% if(member.email == "director@vtion.in" || member.email == "Rajshree.dave@vtion.in" || member.email == "Ritesh.dhawan@vtion.in"){ %>
						<img src="/assets/img/new-vtion.png">
					<% } else { %>
						<!-- <img src="assets/minifiedImg/Logo.png" style="width: 100px;"> -->
					<% } %>
					</a>
					<button type="button" class="navbar-toggle" data-click="sidebar-toggled">
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
					</button>
				</div>
				<!-- end mobile sidebar expand / collapse button -->
				<!-- begin header navigation right -->
				<ul class="nav navbar-nav navbar-right">
					<li class="dropdown only_app" title="Settings">
						<a class="dropdown-toggle only_app" data-toggle="dropdown" title="Settings">
							<img src="assets/minifiedImg/settings_top.svg" alt="Settings" />
						</a>
						<ul class="dropdown-menu animated fadeInLeft">
							<li name="menu-submanagemodules"><a href="dashboard?action=module#/mod/view"><span id="0018">Manage Modules</span></a></li>
							<li class="only_admin" name="menu-subusermanagement" id="user-management-menu"><a href="dashboard?action=allusers"><span id="0019">User Management</span></a></li>
							<!-- <li name="menu-subuploadtest"><a href="dashboard?action=uploadtestdata"><span id="0020">Upload Test Data</span></a></li> -->
							<li class="only_admin" name="menu-appsetting" id="show-settings-menu" ><a id="003">App Setting</a></li>
							<!-- <li name="menu-sessionsetting"><a href="dashboard?action=sessionSetting#/screenshotSettings"><span>Playback Setting</span></a></li> -->
							<li name="menu-subdisplaypref"><a href="dashboard?action=displaypref"><span id="0021">Display Preference</span></a></li>
						</ul>
					<li class="dropdown navbar-user">
						<a class="dropdown-toggle" data-toggle="dropdown">
							<img src="/users/<%=member._id%>.jpg" alt="" id="imgUserIcon" class="only_app" style="width: 30px; display:block;" />
							<span class="hidden-xs"><%if(member.full_name){%>
								<%=member.full_name%>
								<%}%>
							</span> <b class="caret"></b>
						</a>
						<ul class="dropdown-menu animated fadeInLeft">
							<li class="arrow"></li>
							<li id="editProfile"><a href="dashboard?action=profile">Edit Profile</a></li>
							<li style="display:none"><a><span class="badge badge-danger pull-right">2</span> Inbox</a></li>
							<li class="divider"></li>
							<li><a id="logout">Log Out</a></li>
						</ul>
					</li>
				</ul>
			</div>
			<!-- end container-fluid -->
		</div>
		<!-- end #header -->
	<!-- begin #sidebar -->
	<div id="sidebar" class="sidebar sidebar-container">
			<!-- begin sidebar scrollbar -->
			<div data-scrollbar="true" data-height="100%">
			<!-- begin sidebar nav -->
			<ul class="nav">
			<!-- <li class="nav-header">Navigation</li> -->
			<li <% if(action==''){ %> class="has-sub active" <% } else { %> class="has-sub" <% } %> >
			<a href="dashboard">
			<!-- <i class="fa fa-home"></i> -->
			<img src="assets/minifiedImg/home.svg" alt="Home" />
			<span>Home</span>
			</a>
			</li>
			<% displayPref.forEach(function(parent,index){ %>
			<% if(parent.id==1) { %>
			<li <% if(action=='dashboard' || action=='users'){ %> class="has-sub active" <% } else { %>
			class="has-sub" <% } %>>
			<a class="gotoDashboard">
			<!-- <i class="fa fa-laptop"></i> -->
			<img src="assets/minifiedImg/dashboard.svg" alt="Dashboard" />
			<span>Dashboard</span>
			</a>
			</li>
			<%}%>
			<% if(currentappid == "5fa41afe6fc1e678a8344311" && currentappid == "5bebe93c25d705690ffbc758") { %>
			<li <% if(action=='insight'){ %> class="has-sub active" <% } else { %>
				class="has-sub" <% } %>>
				<a href="javascript:gotoinsight();">
				<!-- <i class="fa fa-laptop"></i> -->
				<img src="assets/minifiedImg/dashboard.svg" alt="Dashboard" />
				<span>App insight</span>
				</a>
			</li>
			<% } %>
			<% if(parent.id==2) { %>
			<li id="setupApps" <% if(action=='createapp' || action=='createchatbot'){ %> class="has-sub active" <% } else { %>
			class="has-sub" <% } %>>
			<a>
			<b class="caret pull-right"></b>
			<!-- <i class="fa fa-mobile sidebar-icon-margin"></i> -->
			<img src="assets/minifiedImg/my-apps.svg" alt="Apps" />
			<span>Setup Apps</span>
			</a>
			<ul class="sub-menu">
			<% parent.nodes.forEach(function(child,index){ %>
			<% if(child.p==1) { %>
			<li name="menu-subsetupapp"><a href='dashboard?action=createapp' id="002">Setup New App</a>
			</li>
			<%}%>
			<%})%>
			</ul>
			</li>
			<%}%>
			
			<%if(parent.id == 3) { %>
			<li <% if(action=='demographics' || action=='aud'){ %> class="has-sub active only_app" <% } else { %>
			class="has-sub only_app" <% } %>>
			<a>
			<b class="caret pull-right"></b>
			<!-- <i class="fa fa-suitcase"></i> -->
			<img src="assets/minifiedImg/users.svg" alt="Users" />
			<span>Users</span>
			</a>
			<ul class="sub-menu">
			<%parent.nodes.forEach(function(child,index){ %>
			<%if(child.p == 1) { %>
			<li hidden class="demographics" name="menu-demographics"><a href="dashboard?action=demographics"
			id="005">Demographics</a></li>
			<%}%>
			<%if(child.p==2) { %>
			<li name="menu-subaudiencesegment"><a href="dashboard?action=aud#/aud/view"
			id="006">Audience segments</a></li>
			<%}%>
			<%})%>
			</ul>
			</li>
			<% } %>
			
			<% if(parent.id == 4) { %>
			
			<li <% if(action=='installs' || action=='uploads'){ %> class="has-sub active only_app" <% } else { %>
			class="has-sub only_app" <% } %>>
			<a>
			<b class="caret pull-right"></b>
			<!-- <i class="fa fa-file-o"></i> -->
			<img src="assets/minifiedImg/acquisition.svg" alt="Acquisition" />
			<span>Acquisition</span>
			</a>
			<ul class="sub-menu">
			<% parent.nodes.forEach(function(child,index) {%>
			<%if(child.p == 1) { %>
			<li name="menu-subinstalls"><a href="dashboard?action=installs" id="008">App Acquisition</a>
			</li>
			<%}%>
			<!-- <%if(child.p==2) { %>
			<li name="menu-subuploads"><a href="dashboard?action=uploads" id="009">Upload Past Data</a>
			</li>
			<%}%> -->
			<%})%>
			</ul>
			</li>
			<%}%>
			<%if(parent.id==5) {%>
			
			<li <% if(action=='insideapp' || action=='otherapps' || action ==='funnels'){ %>
			class="has-sub active only_app" <% } else { %> class="has-sub only_app" <% } %>>
			
			<a>
			<b class="caret pull-right"></b>
			<!-- <i class="fa fa-th"></i> -->
			<img src="assets/minifiedImg/activities.svg" alt="Activities" />
			<span>Activities</span>
			</a>
			
			<ul class="sub-menu">
			<%parent.nodes.forEach(function(child,index){%>
			<%if(child.p==1) { %>
			<li name="menu-subcustomevents">
				<a class="insideApp" id="0011">Inside the
							App</a>
			<ul class="sub-menu" id="insideul">
			<%child.nodes.forEach(function(subchild,index){ %>
			<%if(subchild.p==1) { %>
			<li class="usage" <% if(action ==='funnels'){ %> class="insidesList" <% } else { %>
			class="insidesList " <% } %>><a
			href="dashboard?action=usage#/usage">Usage</a></li>
			<%}%>
			<%if(subchild.p==2) { %>
			<li class="insidesList"><a href="dashboard?action=insideapp#/events">Events</a></li>
			<%}%>
			<%if(subchild.p==3) { %>
			<li <% if(action ==='funnels'){ %> class="insidesList " <% } else { %>
			class="insidesList" <% } %>><a
			href="dashboard?action=insideapp#/funnels/data">Funnels</a></li>
			<%}%>
			<!-- <%if(subchild.p==4) { %>
			<li class="insidesList"><a href="dashboard?action=insideapp#/playback">Screen
			Playback</a></li>
			<%}%> -->
			<%if(subchild.p==4) { %>
			<li id="journeynavbar" class="insidesList"><a href="dashboard?action=insideapp#/journey/table">Journeys</a>
			</li>
			<%}%>
			<% })%>
			</ul>
			</li>
			<%}%>
			<%if(child.p==2) { %>
			<li id="outsidetheapp-li" name="menu-otherapps"><a href="dashboard?action=otherapps#app/groups" id="0012">Outside
			the App</a></li>
			<%}%>
			<%})%>
			</ul>
			</li>
			<%}%>
			
			<%if(parent.id==6) {%>
			<!-- Campaings -->
			<li <% if(action=='campaigns' || action=='transactionalCampaigns' || action=='camp' || action=='utmbuilder'){ %>
			class="has-sub active only_app" <% } else { %> class="has-sub only_app" <% } %>>
			<a>
			<b class="caret pull-right"></b>
			<img src="assets/minifiedImg/engagement.svg" alt="Engagement" />
			<span>Engagement</span>
			</a>
			<ul class="sub-menu">
			<%parent.nodes.forEach(function(child,index){ %>
			<%if(child.p==1) {%>
			<li <% if(action=='campaigns' || action=='camp'){ %> class="active" <% } %>
			name="menu-subcampaigns"><a class="gotoCampaign" id="0014">Campaigns</a>
			</li>
			<%}%>
			 <%if(child.p==2) {%>
			<li hidden id="trans_camp" name="menu-subcampaignsTransitional"><a
			href="dashboard?action=transactionalCampaigns#/campaigns" id="00314">Transactional
			Campaigns</a></li>
			<%}%>	
			<%if(child.p==3) {%>
				<li hidden class="utm" name="menu-utmbuilder"><a
				href="dashboard?action=utmbuilder" id="63">UTM Builder</a></li>
				<%}%> 
			<%})%>
			
			</ul>
			</li>
			<%}%>
			<%if(parent.id==7) {%>
				<li id="churn_" class="only_app" <% if(action=='uninstalls'){ %> class="has-sub active only_app" <% } else { %> class="has-sub only_app" <% } %>>
					<a href="dashboard?action=uninstalls">
					<img src="assets/minifiedImg/uninstalls.svg" alt="Uninstalls" />
					<span>Churn</span>
			</a>
			</li>
			<%}%>
			<%if(parent.id==9) { %>
			<li id="documentation-li" class="has-sub">
			<a>
			<b class="caret pull-right"></b>
			<img src="assets/minifiedImg/documentation.svg" alt="Documentation" />
			<span>Documentation</span>
			</a>
			<ul class="sub-menu">
			<%parent.nodes.forEach(function(child,index){ %>
			<%if(child.p==1) { %>
			<li name="menu-subusermanagement"><a
			href="javascript:void(0)"
			target="new"><span id="0022">Android Studio Integration</span></a></li>
			<%}%>
			<%if(child.p==2) { %>
			<li name="menu-subuploadtest"><a
			href="javascript:void(0)"
			target="new"><span id="0023">iOS Integration</span></a></li>
			<%}%>
			<%if(child.p==3) { %>
			<li name="menu-subuploadtest"><a
			href="javascript:void(0)"
			target="new"><span id="0024">Cordova Integration</span></a></li>
			
			<%}%>
			<%if(child.p==4) { %>
			<li name="menu-subuploadtest"><a
			href="javascript:void(0)"
			target="new"><span id="0025">React Integration</span></a></li>
			
			<%}%>
			<%})%>
			</ul>
			</li>
			<%}%>
			<%if(parent.id==10) { %>
				<li class="has-sub reports only_app">
					<a>
						<b class="caret pull-right"></b>
						<img src="assets/minifiedImg/documentation.svg" alt="Documentation" />
						<span>Reports</span>
					</a>
					<ul class="sub-menu">
						<%parent.nodes.forEach(function(child,index){ %>
							<%if(child.p==1) { %>
							<li name="menu-subusermanagement">
								<a href="dashboard?action=insideapp#/jobs/export">
									<span id="101">Export</span>
								</a>
							</li>
							<%}%>
						<%})%>
					</ul>
				</li>
				<%}%>
			<% }) %>
			<!-- begin sidebar minify button -->
			<li><a class="sidebar-minify-btn" data-click="sidebar-minify"><i
			class="fa fa-angle-double-left"></i></a></li>
			<!-- end sidebar minify button -->
			</ul>
			<!-- end sidebar nav -->
			</div>
			<!-- end sidebar scrollbar -->
			</div>
    <div class="sidebar-bg"></div>
	<!-- end #sidebar -->
		<!-- begin #content -->
		<div id="content" class="content">
			<!--Create App Panel Starts here-->
			<% if( action == 'createapp' || ((!userOfApps.length) && action == false)) { %>
				<% include createapp.html %>
			<%}%>
			<!--Create App Panel Ends here-->
			<%if(action == 'profile'){%>
				<% include userprofile.html %>
			<%}%>
			<!--Dashboard showing app data starts here -->
			<%if(action=='dashboard') {%>
				<% include appdashboard.html %>
			<%}%>
			<%if(action=='insight') {%>
				<% include app-insight.html %>
			<%}%>
			<!--Dashboard showing app data ends here -->
			<!--Normal Dashboad tiled view Starts here-->
			<%if(action == false) {%>
				<% if(typeof(currentappid) == "object") { %>
						<% include myapps.html %>
				<% } %>
			<%}%>
			<!--Normal Dashboad tiled view Starts here-->
			<!-- App settings Starts here-->
			<%if(action=='appsetting'){%>
				<% var appid='';  var appkey=''; var appmode = false;%>
				<% var appiceKey = devepnukey= devcert1= devcert2= devpass1= devpass2=googleUrl=iosUrl= name=category=icon=callbackurl='', httpMethod='', webhook_installs=false,  webhook_events=false;
				var emailCfg={}, smsCfg={}, fcmCert='', fcmdb='', web_private_key='', web_public_key='', web_subject=''
				%>
					<% for (var i = 0; i < userOfApps.length; i++) { %>
					   <% if(userOfApps[i]._id== currentappid){%>
								<% if(userOfApps[i].dev_epnu_key!=null){%>
				  		 			<%  devepnukey=userOfApps[i].dev_epnu_key;%>
				   				<%}%>
				   			<% if(userOfApps[i].appiceKeys!=null){%>
				  		 			<%  appiceKey=userOfApps[i].appiceKeys;%>
				   			<%}%>
				   			<% if(userOfApps[i].dev_ios_cert1!=null){%>
									<%    devcert1=userOfApps[i].dev_ios_cert1; %>
								<%}%>
				   			<% if(userOfApps[i].dev_ios_pass1!=null){%>
									<%    devpass1=userOfApps[i].dev_ios_pass1; %>
								<%}%>
								<% if(userOfApps[i].dev_ios_cert2!=null){%>
									<%    devcert2=userOfApps[i].dev_ios_cert2; %>
								<%}%>
								<% if(userOfApps[i].dev_ios_cert3!=null){%>
									<%    devcert3=userOfApps[i].dev_ios_cert3; %>
								<%}%>
								<% if(userOfApps[i].dev_ios_keyid!=null){%>
									<%    devcert3=userOfApps[i].dev_ios_keyid; %>
								<%}%>
								<% if(userOfApps[i].dev_ios_teamid!=null){%>
									<%    devcert3=userOfApps[i].dev_ios_teamid; %>
								<%}%>
				   			<% if(userOfApps[i].dev_ios_pass2!=null){%>
									<%    devpass2=userOfApps[i].dev_ios_pass2; %>
								<%}%>
				   			<%    appid=userOfApps[i]._id; %>
				   			<%    appkey=userOfApps[i].key; %>
							<% if(userOfApps[i].googleUrl!=null){%>
								<%    googleUrl=userOfApps[i].googleUrl; %>
							<%}%>
							<% if(userOfApps[i].fcmKey_dev!=null){%>
								<%    fcmdb=userOfApps[i].fcmKey_dev; %>
							<%}%>
							<% if(userOfApps[i].fcmKey_prod!=null){%>
								<%    fcmdb=userOfApps[i].fcmKey_prod; %>
								<!-- Web push init start-->
								<%
								if(userOfApps[i].webPush_dev!=null){
									web_private_key=userOfApps[i].webPush_dev.privateKey;
									web_public_key=userOfApps[i].webPush_dev.publicKey;
									web_subject=userOfApps[i].webPush_dev.subject;
								}
								if(userOfApps[i].webPush_prod!=null){
									web_private_key=userOfApps[i].webPush_prod.privateKey;
									web_public_key=userOfApps[i].webPush_prod.publicKey;
									web_subject=userOfApps[i].webPush_prod.subject;
								}
								%>
								<!-- Web push init end-->
								<%}%>
								<% if(userOfApps[i].iosUrl!=null){%>
									<%    iosUrl=userOfApps[i].iosUrl; %>
								<%}%>
								<% if(userOfApps[i].name!=null){%>
									<%    name=userOfApps[i].name; %>
								<%}%>
								<% if(userOfApps[i].icon!=null){%>
									<%    icon=userOfApps[i].icon; %>
								<%}%>
								<% if(userOfApps[i].category!=null){%>
								<%  category=userOfApps[i].category;%>
								<%}%>
								<% if(userOfApps[i].callbackurl) { %>
								 <% callbackurl = userOfApps[i].callbackurl; %>
							 <% } %>
							 
							 <% if(userOfApps[i].url) { %>
								 <% url = userOfApps[i].url; %>
							 <% } %>
							 
							 <% if(userOfApps[i].httpMethod) { %>
								 <% httpMethod = userOfApps[i].httpMethod; %>
							 <% } %>
							 
							 <% if(userOfApps[i].partner) { %>
								 <% partner = userOfApps[i].partner; %>
							 <% } %>
							 
							 <% if(userOfApps[i].channel) { %>
								 <% channel = userOfApps[i].channel; %>
							 <% } %>
							 
							 <% if(userOfApps[i].installs) { %>
								 <% webhook_installs = userOfApps[i].installs; %>
							 <% } %>
							 
							 <% if(userOfApps[i].events) { %>
								 <% webhook_events = userOfApps[i].events; %>
							 <% } %>
							 
							 <% if(userOfApps[i].emailCfg) { %>
								 <% emailCfg = userOfApps[i].emailCfg; %>
							 <% } %>
							 
							 <% if(userOfApps[i].smsCfg) { %>
								 <% smsCfg = userOfApps[i].smsCfg; %>
							 <% } %>
							 
							 <% if(userOfApps[i].isappmodeproduction) { %>
								 <% appmode = userOfApps[i].isappmodeproduction; %>
							 <% } %>
							 
						<% }%>
				 <% }%>
				 <% include appsettings.html %>
			 <%}%>
			<!-- App settings Starts here-->
			<!--Audience segment View starts here-->
			<%if(action=='audiencesegment'){%>
	    		<% include audienceview.html %>
			<%}%>
			<!--userlist eventlit  -->
			<%if(action=='userlist'){%>
	    		<% include userlist.html %>
			<%}%>
			<!--Audience segment View starts here-->
			<%if(action=='demographics'){%>
		<% include demographics.html %>
			<%}%>
			<%if(action=='uploadtestdata') {%>
				<div class="row">
	    			 <!-- begin col-12 -->
			    <div class="col-md-12">
			        <!-- begin panel -->
                    <div class="panel panel-inverse">
                        <div class="panel-body">
                                <form id="uploadTestdata" class="form-horizontal">
                                	<div class="form-group">
                                		<label class="col-md-3 control-label" style="font-size:20px;">Choose data type </label>
					        			<div class="col-md-6">
							        		<label>
                                                <input type="radio" name="datatype" value="I" id="rdbInstallData" checked >
	                                                Insall Data
                                            </label>
                                            <label>
                                                <input type="radio" name="datatype" value="U" id="rdbUnInstallData" >
	                                                Un Install Data
                                            </label>
					  					</div>
						        	</div>
							        <div class="form-group">
										<label class="col-md-3 control-label" style="font-size:20px;">Test File </label>
					  					<div class="col-md-6">
					  						<input type="text" id="testfile" disabled="" value="" placeholder="Test File" class="form-control" autocomplete="off">
					 								</div>
					 					<div class="col-md-1">
											
										</div>
									</div>
						        </form>
						        <form id="uploadTestdata" class="form-horizontal">
							        <div class="form-group">
										<label class="col-md-3 control-label" style="font-size:20px;">APP Key  </label>
					  					<div class="col-md-6">
					  						<input type="text" id="appKey"   placeholder="App Key" class="form-control" autocomplete="off">
					 					</div>
									</div>
						        </form>
						       <button style="font-size:15px;" class="btn btn-sm btn-primary m-r-5 col-md" type="button" id="processTestData">Process Files</button>
                            </div>
                        </div>
                    </div>
                    <!-- end panel -->
                </div>
                <!-- end col-12 -->
	    		</div>
			<%}%>
			<!-- <%if(action=='sessionSetting') {%>
					<div data-ng-view></div>
			<%}%> -->
			<%if(action == "customevents"){%>
				<% include customevents.html %>
			<%}%>
			<%if(action == "insideapp"){%>
				<% include insideapp.html %>
			<%}%>
			<%if(action == "usage"){%>
				<% include insideapp.html %>
			<%}%>
			<!--Create Audience Segment section starts here-->
			<%if(action=="createAudSegment" || action == "editSegment"){%>
				<% include audience.html %>
			<%}%>
			<!--Create Audience Segment ends here-->
			<%if(action=="campaigns"){%>
				<% include campaigns.html %>
			<%}%>
			 <%if(action=="transactionalCampaigns"){%>
				<% include campaignsTrans.html %>
			<%}%> 
			<%if(action=="utmbuilder"){%>
				<% include utmbuilder.html %>
			<%}%>  
			<%if(action=="tools" || action=="campaigns"){%>
				<% include engagementtools.html %>
			<%}%>
			<!--Start of installs section -->
			<%if (action=="installs"){%>
				<% include installs.html %>
			<%}%>
			<!--end of installs section-->
			<!--Start of installs section -->
			<%if (action=="uninstalls"){%>
				<% include uninstalls.html %>
			<%}%>
			<!--end of installs section-->
			 <!-- Start of uploads section -->
			 <!-- <%if (action=="uploads"){%>
			 	<% include uploads.html %>
			 <%}%> -->
			<%if (action=="policy"){%>
				<% include privacypolicy.html %>
			<%}%>
			<%if (action=="funnels"){%>
				<div data-ng-view></div>
			<%}%>
			<%if (action=="aud"){%>
				<div data-ng-view></div>
			<%}%>
			<%if (action=="camp"){%>
				<div data-ng-view></div>
			<%}%>
			<%if (action=="module"){%>
				<div data-ng-view></div>
			<%}%>
			<%if (action=="otherapps"){%>
				<div data-ng-view></div>
			<%}%>
			<%if (action=="childapps"){%>
				<div data-ng-view></div>
			<%}%>
			<%if(action=='allusers'){%>
				<% include users.html %>
			<%}%>
			<%if(action=='addusers'){%>
				<% include addUser.html %>
			<%}%>
			<%if(action=='displaypref'){%>
				<% include displayPref.html %>
			<%}%>
			<%if(action=='users'){%>
	    		<div ng-view></div>
			<%}%>
			<%if (action=="createchatbot"){%>
				<div data-ng-view></div>
			<%}%>
			<%if (action=="insides"){%>
				<div data-ng-view></div>
			<%}%>
			<!--Start of analyse section -->
			<%if (action=="analytics"){%>
				<div data-ng-view></div>
			<%}%>
			<!--end of analyse section-->
			<!--Start of analyse section -->
			<%if (action=="aidql"){%>
				<div data-ng-view></div>
			<%}%>
			<!--end of analyse section-->
			<%if(action=="push"){%>
			   <h1 class="page-header">Push Manager<small>       Create and Push Direct Campaigns</small></h1>
			   <div class="row">
			    <!-- begin col-12 -->
			    <div class="col-md-12 ui-sortable">
			        <!-- begin panel -->
                    <div class="panel panel-inverse">
                        <div class="panel-heading">
                            <div class="panel-heading-btn">
                                <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-default" data-click="panel-expand"><i class="fa fa-expand"></i></a>
                                <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-success" data-click="panel-reload"><i class="fa fa-repeat"></i></a>
                                <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-warning" data-click="panel-collapse"><i class="fa fa-minus"></i></a>
                                <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-danger" data-click="panel-remove"><i class="fa fa-times"></i></a>
                            </div>
                            <h4 class="panel-title">Data Table - Default</h4>
                        </div>
                        <div class="panel-body">
                            <div class="table-responsive">
                                <div id="data-table_wrapper" class="dataTables_wrapper no-footer"><div class="dataTables_length" id="data-table_length"><label>Show <select name="data-table_length" aria-controls="data-table" class=""><option value="10">10</option><option value="25">25</option><option value="50">50</option><option value="100">100</option></select> entries</label></div><div id="data-table_filter" class="dataTables_filter"><label>Search:<input type="search" class="" placeholder="" aria-controls="data-table"></label></div><table id="data-table-campaigns" class="table table-striped table-bordered dataTable no-footer" role="grid" aria-describedby="data-table_info">
                                    <thead>
                                        <tr role="row"><th class="sorting_asc" tabindex="0" aria-controls="data-table" rowspan="1" colspan="1" aria-sort="ascending" aria-label="Campaign Id: activate to sort column descending" style="width: 157px;">Campaign ID</th><th class="sorting" tabindex="0" aria-controls="data-table" rowspan="1" colspan="1" aria-label="Campaign Name: activate to sort column ascending" style="width: 230px;">Campaign Name</th><th class="sorting" tabindex="0" aria-controls="data-table" rowspan="1" colspan="1" aria-label="Campaign Start Date: activate to sort column ascending" style="width: 210px;">Created At</th><th class="sorting" tabindex="0" aria-controls="data-table" rowspan="1" colspan="1" aria-label="Expiry Date: activate to sort column ascending" style="width: 133px;">Expiry Date</th><th class="sorting" tabindex="0" aria-controls="data-table" rowspan="1" colspan="1" aria-label="Status: activate to sort column ascending" style="width: 95px;">Status</th>
                                        	<th tabindex="0" aria-controls="data-table" rowspan="1" colspan="1" style="width: 95px;"></th>
                                        	<th tabindex="0" aria-controls="data-table" rowspan="1" colspan="1" style="width: 95px;"></th>
                                        	<th tabindex="0" aria-controls="data-table" rowspan="1" colspan="1" style="width: 95px;"></th>
                                        </tr>
                                    </thead>

                                    </tbody>
                                </table>
                             </div>
                            </div>
                            <a class="btn btn-primary btn-lg" style="margin-left:40%;margin-bottom:10px;" id="createCampaignBtn" href="#">Create New Campaign</a>
                        </div>
                    </div>
                    <!-- end panel -->
                </div>
                <!-- end col-12 -->
            </div>
			<!--Start of Panel for Create Campaign-->
            <div class="row" id="createCampaignDiv" style="display:none;">
			    <!-- begin col-12 -->
			    <div class="col-md-12 ui-sortable">
			        <!-- begin panel -->
                    <div class="panel panel-inverse">
                        <div class="panel-heading">
                            <div class="panel-heading-btn">
                                <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-default" data-click="panel-expand"><i class="fa fa-expand"></i></a>
                                <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-success" data-click="panel-reload"><i class="fa fa-repeat"></i></a>
                                <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-warning" data-click="panel-collapse"><i class="fa fa-minus"></i></a>
                                <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-danger" data-click="panel-remove"><i class="fa fa-times"></i></a>
                            </div>
                            <h4 class="panel-title">Create/Update a  Campaign</h4>
                        </div>
                        <div class="panel-body panel-form">
                        	<form class="form-horizontal form-bordered" data-parsley-validate="true" name="campaign-form" novalidate="">
								<div class="form-group">
									<label class="control-label col-md-4 col-sm-4" for="campaignName">Campaign Name * :</label>
									<div class="col-md-6 col-sm-6">
										<input class="form-control" type="text" id="campaignName" name="campaignName" placeholder="Required" data-parsley-required="true" data-parsley-id="6330"><ul class="parsley-errors-list" id="parsley-id-6330"></ul>
									</div>
								</div>
								<div class="form-group">
									<label class="control-label col-md-4 col-sm-4" for="campaignHeader">Header :</label>
									<div class="col-md-6 col-sm-6">
										<input class="form-control" type="text" id="campaignHeader" name="campaignHeader">
									</div>
								</div>
								<div class="form-group">
									<label class="control-label col-md-4 col-sm-4" for="campaignDesc">Description :</label>
									<div class="col-md-6 col-sm-6">
										<input class="form-control" type="text" id="campaignDesc" name="campaignDesc">
									</div>
								</div>

								<div class="form-group">
									<label class="control-label col-md-4 col-sm-4" for="campaignImg">Image :</label>
									
								</div>
								<div class="form-group">
									<label class="control-label col-md-4 col-sm-4" for="campaignExpandText">Expand Text :</label>
									<div class="col-md-6 col-sm-6">
										<input class="form-control" type="text" id="campaignExpandText" name="campaignExpandText">
									</div>
								</div>
								<div class="form-group">
									<label class="control-label col-md-4 col-sm-4" for="campaignExpandImg">Expand Image :</label>
									
								</div>
								<div class="form-group">
									<label class="control-label col-md-4 col-sm-4" for="campaignExtUrl">Ext URL/Deep Link :</label>
									<div class="col-md-6 col-sm-6">
										<input class="form-control" type="text" id="campaignExtUrl" name="campaignExtUrl">
									</div>
								</div>
								<div class="form-group">
									<label class="control-label col-md-4 col-sm-4" for="campaignExpires">Expires On :</label>
									<div class="col-md-6 col-sm-6">
										<input type="text" class="form-control" id="datepicker-default" placeholder="Select Date">
									</div>
								</div>

								<div class="form-group">
									<label class="control-label col-md-4 col-sm-4"></label>
									<div class="col-md-6 col-sm-6">
										<a class="btn btn-primary " style="margin-left:40%;margin-bottom:10px;" id="saveCampaignBtn" href="#">Save & Push</a>
									</div>
								</div>
                            </form>

                        </div>
                    </div>
                    <!-- end panel -->
                </div>
                <!-- end col-12 -->
            </div>
            <!--End of Panel for Create Campaign-->
			<%}%>
		<!-- end #content -->
		<!-- begin scroll to top btn -->
		<a href="javascript:;" class="btn btn-icon btn-circle btn-success btn-scroll-to-top fade" data-click="scroll-top"><i class="fa fa-angle-up"></i></a>
		<!-- end scroll to top btn -->
		<!-- Dialog for delete Start-->
		<div class="modal fade" id="modal-alert" aria-hidden="true" style="display: none;">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
						<h4 class="modal-title" id="dialogheader">Remove App</h4>
					</div>
					<div class="modal-body">
						<div class="alert alert-danger m-b-0">
							<h4><i class="fa fa-info-circle"></i> <span id="spanAppName"></span></h4>
							<p>Are you sure to remove this app?</p>

						</div>
					</div>
					<div class="modal-footer">
						<a class="btn btn-sm btn-white" data-dismiss="modal" style="width:15%;font-size:15px;">No</a>
						<a id="deleteApp" href="javascript:deleteApp();" class="btn btn-sm btn-danger" style="width:15%;background:#B83E3B;border-color:#B83E3B;font-size:15px;">Yes</a>
					</div>
				</div>
			</div>
		</div>
		<!-- Dialog for delete End-->
		<input type="hidden" id="hdnusremail" value="<%=member.email%>"/>
	</div>
	<!-- end page container -->
	<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/bundle/js/utils-assets.js"></script>
	<script nonce="<%=nonce%>" src="/assets/js/cookie.js"></script>
	<script nonce="<%=nonce%>" type="text/javascript" src="app/app.js"></script>
	<script nonce="<%=nonce%>" language="javascript" type="text/javascript" src="/javascripts/semusi/semusi.common.js"></script>
	<!-- show overlay -->
	<script type="text/javascript" nonce="<%=nonce%>">
		$(document).ready(function () {
			// set the user status in the common
			semusiCommon.setActiveUser({ 'ur': { admin: ("<%- JSON.parse(adminAppids) %>" != "") ? "<%- JSON.parse(adminAppids) %>".split(',') : [], manager: ("<%- JSON.parse(managerAppids) %>" != "") ? "<%- JSON.parse(managerAppids) %>".split(',') : [], marketer: ("<%- JSON.parse(marketerAppids) %>" != "") ? "<%- JSON.parse(marketerAppids) %>".split(',') : [] }, "a": "<%= member.api_key %>", "aar": (typeof "<%- member.approvedAppids %>" === 'string' && "<%- member.approvedAppids %>".trim() !== '') ? "<%- member.approvedAppids %>".split(',').map(id => id.trim()) : [] });

			$(".insidesList").click(function(){
				$(".insidesList").removeClass('active');
				$(this).addClass('active');
			});
			
			
			//get csrf Token
			semusiCommon.getCsrfToken();;
			// Set its status 
			semusiCommon.setGlobalAdmin(( "<%= member.global_admin %>" == 'false') ? false :true )
			
			semusiCommon.setPanelURL("<%- newPanelUrl%>");

			const sessionId = "<%=sessionId%>" ;
			appiceCookies.setCookie('sid', sessionId);
		   $("#overlay").show();
		   const logoutBtn = document.querySelector('#logout');
		   logoutBtn.addEventListener('click', function (event) {
            event.preventDefault(); // Prevent the link from navigating to another 
            deleteAllCookies()
				function deleteAllCookies() {

				    const cookies = document.cookie.split(";");

				    for (let i = 0; i < cookies.length; i++) {
				        const cookie = cookies[i];
				        const eqPos = cookie.indexOf("=");
				        const name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
				        document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
				    }
				}
                window.location.href = "/logout"; 
        
        });
		});
	</script>
	<%if(action=='camp' ){%>
		<script nonce="<%=nonce%>" language="javascript" type="text/javascript" src="/javascripts/semusi/semusi.campaignScript.js" defer="defer"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/bee/BeePlugin.js" type="text/javascript" crossorigin="anonymous"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/highcharts/highcharts.js"  crossorigin="anonymous"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/highcharts/exporting.js"  crossorigin="anonymous"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/highcharts/export-data.js"  crossorigin="anonymous"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/highcharts/accessibility.js"  crossorigin="anonymous"></script>
		<script nonce="<%=nonce%>" src="/assets/plugins/select2/select2.min.js"></script>
		<link href="<%= cdnUrl %>/assets/plugins/bootstrap-datetimepicker/css/datetimepicker.css" rel="stylesheet" />
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js" ></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/bootstrap-switch/js/bootstrap-switch.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="<%= cdnUrl %>/scripts/angular-bootstrap-switch.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/bootstrap-wizard/js/bwizard.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>
		<script nonce="<%=nonce%>" src="/assets/plugins/editor/jquery-te-1.4.0.min.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/services/appIceService.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/campaignsController.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/templatesController.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/directives/campaignDirective.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/campaignDetailsController.js"></script>
		<!-- Datatables  Links-->
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/DataTables/js/jquery.dataTables.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/DataTables/js/jquery.dataTables.columnFilter.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/DataTables/js/dataTables.fixedColumns.js"></script>

		<script type="text/javascript" nonce="<%=nonce%>">
			$(document).ready(function () {
			   $("#campaignwizard").bwizard();
			});
		</script>
	<%}%>
	<%if(action=='dashboard' || action=='insight'){%>
		
		<script nonce="<%=nonce%>" type="text/javascript" src="app/services/appIceService.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/appDashboardController.js"></script>
		
	<%}%>
	<%if(action == 'tools' || action =="campaigns" || action =="transactionalCampaigns"){%>
	<script nonce="<%=nonce%>" type="text/javascript" src="<%= cdnUrl %>/assets/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>		
	<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/bootstrap-wizard/js/bwizard.js"></script>
	<script nonce="<%=nonce%>" language="javascript" type="text/javascript" src="/javascripts/semusi/semusi.engagementtools.js"></script>
	<script type="text/javascript" nonce="<%=nonce%>">
		$(document).ready(function () {
			setTimeout(function(){
				if(!appiceCookies.checkCookie('_camp_key', '_camp_modal_campaign')){
					$('.modal-campaign').modal('show');
				}
			}, 1000);
		});
	</script>
	<%}%>

	<%if(action=='displaypref'){%>		
		<script nonce="<%=nonce%>"  type="text/javascript" src="app/controllers/script.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/services/appIceService.js"></script>
	<%}%>

	<%if(action=='customevents' || action == 'insideapp'){%>

		<script nonce="<%=nonce%>" type="text/javascript" src="<%= cdnUrl %>/assets/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>
		<link rel="stylesheet" type="text/css" href="/assets/plugins/linearicons/style.css" />
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/js/chart_2.8.min.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="<%= cdnUrl %>/assets/plugins/dropdownchecklist/jquery.multiple.select.js"></script>
		<link rel="stylesheet" type="text/css" href="<%= cdnUrl %>/assets/plugins/funnel-graph/main.min.css" integrity="sha256-odymijcCVYDlog8Ujk0tUcKV79GJGuF6x10fvUJSN+U=" crossorigin="anonymous">
		<link rel="stylesheet" type="text/css" href="<%= cdnUrl %>/assets/plugins/funnel-graph/theme.min.css" integrity="sha256-CJ6Q0GfiAlNjlSA8XUYb4PNlL82/+Wp0keGHAMjXDiQ=" crossorigin="anonymous">
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/funnel-graph/funnel-graph.min.js" integrity="sha256-CqBCRKhXlFDPWxkURlVr6G1+8j1Ma1SiPOBK/I4npSg=" crossorigin="anonymous"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="javascripts/semusi/semusi.session.js"></script>
		<link href="<%= cdnUrl %>/assets/plugins/bootstrap-switch/css/bootstrap-switch.css" rel="stylesheet">
		<script nonce="<%=nonce%>" type="text/javascript" src="<%= cdnUrl %>/scripts/angular-bootstrap-switch.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="<%= cdnUrl %>/assets/plugins/bootstrap-switch/js/bootstrap-switch.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="<%= cdnUrl %>/assets/plugins/bootstrap-sweetalert/sweetalert.min.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/services/appIceService.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/eventsController.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/funnelsController.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/funnelsViewController.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/funnelsTableController.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/jobsController.js"></script>

		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/screenPlaybackController.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/other/d3.v4.min.js" integrity="sha256-hYXbQJK4qdJiAeDVjjQ9G0D6A0xLnDQ4eJI9dkm7Fpk=" crossorigin="anonymous"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/sankey.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/other/d3-scale-chromatic.v1.min.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/anychart/js/anychart-base.min.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/anychart/js/anychart-ui.min.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/anychart/js/anychart-exports.min.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/anychart/js/anychart-sunburst.min.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/anychart/js/anychart-data-adapter.min.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/DataTables/js/jquery.dataTables.js"></script>
	    <script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/DataTables/js/jquery.dataTables.columnFilter.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/DataTables/js/dataTables.fixedColumns.js"></script>
		<link rel="stylesheet" href="<%= cdnUrl %>/assets/plugins/anychart/anychart-ui.min.css" >
		<link rel="stylesheet" href="<%= cdnUrl %>/assets/css/anychart-font.min.css" >
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/journeyCreateController.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/journeyTableController.js"></script>

	<%}%>

	<%if(action=='usage' ){%>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/services/appIceService.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/anychart/anychart-base.min.js" integrity="sha256-t7mmfIObJuVFdb2YuGIkEDBzfgOK3L52MrHX0vDxZug=" crossorigin="anonymous"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/anychart/anychart-core.min.js" integrity="sha256-VbwKSaVHu+0U7cFUKp/tbiB67NPcbMUI6t3MdyKAHE4=" crossorigin="anonymous"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/anychart/anychart-heatmap.min.js" integrity="sha256-SdletQlCdG9Qh8z+PThrqDoZzePATSAnWtyZQO/13Ww=" crossorigin="anonymous"></script>
		<link rel="stylesheet" href="<%= cdnUrl %>/assets/plugins/anychart/anychart-ui.min.css" >
		<link rel="stylesheet" href="<%= cdnUrl %>/assets/css/anychart-font.min.css" >
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/DataTables/js/jquery.dataTables.js"></script>
	    <script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/DataTables/js/jquery.dataTables.columnFilter.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/DataTables/js/dataTables.fixedColumns.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/usagePageController.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="<%= cdnUrl %>/assets/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>
	<%}%>

	
	<!-- <%if(action=='sessionSetting'){%>
		<script type="text/javascript" src="app/services/appIceService.js"></script>
		<script type="text/javascript" src="app/controllers/newScreenshotSettingController.js"></script>
		<script type="text/javascript" src="app/controllers/screenshotController.js"></script>
		<script type="text/javascript">
			$(window).load(function () {
			   $("#overlay").hide();
			});
		</script>
	<%}%> -->
	<%if(action == 'audiencesegment' ||  action =='push' || action=="campaigns" || action =="transactionalCampaigns"){%>
		<!-- ================== BEGIN PAGE LEVEL STYLE for Audience Segments================== -->
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/DataTables/js/jquery.dataTables.js"></script> 
	    <script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/DataTables/js/jquery.dataTables.columnFilter.js"></script>
	    <script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/DataTables/js/dataTables.fixedColumns.js"></script>
		<!-- ================== END PAGE LEVEL STYLE ================== -->
	<%}%>	

	<%if(action == 'users'){%>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/DataTables/js/jquery.dataTables.js"></script> 
	    <script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/DataTables/js/jquery.dataTables.columnFilter.js"></script>
	    <script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/DataTables/js/dataTables.fixedColumns.js"></script>
	<%}%>

	<%if(action=='funnels' ){%>
		<link href="<%= cdnUrl %>/assets/plugins/bootstrap-datepicker/css/datepicker.css" rel="stylesheet" />
        <script nonce="<%=nonce%>" src="/assets/plugins/select2/select2.min.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/services/appIceService.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/funnelsController.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/funnelsViewController.js"></script>
	<%}%>

	<%if(action=='createchatbot' || action=='insides'){%>
		<script nonce="<%=nonce%>" type="text/javascript" src="<%= cdnUrl %>/assets/plugins/cohort/cohort.min.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/bootstrap-switch/js/bootstrap-switch.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/bootstrap-wizard/js/bwizard.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/services/appIceService.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/chatbotSettingController.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/chatbotSessionController.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/insidesController.js"></script>
		<script type="text/javascript" nonce="<%=nonce%>">
			$(window).load(function(){
				$('#overlay').hide();
			});
		</script>
	<%}%>
	<!-- <%if(action=="transactionalCampaigns"){%>
	    <script type="text/javascript" src="assets/plugins/chart-js/canvasjs.min.js"></script>
		<script src="<%= cdnUrl %>/assets/plugins/chart-js/line-bar-chart.js"></script>
		<script src="<%= cdnUrl %>/assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
		<script src="<%= cdnUrl %>/assets/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>
		<script type="text/javascript" src="app/services/appIceService.js"></script>
		<script type="text/javascript" src="app/controllers/transactionalCampaignsController.js"></script>
	<%}%> -->
	<%if(action=='aud' ){%>
		<link href="<%= cdnUrl %>/assets/plugins/bootstrap-switch/css/bootstrap-switch.css" rel="stylesheet">
		<script nonce="<%=nonce%>" type="text/javascript" src="<%= cdnUrl %>/scripts/angular-bootstrap-switch.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="<%= cdnUrl %>/assets/plugins/bootstrap-switch/js/bootstrap-switch.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="<%= cdnUrl %>/assets/plugins/bootstrap-sweetalert/sweetalert.min.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/bootstrap-multiselect/bootstrap-multiselect.min.js" integrity="sha256-qoj3D1oB1r2TAdqKTYuWObh01rIVC1Gmw9vWp1+q5xw=" crossorigin="anonymous"></script>
		<script nonce="<%=nonce%>" src="/assets/plugins/select2/select2.min.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="<%= cdnUrl %>/assets/plugins/dropdownchecklist/jquery.multiple.select.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/js/countUp.min.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/services/appIceService.js">
		</script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/audienceController.js">
		</script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/audienceViewController.js">
		</script>
		<script type="text/javascript" nonce="<%=nonce%>">
			$(window).load(function(){
				$('#overlay').hide();
				var script = document.createElement('script');		
				script.setAttribute( 'src', "https://maps.googleapis.com/maps/api/js?key=<%= GoogleMapApiKey %>&callback=initMap&libraries=drawing,places&v=weekly");
				script.setAttribute( 'nonce', "<%=nonce%>" );
				document.head.appendChild(script);
				var script2 = document.createElement('script');		
				script2.setAttribute( 'src', "https://polyfill.io/v3/polyfill.min.js?features=default");
				script2.setAttribute( 'nonce', "<%=nonce%>" );
				document.head.appendChild(script2);
			});
		</script>
	<%}%>
	<%if(action=='module' ){%>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/services/appIceService.js">
		</script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/globalAppModuleController.js">
		</script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/appModuleController.js">
		</script>
		<script type="text/javascript" nonce="<%=nonce%>">
			$(window).load(function(){
				$('#overlay').hide();
			});
		</script>
	<%}%>
	<%if(action=='otherapps' ){%>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/services/appIceService.js">
		</script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/appGroupsController.js">
		</script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>
	<%}%>
	<%if(action=='childapps' ){%>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/services/appIceService.js">
		</script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/appChildController.js">
		</script>
	<%}%>
	<%if(action=='demographics'){%>
		<script nonce="<%=nonce%>" language="javascript" type="text/javascript" src="<%= cdnUrl %>/assets/js/chart.min.js"></script>
		<script nonce="<%=nonce%>" language="javascript" type="text/javascript" src="/javascripts/semusi/semusi.demographics.js"></script>
	<%}%>
	<%if(action=='userlist'){%>
		<link href="assets/css/userlist.css" rel="stylesheet">
		<link href="<%= cdnUrl %>/assets/plugins/DataTables/css/data-table.css" rel="stylesheet" />
		<link rel="stylesheet" href="<%= cdnUrl %>/assets/plugins/DataTables/css/jquery.dataTables.min.css">
		<!--script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/bootstrap/js/bootstrap.js"></script-->
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/DataTables/js/jquery.dataTables.js"></script>
	    <script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/DataTables/js/jquery.dataTables.columnFilter.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/DataTables/js/dataTables.fixedColumns.js"></script>
		<script nonce="<%=nonce%>" language="javascript" type="text/javascript" src="/javascripts/semusi/semusi.userlist.js"></script>	
		<%}%>
		<%if(action=='utmbuilder'){%>
			<link href="assets/css/utmbuilder.css" rel="stylesheet">
			<script nonce="<%=nonce%>" language="javascript" type="text/javascript" src="/javascripts/semusi/semusi.utmbuilder.js"></script>	
			<%}%>
	<!-- <%if(action=='uploads'){%>
		<script language="javascript" type="text/javascript" src="/javascripts/semusi/semusi.metrices.js"></script>
		<script type="text/javascript">
			$(window).load(function(){
				$('#overlay').hide();
			});
		</script>
	<%}%> -->
	<%if(action=='create' || action=='createapp'){%>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/bootstrap-wizard/js/bwizard.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/parsley/dist/parsley.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="/javascripts/semusi/semusi.app.js"></script>
		<script type="text/javascript" nonce="<%=nonce%>">
			$(window).load(function(){
				// Check if the user is neither a global admin nor an admin
				const globalAdmin = "<%= member.global_admin %>";
				if( !semusiCommon.isAdmin() && !globalAdmin){
					// Redirect to the "/dashboard" page incase user is neither admin nor global admin
					window.location =  "/dashboard";
				}
				$('#overlay').hide();
			});
		</script>
	<%}%>
	<%if(action=='dashboard'){%>
	<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/bundle/plugins/bootstrap-libs.js"></script>
	<script nonce="<%=nonce%>" language="javascript" type="text/javascript" src="/javascripts/semusi/semusi.common.data.js"></script>
	<script nonce="<%=nonce%>" language="javascript" type="text/javascript" src="/javascripts/semusi/semusi.dashboard.chart.js"></script>
	<script nonce="<%=nonce%>" language="javascript" type="text/javascript" src="/javascripts/semusi/semusi.session.js"></script>
	<%}%>
	<%if(action=='insight'){%>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/bundle/plugins/bootstrap-libs.js"></script>
		<script nonce="<%=nonce%>" language="javascript" type="text/javascript" src="/javascripts/semusi/semusi.common.data.js"></script>
		<script nonce="<%=nonce%>" language="javascript" type="text/javascript" src="/javascripts/semusi/semusi.dashboard.chart.js"></script>
		<script nonce="<%=nonce%>" language="javascript" type="text/javascript" src="/javascripts/semusi/semusi.session.js"></script>
	<%}%>
	<%if(action=='oldinstalls' || action=='olduninstalls'){%>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/bootstrap-switch/js/bootstrap-switch.js"></script>
		<script nonce="<%=nonce%>" language="javascript" type="text/javascript" src="/javascripts/semusi/semusi.metrices.js"></script>
		<script nonce="<%=nonce%>" language="javascript" type="text/javascript" src="<%= cdnUrl %>/assets/plugins/chart-js/Chart.HorizontalBar.js"></script>
	<%}%>
	<%if(action=='installs'){%>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/anychart/js/anychart-core.min.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/anychart/js/anychart-pie.min.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/anychart/js/anychart-data-adapter.min.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/anychart/js/anychart-map.min.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/anychart/js/anychart-ui.min.js"></script>
        <script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/other/proj4.js" data-export="true"></script>
		
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/js/chart_2.8.min.js"></script>

		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/chart-js/Chart.StackedBar.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/DataTables/js/jquery.dataTables.js"></script>
	    <script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/DataTables/js/jquery.dataTables.columnFilter.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/DataTables/js/dataTables.fixedColumns.js"></script>
		<script nonce="<%=nonce%>" language="javascript" type="text/javascript" src="/javascripts/semusi/semusi.installs.js"></script>

	<%}%>
	<%if(action=='uninstalls'){%>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/anychart/js/anychart-core.min.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/anychart/js/anychart-pie.min.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/anychart/js/anychart-data-adapter.min.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/anychart/js/anychart-map.min.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/anychart/js/anychart-ui.min.js"></script>

		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/other/proj4.js" integrity="sha256-6++UKnQk+NIDSQU3hYXFr7O0GBfCEw6Swq0RJjWTF84=" crossorigin="anonymous" data-export="true"></script>

		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>

		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/js/chart_2.8.min.js"></script>

		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/chart-js/Chart.StackedBar.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/DataTables/js/jquery.dataTables.js"></script>
	    <script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/DataTables/js/jquery.dataTables.columnFilter.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/DataTables/js/dataTables.fixedColumns.js"></script>
		<script nonce="<%=nonce%>" language="javascript" type="text/javascript" src="/javascripts/semusi/semusi.common.data.js"></script>
		<script nonce="<%=nonce%>" language="javascript" type="text/javascript" src="/javascripts/semusi/semusi.uninstalls.js"></script>	
	<%}%>
	<%if( action=='allusers' || action=='push' || action =="appsetting"){%>

	<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/DataTables/js/jquery.dataTables.js"></script>
	<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/DataTables/js/jquery.dataTables.columnFilter.js"></script>
	<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/DataTables/js/dataTables.fixedColumns.js"></script>		
	<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/bootstrap-wizard/js/bwizard.js"></script>
	<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/parsley/dist/parsley.js"></script>
	<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/bootstrap-switch/js/bootstrap-switch.js"></script>
	<script nonce="<%=nonce%>" type="text/javascript" src="<%= cdnUrl %>/assets/plugins/clipboard/clipboard.min.js"></script>
	<script nonce="<%=nonce%>" src="assets/plugins/jquery/sha256.min.js"></script>
	<script type="text/javascript" nonce="<%=nonce%>">
		function copyText(id){
		    try{
		    	var inputBox = $('#'+id).attr('data-clipboard-target')
		    	window.setTimeout (function(){
			       $(inputBox).select();
			    },100);

		        var clipboard = new Clipboard('#'+id);
		        clipboard.on('success', function(e) {
		            e.clearSelection();
		        });

		        clipboard.on('error', function(e) {
		        });
		    }
		    catch (e){
		    }
		}
		$(window).load(function(){
			$('#overlay').hide();
		});
	</script>
	<%}%>
	<%if( action =="appsetting"){%>
		<script nonce="<%=nonce%>" type="text/javascript" src="/javascripts/semusi/semusi.appsetting.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="/javascripts/semusi/semusi.app.js"></script>
	<%}%>
	<%if( action =="allusers"){%>
		<script nonce="<%=nonce%>" type="text/javascript" src="/javascripts/semusi/semusi.userManagement.js"></script>
	<%}%>
	<%if(action == 'push'){%>
		<script nonce="<%=nonce%>" language="javascript" type="text/javascript" src="/javascripts/semusi/semusi.campaigns.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
	<%}%>
	
	<%if(action=='users'){ %>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>
		<script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/timeline/jquery.timeline.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/services/appIceService.js">
		</script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/appUsersController.js">
		</script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/appUserDetailsController.js">
		</script>
	<%}%>

	<% if(action=="analytics" || action=='aidql') { %>
		 <script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
		 <script nonce="<%=nonce%>" src="<%= cdnUrl %>/assets/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>
		 <script nonce="<%=nonce%>" src="/assets/plugins/select2/select2.min.js"></script>
		 <script nonce="<%=nonce%>" src="/assets/plugins/jstree-viwer/jquery.json-view.js"></script>
		 <script nonce="<%=nonce%>" type="text/javascript" src="app/services/appIceService.js">
		</script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/analyticsController.js"></script>
		<script nonce="<%=nonce%>" type="text/javascript" src="app/controllers/rawDataController.js"></script>
		<script type="text/javascript" nonce="<%=nonce%>">
			$(window).load(function(){
				$('#overlay').hide();
			});
		</script>
	<% } %>
	<!-- ================== END PAGE LEVEL JS ================== -->
<script nonce="<%=nonce%>">
	$(".insideApp").click(function(){
		gotoInsideApp();
	});
	$(".gotoDashboard").click(function(){
		gotoDashboard();
	});
	$(".gotoCampaign").click(function(){
		gotoCampaign();
	});
	function validateUploadFile(str) {
		if (str.indexOf('.') !== str.lastIndexOf('.')) {
			return false;
		}
		return true;
   }

$(document).ready(function() {
			App.init();
			function showSettingMenu(){
				var setupApps = document.getElementById("setupApps");

				if(semusiCommon.ACTIVE_APP_ID == 0){
					$('.only_app').css('display','none');
                       if (setupApps) {
                           setupApps.style.display = "show"; 
                       }
				}else if(semusiCommon.ACTIVE_APP_ID !=0){
					if (setupApps) {
                           setupApps.style.display = "hide"; 
                       }
						$('.only_app').css('display','block');
						$('#show-settings-menu a').attr('href','/dashboard?app_id='+semusiCommon.ACTIVE_APP_ID+'&action=appsetting');
				}
			}

			           var docNav = document.getElementById("documentation-li");
                       if (docNav) {
						docNav.style.display = "none"; 
                       }
					   var churn = document.getElementById("churn_");
                       if (churn) {
						churn.style.display = "none"; 
                       }

			function hideDisabledFeature() {
    return new Promise((resolve, reject) => {
        if (semusiCommon.ACTIVE_APP_ID != 0) {
            $.ajax({
                type: "GET",
                url: semusiCommon.API_PARTS.apps.r + '/getFeaturesSettings',
                data: {
                    args: JSON.stringify({
                        app_id: semusiCommon.ACTIVE_APP_ID,
                    }),
                    app_id: semusiCommon.ACTIVE_APP_ID,
                    api_key: semusiCommon.getActiveUser.api_key,
                    uniqueNumber: semusiCommon.randomNumber(),
                },
                success: function (data) {
                    semusiCommon.setEmailState(true);
                    if (data && data.length > 0 && data[0].siteSettings) {
                        const siteSettings = data[0].siteSettings;
                        let addUserLabel = 'User Email :';
                        let placeholderText = "Enter the user email";
						// for Add User Html page
                        if (siteSettings.sso_type == "ad"){
                            addUserLabel = 'SSO Id :';
                            placeholderText = "Enter the SSO Id";
                        }
                        $("#user_email").attr("placeholder", placeholderText);
                        $("#addUserLabel").text(addUserLabel);
                    }

                    if (data && data.length > 0 && data[0].features) {
                        const features = data[0].features;

                        if (features.demographics && $('.demographics').length > 0) {
                            $('.demographics').hide();
                        }else{
                            $('.demographics').show();
						}
                        if (features.usage && $('.usage').length > 0) {
                            $('.usage').hide();
                        }
                        if (features.usage && $('#usage-details').length > 0) {
                            $('#usage-details').text('');
                        }
                        if (features.reports && $('.reports').length > 0) {
                            $('.reports').hide();
                        }
                        if (features.churn && $('#churn_').length > 0) {
                            $('#churn_').hide();
                        }else{
                            $('#churn_').show();
						}
                        if (features.churn && $('#churn-details').length > 0) {
                            $('#churn-details').text('');
                        }
                        if (features.expImg) {
                            if ($('.exp-push').length > 0) $('.exp-push').hide();
                            if ($('.exp-webPush').length > 0) $('.exp-webPush').hide();

                            $('#header-dis').css('width', '230px');
                            $('#notificationHeader').css('width', '230px');
                            $('#notificationDescription').css('width', '230px');
                            $('#notificationDescription').css('marginLeft', '10px');
                            $('#exptextdiv').css('width', '230px');
                            $('#exp-text').css('marginLeft', '10px');
                            $('#header-pen').css('marginRight', '-240px');
                        }

						const ids = ['#fb', '#web-push', '#web-popUp', '#email-camp', '#in-app-survey', 
                               '#in-app-rating', '#in-app-camp', '#sms', '#whatsapp'];

                          if (features.campExceptPush) {
                              ids.forEach(id => {
                                  if ($(id).length > 0) { 
                                      $(id).hide();       
                                  }
                              });
                          } else {
                              ids.forEach(id => {
                                  $(id).show();  
                              });
                          }
                          
                           

                        if (features.email_editor) {
                            $("#email_editor_template").hide();
                            semusiCommon.setEmailState(false);
                        }

                        if (features.transactionalCamp && $('#trans_camp').length > 0) {
                            $('#trans_camp').hide();
                        }else{
                            $('#trans_camp').show();

						}

						   // Apply settings based on feature flags
						   if (features.advPush && $('#expandedNotify').length > 0) {
                    $('#expandedNotify').attr('accept', '.jpg, .jpeg, .png');
                }

                if (features.userprofileImg) {
                    if ($('#imgUserIcon').length > 0) {
                        $('#imgUserIcon').hide();
                    }
                    if ($('#fileupload').length > 0) {
                        $('#fileupload').hide();
                    }
                    const nameLabel = $('#nameLabel');
                    if (nameLabel.length > 0) {
                        nameLabel.css('margin-top', '10%');
                    }
                }

                if (features.optimisation) {
                    ['optimisation', 'staggered'].forEach(id => $(`#${id}-div`).hide());
                }

                if (features.appInboxAndDeliveryType && $('#appinboxexp').length > 0 && $('#dt').length > 0) {
                    $('#appinboxexp').hide();
                    $('#dt1').hide();
                    $('#dt3').hide();
                    document.getElementById("dt1").selected = false;
                    document.getElementById("dt2").selected = true;
                }

                if (features.documentation && $('#documentation-li').length > 0) {
                    $('#documentation-li').hide();
                }else{
                    $('#documentation-li').show();
				}

                if (features.outsideTheApp && $('#outsidetheapp-li').length > 0) {
                    $('#outsidetheapp-li').hide();
                }

                if (features.campaignDetailsCsv && $('#camp_details_csv').length > 0) {
                    $('#camp_details_csv').hide();
                }

                if (features.embedCustomField) {
                    if ($('#pencil3').length > 0) $('#pencil3').hide();
                    if ($('#header-pen').length > 0) $('#header-pen').hide();
                    if ($('#pen_1').length > 0) $('#pen_1').hide();
                    if ($('#pen_3').length > 0) $('#pen_3').hide();
                    if ($('#pen_4').length > 0) $('#pen_4').hide();
                }

                if (features.category) {
                    $('#eng-camp').prop('disabled', true);
                }

                if (features.utmBuilder) {
                    if ($('.utm').length > 0) $('.utm').hide();
                }else{
                     $('.utm').show();
				}

                if (features.advancedFreq) {
                    if ($('#advancedFrequency').length > 0) $('#advancedFrequency').hide();
                }

                if (features.launchCampFreq) {
                    if ($('#frequency-div').length > 0) $('#frequency-div').hide();
                }

                if (features.conversionSettings) {
                    if ($('#conversion_lcamp').length > 0) $('#conversion_lcamp').hide();
                }

                if (features.actionbuttonSettings) {
                    if ($('#actionButtonPush').length > 0) $('#actionButtonPush').hide();
                }

                if (features.specialattributes) {
                    if ($('#specialAttributes').length > 0) $('#specialAttributes').hide();
                }

                if (features.journeynavsettings) {
                    if ($('#journeynavbar').length > 0) $('#journeynavbar').hide();
                }

                if (features.setupAppsSettings && $('#setupApps').length > 0) {
                     $('#setupApps').hide();
                }else{
                     $('#setupApps').show();
				}

                if (features.delayLauch) {
                    if ($('#delayLcamp').length > 0) $('#delayLcamp').hide();
                }

                if (features.liveEventSett) {
                    if ($('#liveEvent_lcamp').length > 0) $('#liveEvent_lcamp').hide();
                }

                if (features.schedulerSett) {
                    if ($('#scheduler_lcamp').length > 0) $('#scheduler_lcamp').hide();
                }

                if (features.allowList) {
                    if ($('#allowlisttab').length > 0) $('#allowlisttab').hide();
                }

                        if (features.removeWeb) {
                            const selectors = [
                                "#statsplatform option[value='Web']",
                                "#statsplatform option[value='web']",
                                "#acquisitionSources a[data-attr='web']",
                                "#osDropdown a[data-attr='web']",
                                "#avByPlatform option[value='web']",
                                "#dropdownMenuTimeWise li a[data-attr='web']",
                                "#dropdownMenuDayWise li a[data-attr='web']",
                                "#funnelDD .platform-select[data-attr='web']",
                            ];
                        
                            selectors.forEach(selector => {
                                const element = document.querySelector(selector);
                                if (element) {
                                    if (element.tagName === 'OPTION') {
                                        element.remove();
                                    } else {
                                        element.parentNode.style.display = "none";
                                    }
                                }
                            });
                        }
                    }

                    resolve(data); 
                },
                error: function (error) {
                    reject(error); 
                }
            });
        } else {
            reject("No active app ID.");
        }
    });
}

    	//Check string is valid JSON before parse  
    function isJson(str) {
        try {
            JSON.parse(str);
        } catch (e) {
              return false;
        }
          return true;
      }  
    		//Check isAdmin validator
    		function isAdmin() {
    		let role = isJson(localStorage.getItem('user_role'))?JSON.parse(localStorage.getItem('user_role')):localStorage.getItem('user_role');
    		if(role && role == 'admin') {		
    			return true;
    		}else{
    			return false;
    		}
    		
    	}
    	 //Check isGlobal Admin
    	 function isGlobalAdmin() {
	  		if(semusiCommon.isGlobalAdmin) {
    		  return true;
    	  }
    	  else{
    		  return false;
    	  }
    
      }
			$(window).load(function(){

				// get the sso_type from the router , 
				const  sso_type = '<%=sso_type%>';
				// for type ad Auth , we will hide the setitng page , 
				if(sso_type =="ad"){
					$('#editProfile').hide();
				}
				if(isGlobalAdmin() != true && isAdmin() != true) {
					$('.featureSet').hide();
					$('#setupApps').hide();
				}else{
				$('#setupApps').show();
			   }
				hideDisabledFeature();
				showSettingMenu();
			});



			function renderToDashboard(feature) {
              hideDisabledFeature()
                  .then(data => {
                      if (data && data.length > 0) {  
                          if (semusiCommon.isFeatureDisabled(feature, data[0].features)) {
                              window.location.href = "/dashboard";
                          }
                      } else {
                          console.error('Unexpected data format:', data);
                      }
                  })
                  .catch(error => {
					  window.location.href = "/dashboard";
                      console.error('Error fetching feature settings:', error);
                  });
            }

			// view details page
			$(".view-details").on('click',function(){
				var url = $(this).data('page');
	 			window.location = url;
		 	})

			$('#viewCsvData').on('click',function(){
	 			$('#showUploadData').show();
	 			$('#showUplad').hide();
		 	})
			$('#newCsvData').on('click', function(){
				$('#showUploadData').hide();
		 		$('#showUplad').show();
			});
			setActiveMenu();

			$(".sidebar-minify-btn").click(function(){
				$(".slimScrollBar").css("background","cyan");
			});

			<%if(action == 'createapp'){%>
				renderToDashboard('setupAppsSettings');
				const globalAdmin = "<%= member.global_admin %>";
				// Check if the user is neither a global admin nor an admin
				if( !semusiCommon.isAdmin() && !globalAdmin){
					  // Redirect to the "/dashboard" page if the user is neither admin nor global admin
					window.location =  "/dashboard";
				}
				$('#appCategory').text('setexample'); // set hotstar in the example entry
			<%}%>
			<%if(action == 'customevents' || action == 'insideapp'){%>
			<%}%>

			<%if(action == 'demographics'){%>
				renderToDashboard('demographics');
				semusiDemographics.Init();
			<%}%>

			<%if(action == 'push'){%>
				var campaignImg= '';
				var campaignExpandImg = '';
				var sharedCampaignObj= {};

				 $('#datepicker-default').datepicker({
			        todayHighlight: true,
			        autoclose: true
			    });

				var handleDataTableDefault = function() {
					"use strict";

				    if ($('#data-table').length !== 0) {
				        $('#data-table').DataTable();
				    }
				};
				//get all campaigns
				$.when(semusiCampaigns.initialize()).then(function()
				{
					var campaignsData = semusiCampaigns.getCampaignsData();
					
					sharedCampaignObj = campaignsData;
					campaignsData.forEach(function(campaignObj) {
					  $('#data-table-campaigns tr:last').after('<tr class="gradeA odd" role="row"><td class="sorting_1">'+ campaignObj._id +'</td><td>'+ campaignObj.name +'</td><td>' + new Date(campaignObj.createdat).toLocaleDateString()+ '</td><td>'+ new Date(campaignObj.expires).toLocaleDateString()+'</td><td>' + campaignObj.status + '</td><td><button type="button" class="btn btn-success m-r-5 m-b-5" id="run_'+ campaignObj._id +'" name="runBtn">Run Again</button></td><td><button type="button" class="btn btn-success m-r-5 m-b-5" id="edit_'+ campaignObj._id +'" name="editBtn">Edit</button></td><td><button type="button" class="btn btn-danger m-r-5 m-b-5" id="delete_'+ campaignObj._id +'" name="deleteBtn">Delete</button></td></tr>');
					});
				});
				$('#createCampaignBtn').click(function(){
					sharedCampaignObj= {};
					localStorage.removeItem('cureditcampaignid');
					$('#createCampaignDiv').show();
					 $("html, body").animate({ scrollTop: $(document).height() }, "slow");
					 		$('#campaignName').val('');
							$('#campaignHeader').val('');
							$('#campaignDesc').val('');
							$('#campaignExtUrl').val('');
							$('#campaignExpandText').val('');
				});
				$('#campaignImg').change(function(evt) {
        		    uploadCampaignImage('img');
    			});
				$('#campaignExpandImg').change(function(evt)
				{
					uploadCampaignImage('extimg');
				});

				function uploadCampaignImage(imgType)
				{
					if(imgType == 'img')
					{
						var logofiles = $('#campaignImg').get(0).files;
					}
					else
					{
						var logofiles = $('#campaignExpandImg').get(0).files;
					}

					 if(logofiles.length >= 1 )
					 {
					 	//upload the first logo file
					 	var fd = new FormData();
						fd.append('campaign_image', logofiles[0]);
			  		  $.ajax({
			        	url: '/campaign/images',
						data: fd,
						cache: false,
						contentType: false,
						processData: false,
						type: 'POST',
						success: function(data){
							   
							   if(imgType == 'img')
								{
									campaignImg = data;
								}
								else
								{
									campaignExpandImg = data;
								}
							}
			        	});
			  		}
				}
				$('#saveCampaignBtn').click(function(){
					campaignObj = {};
					campaignObj.name = $('#campaignName').val();
					campaignObj.expires = new Date($('#datepicker-default').val()).toISOString();
					campaignObj.pushtype="direct";
					campaignObj.content = {};
					campaignObj.content.header = $('#campaignHeader').val();
					campaignObj.content.desc = $('#campaignDesc').val();
					if(campaignImg != '')
					{
						campaignObj.content.img = "<%= cdnUrl %>" +campaignImg;
					}
					if(campaignExpandImg != '')
					{
						campaignObj.content.expandimg = "<%= cdnUrl %>" + campaignExpandImg;
					}
					campaignObj.content.exturl = $('#campaignExtUrl').val();
					campaignObj.content.expandtext = $('#campaignExpandText').val();


					if(store('cureditcampaignid') != null)
					{
						campaignObj._id = store('cureditcampaignid')
						semusiCampaigns.updateCampaign(campaignObj,function()
							{
								$('#createCampaignDiv').hide();
								refreshCampaigns();
								alert('Campaign updated, dont forget to run again');
							});
					}
					else
					{
						semusiCampaigns.saveCampaign(campaignObj,function()
							{
								$('#createCampaignDiv').hide();
								refreshCampaigns();
							});
					}
				});

				$('[name="deleteBtn"]').live('click',function(el){
					//get the id of this button
					var campaignid = $(this).attr("id").substring(7,$(this).attr("id").length);
					semusiCampaigns.deleteCampaign(campaignid,function()
					{
						refreshCampaigns();
					});
				});

				$('[name="runBtn"]').live('click',function(el){
					//get the id of this button
					var campaignid = $(this).attr("id").substring(4,$(this).attr("id").length);
					semusiCampaigns.runCampaign(campaignid,function()
					{
						alert('Campaign Ran Successfully...');
					});
				});

				$('[name="editBtn"]').live('click',function(el){
					//get the id of this button
					var campaignid = $(this).attr("id").substring(5,$(this).attr("id").length);
					//open the div below
					$('#createCampaignDiv').show();
					 $("html, body").animate({ scrollTop: $(document).height() }, "slow");
					//get the data from the shared campaignsData object
					sharedCampaignObj.forEach(function(campaignObj) {
						if(campaignObj._id == campaignid)
						{
							store('cureditcampaignid', JSON.stringify(campaignObj._id))
							$('#campaignName').val(campaignObj.name);
							$('#datepicker-default').val(moment(campaignObj.expires).format('MM/DD/YYYY'));
							$('#campaignHeader').val(campaignObj.content.header);
							$('#campaignDesc').val(campaignObj.content.desc);
							$('#campaignExtUrl').val(campaignObj.content.exturl);
							$('#campaignExpandText').val(campaignObj.content.expandtext);
						}
					});
				});

				function refreshCampaigns(){
					$.when(semusiCampaigns.refresh()).then(function(){
						var campaignsData = semusiCampaigns.getCampaignsData();
						sharedCampaignObj = campaignsData;
						localStorage.removeItem('cureditcampaignid');
						//clear the table, except header
						 $("#data-table-campaigns").find("tr:gt(0)").remove();
							campaignsData.forEach(function(campaignObj) {
						  $('#data-table-campaigns tr:last').after('<tr class="gradeA odd" role="row"><td class="sorting_1">'+ campaignObj._id +'</td><td>'+ campaignObj.name +'</td><td>' + new Date(campaignObj.createdat).toLocaleDateString()+ '</td><td>'+ new Date(campaignObj.expires).toLocaleDateString()+'</td><td>' + campaignObj.status + '</td><td><button type="button" class="btn btn-success m-r-5 m-b-5" id="run_'+ campaignObj._id +'" name="runBtn">Run Again</button></td><td><button type="button" class="btn btn-success m-r-5 m-b-5" id="edit_'+ campaignObj._id +'" name="editBtn">Edit</button></td><td><button type="button" class="btn btn-danger m-r-5 m-b-5" id="delete_'+ campaignObj._id +'" name="deleteBtn">Delete</button></td></tr>');
						});

					});
				}
			<%}%>

			<%if(action == 'dashboard' && currentappid){%>
	$('.only_admin').css('display','none');
	const globalAdmin = "<%= member.global_admin %>";
	semusiCommon.setPeriod("month");
	var currentAppName = '<%=currentAppName%>';
	currentAppName = currentAppName.replace(/(\t\n|\n|\t|\n)/gm,"");
	semusiCommon.setActiveApp("<%=currentappid%>",currentAppName,"<%=currentAppIcon%>","<%=member.api_key%>");
	
	if (globalAdmin!=='true') {
	    const userRole = semusiCommon.getActiveUser.user_role || {};
	    const appid = JSON.parse(localStorage.getItem('semusi_active_app'));
	    let currentRole;
	    for (const role in userRole) {
	        if (userRole[role].includes(appid)) {
	            currentRole = role;
	            break;
	        }
	    }
	    localStorage.setItem('user_role', JSON.stringify(currentRole));
	} else {
	    localStorage.setItem('user_role', JSON.stringify('admin'));
	}	

	
	if(semusiCommon.isAdmin() || globalAdmin == 'true'){
		$('.only_admin').css('display','block');
	}
<%}%>

<%if(action == 'profile'){%>
	$('#userfile').change(function(evt) {
	uploadUserImage();
	});
<%}%>

//load the top icon image
$('#imgUserIcon').error(function() {
		$('#imgUserIcon').attr("src","assets/img/user_icon.png");
		$('#imgUserProfile').attr("src","assets/img/user_icon.png");
});

	<%if(action == 'dashboard' || action=='insight'){%>
		semusiChart.Initialize();
	<%}%>
	<%if(action == 'oldinstalls'){%>
		semusiMetrics.InitInstalls();
	<%}%>
	// <%if(action == 'uploads'){%>
	// 	semusiMetrics.getCSVLogs();
	// <%}%>
	<%if(action == 'olduninstalls'){%>
		semusiMetrics.InitUninstalls();
	<%}%>

	<%if(action == undefined || action==false){%>
		getAppStats();
	<%}%>
	<%if(action == 'installs'){%>
		semusiInstalls.Initialize();
	<%}%>
	<%if(action == 'uninstalls'){%>
		semusiUnInstalls.Initialize();
	<%}%>
	<%if(action == 'addusers'){%>
		if( !semusiCommon.isAdmin() ){
		window.location =  "/dashboard";
	}
	<%}%>

    <% if (action == 'uninstalls') { %>
    	renderToDashboard('churn');
    <% } %>
    
    <% if (action == 'transactionalCampaigns') { %>
    	renderToDashboard('transactionalCamp');
    <% } %>
    
    <% if (action == 'displaypref') { %>
    	renderToDashboard('displaypref');
    <% } %>
    
    <% if (action == 'uploads') { %>
       window.location.href = "/dashboard";
    <% } %>    
    
    <% if (action == 'usage') { %>
    	renderToDashboard('usage');
    <% } %>
    
});

//functions for create app part only
<%if(action==false || action == 'createapp' ||action=="appsetting"){%>

	$('#appname').change(function(){
		$('#app_name').text($('#appname').val());
		if($('#appname').val() != '')
		{
			$('#createappbtn').removeClass("btn btn-white disabled");
			$('#createappbtn').addClass("btn btn-success btn-lg");
		}
		else
		{
			$('#createappbtn').removeClass("btn btn-success btn-lg");
			$('#createappbtn').addClass("btn btn-white disabled");
		}
	});

	$('#devemailid').keyup(function(){
		$('#dev_emailid').text($('#devemailid').val());
	});

	$('#dev_emailid').text('N/A');

	$('#RappImageGoogle').click(function(){
		$('#appnameGoogle').val('');
		setExampleValues();

	});
	$('#RappImageStore').click(function(){
		$('#appnameStore').val('');
		setExampleValues();
	});

	function setExampleValues()
	{
		 if("<%=action%>"!="appsetting"){
			$('#appCategory').text('setexample')
			$('#appCategory').text('');
			$('#appImage').attr("src","images/dashboard/hotstart.png");
			$('#app_Image').attr("src","");
			$('#lblappnamegp').text('https://play.google.com/store/apps/details?id=in.startv.hotstar');
			$('#lblappnameas').text('https://itunes.apple.com/in/app/hotstar/id934459219?mt=8');
			$('#appname').text('hotstar live TV movies cricket');
			$('#app_name').text('');
			$('#createappbtn').removeClass("btn btn-success btn-lg");
			$('#createappbtn').addClass("btn btn-white disabled");
		}
	}

	$('#createappbtn').click(function(){
		var appid=store("hdnApp_id");
		window.location =  encodeURI("dashboard?action=dashboard&app_id=" + appid);
	});
	function setDeleteInfo(id,name)
	{
		$("#spanAppName").text(name);
		store('hdnAppId', JSON.stringify(id));
	}
<%}%>

<%if(action=='profile'){%>
	function uploadUserImage() {
		  var logofiles = $('#userfile').get(0).files;

    var fileName = logofiles[0].name.split(".");
    if (fileName.length < 2 || !validateUploadFile(logofiles[0].name) || (fileName[fileName.length - 1] !== 'png' && fileName[fileName.length - 1] !== 'jpg' && fileName[fileName.length - 1] !== 'jpeg')) {
        showMessage("Please Enter Only jpg jpeg png images");
		$(this).val('')
		$("#message").delay(3000).fadeOut(300); 
            flag = false;
            return false;
        }

		 if(logofiles.length >= 1 )
		 {
		 	//upload the first logo file
		 	var fd = new FormData();
			fd.append('user_image', logofiles[0]);
			fd.append('file_name', logofiles[0].name)
			fd.append('user_image_id',"<%= member._id %>");
  		  $.ajax({
        	url: '/users/images',
			data: fd,
			cache: false,
			contentType: false,
			processData: false,
			type: 'POST',
			headers: {
                'csrf-token': appiceCookies.getCookie('_csrf')
            },
			success: function(data){
				d = new Date();
				$("#imgUserProfile").attr("src",data+"?"+d.getTime());
				$("#imgUserIcon").attr("src",data+"?"+d.getTime());
				},
				error: function(){
				showMessage("Something went wrong");
				$("#message").delay(3000).fadeOut(300); 
			}
        	});
  		}
		}

		$('#profileForm').submit(function(){
				var user_id="<%=member._id%>"
			var full_name = $('#full_name').val();
			var title = $('#usertitle').val();
			var company = $('#usercompany').val();
			var email= $('#useremail').val();
			var phone= $('#userphone').val();
			var password = $('#userpassword').val();
			var confirmpassword= $('#userconfirmpassword').val();
		//   Validating the username to contain only alphabet, number and space
          	var re = /([\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]+)/g;
          	  if (!re.test(full_name)) {
				$("#errorDiv").show();
				$("#lblErrorMsg").text("Enter Valid Username.");
          	      return false;
          	  }
			if (title != "" && !re.test(title)) {
				$("#errorDiv").show();
				$("#lblErrorMsg").text("Enter valid title.");
          	      return false;
          	  }
		//   Validating the Company name
				var ree = /^[.@&]?[a-zA-Z0-9 ]+[ !.@&()]?[ a-zA-Z0-9!()]+/;
			if (!ree.test(company)) {
				$("#errorDiv").show();
				$("#lblErrorMsg").text("Enter Valid Company name.");
          	      return false;
          	  }
		//   Validating the user phone number to contain only number upto ten 
			var rew =/^[0-9]{10}$/;
			if (!rew.test(phone)) {
				$("#errorDiv").show();
				$("#lblErrorMsg").text("Enter Valid Phone number.");
          	      return false;
          	  }
			if(password.length>0 && password.trim().length==0){
				$("#errorDiv").show();
				$("#lblErrorMsg").text("Invalid password.");
				return false;
			}
			//   Validating Password should be at least 8 characters and no more than 15 characters
		    var regularExpression = /^(?:(?=.*[a-z])(?:(?=.*[A-Z])(?=.*[\d\W])|(?=.*\W)(?=.*\d))|(?=.*\W)(?=.*[A-Z])(?=.*\d)).{8,}$/
		    if(!regularExpression.test(password)) {
				$("#errorDiv").show();
				$("#lblErrorMsg").text( "Password must be at least 8 characters and contain at least one uppercase letter or one lowercase letter or one number or special character.");
				return false;
              }
			else if(password != confirmpassword)
			{
				$("#errorDiv").show();
				$("#lblErrorMsg").text("Passwords do not match.");
				return false;
			}
			else
			{
				$("#errorDiv").hide();
			}

			<% if(t == 'sha256'){ %>
				password = sha256(password);
			<% }else{ %>
				password = window.btoa(password);
			<% } %>	
		  $.ajax({
            type:"POST",
            url:semusiCommon.API_PARTS.users.w + '/update',
            data:{
                args:JSON.stringify({
                	user_id:user_id,
                    full_name:full_name,
                    title:title,
                    company:company,
                    password:password,
                	phone:phone
                }),
                app_id: semusiCommon.ACTIVE_APP_ID,
                api_key: semusiCommon.getActiveUser.api_key,
				uniqueNumber : semusiCommon.randomNumber(),
            },
            headers: {
                'csrf-token': appiceCookies.getCookie('_csrf')
            },
            success:function (data) {
				semusiCommon.getCsrfToken();
            	window.location =  "/dashboard";
			},
			error: function (xhr, status, error) {
				if(xhr.status == 422){
					$("#errorDiv").show();
				    $("#lblErrorMsg").text("validation error");
				}
           }
		});

});
<%}%>


		<% if (message){ %>
			showMessage("<%= message %>");
		<% } %>


function createappbtn(){
	var appName = $('#appname').text();
	var imagesrc = $('#appImage').attr('src');
	var isAppDeleted="false";
	var category=$('#appCategory').text();
	if(category=='semusi'){
		category='';
	}
	if(appName != '' && category!='setexample'){
	    $.ajax({
        	type:"GET",
            url:semusiCommon.API_PARTS.apps.w + '/create',
            data:{
                args:JSON.stringify({
                    name:appName,
                    category:category,
                    icon:imagesrc,
                	isAppDeleted:isAppDeleted,
                	googleUrl:$('#lblappnamegp').text(),
                	iosUrl:$('#lblappnameas').text()
                }),
                api_key: semusiCommon.getActiveUser.api_key,
				app_id: semusiCommon.ACTIVE_APP_ID,
				uniqueNumber : semusiCommon.randomNumber(),
            },
            
            success:function (data) {
                var newAppObj = {
                    "_id":data._id,
                    "name":data.name,
                    "key":data.key
                };
				store("hdnApp_id", JSON.stringify(data._id));
				store("hdnApp_key", JSON.stringify(data.key));
                $('#appCategory').text('setexample')
                if($.trim($('#appnameGoogle').val())!=''){
     				AndriodSteps(data._id, data.key);
     			}
     			else{
     			 	$('#stepAndriod').css('display','none');
     			}
     			if($.trim($('#appnameStore').val())!=''){
     				IOSSteps(data._id, data.key);
     			}
     			else{
     			 	$('#stepIOS').css('display','none');
     			}
				$('#createappbtn').removeClass("btn btn-white disabled");
				$('#createappbtn').addClass("btn btn-success btn-lg");
				return true;
		}});
	}
	else{
		showMessage('Please provide an AppName');
		return false;
	}

}

function AndriodSteps(id, key)
{
	var part1='&lt;!-- Play service meta-data --&gt;  <br>&lt;meta-data<br>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; android:name="com.google.android.gms.version" <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; android:value="@integer/google_play_services_version" /&gt; <br><br/> &lt;!-- Required Meta-Data keys for SemusiSDK --&gt; <br/>&lt;meta-data  <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; android:name="com.semusi.analytics.appid"<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; android:value="' ;
	                	part1=part1+ id;
	                    part1=part1+'"/&gt; <br/> &lt;meta-data <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; android:name="com.semusi.analytics.appkey"<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; android:value="';
	                    part1=part1+ key;
	                   	part1= part1+ '"/&gt;<br/>&lt;meta-data <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; android:name="com.semusi.analytics.apikey" <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; android:value="';
	                   	part1=part1+ semusiCommon.getActiveUser.api_key;
	                   	part1=part1+'"/&gt;<br/><br> &lt;!-- End of required meta-data --&gt;';
	                    $('#devdata').html(part1);
}

function IOSSteps(id, key){
	var	part1= '---- Define meta-data keys for semusi SDK Please copy from setting -> app setting';
	$('#devdataIOS').html(part1);
}



		function showMessage(key) {
			$('#message').show();
			$('#messagebox').text(key);
		}

		function showMessagesucess(key) {
			$('#messagesucess').show();
			$('#messageboxsucess').text(key);
		}

		function showMessageInfo(key){
			$('#messageInfo').show();
			$('#messageboxInfo').text(key);
		}

		function startLoader(message){
			document.getElementById('load').style.visibility="visible";
			showMessageInfo(message)
		}
		function endLoader(message){
			document.getElementById('load').style.visibility="hidden";
			$("#messageInfo").delay(100).fadeOut(100);
		}
		function getParameterByName(name) {
		    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
		    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
		        results = regex.exec(location.search);
		    return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
		}

		function navigateToUrl(url)
		{
			window.location =  url;
		}
		function showError(message){
			$("#messagebox").text(message);
					$("#message").show();
				  setTimeout(() => {
					  $("#message").hide();
				  },3000)
		}

		function initAppDashboard(appid) {

			// Check if the user is global admin ,  or if the user has been approved to use this app 
			// then only navigate to the app dashboard page  
			if(semusiCommon.isGlobalAdmin ||semusiCommon.getActiveUser.approved_appids.includes(appid)){
				navigateToUrl(`/dashboard?action=dashboard&app_id=${appid}`);
			}else{
				// Otherwise show message to the user
				showError("Your approval is pending for this App. Please contact the Admin.")
			}
			
	      
}

		function gotoDashboard(){
			if(semusiCommon.ACTIVE_APP_ID==""){
				window.location =  "/dashboard";
			}
			else{
				window.location= encodeURI("/dashboard?action=dashboard&app_id=" + semusiCommon.ACTIVE_APP_ID);
			}
		}
        function gotoinsight(){
			if(semusiCommon.ACTIVE_APP_ID==""){
				window.location =  "/insight";
			}
			else{
				window.location= "/dashboard?action=insight&app_id=" + semusiCommon.ACTIVE_APP_ID;
			}
		}
		gotoInsideApp = function(){
			$("#insideul").toggle();
	    }
	    gotoCampaign = function(){
	      window.location = "/dashboard?action=campaigns";
	    }
		closeMessage = function(id){
			$("#"+id).hide();
		}

		function setActiveMenu(){
			$("li[name='menu-policy']").removeClass('active');
			$("li[name='menu-dashboard']").removeClass('active');
			$("li[name='menu-myapps']").removeClass('active');
			$("li[name='menu-myapps']").addClass('has-sub');
			$("li[name='menu-audiencesegment']").removeClass('active');
			$("li[name='menu-audiencesegment']").addClass('has-sub');
			$("li[name='menu-installs']").removeClass('active');
			$("li[name='menu-installs']").addClass('has-sub');
			$("li[name='menu-customevents']").removeClass('active');
			$("li[name='menu-customevents']").addClass('has-sub');
			$("li[name='menu-engagementtools']").removeClass('active');
			$("li[name='menu-engagementtools']").addClass('has-sub');
			$("li[name='menu-churn']").removeClass('active');
			$("li[name='menu-churn']").addClass('has-sub');
			$("li[name='menu-analytics']").removeClass('active');
			$("li[name='menu-analytics']").addClass('has-sub');
			$("li[name='menu-settings']").removeClass('active');
			$("li[name='menu-settings']").addClass('has-sub');
			<%if(action == 'tools'){%>
				$("li[name='menu-engagementtools']").addClass('has-sub active');
				$("li[name='menu-subtools']").addClass('has-sub active');
			<%}%>
			<%if(action == "campaigns"){%>
				$("li[name='menu-engagementtools']").addClass('has-sub active');
				$("li[name='menu-subcampaigns']").addClass('has-sub active');
			<%}%>
			<%if(action == 'insideapp' || action == "funnels"){%>
				$("li[name='menu-customevents']").addClass('has-sub active');
				$("li[name='menu-subcustomevents']").addClass('has-sub active');
			<%}%>
			<%if(action == undefined || action == false){%>
				$("li[name='menu-myapps']").addClass('has-sub active');
			<%}%>
			<%if(action == 'installs'){%>
				$("li[name='menu-installs']").addClass('has-sub active');
				$("li[name='menu-subinstalls']").addClass('has-sub active');
			<%}%>
			// <%if(action == "uploads"){%>
			// 	$("li[name='menu-installs']").addClass('has-sub active');
			// 	$("li[name='menu-subuploads']").addClass('has-sub active');
			// <%}%>

			<%if(action == 'uninstalls' ){%>
				$("li[name='menu-churn']").addClass('has-sub active');
				$("li[name='menu-subuninstalls']").addClass('has-sub active');
			<%}%>
			<%if(action == 'allusers' ){%>
				$("li[name='menu-settings']").addClass('has-sub active');
				$("li[name='menu-subusermanagement']").addClass('has-sub active');
			<%}%>
			<%if(action == 'uploadtestdata' ){%>
				$("li[name='menu-settings']").addClass('has-sub active');
				$("li[name='menu-subuploadtest']").addClass('has-sub active');
			<%}%>
			<%if(action == 'aud'){%>
				$("li[name='menu-audiencesegment']").addClass('has-sub active');
				$("li[name='menu-subaudiencesegment']").addClass('has-sub active');
			<%}%>
			<%if(action == 'createapp'){%>
				$("li[name='menu-dashboard']").addClass('has-sub active');
				$("li[name='menu-subsetupapp']").addClass('has-sub active');
			<%}%>
			<%if(action == 'createchatbot'){%>
				$("li[name='menu-createchatbot']").addClass('has-sub active');
				$("li[name='menu-createchatbot']").addClass('has-sub active');
			<%}%>
			<%if(action == "dashboard"  ){%>
				$("li[name='menu-dashboard']").addClass('has-sub active');
			<%}%>
			<%if(action == 'appsetting'){%>
				$("li[name='menu-appsetting']").addClass('has-sub active');
			<%}%>
			<%if(action == "policy"  ){%>
				$("li[name='menu-policy']").addClass('has-sub active');
			<%}%>
			<%if(action == "demographics"  ){%>
				$("li[name='menu-demographics']").addClass('has-sub active');
			<%}%>
			<%if(action == "insides"){%>
			<%}%>
			<%if(action == "transactionalCampaigns"){%>
			 	$("li[name='menu-subcampaignsTransitional']").addClass('has-sub active');
			<%}%>
			$(".slimScrollBar").css("background","cyan");
		}

		<%if((action == 'uploadtestdata')){%>
			$(window).load(function(){
				$('#overlay').hide();
			});

 			$('#uploadTest').change(function(evt) {
 			var csvfile = $('#uploadTest').get(0).files;

	        	if(csvfile.length >= 1 )
				 {
				 	var filetime=Math.floor(((new Date()).getTime()) / 1000);
                	var fd = new FormData();
					fd.append('app_cert', csvfile[0]);
					fd.append('app_cert_name', csvfile[0].name);
					fd.append('datetime',filetime);

		  		  $.ajax({
						url: '/data/testdata',
						data: fd,
						cache: false,
						contentType: false,
						processData: false,
						type: 'POST',
						success: function(data){
							$("#testfile").attr("value",csvfile[0].name);
							store('hdn_processfile', JSON.stringify(data))
						}
					});
		  		}
	    	  });
 			$('#processTestData').click(function(){
				var filepath=store('hdn_processfile')
				var appkey=$('#appKey').val();
				var url;
				if($('input[name=datatype]:checked').val()=="I"){
					url = semusiCommon.API_PARTS.apps.w + '/processfile';
				}
				else{
					url = semusiCommon.API_PARTS.apps.w + '/processUninstallData';
				}
				$.ajax({
                  type:"GET",
                  url: url,
                  data:{
                      args:JSON.stringify({
                        filename:filepath,
                        appkey:appkey
                      }),
                      api_key: semusiCommon.getActiveUser.api_key,
					  app_id: semusiCommon.ACTIVE_APP_ID,
					  uniqueNumber : semusiCommon.randomNumber(),
                  },
                  
                  success:function (data) {
                  }});

			});
		<%}%>
		<%if(action==undefined || action==false){%>
			function getAppStats(){
				$.ajax({
					type:"GET",
					url:semusiCommon.API_PARTS.metrices.r + '/getAppStats',
					data:{
		                api_key: semusiCommon.getActiveUser.api_key,
						app_id: semusiCommon.ACTIVE_APP_ID,
						uniqueNumber:semusiCommon.randomNumber(),
		            },
					
					success:function (data) {
						if(data != undefined && data != '' && data != [] ){
							fillAppStats(data);
						}else{
							window.location = "/dashboard?action=createapp";
						}
						
					},
					error: function (err) {
						$('#overlay').hide();
					}
				});
			}
			function fillAppStats(appdata){
				var appIds = Object.keys(appdata.data);
				if(appIds.length > 0){
					appIds.forEach(function(value){
						if($.inArray(value,appIds) != -1){
							$("#i_android_"+value).text(appdata.data[value].androidInstallTotal);
							$("#i_ios_"+value).text(appdata.data[value].iosInstallTotal);
							$("#i_web_"+value).text(appdata.data[value].webInstallTotal);
							$("#c_android_"+value).text(appdata.data[value].androidUnInstallTotal);
							$("#c_ios_"+value).text(appdata.data[value].iosUnInstallTotal);
							$("#c_web_"+value).text(appdata.data[value].webUnInstallTotal);

						}else{
							$("#i_android_"+value).text(0);
							$("#i_ios_"+value).text(0);
							$("#i_web_"+value).text(0);
							$("#c_android_"+value).text(0);
							$("#c_ios_"+value).text(0);
							$("#c_web_"+value).text(0);
						}
					});
				}
			}
		<%}%>
	</script>
</body>
</html>
