PageSourceSearch

https://web.rosknroll.fi/rosknroll/js/dhtmlxSuite/sources/dhtmlxMessage/codebase/dhtmlxmessage.js

js rosknroll.fi collected 2026-09-26 03:00:24 UTC 7,119 bytes, 257 lines download raw bytes

1/*
2Product Name: dhtmlxSuite 
3Version: 5.1.0 
4Edition: Professional 
5License: content of this file is covered by DHTMLX Commercial or Enterprise license. Usage without proper license is prohibited. To obtain it contact [email protected]
6Copyright UAB Dinamenta http://www.dhtmlx.com
7*/
8
9if(!window.dhtmlx)
10	window.dhtmlx = {};
11
12(function(){
13	var _dhx_msg_cfg = null;
14	function callback(config, result){
15			var usercall = config.callback;
16			modality(false);
17			config.box.parentNode.removeChild(config.box);
18			_dhx_msg_cfg = config.box = null;
19			if (usercall)
20				usercall(result);
21	}
22	function modal_key(e){
23		if (_dhx_msg_cfg){
24			e = e||event;
25			var code = e.which||event.keyCode;
26			if (dhtmlx.message.keyboard){
27				if (code == 13 || code == 32)
28					callback(_dhx_msg_cfg, true);
29				if (code == 27)
30					callback(_dhx_msg_cfg, false);
31			}
32			if (e.preventDefault)
33				e.preventDefault();
34			return !(e.cancelBubble = true);
35		}
36	}
37	if (document.attachEvent)
38		document.attachEvent("onkeydown", modal_key);
39	else
40		document.addEventListener("keydown", modal_key, true);
41		
42	function modality(mode){
43		if(!modality.cover){
44			modality.cover = document.createElement("DIV");
45			//necessary for IE only
46			modality.cover.onkeydown = modal_key;
47			modality.cover.className = "dhx_modal_cover";
48			document.body.appendChild(modality.cover);
49		}
50		var height =  document.body.scrollHeight;
51		modality.cover.style.display = mode?"inline-block":"none";
52	}
53
54	function button(text, result){
55		return "<div class='dhtmlx_popup_button' result='"+result+"' ><div>"+text+"</div></div>";
56	}
57
58	function info(text){
59		if (!t.area){
60			t.area = document.createElement("DIV");
61			t.area.className = "dhtmlx_message_area";
62			t.area.style[t.position]="15px";
63			document.body.appendChild(t.area);
64		}
65
66		t.hide(text.id);
67		var message = document.createElement("DIV");
68		message.innerHTML = "<div>"+text.text+"</div>";
69		message.className = "dhtmlx-info dhtmlx-" + text.type;
70		message.onclick = function(){
71			if (text) t.hide(text.id);
72			text = null;
73		};
74
75		if (t.position == "bottom" && t.area.firstChild)
76			t.area.insertBefore(message,t.area.firstChild);
77		else
78			t.area.appendChild(message);
79		
80		if (text.expire > 0)
81			t.timers[text.id]=window.setTimeout(function(){
82				t.hide(text.id);
83			}, text.expire);
84
85		t.pull[text.id] = message;
86		message = null;
87
88		return text.id;
89	}
90	function _boxStructure(config, ok, cancel){
91		var box = document.createElement("DIV");
92		box.className = " dhtmlx_modal_box dhtmlx-"+config.type;
93		box.setAttribute("dhxbox", 1);
94			
95		var inner = '';
96
97		if (config.width)
98			box.style.width = config.width;
99		if (config.height)
100			box.style.height = config.height;
101		if (config.title)
102			inner+='<div class="dhtmlx_popup_title">'+config.title+'</div>';
103		inner+='<div class="dhtmlx_popup_text"><span>'+(config.content?'':config.text)+'</span></div><div  class="dhtmlx_popup_controls">';
104		if (ok)
105			inner += button(config.ok || "OK", true);
106		if (cancel)
107			inner += button(config.cancel || "Cancel", false);
108		if (config.buttons){
109			for (var i=0; i<config.buttons.length; i++)
110				inner += button(config.buttons[i],i);
111		}
112		inner += '</div>';
113		box.innerHTML = inner;
114
115		if (config.content){
116			var node = config.content;
117			if (typeof node == "string") 
118				node = document.getElementById(node);
119			if (node.style.display == 'none')
120				node.style.display = "";
121			box.childNodes[config.title?1:0].appendChild(node);
122		}
123
124		box.onclick = function(e){
125			e = e ||event;
126			var source = e.target || e.srcElement;
127			if (!source.className) source = source.parentNode;
128			if (source.className == "dhtmlx_popup_button"){
129				var result = source.getAttribute("result");
130				result = (result == "true")||(result == "false"?false:result);
131				callback(config, result);
132			}
133		};
134		config.box = box;
135		if (ok||cancel)
136			_dhx_msg_cfg = config;
137
138		return box;
139	}
140	function _createBox(config, ok, cancel){
141		var box = config.tagName ? config : _boxStructure(config, ok, cancel);
142		
143		if (!config.hidden)
144			modality(true);
145		document.body.appendChild(box);
146		var x = config.left||Math.abs(Math.floor(((window.innerWidth||document.documentElement.offsetWidth) - box.offsetWidth)/2));
147		var y = config.top||Math.abs(Math.floor(((window.innerHeight||document.documentElement.offsetHeight) - box.offsetHeight)/2));
148		if (config.position == "top")
149			box.style.top = "-3px";
150		else
151			box.style.top = y+'px';
152		box.style.left = x+'px';
153		//necessary for IE only
154		box.onkeydown = modal_key;
155
156		box.focus();
157		if (config.hidden)
158			dhtmlx.modalbox.hide(box);
159
160		return box;
161	}
162
163	function alertPopup(config){
164		return _createBox(config, true, false);
165	}
166	function confirmPopup(config){
167		return _createBox(config, true, true);
168	}
169	function boxPopup(config){
170		return _createBox(config);
171	}
172	function box_params(text, type, callback){
173		if (typeof text != "object"){
174			if (typeof type == "function"){
175				callback = type;
176				type = "";
177			}
178			text = {text:text, type:type, callback:callback };
179		}
180		return text;
181	}
182	function params(text, type, expire, id){
183		if (typeof text != "object" || !text)
184			text = {text:text, type:type, expire:expire, id:id};
185		text.id = text.id||t.uid();
186		text.expire = text.expire||t.expire;
187		return text;
188	}
189	dhtmlx.alert = function(){
190		var text = box_params.apply(this, arguments);
191		text.type = text.type || "confirm";
192		return alertPopup(text);
193	};
194	dhtmlx.confirm = function(){
195		var text = box_params.apply(this, arguments);
196		text.type = text.type || "alert";
197		return confirmPopup(text);
198	};
199	dhtmlx.modalbox = function(){
200		var text = box_params.apply(this, arguments);
201		text.type = text.type || "alert";
202		return boxPopup(text);
203	};
204	dhtmlx.modalbox.hide = function(node){
205		while (node && node.getAttribute && !node.getAttribute("dhxbox"))
206			node = node.parentNode;
207		if (node){
208			node.parentNode.removeChild(node);
209			modality(false);
210			_dhx_msg_cfg = null;
211		}
212	};
213	var t = dhtmlx.message = function(text, type, expire, id){
214		text = params.apply(this, arguments);
215		text.type = text.type||"info";
216
217		var subtype = text.type.split("-")[0];
218		switch (subtype){
219			case "alert":
220				return alertPopup(text);
221			case "confirm":
222				return confirmPopup(text);
223			case "modalbox":
224				return boxPopup(text);
225			default:
226				return info(text);
227			break;
228		}
229	};
230
231	t.seed = (new Date()).valueOf();
232	t.uid = function(){return t.seed++;};
233	t.expire = 4000;
234	t.keyboard = true;
235	t.position = "top";
236	t.pull = {};
237	t.timers = {};
238
239	t.hideAll = function(){
240		for (var key in t.pull)
241			t.hide(key);
242	};
243	t.hide = function(id){
244		var obj = t.pull[id];
245		if (obj && obj.parentNode){
246			window.setTimeout(function(){
247				obj.parentNode.removeChild(obj);
248				obj = null;
249			},2000);
250			obj.className+=" hidden";
251			
252			if(t.timers[id])
253				window.clearTimeout(t.timers[id]);
254			delete t.pull[id];
255		}
256	};
257})();

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.