Subversion Repositories SmartDukaan

Rev

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

Rev 25685 Rev 25759
Line 1... Line 1...
1
$(function() {
1
$(function() {
2
	$('.send-notification').live('click', function() {
2
	$('.send-notification').live('click', function() {
3
		
3
 
4
		loadNotificationPanel("main-content");
4
		loadNotificationPanel("main-content");
5
	});
5
	});
6
 
6
 
7
	$('.create-notification-button')
7
	$('.create-notification-button')
8
			.live(
8
			.live(
Line 18... Line 18...
18
						var title = $('input[name="title"]').val();
18
						var title = $('input[name="title"]').val();
19
						var message = $('input[name="message"]').val();
19
						var message = $('input[name="message"]').val();
20
						var imageUrl = $('input[name="imageUrl"]').val();
20
						var imageUrl = $('input[name="imageUrl"]').val();
21
						var type = $('#type').val();
21
						var type = $('#type').val();
22
						var expiryTime = $('#expireSat').val();
22
						var expiryTime = $('#expireSat').val();
-
 
23
 
-
 
24
						var val = $("#selectedUrl").val();
-
 
25
						console.log(val);
-
 
26
						if (val == "other") {
23
						var url = $('input[name="url"]').val();
27
							url = $('input[name="url"]').val();
-
 
28
						} else {
-
 
29
							url = val;
-
 
30
						}
-
 
31
 
24
						var messageType = $('#messageType').val();
32
						var messageType = $('#messageType').val();
25
 
33
 
26
						$('#showImage').on('change', function() {
34
						$('#showImage').on('change', function() {
27
							this.value = this.checked ? true : false;
35
							this.value = this.checked ? true : false;
28
						}).change();
36
						}).change();
29
 
37
 
30
						if (userIds.length === 0 && campaignName === ""
38
						if (userIds.length === 0 && campaignName === ""
31
								&& title === "" && message === ""
39
								&& title === "" && message === ""
32
								&& expiryTime === "" && type === ""&& messageType==="") {
40
								&& expiryTime === "" && type === ""
-
 
41
								&& messageType === "") {
33
							alert("Field can't be empty");
42
							alert("Field can't be empty");
34
							return;
43
							return;
35
						}
44
						}
36
						if (userIds.length === 0) {
45
						if (userIds.length === 0) {
37
							alert("please select the user");
46
							alert("please select the user");
Line 51... Line 60...
51
						}
60
						}
52
						if (expiryTime === "") {
61
						if (expiryTime === "") {
53
							alert("ExpiryTime is required");
62
							alert("ExpiryTime is required");
54
							return;
63
							return;
55
						}
64
						}
56
						
65
 
57
						if (messageType === null) {
66
						if (messageType === null) {
58
							alert("message type is required");
67
							alert("message type is required");
59
							return;
68
							return;
60
						}
69
						}
61
						if (type === "") {
70
						if (type === "") {
Line 79... Line 88...
79
								.val();
88
								.val();
80
						notificationData['message'] = $('#message').val();
89
						notificationData['message'] = $('#message').val();
81
						notificationData['imageUrl'] = $(
90
						notificationData['imageUrl'] = $(
82
								'input[name="imageUrl"]').val();
91
								'input[name="imageUrl"]').val();
83
						notificationData['type'] = $('#type').val();
92
						notificationData['type'] = $('#type').val();
84
						notificationData['url'] = $('input[name="url"]').val();
93
						notificationData['url'] = url;
85
						notificationData['expiresat'] = startDate;
94
						notificationData['expiresat'] = startDate;
86
						notificationData['showImage'] = $(
95
						notificationData['showImage'] = $(
87
								'input[name="showImage"]').val();
96
								'input[name="showImage"]').val();
88
						notificationData['documentId'] = localStorage
97
						notificationData['documentId'] = localStorage
89
								.getItem("notifyDocument");
98
								.getItem("notifyDocument");
90
						notificationData['messageType'] = $('#messageType')
99
						notificationData['messageType'] = $('#messageType')
91
								.val();
100
								.val();
92
						console.log(notificationData)
101
						console.log(notificationData)
93
 
102
 
94
						if (confirm("Are you sure you want to send notification!") == true) {
103
						if (confirm("Are you sure you want to send notification!") == true) {
95
							doPostAjaxRequestWithJsonHandler(
104
							doPostAjaxRequestWithJsonHandler(context
96
									context + "/sendNotification",
105
									+ "/sendNotification", JSON
97
									JSON.stringify(notificationData),
106
									.stringify(notificationData), function(
98
									function(response) {
107
									response) {
99
										if (response == 'true') {
108
								if (response == 'true') {
100
											alert("successfully send");
109
									alert("successfully send");
101
											loadNotificationPanel("main-content");
110
									loadNotificationPanel("main-content");
102
											localStorage
-
 
103
													.removeItem("notifyDocument");
111
									localStorage.removeItem("notifyDocument");
104
										}
112
								}
105
									});
113
							});
106
 
114
 
107
							return false;
115
							return false;
108
						}
116
						}
109
 
117
 
110
					});
118
					});
111
 
119
 
112
});
120
});
113
 
121
 
114
function loadNotificationPanel(domId) {
122
function loadNotificationPanel(domId) {
115
	localStorage
-
 
116
	.removeItem("notifyDocument");
123
	localStorage.removeItem("notifyDocument");
117
	doGetAjaxRequestHandler(context + "/sendNotificationPanel", function(
124
	doGetAjaxRequestHandler(context + "/sendNotificationPanel", function(
118
			response) {
125
			response) {
119
		$('#' + domId).html(response);
126
		$('#' + domId).html(response);
-
 
127
		$("#url").hide();
120
 
128
 
121
	});
129
	});
122
 
130
 
123
}
131
}
124
 
132
 
Line 157... Line 165...
157
							// is required");
165
							// is required");
158
						}
166
						}
159
					} else {
167
					} else {
160
						// Do nothing!
168
						// Do nothing!
161
					}
169
					}
162
				});
-
 
163
170
				});
-
 
171
 
-
 
172
function changeUrl() {
-
 
173
	var val = $("#selectedUrl").val();
-
 
174
	console.log(val);
-
 
175
	if (val == "other") {
-
 
176
		$("#url").show();
-
 
177
	} else {
-
 
178
		$("#url").hide();
-
 
179
	}
-
 
180
 
-
 
181
}
-
 
182