PageSourceSearch

https://dewiar.com/js/btn_img.js

js dewiar.com collected 2026-10-05 02:14:03 UTC 9,244 bytes, 305 lines download raw bytes

1$(document).ready(function(){
2
3// коллекция расторвых изображений
4$(document).on("click",'#fonbgr img',function()
5{
6var thissrc=$(this).attr("src");
7thissrc=thissrc.replace("/shablon","");
8thissrc=thissrc.replace(".jpg",".png");
9var svg=$("#btnimg svg").attr("id");
10if(svg==undefined)
11{
12$("#btnimg img").attr("src",thissrc);
13$("#btnimg img").removeClass("imgnullbtn").addClass("imgyesbtn").addClass("img_pad0");
14$("#btnimg img").attr("style","");
15}
16else
17{
18$("#"+svg).hide();
19$('#btnimg .butn img').remove();
20$('#btnimg .butn').prepend('<img src="'+thissrc+'" class="imgyesbtn img_pad0">');
21}
22saveBtnImg(thissrc);
23});
24// удаление
25$(document).on("click",'#fonbgr div span',function()
26{
27var xtarget=$("#xtarget").attr("src");
28if(xtarget!=undefined){$("#btnimg img").attr("src",xtarget);}
29else
30{
31$("#btnimg img").addClass("imgnullbtn").removeClass("imgyesbtn").removeClass("img_pad0");
32var svg=$("#btnimg svg").attr("id");
33if(svg==undefined)
34{
35$("#btnimg img").attr("style","margin: 10% auto 8% auto;").attr("src","/qr-icon/1000.png");
36}
37else
38{
39$("#"+svg).show();
40$('#btnimg .butn img').remove();
41}
42}
43saveBtnImg("");
44});
45
46
47function saveBtnImg(shablon_img)
48{
49var admA=$("#admA").val();
50var kodA=$("#kodA").val();
51var id_user_adb=$("#id_user_adb").val();
52var id_btn=$("#id_btn").val();
53mes_sh_none();$("#shag_nazad_loader").show();
54var uRl="/btn_save4.php";
55$.postJSON = function(url, data, callback){$.post(url, data, callback, "json");}
56$.postJSON(uRl,{
57'admA_set':id_user_adb,
58'admA':admA,
59'kodA':kodA,
60'id_btn':id_btn,
61'shablon_img':shablon_img
62},function(data){
63    $("#shag_nazad_loader").hide();
64    if(data.dell!=0)
65        {
66        Mes_shn_close(data.mes);
67        }
68REFRESH_BTN();
69});//$postJSON
70}
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88$(document).on("change",'#f_btn input:radio[name=cRadio],#f_btn input:radio[name=aRadio]',function()
89{
90var img_size=$('#f_btn input:radio[name=cRadio]:checked').val();
91$("#boxsvg img").removeClass('img_size1').removeClass('img_size2');
92if(img_size==1){$("#boxsvg img").addClass('img_size1');}
93else if(img_size==2){$("#boxsvg img").addClass('img_size2');}
94var img_pad=$('#f_btn input:radio[name=aRadio]:checked').val();
95$("#boxsvg img").removeClass('img_pad0').removeClass('img_pad1').removeClass('img_pad2');
96if(img_pad==1){$("#boxsvg img").addClass('img_pad1');}
97else if(img_pad==2){$("#boxsvg img").addClass('img_pad2');}
98else{$("#boxsvg img").addClass('img_pad0');}
99var admA=$("#admA").val();
100var kodA=$("#kodA").val();
101var id_user_adb=$("#id_user_adb").val();
102var id_btn=$("#id_btn").val();
103mes_sh_none();$("#shag_nazad_loader").show();
104var uRl="/btn_save3.php";
105$.postJSON = function(url, data, callback){$.post(url, data, callback, "json");}
106$.postJSON(uRl,{
107'admA_set':id_user_adb,
108'admA':admA,
109'kodA':kodA,
110'img_size':img_size,
111'id_btn':id_btn,
112'img_pad':img_pad
113},function(data){
114    $("#shag_nazad_loader").hide();
115    if(data.dell!=0)
116        {
117        Mes_shn_close(data.mes);
118        }
119    else
120    {
121
122    }
123});//$postJSON
124});
125
126
127
128
129
130var files;
131$(document).on("click",'#btnPh',function(){$('#f_btn input[type=file]').click();});
132$(document).on("change",'#f_btn input[type=file]',function(){
133files = this.files;
134$('#btn_f').click();//Получим данные файлов и добавим их в переменную
135});
136// Вешаем функцию ан событие click и отправляем AJAX запрос с данными файлов
137$(document).on("click",'#btn_f',function(event){
138event.stopPropagation(); // Остановка происходящего
139event.preventDefault();  // Полная остановка происходящего
140// Создадим данные формы и добавим в них данные файлов из files
141var data = new FormData();
142var false_load=1;// сигнализирует, выбрали мы фото или нет
143$.each(files, function( key, value ){false_load=0;data.append(key,value);});
144if(false_load==1){Mes_shn_close("Не выбрано фото");}
145else
146{
147//$("#ph_loader2").show();
148var admA=$("#admA").val();
149var u=$("#id_user_adb").val();
150var kodA=$("#kodA").val();
151var id_btn=$("#id_btn").val();
152var xhr = new XMLHttpRequest();
153$("#prel_prc").show(); $("#prel_prc .ld").css("width","0%");
154// обработчик для отправки
155xhr.upload.onprogress = function(event) {var percentageUploaded = parseFloat((event.loaded / event.total * 100).toFixed(1)); $("#prel_prc .ld").css("width", percentageUploaded+"%").text(percentageUploaded+"%");}
156// обработчики успеха и ошибки
157xhr.onload = xhr.onerror = function() 
158{
159if(this.status == 200) 
160    {
161    // Файлы успешно загружены, делаем что нибудь здесь
162    $("#prel_prc").hide();
163////########################################################################################################
164// Файлы успешно загружены, делаем что нибудь здесь
165//$("#ph_loader2").hide();
166$.get("/btn_photo.php?a_l=1&bt="+id_btn+"&u="+u, function(datax)
167    {
168    $("#ph_cont_btn").html(datax);
169    REFRESH_BTN();
170    xinitJcrop();
171    });
172////########################################################################################################
173    }
174    else 
175    {
176    $("#prel_prc").hide();
177    $("#ph_loader2").hide();
178    //Mes_shn_warning("error " + this.status);
179    alert("НЕ УДАЛОСЬ ЗАГРУЗИТЬ. ОШИБКА: " + this.status +", readyState="+this.readyState);
180    }
181  };
182xhr.open("POST", '/btn_upload.php?admA='+admA+'&id_btn='+id_btn+'&kodA='+kodA+'&uploadfiles', true);
183//xhr.timeout = 1800000;//10000 
184xhr.send(data);
185 }//else
186});//$(document).on("click",'#btn_f',function(event){
187
188//УДАЛИТЬ ФОТО
189$(document).on("click",'#ph_cont_btn .delbg_ico',function(){
190$("#shag_nazad_loader").show();
191var admA=$("#admA").val();
192var kodA=$("#kodA").val();
193var id_btn=$("#id_btn").val();
194var u=$("#id_user_adb").val();
195$.postJSON = function(url, data, callback){$.post(url, data, callback, "json");};
196$.postJSON("/btn_photo_del.php",{'admA':admA,'id_btn':id_btn,'kodA':kodA,'asin
196hr_load':1}, function(data)
197{
198$('#shag_nazad_loader').hide();
199var reaction=data.reaction;
200var mes=data.mes;
201if(reaction==0){
202Mes_shn_close(mes);
203}
204else if(reaction==1){
205//Mes_shn_ok(mes);
206$.get("/btn_photo.php?a_l=1&bt="+id_btn+"&u="+u, function(datax)
207    {
208    $("#ph_cont_btn").html(datax);
209    REFRESH_BTN();
210    //alert('успешно удалено');
211    });
212
213}});//$.postJSON
214return false;
215});//$(document).on("click",'#ph_cont_btn .delbg',function(){
216
217//ПОВЕРНУТЬ ФОТО
218$(document).on("click",'#ph_cont_btn .rotate_ico',function(){
219$("#shag_nazad_loader").show();
220var admA=$("#admA").val();
221var kodA=$("#kodA").val();
222var id_btn=$("#id_btn").val();
223var u=$("#id_user_adb").val();
224$.postJSON = function(url, data, callback){$.post(url, data, callback, "json");};
225$.postJSON("/btn_photo_rotate.php",{'admA':admA,'id_btn':id_btn,'kodA':kodA,'asinhr_load':1}, function(data)
226{
227$('#shag_nazad_loader').hide();
228var reaction=data.reaction;
229var mes=data.mes;
230if(reaction==0){
231Mes_shn_close(mes);
232}
233else if(reaction==1){
234//Mes_shn_ok(mes);
235$.get("/btn_photo.php?a_l=1&bt="+id_btn+"&u="+u, function(datax)
236    {
237    $("#ph_cont_btn").html(datax);
238    REFRESH_BTN();
239    xinitJcrop();
240    });
241}});//$.postJSON
242return false;
243});//$(document).on("click",'#ph_cont_logo .rotate',function(){
244
245
246// нажатие на кнопку "обрезать фото"
247$(document).on("click","#xsub_cropb",function()
248{
249var st=$(".jcrop-widget.active").attr("style");
250var rect_w=$("#xrect_w").val();
251var rect_h=$("#xrect_h").val();
252$("#shag_nazad_loader").show();
253var admA=$("#admA").val();
254var kodA=$("#kodA").val();
255var id_btn=$("#id_btn").val();
256var u=$("#id_user_adb").val();
257$.postJSON = function(url, data, callback){$.post(url, data, callback, "json");};
258$.postJSON("/logo_btn_crop.php",{'admA':admA,'id_btn':id_btn,'kodA':kodA,'st':st,'asinhr_load':1,'rect_w':rect_w,'rect_h':rect_h}, function(data)
259{
260$('#shag_nazad_loader').hide();
261var reaction=data.reaction;
262var mes=data.mes;
263if(reaction==0){Mes_shn_close(mes);}
264else if(reaction==1)
265{
266//$.get("/btn_photo2.php?asinhr_load=1&xparam="+id_btn, function(datax){$("#xasdf2").html(datax);});
267$.get("/btn_photo.php?a_l=1&bt="+id_btn+"&u="+u, function(datax)
268    {
269    //$("#ph_cont_btn").html(datax);
270    REFRESH_BTN();
271    //xinitJcrop();
272    });
273}});//$.postJSON
274return false;
275});
276
277// простая функция
278function xinitJcrop()
279{
280var jcp;
281Jcrop.load('xtarget').then(img => 
282{
283jcp = Jcrop.attach(img,{aspectRatio: 1, multi:false});
284const rect = Jcrop.Rect.sizeOf(jcp.el);
285jcp.newWidget(rect.center(rect.w,rect.h));
286jcp.focus();
287$("<div class=\"btn btn-dark btn-sm\" id=\"xsub_cropb\">ОБРЕЗАТЬ ИКОНКУ</div><input type='hidden' id='xrect_w' value='"+rect.w+"'><input type='hidden' id='xrect_h' value='"+rect.h+"'>").prependTo('#xasdf');
288});//Jcrop.load('target')
289};
290
291if($("#xtarget").attr("src")!=undefined)
292{
293xinitJcrop();
294}
295
296
297
298
299
300function REFRESH_BTN()
301{
302var id_user_adb=$("#id_user_adb").val();
303var id_btn=$("#id_btn").val();
304$.get("/btnimg.php?a_l=1&bt="+id_btn+"&us="+id_user_adb, function(datax){$("#btnimg").html(datax);});}
305});//$(document).ready(function(){

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.