PageSourceSearch

https://dabasdati.lv/js/comments.js

js dabasdati.lv collected 2026-10-02 12:49:28 UTC 2,682 bytes, 93 lines download raw bytes

1/* loads comment part */
2var idCom="commentsArea",idHist="historyArea";
3$(document).ready(function(){ if($("#"+idCom).length > 0) initComments(); });
4$(document).ready(function(){ if($("#"+idHist).length > 0) initHistory(); });
5
6function initComments(){
7	aname = "#"+idCom;
8	id = $(aname).data("source");
9	target = $(aname).data("type");
10	reloadComments({'c':'comments','d':'{"i":'+id+',"t":"'+target+'"}'},aname);
11}
12function initHistory(){
13	var hname = "#"+idHist;
14	id = $(hname).data("source");
15	target = $(hname).data("type");
16	send = {'c':'history','d':'{"i":'+id+',"t":"'+target+'"}'};
17	$.ajax({
18		url:"/cmd/",
19		type:'post',
20		data: send,
21	}).success(function(data){
22		result = JSON.parse(data);
23		if (typeof result.error!="undefined"){
24			$(hname).html("");
25		} else {
26			if (typeof result.result=="undefined"){
27				$(hname).html("");
28			} else {
29				trg = b64DecodeUnicode(result.result);
30				$(hname).html(trg);
31			}
32		}
33	}).fail(function(){
34		$(hname).html('');
35	});
36}
37function b64DecodeUnicode(str) {
38	return decodeURIComponent(Array.prototype.map.call(atob(str), function(c){
39		return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
40	}).join(''));
41}
42function b64EncodeUnicode(str) {
43	return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function(match,p1){
44		return String.fromCharCode('0x' + p1);
45	}));
46}
47function commentsFuncs(){
48	if ($("#commentAdd").length>0){
49		$("#commentAdd").on("click",function(){sendComment();});
50	}
51}
52function sendComment(){
53	aname = "#"+idCom;
54	id = $(aname).data("source");
55	target = $(aname).data("type");
56	txt = $("#commentbody").val();
57	reloadComments({'c':'comment','d':'{"i":'+id+',"t":"'+target+'","c":"'+b64EncodeUnicode(txt)+'"}'},aname);
58}
59function spinnerAdd(elem){
60	$(elem).html('<div style="text-align:center;"><img style="width:20px;height:20px;margin:0 auto;" src="/baltiestarki/images/loader.gif" /></div>');
61}
62function reloadComments(send,targ){
63	var aname = "#"+idCom;
64	spinnerAdd(aname);
65	$.ajax({
66		url:"/cmd/",
67		type:'post',
68		data: send,
69	}).success(function(data){
70		result = JSON.parse(data);
71		if (typeof result.error!="undefined"){
72			$(aname).html("Kļūda ielādējot komentārus: "+result.error);
73		} else {
74			if (typeof result.result=="undefined"){
75				$(aname).html("Kļūda ielādējot komentārus!");
76			} else {
77				trg = b64DecodeUnicode(result.result);
78				$(aname).html(trg);
79				commentsFuncs();
80			}
81		}
82	}).fail(function(){
83		$(aname).html('');
84	});
85}
86function commentManage(i,t){
87	if (confirm(t)){
88		ccid = "#"+idCom;
89		target = $(ccid).data("type");
90		id = $(ccid).data("source");
91		reloadComments({'c':'commentManage','d':'{"i":'+id+',"m":"'+i+'","t":"'+target+'"}'},ccid);
92	}
93}

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.