FB._https = (window.location.protocol == "https:");
FB.init({
appId: '2511208999168874',
status: true,
cookie: true,
xfbml: true,
channelUrl: 'https://'+window.location.hostname+'/channel.html',
oauth: true,
version: 'v16.0'
});
//FB.AppEvents.logPageView();
function FBresize() {
FB.Canvas.setSize({width: 640, height: 810});
FB.Canvas.setAutoGrow();
}
function fwl() {
var time = new Date().getTime();
top.location.href = 'https://'+window.location.hostname+'/main';
}
function FB_login() {
FB.login(function (response) {
if (response.authResponse) {
setTimeout(fwl(), 1000);
}
else {
setTimeout(fwl(), 1000);
}
}, {scope: 'email,pages_manage_posts,pages_show_list,pages_read_engagement,business_management,ads_management,read_insights,public_profile,pages_manage_ads,instagram_content_publish,instagram_basic,publish_to_groups,leads_retrieval,pages_manage_metadata,ads_read,pages_read_user_content,publish_video,read_insights,instagram_manage_insights'});
};
function auto_grow(element) {
element.style.height = "5px";
if (element.scrollHeight < 100) {
element.style.height = "99px";
} else {
element.style.height = element.scrollHeight + "px";
}
}
function count_letters_textarea(){
var htags=$("#link_text").val().split('#').length-1;
var conunt_l=$("#link_text").val().length;
var insta=$("#chk_instagram").val();
if(insta==1){
if(htags>=30){
if(localStorage.getItem('htags_status')!=1){
Toastify({text: "Przekroczono limit 30 hashtagów.",className: "bg-danger",duration: 6000}).showToast();
localStorage.setItem('htags_status', '1');
}
htags=""+htags+"";
}else{
localStorage.setItem('htags_status', '0');
}
if(conunt_l>=2200){
if(localStorage.getItem('conunt_l_status')!=1){
Toastify({text: "Przekroczono limit 2200 znaków.",className: "bg-danger",duration: 6000}).showToast();
localStorage.setItem('conunt_l_status', '1');
}else{
localStorage.setItem('conunt_l_status', '0');
}
conunt_l=""+conunt_l+"";
}
}
$("#count-text").html(conunt_l+" #"+htags);
//Toastify({text: html[1],className: "bg-danger",duration: 6000}).showToast();
}
$(document).ready(function () {
FB.getLoginStatus(function (response) {
if (response.status === 'connected') {
} else if (response.status === 'not_authorized') {
} else {
}
});
});
setTimeout(function () {
var ap = 1;
$('.ap').hover(function () {
$(this).css('animation-name', 'pulse');
}).mouseleave(function () {
if (ap == 1) {
ap = 0;
setTimeout(function () {
$('.ap').css('animation-name', 'none');
ap = 1;
}, 2500);
}
});
}, 4000);
//menu_post
//onmousein=\"$('.promo-item2').toggle(300);\"
$('.ti-menu').click(function () {
$('.promo-item2').toggle(300);
})
function submit_link_form(){
event.preventDefault();
$('#ModalPost').modal('show');
$('#modal_send').html('');
var options = {
xhrFields: {withCredentials: true},
error: function() {
// $('#modal_send').html("Bład sieci");
$('#modal_send').html("
Błąd sieci
");
},
success: function (html) {
event.preventDefault();
var html = html.split('||');
$('#modal_send').html(html[1]+'
'+html[0]);
//$('#post_add_title').html(html[0]+'
'+html[1]);
}
};
$('#link_form').ajaxSubmit(options);
}
//formularz dodawania posta
$(document).ready(function () {
$('.qswitch').click(function () {
var qid=$(this).attr('data-id');
var page_q=$(this).attr('data-page')
if ($(this).is(':checked')) {
var qd=0;
}else{
var qd=1;
}
var data='page_id='+page_q+'&bt=1&qid='+qid+'&qd='+qd;
$.ajax({
url: '/queue_disabled',
type: 'POST',
data: data,
processData: false,
cache: false,
// async: false,
dataType: 'html',
success: function (html) {
}
});
});
$('#link_formX').submit(function (event) {
event.preventDefault();
$('#ModalPost').modal('show');
$('#modal_send').html('');
var options = {
xhrFields: {withCredentials: true},
error: function() {
// $('#modal_send').html("Bład sieci");
$('#modal_send').html("
Błąd sieci
");
},
success: function (html) {
event.preventDefault();
var html = html.split('||');
$('#modal_send').html(html[1]+'
'+html[0]);
//$('#post_add_title').html(html[0]+'
'+html[1]);
}
};
$('#link_form').ajaxSubmit(options);
})
$('.settings_click').click(function (event) {
event.preventDefault();
var data = 'bt=1';
$.ajax({
url: "/settings-modal",
type: "POST",
data: data,
processData: false,
cache: false,
// async: false,
dataType: "html",
success: function (html) {
$("#modal_uni").html(html);
$("#title_uni").html("Ustawienia");
$("#ModalUni").modal("show");
$('.js-example-basic-singles').select2();
}
});
})
$("#ai-eddy-hash").click(function(){
var text_ai=$('#link_text').val();
if(text_ai==''){
Toastify({text: 'Aby wygenerować hashtagi wpisz treść posta.',className: "bg-danger",duration: 6000}).showToast();
}else{
$("#ai-eddy-hash-locading").show();
$("#ai-eddy-hash").hide();
var data = 'bt=1&command=Generate 5 hashtags for text. Text: '+text_ai;
$.ajax({
url: "/ai-some",
type: "POST",
data: data,
processData: false,
cache: false,
// async: false,
dataType: "html",
success: function (html) {
var html = html.split('||');
if(html[1]==''){
$("#link_text").val(text_ai+"\n"+html[0]);
$('#prev_text').html(text_ai+"\n"+html[0]);
$("#prev_text").html(function(_, html) {
return html.replace(/#([^ ]+)/g, '#$1');
});
}else{
Toastify({text: html[1],className: "bg-danger",duration: 6000}).showToast();
}
// auto_grow($("#ai-eddy-test"););
var element = document.getElementById('link_text');
element.style.height = element.scrollHeight + "px";
count_letters_textarea()
$("#ai-eddy-hash-locading").hide();
$("#ai-eddy-hash").show();
}
});
}
})
$("#ai-some-write-img").click(function(){
$("#ai-some-img-locading,#ai-some-locading-img").show();
$("#ai-some-img").hide();
var text_ai=$('#ai-some-img-input').val();
var data = 'bt=1&command='+text_ai;
$.ajax({
url: "/ai-some-img",
type: "POST",
data: data,
processData: false,
cache: false,
// async: false,
dataType: "html",
success: function (html) {
var html = html.split('||');
if(html[1]==''){
$(".prev_img").html("");
$(".prev_img img").attr("src","/images/openai/"+html[0]);
$("#img_ai").val(html[0]);
$("#customFile").removeAttr("required");
var ai_count_img=$('#ai_count_img').html();
ai_count_img=ai_count_img-1;
$('#ai_count_img').html(ai_count_img);
}else{
Toastify({text: html[1],className: "bg-danger",duration: 6000}).showToast();
}
$("#ai-some-img-locading,#ai-some-locading-img").hide();
$("#ai-some-img").show();
$('#ModalAIimg').modal('hide');
}
});
})
$('#ai-some-img').click(function(){
event.preventDefault();
$('#ModalAIimg').modal('show');
})
$('#ai-eddy-go').click(function(){
event.preventDefault();
var page = $("#link_fanpage").val();
var data = 'bt=1&page_id='+page;
$.ajax({
url: "/ai-form",
type: "POST",
data: data,
processData: false,
cache: false,
// async: false,
dataType: "html",
success: function (html) {
$('#ai-form').html(html);
$('.js-example-basic-single2').select2();
$('#ModalAI').modal('show');
}
});
})
//light-dark-mode
$(".light-dark-mode").click(function () {
var mode=$('html').attr('data-layout-mode');
$('html').attr('data-sidebar', mode);
var data = 'theme='+mode;
$.ajax({
url: "/theme-save",
type: "POST",
data: data,
processData: false,
cache: false,
// async: false,
dataType: "html",
success: function (html) {
}
});
console.log('Theme '+mode);
})
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
console.log("Timezone: "+timezone);
$("#timezone").val(timezone);
document.cookie = "tz="+timezone;
})
function openPopup(url, width, height) {
// Oblicz pozycję środka ekranu.
const left = screen.width / 2 - width / 2;
const top = screen.height / 2 - height / 2;
// Otwórz nowe okno popup.
window.open(url, '_blank', `toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=${width},height=${height},top=${top},left=${left}`);
}
function applyStyle(style) {
const editor = document.getElementById('link_text');
const selectedText = editor.value.substring(editor.selectionStart, editor.selectionEnd);
const styledText = unicodeConvert(selectedText, style);
editor.setRangeText(styledText, editor.selectionStart, editor.selectionEnd, 'end');
}
function unicodeConvert(text, style) {
const styles = {
'bold': {
'Q': '𝗤', 'W': '𝗪', 'E': '𝗘', 'R': '𝗥', 'T': '𝗧', 'Y': '𝗬', 'U': '𝗨', 'I': '𝗜', 'O': '𝗢', 'P': '𝗣',
'A': '𝗔', 'S': '𝗦', 'D': '𝗗', 'F': '𝗙', 'G': '𝗚', 'H': '𝗛', 'J': '𝗝', 'K': '𝗞', 'L': '𝗟', 'Z': '𝗭',
'X': '𝗫', 'C': '𝗖', 'V': '𝗩', 'B': '𝗕', 'N': '𝗡', 'M': '𝗠',
'q': '𝗾', 'w': '𝘄', 'e': '𝗲', 'r': '𝗿', 't': '𝘁', 'y': '𝘆', 'u': '𝘂', 'i': '𝗶', 'o': '𝗼', 'p': '𝗽',
'a': '𝗮', 's': '𝘀', 'd': '𝗱', 'f': '𝗳', 'g': '𝗴', 'h': '𝗵', 'j': '𝗷', 'k': '𝗸', 'l': '𝗹', 'z': '𝘇',
'x': '𝘅', 'c': '𝗰', 'v': '𝘃', 'b': '𝗯', 'n': '𝗻', 'm': '𝗺',
'1': '𝟭', '2': '𝟮', '3': '𝟯', '4': '𝟰', '5': '𝟱', '6': '𝟲', '7': '𝟳', '8': '𝟴', '9': '𝟵', '0': '𝟬',
'ą': '𝗮̨' ,'ć': '𝗰́' ,'ę': '𝗲̨' ,'ł': '𝗹́','ń': '𝗻́','ó': '𝗼́','ś': '𝘀́','ź': '𝘇́','ż': '𝘇̇'
},
'italic': {
'Q': '𝑄', 'W': '𝑊', 'E': '𝐸', 'R': '𝑅', 'T': '𝑇', 'Y': '𝑌', 'U': '𝑈', 'I': '𝐼', 'O': '𝑂', 'P': '𝑃',
'A': '𝐴', 'S': '𝑆', 'D': '𝐷', 'F': '𝐹', 'G': '𝐺', 'H': '𝐻', 'J': '𝐽', 'K': '𝐾', 'L': '𝐿', 'Z': '𝑍',
'X': '𝑋', 'C': '𝐶', 'V': '𝑉', 'B': '𝐵', 'N': '𝑁', 'M': '𝑀',
'q': '𝑞', 'w': '𝑤', 'e': '𝑒', 'r': '𝑟', 't': '𝑡', 'y': '𝑦', 'u': '𝑢', 'i': '𝑖', 'o': '𝑜', 'p': '𝑝',
'a': '𝑎', 's': '𝑠', 'd': '𝑑', 'f': '𝑓', 'g': '𝑔', 'h': 'ℎ', 'j': '𝑗', 'k': '𝑘', 'l': '𝑙', 'z': '𝑧',
'x': '𝑥', 'c': '𝑐', 'v': '𝑣', 'b': '𝑏', 'n': '𝑛', 'm': '𝑚',
'ą': '𝘢̨', 'ć': '𝘤́', 'ę': '𝘦̨', 'ł': '𝘭́', 'ń': '𝘯́', 'ó': '𝘰́', 'ś': '𝑠́', 'ź': '𝑧́', 'ż': '𝑧̇'
}
};
const styledArray = Array.from(text).map(char => {
const styledChar = styles[style][char] || char;
return styledChar;
});
return styledArray.join('');
}