var c=0
var photo
var topsc
var load_map
var map
var map_edit
var max
var last=20
var load_sb
var logged=1
var fold
function mmico(ico) {
document.form1.txt.focus();
document.form1.txt.value += ico;
}
function mmcode(pre,after) {
var pole = document.form1.txt;
pole.focus();
if (pole.selectionStart >= 0) {
var startPos = pole.selectionStart;
var endPos = pole.selectionEnd;
pole.value = pole.value.substring(0, startPos)+pre+pole.value.substring(startPos,endPos)+after+pole.value.substring(endPos, pole.value.length);
} else {
pole.value += pre+after;
pole.setSelectionRange(pole.value.length-after.length,pole.value.length-after.length);
}
}
function urlencode(str) {
str = str.replace('#', '%23');
str = str.replace('+', '%2B');
str = str.replace('%20', '+');
str = str.replace('*', '%2A');
str = str.replace('/', '%2F');
str = str.replace('@', '%40');
return str;
}
function is_shit() {
return '\v' == 'v';
}
function adb(callback){
var testURL = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'
var myInit = {
method: 'HEAD',
mode: 'no-cors'
};
var myRequest = new Request(testURL, myInit);
fetch(myRequest).then(function(response) {
return ;
}).then(function(response) {
callback(false)
}).catch(function(e){
callback(true)
});
}
function Linkify(inputText) {
var replacePattern1 = /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim;
var replacedText = inputText.replace(replacePattern1, '$1');
if (inputText != replacedText) {
return replacedText;
exit;
}
//improved:
var replacePattern2 = /(\bwww.[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim;
var replacedText = replacedText.replace(replacePattern2, '$1');
if (inputText != replacedText) {
return replacedText;
exit;
}
var replacePattern3 = /(\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,6})/gim;
var replacedText = replacedText.replace(replacePattern3, '$1');
return replacedText
}
$(document).ready(function() {
adb(function(bl){
bl ? $(".serwisinfo").show() : $(".serwisinfo").hide();
});
$("#menu a").dropShadow({left: 0, top: 1, blur: 0, color: "#bbb", swap: false});
$('#login').focus();
$('#marka').focus();
if (load_map == 2) {
load();
}
$(document).find('.answer').click(function() {
if ($(this).attr('title')!='') {
$('#c'+$(this).attr('name')).after('
');
$('#answer-'+$(this).attr('title')).show("slow");
$('.comcancel').click(function() {
$('#a'+$(this).attr('title')).attr("title",$(this).attr('title'));
$(this.parentNode).hide("slow");
});
$('#ta'+$(this).attr('title')).focus();
$(this).attr('title','');
}
});
$(document).find('.ylink').click(function() {
if ($(this).attr("href").indexOf('http://www.youtube.com/watch?v=')==0) {
if ($(this).attr("name")!="clicked") {
$(this).after('');
$(this).attr("name","clicked");
return false;
} else { $(this.parentNode.parentNode).find('.cont').slideUp(200); $(this).attr("name",""); return false;}
} else
if ($(this).attr("href").substr(-4)=='.jpg') {
if ($(this).attr("name")!="clicked") {
$(this).after('');
$(this).attr("name","clicked");
return false;
} else { $(this.parentNode.parentNode).find('.cont').slideUp(200); $(this).attr("name",""); return false;}
}
});
$(".linkit").each(function() {
vv = $(this).html();
$(this).html(Linkify(vv,false));
});
$('.mini_photo').click(function() {
if (logged==1) {
if (!is_shit()) {
if (window.pageYOffset<=180)
window.scrollTo(0,topsc);
$('#show').css('margin-top',(window.pageYOffset==0)?window.pageYOffset:window.pageYOffset-topsc); } else {
window.scrollTo(0,topsc);
}
$('.sw').css('visibility','hidden');
$('#show').html('').show();
$('.mini_photo').fadeTo(10,1);
$(this).fadeTo(200,0.4);
window.location.href = window.location.href.indexOf("#") > 0 ? window.location.href.substr(0,location.href.indexOf("#"))+"#photo:"+($(this).attr('src').substr(31).replace('.jpg','').replace(fold,'')) : location.href+"#photo:"+($(this).attr('src').substr(31).replace('.jpg','').replace(fold,''));
$('#show').prepend(''+desc[$(this).attr('id').substring(6)]+'
');
photo = $(this).attr('id').substring(6);
} else window.alert('Zaloguj się, aby móc powiększać zdjęcia.');
});
if (window.location.href.indexOf("#photo:") > 0) {
$('.mini_photo').each(function() {
if ($(this).attr("src").indexOf(window.location.href.substr(location.href.indexOf("#photo:")+7))>0) {
$(this).click();
}
});
//$("#photo_"+(location.href.substr(location.href.indexOf("#photo")+6)-1)).click();
}
$('#show').click(function() {
$(this).fadeOut(100);
$('.mini_photo').fadeTo(200,1);
$('.sw').css('visibility','visible');
})
$('#sb_submit').click(function() {
if ($('#sb').val()!='') {
var txt = $('#sb').val();
$('#sb').val('');
$.ajax({
type: "POST",
url: "sb_add.php",
data: "shout="+urlencode(txt.replace(/&/g,'%26')),
cache: false,
success: function(html) {
if (html!='') {
$('#cont').prepend(html);
last++;
}
}
});
}
});
$(".todrop").droppable({
hoverClass: 'hc',
drop: function(event, ui) {
var dropped = $(this).attr("id").substr(1);
var el = $(this);
$.ajax({
url: "http://mojemoto.pl/update_comment.php?id="+$(ui.draggable).attr("id").substr(1)+"&to_update="+dropped,
cache: false,
success: function(html){
if (html!='') {
el.after(html);
$(ui.draggable).fadeOut(400);
} else window.alert('Nie przeniesiesz tego komentarza, ponieważ zawiera on odpowiedzi, jest starszy niż komentarz, do którego chcesz go przenieść lub nie posiadasz uprawnień.');
}
});
}
});
$(".todrop2").droppable({
hoverClass: 'hc',
drop: function(event, ui) {
var dropped = $(this).attr("id").substr(1);
var el = $(this);
$.ajax({
url: "http://mojemoto.pl/update_comment2.php?id="+$(ui.draggable).attr("id").substr(1)+"&to_update="+dropped,
cache: false,
success: function(html){
if (html!='') {
el.after(html);
$(ui.draggable).fadeOut(400);
} else window.alert('Nie przeniesiesz tego komentarza, ponieważ zawiera on odpowiedzi, jest starszy niż komentarz, do którego chcesz go przenieść lub nie posiadasz uprawnień.');
}
});
}
});
$(".todrop").css('width','600px');
$(".todrop").draggable({
cursor: 'move',
opacity: 0.3, helper: 'clone'
});
$(".todrop2").css('width','600px');
$(".todrop2").draggable({
cursor: 'move',
opacity: 0.3, helper: 'clone'
});
if (load_sb == 2) {
window.setInterval("sb_is_new(max)",8000);
window.setInterval("get_online()",30000);
}
$('#sb').keydown(function(e) {
var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
if (key==13) $('#sb_submit').click();
})
})
function photo_left() {
if (photo==0) photo=max;
$('#photo_'+(photo-1)).click();
};
function photo_right() {
if (photo==(max-1)) photo=-1;
$('#photo_'+(parseInt(photo)+1)).click();
};
function showlink() {
prompt("Link do tego zdjęcia:", window.location.href);
}
function vote(type,id,v) {
$("#p"+id).fadeOut(200);
$.ajax({
url: "http://mojemoto.pl/vote.php?type="+type+"&c_id="+id+"&v="+v,
cache: false,
success: function(html){
if (html[0] == "!") window.alert(html); else {
$("#p"+id).html(html);
}
}
});
$("#p"+id).fadeIn(200);
}
function removeComment(type,id,l) {
$.ajax({
url: "http://mojemoto.pl/remove.php?type="+type+"&c_id="+id,
type: "GET",
cache: false,
success: function(html){
if (html=="ok") {
$(document).find("#c"+id).effect("explode",{pieces:12},900);
if (l!=0) {
$("#co").html(l-c);
$("#co2").html(l-c);
c++;
}
} else window.alert("Błąd");
}
});
}
function votemoto(vote,pid) {
$("#votediv").html('czekaj... ');
$.ajax({
url: "http://mojemoto.pl/votemoto.php?pid="+pid+"&vote="+vote,
cache: false,
success: function(html){
$("#votediv").html(html);
$("#votediv").fadeIn(200);
}
});
}
function voteauto(vote,pid) {
$("#votediv").html('czekaj... ');
$.ajax({
url: "http://mojemoto.pl/voteauto.php?pid="+pid+"&vote="+vote,
cache: false,
success: function(html){
$("#votediv").html(html);
$("#votediv").fadeIn(200);
}
});
}
function get_comment(type,id) {
$.ajax({
url: "http://mojemoto.pl/comment_edit_get.php?type="+type+"&c_id="+id,
cache: false,
success: function(html){
$("#comedit"+id).html(html);
}
});
}
function comedit_cancel(id) {
$("#comedit"+id).html($(document).find("#editme"+id).text());
}
function comedit_save(type,id) {
$.ajax({
type: "POST",
url: "http://mojemoto.pl/comment_edit_save.php",
data: "type="+type+"&c_id="+id+"&text="+$(document).find("#editme"+id).val(),
cache: false,
success: function(html){
$("#comedit"+id).html(html);
}
});
}
function sb_is_new(shout_id) {
$.ajax({
url: "sb_last_id.php?shout="+shout_id,
cache: false,
success: function(html){
if (html != '') {
max = html;
last++;
sb_load_new(shout_id);
}
}
});
}
function sb_load_new(shout_id) {
$.ajax({
url: "sb_load.php?shout="+shout_id,
cache: false,
success: function(html){
$('#cont').prepend(html);
}
});
}
function sb_load_older(shout_id) {
$.ajax({
url: "sb_load_older.php?shout="+shout_id,
cache: false,
success: function(html){
last+=20;
$('#cont').append(html);
$('.ylink').click(function() {
if ($(this).attr("href").indexOf('http://www.youtube.com/watch?v=')==0) {
if ($(this).attr("name")!="clicked") {
$(this).after('');
$(this).attr("name","clicked");
return false;
} else { $(this.parentNode.parentNode).find('.cont').slideUp(200); $(this).attr("name",""); return false;}
} else
if ($(this).attr("href").substr(-4)=='.jpg') {
if ($(this).attr("name")!="clicked") {
$(this).after('');
$(this).attr("name","clicked");
return false;
} else { $(this.parentNode.parentNode).find('.cont').slideUp(200); $(this).attr("name",""); return false;}
}
});
}
});
}
function sb_del(shout) {
$.ajax({
url: "sb_del.php?shout="+shout,
cache: false,
success: function(html){
if (html=='ok') {
last-=1;
$('#shout_'+shout).hide("drop", { direction: "down" }, 600);
}
}
});
}
function sb_edit(shout) {
$.ajax({
url: "sb_edit_1.php?shout="+shout,
cache: false,
success: function(html){
//$('#sb_edit').show().html(html);
$('#shout_'+shout).after(html);
}
});
}
function sb_edit_save(shout) {
var text = $(document).find('#sb_ed'+shout).val();
$.ajax({
url: "sb_edit_save.php?shout="+shout+"&text="+urlencode(text.replace(/&/g,'%26')),
cache: false,
success: function(html){
$(document).find('#editbox'+shout).fadeOut(500);
$('#shout_'+shout).html(html);
}
});
}
function get_online() {
$.ajax({
url: "get_online.php",
cache: false,
success: function(html){
if ($('#online_users').html() != html) {
$('#online_users').fadeOut(200).html(html).fadeIn(200);
}
}
});
}
function close_sb(sbid) {
$(document).find('#editbox'+sbid).slideUp(500);
}