| 
									
										
										
										
											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({ | 
					
						
							| 
									
										
										
										
											2023-10-06 16:31:05 +08:00
										 |  |  | 				title: lang_admin_contest_add_contest, | 
					
						
							| 
									
										
										
										
											2021-03-17 19:44:39 +08:00
										 |  |  | 				size: BootstrapDialog.SIZE_WIDE, | 
					
						
							|  |  |  | 				cssClass: 'create-contest-dialog', | 
					
						
							|  |  |  | 				nl2br: false, | 
					
						
							|  |  |  | 				message: html, | 
					
						
							|  |  |  | 				buttons: [{ | 
					
						
							| 
									
										
										
										
											2023-10-06 16:31:05 +08:00
										 |  |  | 					label: lang_admin_close, | 
					
						
							| 
									
										
										
										
											2021-03-17 19:44:39 +08:00
										 |  |  | 					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-08 14:57:27 +08:00
										 |  |  | 			$(".contest_" + contestid).text(lang_admin_contest_menu_n_active); | 
					
						
							| 
									
										
										
										
											2023-10-06 15:26:34 +08:00
										 |  |  | 			$('.btn_' + contestid).html(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 15:26:34 +08:00
										 |  |  | 			$('.contest_' + contestid).text(lang_admin_contest_menu_active); | 
					
						
							|  |  |  | 			$('.btn_' + contestid).html(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({ | 
					
						
							| 
									
										
										
										
											2023-10-07 04:17:08 +08:00
										 |  |  | 		title: lang_admin_danger, | 
					
						
							|  |  |  | 		message: lang_admin_contest_deletion_warning + 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({ | 
					
						
							| 
									
										
										
										
											2023-10-07 04:17:08 +08:00
										 |  |  | 		title: lang_admin_danger, | 
					
						
							|  |  |  | 		message: lang_admin_contest_active_all_warning, | 
					
						
							| 
									
										
										
										
											2021-10-24 01:44:41 +08:00
										 |  |  | 		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({ | 
					
						
							| 
									
										
										
										
											2023-10-07 04:17:08 +08:00
										 |  |  | 		title: lang_admin_danger, | 
					
						
							|  |  |  | 		message: lang_admin_contest_deactive_all_warning, | 
					
						
							| 
									
										
										
										
											2021-10-24 01:44:41 +08:00
										 |  |  | 		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
										 |  |  | } |