141 lines
3.3 KiB
JavaScript
141 lines
3.3 KiB
JavaScript
let bounds = [
|
|
[42.9130026312, 75.6166317076],
|
|
[20.5782370061, 35.5092252948],
|
|
];
|
|
|
|
// var map = L.map("map", {
|
|
// maxBounds: bounds,
|
|
// minZoom: 6,
|
|
// }).setView([35.657296, 51.437884], 1);
|
|
// L.tileLayer("https://testmap.141.ir/141map/{z}/{x}/{y}.png", {}).addTo(map);
|
|
|
|
|
|
$("#inputFile1").change(function () {
|
|
$("#firstshow").css("display", "none");
|
|
readURL1(this);
|
|
});
|
|
$("#inputFile2").change(function () {
|
|
$("#secondshow").css("display", "none");
|
|
readURL2(this);
|
|
});
|
|
$("#inputFile3").change(function () {
|
|
$("#thirdshow").css("display", "none");
|
|
readURL3(this);
|
|
});
|
|
function readURL1(input) {
|
|
if (input.files && input.files[0]) {
|
|
var reader = new FileReader();
|
|
|
|
reader.onload = function (e) {
|
|
$("#image_upload_first").css("display", "block");
|
|
$("#image_upload_first").attr("src", e.target.result);
|
|
uploadUpdateImage(1, input);
|
|
};
|
|
reader.readAsDataURL(input.files[0]);
|
|
}
|
|
}
|
|
function readURL2(input) {
|
|
if (input.files && input.files[0]) {
|
|
var reader = new FileReader();
|
|
|
|
reader.onload = function (e) {
|
|
$("#image_upload_second").css("display", "block");
|
|
$("#image_upload_second").attr("src", e.target.result);
|
|
uploadUpdateImage(2, input);
|
|
};
|
|
reader.readAsDataURL(input.files[0]);
|
|
}
|
|
}
|
|
function readURL3(input) {
|
|
if (input.files && input.files[0]) {
|
|
var reader = new FileReader();
|
|
|
|
reader.onload = function (e) {
|
|
$("#image_upload_third").css("display", "block");
|
|
$("#image_upload_third").attr("src", e.target.result);
|
|
uploadUpdateImage(3, input);
|
|
};
|
|
reader.readAsDataURL(input.files[0]);
|
|
}
|
|
}
|
|
|
|
$("#add-news-button").on("click" , function(){
|
|
$("#stepModalmaintenance").modal("show")
|
|
})
|
|
restrictInputOtherThanArabic($("#texteraenews"));
|
|
|
|
function restrictInputOtherThanArabic($field) {
|
|
// Arabic characters fall in the Unicode range 0600 - 06FF
|
|
var arabicCharUnicodeRange = /[\u0600-\u06FF-0-9-45]/;
|
|
|
|
$field.bind("keypress", function (event) {
|
|
var key = event.which;
|
|
// 0 = numpad
|
|
// 8 = backspace
|
|
// 32 = space
|
|
if (key == 8 || key == 0 || key === 32) {
|
|
return true;
|
|
}
|
|
|
|
var str = String.fromCharCode(key);
|
|
if (arabicCharUnicodeRange.test(str)) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
});
|
|
}
|
|
$("#submitnews").on("click" , function(){
|
|
var texteraenews = $("#texteraenews").val()
|
|
let formData = new FormData();
|
|
formData.append("history-id", texteraenews);
|
|
$.ajax({
|
|
url: '',
|
|
type: "POST",
|
|
headers: {
|
|
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
|
},
|
|
data: formData,
|
|
cache: false,
|
|
contentType: false,
|
|
processData: false,
|
|
success: function (result) {
|
|
|
|
},
|
|
error: function (error) {
|
|
|
|
},
|
|
});
|
|
})
|
|
|
|
|
|
function uploadUpdateImage(index, input) {
|
|
let formData = new FormData();
|
|
formData.append("image", input.files[0]);
|
|
formData.append("name", "image-" + index);
|
|
for (var pair of formData.entries()) {
|
|
console.log(pair[0] + ", " + pair[1]);
|
|
}
|
|
showLoaderScreen();
|
|
$.ajax({
|
|
url: ``,
|
|
type: "POST",
|
|
headers: {
|
|
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
|
},
|
|
data: formData,
|
|
cache: false,
|
|
contentType: false,
|
|
processData: false,
|
|
success: function (result) {
|
|
|
|
},
|
|
error: function (error) {
|
|
|
|
},
|
|
});
|
|
}
|
|
$(".cancel").on("click", function () {
|
|
$("#stepModalmaintenance").modal("hide")
|
|
|
|
}); |