PageSourceSearch

https://launio.org/Scripts/App/zonesManager.js

js launio.org collected 2026-09-27 07:25:03 UTC 4,117 bytes, 163 lines download raw bytes

1chil.ZonesManager = function(){
2	var lang = chil.localization.getLang();
3	var dialogs = chil.dialogs;
4	
5	var actorId = 0;
6	
7	function onAddNewZoneClick(ev){
8		chil.ui.showVeil();
9		chil.ui.showLoading();
10		
11		$.ajax({
12			url: "/add-zone/" + actorId,
13			success: function(response){
14				chil.ui.hideLoading();
15				
16				var $popup = dialogs.popup({
17					title: lang.addZone,
18					body: response
19				});
20				
21				$(".listspicker", $popup).each(function(){
22					var $this = $(this);
23					var name = $this.attr("data-name");
24					
25					$this.listspicker({
26						actorId : actorId,
27						inputName: name,
28						onShowPicker: function($element){
29							$("input", $element.parent()).attr("checked", "checked");  
30						}
31					});
32				});
33					
34				var $saving = $(".saving", $popup);
35            	var $btn = $(".button-submit", $popup);
36            	var $form = $("form", $popup);
37                	
38            	$form.ajaxForm({
39            		beforeSubmit: function(){
40            			$btn.hide();
41            			$saving.show();
42            		},
43            		success: function(r){
44            			if (typeof(r) === 'object' && r.error){
45            				$saving.hide();
46            				$btn.show();
47            				if (r.error.code == "zone_exists"){
48            					$(".name-error").html(lang.zoneExists).show();
49            				}
50            			}
51            			else {
52            				var $r = $(r);
53            				$(".newzone-list").append($r);
54            				setupZoneRow($r);
55            				$popup.remove();
56            				chil.ui.hideVeil();	
57            			}	
58            		}
59            	});
60			}
61		})
62	}
63	
64	function onRemoveZoneClick(ev){
65		var $btn = $(this);
66		
67		dialogs.confirmDialog({
68			message: lang.removeZoneWarning,
69			ok: function(){
70				var $row = $btn.closest(".zone-row");
71				$.ajax({
72					type: "POST",
73					url: "/remove-zone/" + $row.attr("data-id"),
74					success: function(r){
75						$row.remove();		
76					}
77				})		
78			}
79		});
80		
81		ev.preventDefault();
82	}
83	
84	function onEditZoneClick(ev){
85		var $btn = $(this);
86		var $row = $btn.closest(".zone-row");
87		var id = $row.attr("data-id");
88		
89		chil.ui.showVeil();
90		chil.ui.showLoading();
91		
92		$.ajax({
93			url: "/edit-zone/" + id,
94			success: function(response){
95				chil.ui.hideLoading();
96				
97				var $popup = dialogs.popup({
98					title: lang.editZone,
99					body: response
100				});
101				
102				$(".listspicker", $popup).each(function(){
103					var $this = $(this);
104					var name = $this.attr("data-name");
105					
106					$this.listspicker({
107						actorId : actorId,
108						inputName: name,
109						onShowPicker: function($element){
110							$("input", $element.parent()).attr("checked", "checked");  
111						}
112					});
113				});
114					
115				var $saving = $(".saving", $popup);
116            	var $btn = $(".button-submit", $popup);
117            	var $form = $("form", $popup);
118            	
119            	$form.ajaxForm({
120            		beforeSubmit: function(){
121            			$btn.hide();
122            			$saving.show();
123            		},
124            		success: function(r){
125            			if (typeof(r) === 'object' && r.error){
126            				$saving.hide();
127            				$btn.show();
128            				if (r.error.code == "zone_exists"){
129            					$(".name-error").html(lang.zoneExists).show();
130            				}
131            			}
132            			else {
133            				$(".name", $row).html($("input[name=name]", $form).val());
134            				$(".desc", $row).html($("input[name=description]", $form).val());
135            				$popup.remove();
136            				chil.ui.hideVeil();	
137            			}	
138            		}
139            	});
140			}
141		});
142	}
143	
144	function setupZoneRow($row){
145		$(".remove-zone", $row).on("click", onRemoveZoneClick)
146		$(".edit-zone", $row).on("click", onEditZoneClick)
147	}
148	
149	function setup(aid){
150		actorId = aid;
151		
152		$(".add-new-zone").on("click", onAddNewZoneClick);
153		
154		$(".zone-row").each(function(){
155			setupZoneRow($(this));
156		})
157	}
158	
159	return {
160		setup: setup
161	}
162}();
163

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.