| 
									
										
										
										
											2021-03-17 19:44:39 +08:00
										 |  |  | $('.contesttable').DataTable({ | 
					
						
							|  |  |  | 	"pageLength": 25, | 
					
						
							|  |  |  | 	responsive: false, | 
					
						
							|  |  |  | 	ordering: false, | 
					
						
							| 
									
										
										
										
											2021-10-24 01:44:41 +08:00
										 |  |  | 	"scrollY": "400px", | 
					
						
							| 
									
										
										
										
											2021-03-17 19:44:39 +08:00
										 |  |  | 	"scrollCollapse": true, | 
					
						
							| 
									
										
										
										
											2021-10-24 01:44:41 +08:00
										 |  |  | 	"paging": false, | 
					
						
							| 
									
										
										
										
											2021-03-17 19:44:39 +08:00
										 |  |  | 	"scrollX": true, | 
					
						
							|  |  |  | 	dom: 'Bfrtip', | 
					
						
							|  |  |  | 	buttons: [ | 
					
						
							| 
									
										
										
										
											2023-04-25 05:56:29 +08:00
										 |  |  | 		{ | 
					
						
							|  |  |  | 			extend: 'csv', | 
					
						
							|  |  |  | 			exportOptions: { | 
					
						
							|  |  |  | 				columns: [ 0, 1, 2 ] | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2021-03-17 19:44:39 +08:00
										 |  |  | 	] | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // using this to change color of csv-button if dark mode is chosen
 | 
					
						
							| 
									
										
										
										
											2021-10-24 01:44:41 +08:00
										 |  |  | var background = $('body').css("background-color"); | 
					
						
							| 
									
										
										
										
											2021-03-17 19:44:39 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | if (background != ('rgb(255, 255, 255)')) { | 
					
						
							|  |  |  | 	$(".buttons-csv").css("color", "white"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function createContestDialog() { | 
					
						
							|  |  |  | 	$.ajax({ | 
					
						
							|  |  |  | 		url: base_url + 'index.php/contesting/create', | 
					
						
							|  |  |  | 		type: 'post', | 
					
						
							| 
									
										
										
										
											2021-10-24 01:44:41 +08:00
										 |  |  | 		success: function (html) { | 
					
						
							| 
									
										
										
										
											2021-03-17 19:44:39 +08:00
										 |  |  | 			BootstrapDialog.show({ | 
					
						
							|  |  |  | 				title: 'Add Contest', | 
					
						
							|  |  |  | 				size: BootstrapDialog.SIZE_WIDE, | 
					
						
							|  |  |  | 				cssClass: 'create-contest-dialog', | 
					
						
							|  |  |  | 				nl2br: false, | 
					
						
							|  |  |  | 				message: html, | 
					
						
							|  |  |  | 				buttons: [{ | 
					
						
							|  |  |  | 					label: 'Close', | 
					
						
							|  |  |  | 					action: function (dialogItself) { | 
					
						
							|  |  |  | 						dialogItself.close(); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				}] | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function createContest(form) { | 
					
						
							|  |  |  | 	if (form.contestname.value != '') { | 
					
						
							|  |  |  | 		$.ajax({ | 
					
						
							|  |  |  | 			url: base_url + 'index.php/contesting/create', | 
					
						
							|  |  |  | 			type: 'post', | 
					
						
							| 
									
										
										
										
											2021-10-24 01:44:41 +08:00
										 |  |  | 			data: { | 
					
						
							|  |  |  | 				'name': form.contestname.value, | 
					
						
							|  |  |  | 				'adifname': form.adifcontestname.value | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 			success: function (html) { | 
					
						
							| 
									
										
										
										
											2021-03-17 19:44:39 +08:00
										 |  |  | 				location.reload(); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function deactivateContest(contestid) { | 
					
						
							|  |  |  | 	$.ajax({ | 
					
						
							|  |  |  | 		url: base_url + 'index.php/contesting/deactivate', | 
					
						
							|  |  |  | 		type: 'post', | 
					
						
							| 
									
										
										
										
											2021-10-24 01:44:41 +08:00
										 |  |  | 		data: { 'id': contestid }, | 
					
						
							|  |  |  | 		success: function (html) { | 
					
						
							| 
									
										
										
										
											2023-10-06 04:02:26 +08:00
										 |  |  | 			$(`.contest_${contestid}`).text("<?php echo lang('admin_contest_menu_n_active'); ?>"); | 
					
						
							|  |  |  | 			$('.btn_' + contestid).html("<?php echo lang('admin_contest_menu_activate'); ?>"); | 
					
						
							| 
									
										
										
										
											2021-10-24 01:44:41 +08:00
										 |  |  | 			$('.btn_' + contestid).attr('onclick', 'activateContest(' + contestid + ')') | 
					
						
							| 
									
										
										
										
											2021-03-17 19:44:39 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function activateContest(contestid) { | 
					
						
							|  |  |  | 	$.ajax({ | 
					
						
							|  |  |  | 		url: base_url + 'index.php/contesting/activate', | 
					
						
							|  |  |  | 		type: 'post', | 
					
						
							| 
									
										
										
										
											2021-10-24 01:44:41 +08:00
										 |  |  | 		data: { 'id': contestid }, | 
					
						
							|  |  |  | 		success: function (html) { | 
					
						
							| 
									
										
										
										
											2023-10-06 04:02:26 +08:00
										 |  |  | 			$('.contest_' + contestid).text("<?php echo lang('admin_contest_menu_active'); ?>"); | 
					
						
							|  |  |  | 			$('.btn_' + contestid).html("<?php echo lang('admin_contest_menu_deactivate'); ?>"); | 
					
						
							| 
									
										
										
										
											2021-10-24 01:44:41 +08:00
										 |  |  | 			$('.btn_' + contestid).attr('onclick', 'deactivateContest(' + contestid + ')') | 
					
						
							| 
									
										
										
										
											2021-03-17 19:44:39 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function deleteContest(id, contest) { | 
					
						
							|  |  |  | 	BootstrapDialog.confirm({ | 
					
						
							|  |  |  | 		title: 'DANGER', | 
					
						
							| 
									
										
										
										
											2021-10-24 01:44:41 +08:00
										 |  |  | 		message: 'Warning! Are you sure you want to delete the following contest: ' + contest + '?', | 
					
						
							| 
									
										
										
										
											2021-03-17 19:44:39 +08:00
										 |  |  | 		type: BootstrapDialog.TYPE_DANGER, | 
					
						
							|  |  |  | 		closable: true, | 
					
						
							|  |  |  | 		draggable: true, | 
					
						
							|  |  |  | 		btnOKClass: 'btn-danger', | 
					
						
							| 
									
										
										
										
											2021-10-24 01:44:41 +08:00
										 |  |  | 		callback: function (result) { | 
					
						
							|  |  |  | 			if (result) { | 
					
						
							| 
									
										
										
										
											2021-03-17 19:44:39 +08:00
										 |  |  | 				$.ajax({ | 
					
						
							|  |  |  | 					url: base_url + 'index.php/contesting/delete', | 
					
						
							|  |  |  | 					type: 'post', | 
					
						
							| 
									
										
										
										
											2021-10-24 01:44:41 +08:00
										 |  |  | 					data: { | 
					
						
							|  |  |  | 						'id': id | 
					
						
							| 
									
										
										
										
											2021-03-17 19:44:39 +08:00
										 |  |  | 					}, | 
					
						
							| 
									
										
										
										
											2021-10-24 01:44:41 +08:00
										 |  |  | 					success: function (data) { | 
					
						
							| 
									
										
										
										
											2021-03-17 19:44:39 +08:00
										 |  |  | 						$(".contest_" + id).parent("tr:first").remove(); // removes mode from table
 | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				}); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2021-10-24 01:44:41 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | function activateAllContests() { | 
					
						
							|  |  |  | 	BootstrapDialog.confirm({ | 
					
						
							|  |  |  | 		title: 'DANGER', | 
					
						
							|  |  |  | 		message: 'Warning! Are you sure you want to activate all contests?', | 
					
						
							|  |  |  | 		type: BootstrapDialog.TYPE_DANGER, | 
					
						
							|  |  |  | 		closable: true, | 
					
						
							|  |  |  | 		draggable: true, | 
					
						
							|  |  |  | 		btnOKClass: 'btn-danger', | 
					
						
							|  |  |  | 		callback: function (result) { | 
					
						
							|  |  |  | 			if (result) { | 
					
						
							|  |  |  | 				$.ajax({ | 
					
						
							|  |  |  | 					url: base_url + 'index.php/contesting/activateall', | 
					
						
							|  |  |  | 					type: 'post', | 
					
						
							|  |  |  | 					success: function (data) { | 
					
						
							|  |  |  | 						location.reload(); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				}); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function deactivateAllContests() { | 
					
						
							|  |  |  | 	BootstrapDialog.confirm({ | 
					
						
							|  |  |  | 		title: 'DANGER', | 
					
						
							|  |  |  | 		message: 'Warning! Are you sure you want to deactivate all contests?', | 
					
						
							|  |  |  | 		type: BootstrapDialog.TYPE_DANGER, | 
					
						
							|  |  |  | 		closable: true, | 
					
						
							|  |  |  | 		draggable: true, | 
					
						
							|  |  |  | 		btnOKClass: 'btn-danger', | 
					
						
							|  |  |  | 		callback: function (result) { | 
					
						
							|  |  |  | 			if (result) { | 
					
						
							|  |  |  | 				$.ajax({ | 
					
						
							|  |  |  | 					url: base_url + 'index.php/contesting/deactivateall', | 
					
						
							|  |  |  | 					type: 'post', | 
					
						
							|  |  |  | 					success: function (data) { | 
					
						
							|  |  |  | 						location.reload(); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				}); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2023-04-25 05:56:29 +08:00
										 |  |  | } |