Subversion Repositories SmartDukaan

Rev

Rev 25374 | Rev 25649 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 25374 Rev 25383
Line 1... Line 1...
1
$(function() {
1
$(function() {
2
	$('.send-notification').live('click', function() {
2
	$('.send-notification').live('click', function() {
3
		loadNotificationPanel("main-content");
3
		loadNotificationPanel("main-content");
4
	});
4
	});
5
	
-
 
6
	
5
 
7
	$('.create-notification-button').live('click', function() {
6
	$('.create-notification-button')
-
 
7
			.live(
-
 
8
					'click',
-
 
9
					function() {
8
		var userIds = $('#fofo-users').val();
10
						var userIds = $('#fofo-users').val().concat(
-
 
11
								$('#internal-users').val());
9
		console.log("multipleUsers",userIds);
12
						console.log("multipleUsers", userIds);
10
		var campaignName = $('input[name="campaignName"]').val();
13
						var campaignName = $('input[name="campaignName"]')
-
 
14
								.val();
11
		var title = $('input[name="title"]').val();
15
						var title = $('input[name="title"]').val();
12
		var message = $('input[name="message"]').val();
16
						var message = $('input[name="message"]').val();
13
		var imageUrl = $('input[name="imageUrl"]').val();
17
						var imageUrl = $('input[name="imageUrl"]').val();
14
		var type = $('#type').val();
18
						var type = $('#type').val();
15
		var expiryTime=$('#expireSat').val();
19
						var expiryTime = $('#expireSat').val();
16
		var url = $('input[name="url"]').val();
20
						var url = $('input[name="url"]').val();
17
		$('#showImage').on('change', function(){
21
						$('#showImage').on('change', function() {
18
			   this.value = this.checked ? true : false;
22
							this.value = this.checked ? true : false;
19
			}).change();		
23
						}).change();
20
			
-
 
21
	   
-
 
22
	
24
 
23
		if(userIds.length === 0 && campaignName === "" && title === "" && message === "" && expiryTime==="" && type===""){
25
						if (userIds.length === 0 && campaignName === ""
-
 
26
								&& title === "" && message === ""
-
 
27
								&& expiryTime === "" && type === "") {
24
		alert("Field can't be empty");
28
							alert("Field can't be empty");
25
		return;
29
							return;
26
	}
30
						}
27
   if(userIds.length === 0){
31
						if (userIds.length === 0) {
28
		alert("please select the user");
32
							alert("please select the user");
29
		return;
33
							return;
30
	}
34
						}
31
	if(campaignName === ""){
35
						if (campaignName === "") {
32
		alert("Campaign name is required");
36
							alert("Campaign name is required");
33
		return;
37
							return;
34
	}
38
						}
35
	if(title === ""){
39
						if (title === "") {
36
		alert("Title Name is required");
40
							alert("Title Name is required");
37
		return;
41
							return;
38
	}
42
						}
39
	if(message === ""){
43
						if (message === "") {
40
		alert("Message is required");
44
							alert("Message is required");
41
		return;
45
							return;
42
	}
46
						}
43
	if(expiryTime === ""){
47
						if (expiryTime === "") {
44
		alert("ExpiryTime is required");
48
							alert("ExpiryTime is required");
45
		return;
49
							return;
46
	}
50
						}
47
	if(type === ""){
51
						if (type === "") {
48
		alert("type is required");
52
							alert("type is required");
49
		return;
53
							return;
50
	}
54
						}
51
	if(type === "url")
55
						if (type === "url") {
52
	{
-
 
53
	if(url === "")
56
							if (url === "") {
54
	{
-
 
55
	alert("url is required");
57
								alert("url is required");
56
	return;
58
								return;
57
	}
59
							}
58
	
60
 
59
	}	
61
						}
60
		
62
 
61
		var notificationData ={};
63
						var notificationData = {};
62
		notificationData['userIds'] =$('#fofo-users').val();
64
						notificationData['userIds'] = $('#fofo-users').val()
-
 
65
								.concat($('#internal-users').val());
-
 
66
						notificationData['campaignName'] = $(
63
		notificationData['campaignName'] = $('input[name="campaignName"]').val();
67
								'input[name="campaignName"]').val();
64
		notificationData['title']=$('input[name="title"]').val();
68
						notificationData['title'] = $('input[name="title"]')
-
 
69
								.val();
65
		notificationData['message']=$('#message').val();
70
						notificationData['message'] = $('#message').val();
-
 
71
						notificationData['imageUrl'] = $(
66
		notificationData['imageUrl']=$('input[name="imageUrl"]').val();
72
								'input[name="imageUrl"]').val();
67
		notificationData['type']=$('#type').val();
73
						notificationData['type'] = $('#type').val();
68
		notificationData['url']=$('input[name="url"]').val();
74
						notificationData['url'] = $('input[name="url"]').val();
69
		notificationData['expiresat']=startDate;
75
						notificationData['expiresat'] = startDate;
-
 
76
						notificationData['showImage'] = $(
70
		notificationData['showImage']=$('input[name="showImage"]').val();
77
								'input[name="showImage"]').val();
71
		console.log(notificationData)
78
						console.log(notificationData)
72
		
79
 
73
	if(confirm("Are you sure you want to send notification!") == true){
80
						if (confirm("Are you sure you want to send notification!") == true) {
-
 
81
							doPostAjaxRequestWithJsonHandler(context
-
 
82
									+ "/sendNotification", JSON
74
	doPostAjaxRequestWithJsonHandler(context+"/sendNotification", JSON.stringify(notificationData), function(response){
83
									.stringify(notificationData), function(
-
 
84
									response) {
75
	               if (response == 'true') {
85
								if (response == 'true') {
76
						    alert("successfully send");
86
									alert("successfully send");
77
					loadNotificationPanel("main-content");
87
									loadNotificationPanel("main-content");
78
					}
88
								}
79
			});
89
							});
80
			
90
 
81
		return false;	
91
							return false;
82
	}
-
 
83
	 		
92
						}
84
		
93
 
85
	});
94
					});
86
	
95
 
87
});
96
});
88
 
97
 
89
function loadNotificationPanel(domId){
98
function loadNotificationPanel(domId) {
90
  	doGetAjaxRequestHandler(context+ "/sendNotificationPanel", function(response){
99
	doGetAjaxRequestHandler(context + "/sendNotificationPanel", function(
-
 
100
			response) {
91
		$('#' + domId).html(response);
101
		$('#' + domId).html(response);
92
		
102
 
93
	});
103
	});
94
	
104
 
95
}
105
}
96
106