﻿function Username_Keypress(a, b) { var c = document.getElementById(a); if (c.value.length < 4) { return } Ajax_PostUpdate('/User/CheckName', { username: c.value }, b, 'animation', 0) } function User_ShowPassword() { $('#PasswordContainer').slideToggle(100); $('#ShowPassword').css('display', 'none') } function Invite_ShowPreview() { $('#SearchInvite #Preview').slideToggle(500); $('#SearchInvite a').css('display', 'none') } function TimelineEntry_AddComment(a, b) { alert(this) } function CommentEntryForm_KeyPress() { var a = document.getElementById('CommentContents'); if (a === null) { return } var b = (400 - a.value.length); if (b == 0) { b = 0 } else if (b < 0) { b = 0; a.value = a.value.substring(0, 400) } } function CommentEntry_Post(b) { var c = document.getElementById('CommentContents'); if (c == null) return; if (c.value.length <= 0) { return false } var d = $('#CommentForm'); var e = d.serialize(); var f = document.getElementById('CommentForm').parentNode.parentNode; c.focus(); c.blur(); $('#CommentEntry').slideUp(300, function() { $.post('/Comment/Create', e, function(a) { $(a).hide().appendTo($(f)).slideDown(300) }) }); return false } function TimelineEntryForm_KeyPress() { var a = $('#CharsLeft'); var b = document.getElementById('PostContents'); var c = $('#EntryState'); var d = c.attr('u'); if (b === null) { return } var e = 400; var f = (400 - b.value.length); if (f == 0) { f = 0 } else if (f == 400) { f = '&nbsp;' } else if (f < 0) { f = 0; b.value = b.value.substring(0, 400) } var g = document.getElementById('ReplyPostID'); var h = b.value; if (h.charAt(0) == '@') { var i = h.indexOf(' '); if (i != -1 && i > 1) { var j = h.substring(1, i); if (d != j) { c.html(j + ' antworten'); c.attr('u', j) } } else if (d != '') { c.html('Was machst du gerade?'); c.attr('u', ''); if (g != null) g.value = '' } } else { if (d != '') { c.html('Was machst du gerade?'); c.attr('u', ''); if (g != null) g.value = '' } } a.html(f) } function TimelineEntry_Reply(a, b) { var c = document.getElementById('PostContents'); var d = c.value; if (d.charAt(0) == '@') { var e = d.indexOf(' '); if (e != -1) { d = d.substring(e + 1) } d = '@' + a + ' ' + d } else { d = '@' + a + ' ' + d } c.value = d; TimelineEntryForm_KeyPress(); if (c.setSelectionRange) { c.focus(); c.setSelectionRange(400, 400) } else if (c.createTextRange) { var f = c.createTextRange(); f.collapse(true); f.moveEnd('character', 400); f.moveStart('character', 400); f.select() } if (b != null) { document.getElementById('ReplyPostID').value = b } } function TimelineEntry_Delete(b, c) { if (confirm('Willst du diesen Eintrag wirklich löschen?') == false) { return false } var d = '/Notification/Delete/' + b + '/' + c + '/?hash=' + (Math.floor(1000 * Math.random())); var e = $('#Timeline'); var f = $('#CharsLeft'); f.html(Ajax_GetLoadingHtml()); $.get(d, function(a) { if (c == 'ForeignProfile') { window.location.reload(); return false } else if (c == 'Notification') { document.location.href = '/'; return false } else if (c == 'ImageNotification') { document.location.href = '/Home/MyProfile#showPhotos'; return false } TimelineEntryForm_KeyPress(); e.html(a); TimeLine_init() }); return false } function TimelineEntryForm_Reset() { var a = document.getElementById('PostContents'); var b = a.value; document.PostForm.reset(); a.value = b } function TimelineEntryForm_ShowAddEmoticon() { $('#ImageOptions,#AudioOptions,#LinkOptions').css('display', 'none'); var b = $('#EmoticonOptions').css('display', 'block'); var c = '/Notification/Emoticons'; var d = 500; var e = document.getElementById('PostContents'); if (b.attr('loaded') != undefined) { return } b.html(Ajax_GetLoadingHtml()); $.get(c, function(a) { b.fadeOut(d, function() { b.attr('loaded', 'done').html(a).fadeIn(d); $("#EmoticonOptions img").hover(function() { $(this).toggleClass("active", true) }, function() { $(this).toggleClass("active", false) }).click(function() { e.value += this.alt; TimelineEntryForm_KeyPress() }) }) }) } function TimelineEntryForm_ShowAddLink() { $('#ImageOptions,#AudioOptions,#EmoticonOptions').css('display', 'none'); $('#LinkOptions').css('display', 'block'); TimelineEntryForm_Reset() } function TimelineEntryForm_ShowAddImage() { $('#LinkOptions,#AudioOptions,#EmoticonOptions').css('display', 'none'); $('#ImageOptions').css('display', 'block'); TimelineEntryForm_Reset() } function TimelineEntryForm_ShowAddMp3() { $('#LinkOptions,#ImageOptions,#EmoticonOptions').css('display', 'none'); $('#AudioOptions').css('display', 'block'); TimelineEntryForm_Reset() } function TimelineEntry_Post(a) { var b = document.getElementById('PostContents'); if (b.value.length <= 0) { return false } var c = $('#CharsLeft'); if ($('#ImageOptions').css('display') == 'block') { var d = document.getElementById('ImageFile').value; if (d.length > 0) { $('#PostMessage').html('Dein Bild wird hochgeladen, dies kann etwas dauern.'); $('#PostMessage').css('display', 'block') } } else if ($('#AudioOptions').css('display') == 'block') { var e = document.getElementById('AudioTitle').value; var d = document.getElementById('AudioFile').value; if (d.length > 0) { if (e.length == 0) { $('#PostMessage').html('Bitte gebe einen Songtitel für dieses Mp3 ein.'); $('#PostMessage').css('display', 'block'); return false } $('#PostMessage').html('Dein Mp3 wird hochgeladen, dies kann etwas dauern.'); $('#PostMessage').css('display', 'block') } } c.html(Ajax_GetLoadingHtml()); return true } function TimelineEntry_PostFailed() { var a = $('#CharsLeft'); a.html('&nbsp;'); $('#PostMessage').css('display', 'block'); document.getElementById('PostMessage').innerHTML = window.frames['PostTarget'].document.body.innerHTML } function TimelineEntry_PostComplete() { document.PostForm.reset(); var a = $('#CharsLeft'); a.html('&nbsp;'); $('#PostMessage').css('display', 'none'); document.getElementById('Timeline').innerHTML = window.frames['PostTarget'].document.body.innerHTML; document.getElementById('PostContents').value = ''; TimeLine_init() } function MessageEntry_Send(b) { var c = document.getElementById('PostContents'); var d = document.getElementById('TargetUserID'); if (d.value == 0) { alert('Um eine Nachricht zu senden musst du den User auswählen, an den du eine Nachricht schicken möchtest.'); return false } if (c.value.length <= 0) { return false } var e = $('#MessagingForm'); var f = $('#CharsLeft'); var g = e.serialize(); var h = '/Message/Send'; f.html(Ajax_GetLoadingHtml()); $.post(h, g, function(a) { f.html('&nbsp;'); window.location = '/Message/Sent' }); c.value = ''; return false } function Profile_ChangeRelation(b) { var c = $('#UserPanel'); var d = $('#AjaxStatus'); d.html(Ajax_GetLoadingHtml()); $.get(b, function(a) { c.html(a); Ajax_GetUpdateLoading('/Profile/SubscriptionButtons/?hash={1}', 'UserPanel', 'AjaxStatus') }); return false } function Background_UploadBegin(a) { var b = $('#' + a); b.css('display', 'block'); b.html(Ajax_GetLoadingHtml()) } function Background_UploadCompleted(a, b, c) { var d = $('#' + a); var e = $('#' + b); d.css('display', 'none'); document.location = '/Profile/Settings/Design' } function Background_UploadFailed(a, b, c) { var d = $('#' + a); var e = $('#' + b); d.html('&nbsp;'); e.html(c) } function Avatar_UploadBegin(a) { var b = $('#' + a); b.html(Ajax_GetLoadingHtml()) } function Avatar_UploadCompleted(a) { var b = $('#AvatarSettings #AvatarImage'); var c = $('#AvatarUploadMessage'); avatarImage = new Image(96, 96); avatarImage.src = a; b.html(Image_GetHtml(avatarImage, 'Avatar', 96, 96)); c.html('&nbsp;') } function Avatar_UploadFailed(a) { var b = $('#AvatarSettings #AvatarImage'); var c = $('#AvatarUploadMessage'); b.html('&nbsp;'); c.html(a) } function Image_GetHtml(a, b, c, d) { return '<img src="' + a.src + '" alt="' + b + '" width="' + c + '" height="' + d + '" />' } ajaxLoadingImage = new Image(16, 16); ajaxLoadingImage.src = "/Content/Images/ajax-loader.gif"; function Ajax_GetLoadingHtml() { return Image_GetHtml(ajaxLoadingImage, 'Loading...', 16, 16) } function Ajax_GetUpdateLoading(b, c, d) { var e = $('#' + c); var f = $('#' + d); f.html(Ajax_GetLoadingHtml()); $.get(b, function(a) { f.html('&nbsp;'); e.html(a) }); return false } function Ajax_AppendGetUpdate(b, c, d, e) { var f = $('#' + c); $.get(b, function(a) { f.append(a); if (d != 'undefined' && e != 'undefined') { if (d == 'hide') { f.show(e) } else if (d == 'fadeOut') { f.fadeIn(e) } else if (d == 'fadeIn') { f.fadeOut(e) } else if (d == 'slide') { f.slideToggle(e) } } }); return false } function Ajax_GetUpdate(b, c, d, e) { var f = $('#' + c); if (d != 'undefined' && e != 'undefined') { if (d == 'hide') { f.hide(e) } else if (d == 'fadeOut') { f.fadeOut(e) } else if (d == 'fadeIn') { f.fadeIn(e) } else if (d == 'slide') { f.slideToggle(e) } } $.get(b, function(a) { f.html(a); if (d != 'undefined' && e != 'undefined') { if (d == 'hide') { f.show(e) } else if (d == 'fadeOut') { f.fadeIn(e) } else if (d == 'fadeIn') { f.fadeOut(e) } else if (d == 'slide') { f.slideToggle(e) } } }); return false } function Ajax_PostUpdate(b, c, d, e, f) { var g = $('#' + d); if (e != 'undefined' && f != 'undefined') { if (e == 'hide') { g.hide(f) } else if (e == 'fadeOut') { g.fadeOut(f) } else if (e == 'fadeIn') { g.fadeIn(f) } else if (e == 'slide') { g.slideToggle(f) } else if (e == 'animation') { g.html(Ajax_GetLoadingHtml()) } } $.post(b, c, function(a) { g.html(a); if (e != 'undefined' && f != 'undefined') { if (e == 'hide') { g.show(f) } else if (e == 'fadeOut') { g.fadeIn(f) } else if (e == 'fadeIn') { g.fadeOut(f) } else if (e == 'slide') { g.slideToggle(f) } } }); return false } function Ajax_PostFormUpdateLoading(b, c, d, e) { var f = $('#' + c); var g = $('#' + d); var h = $('#' + e); var i = f.serialize(); h.html(Ajax_GetLoadingHtml()); $.post(b, i, function(a) { h.html('&nbsp;'); g.html(a) }); return false } function Ajax_PostFormUpdate(b, c, d, e, f) { var g = $('#' + c); var h = $('#' + d); var i = g.serialize(); if (e != 'undefined' && f != 'undefined') { if (e == 'hide') { h.hide(f) } else if (e == 'fadeOut') { h.fadeOut(f) } else if (e == 'fadeIn') { h.fadeIn(f) } else if (e == 'slide') { h.slideToggle(f) } else if (e == 'animation') { h.html(Ajax_GetLoadingHtml()) } } $.post(b, i, function(a) { h.html(a); if (e != 'undefined' && f != 'undefined') { if (e == 'hide') { h.show(f) } else if (e == 'fadeOut') { h.fadeIn(f) } else if (e == 'fadeIn') { h.fadeOut(f) } else if (e == 'slide') { h.slideToggle(f) } } }); return false } function Ajax_PostForm(b, c, d, e) { var f = $('#' + c); var g = f.serialize(); if (d != 'undefined' && e != 'undefined') { if (d == 'hide') { f.hide(e) } else if (d == 'fadeOut') { f.fadeOut(e) } else if (d == 'fadeIn') { f.fadeIn(e) } else if (d == 'slide') { f.slideToggle(e) } } $.post(b, g, function(a) { if (d != 'undefined' && e != 'undefined') { if (d == 'hide') { f.show(e) } else if (d == 'fadeOut') { f.fadeIn(e) } else if (d == 'fadeIn') { f.fadeOut(e) } else if (d == 'slide') { f.slideToggle(e) } } }); return false } function TimeLine_init() { } function JQuery_init() { TimeLine_init(); $("a.ToolTip").hover(function() { ToolTip_show(this.href, this.id, this.name) }, function() { $('#Bubble').remove() }).click(function() { return false }); $("div.InfoTip,span.InfoTip,a.InfoTip").hover(function() { ToolTip_show('', this.id, this.title) }, function() { $('#Bubble').remove() }); if (typeof ($.farbtastic) != 'undefined') { var f = $.farbtastic('#ColorPicker'); var p = $('#ColorPicker').css('display', 'none'); var k; $('.colorwell').each(function() { f.linkTo(this); $(this).css('opacity', '0.75') }).focus(function() { if (k) { $(k).css('opacity', 0.75).removeClass('colorwell-selected') } f.linkTo(this); p.css('display', 'block'); $(k = this).css('opacity', 1).addClass('colorwell-selected') }) } $(".postcomments").live("click", function() { var a = this.id.substring(12); document.getElementById('CommentPostID').value = a; $(this.parentNode.parentNode.parentNode.parentNode).append($('#CommentEntry')); $('#CommentEntry').css('display', 'block'); var b = document.getElementById('CommentContents'); if (b) { b.value = ''; b.focus() } }); $(".pokies li .on").live("click", function() { var b = this.id.substring(9); var c = $(this.parentNode); $.get('/profile/poke/hide/' + b, function(a) { if (a.charAt(0) == '1') { c.remove() } else { alert('Fehler! Knuffel konnte nicht entfernt werden :-(') } }) }); $(".showcomments").live("click", function() { var d = this.id.substring(12); var e = this.parentNode.parentNode.parentNode; var f = $(this); f.html('Lädt...'); $.get('/comment/details/' + d, function(b) { var c = $(e); $(b).hide().appendTo(c).fadeIn(300); c.append($('#CommentEntry')); $('#CommentEntry').css('display', 'block'); document.getElementById('CommentContents').value = ''; document.getElementById('CommentPostID').value = d; f.html('Kommentieren'); f.click(function() { c.append($('#CommentEntry')); $('#CommentEntry').css('display', 'block'); var a = document.getElementById('CommentContents'); if (a) { a.value = ''; a.focus() } return false }) }) }); $("#ImageView .ajaxImage").live("click", function() { $('#ImageView .command .next').click() }); $(".Attachment .Yt").live("click", function() { var a = this.id.substring(6); var b = "<object width='300' height='250'>" + "<param name='movie' value='http://www.youtube.com/v/" + a + "'></param>" + "<param name='wmode' value='transparent'></param>" + "<embed src='http://www.youtube.com/v/" + a + "' type='application/x-shockwave-flash' wmode='transparent' width='300' height='250'></embed>" + "</object>"; $(this.parentNode).html(b); return false }); $("#Paging #PrevPageButton").live("click", function() { var b = $(this).attr('href'); $('#Paging').html(Ajax_GetLoadingHtml()); $.get(b, function(a) { $('#Paging').remove(); $('#Timeline .LEntry').removeClass('LEntry'); $('#Timeline').append(a) }); return false }); $(".TimelineEntry, .Entry, .pokies li, .profileContent li").live("mouseover", function() { $(this).addClass('Hov') }).live("mouseout", function() { $(this).removeClass('Hov') }); if (typeof ($.address) != 'undefined') { $(".ahistory a").address(); $.address.change(function(e) { var f = e.value; f = f.replace(/#/g, ''); if (f.charAt(0) != '/') f = '/' + f; var g = $.address.state().replace(/^\/$/, '') + f; if (g == $.address.state() + '/') return; var h = $("#SubContent"); if (h.length == 0) return; var i = false; $(".ahistory a").each(function() { var a = $(this.parentNode); var b = '/' + this.id; if (a.hasClass('active')) { if (b == f) { i = true; return } a.removeClass('active'); return } if (b == f) { a.addClass('active') } }); if (i) { return } var j = $('#ImgAjaxLoader'); if (j.length > 0) { j.css('display', 'block') } else { h.html('<div class="loader">' + Ajax_GetLoadingHtml() + ' Lädt...</div>') } $.get(g, function(a) { if (a.length == 0 || $(a).length == 0) { h.html('<div>&nbsp;</div>'); if (j.length > 0) j.css('display', 'none'); return } var b = $(a); var c = b.find('.ajaxImage'); var d = true; if (/chrome/.test(navigator.userAgent.toLowerCase())) { d = false } if (d == true && c.length > 0) { c.load(function() { h.html(b); if (j.length > 0) j.css('display', 'none') }) } else { if (j.length > 0) j.css('display', 'none'); h.html(b) } }) }) } } function ToolTip_show(a, b, c) { if (c == false) { c = "&nbsp;" } var d = document.documentElement; var w = self.innerWidth || (d && d.clientWidth) || document.body.clientWidth; var e = w - getAbsoluteLeft(b); var f = a.replace(/^[^\?]+\??/, ''); var g = parseQuery(f); var h = 255; var i = g['ajax']; if (i !== undefined) { $('#' + b).bind('click', function() { window.location = a.replace('?ajax=' + i, '') }) } var j = 'Right'; var k = 0; if (e > (h + 64)) { k = getElementWidth(b) } else { j = 'Left'; k = -h } var l = getAbsoluteLeft(b) + k; var m = getAbsoluteTop(b) - 32; var n = "<div id='Bubble' style='left:" + l + "px;top:" + m + "px;' class='" + j + "'><div id='BubbleContent'><h4>" + c + "</h4><div id='BubbleInner'><div class='ToolTipLoad'></div></div></div><div id='BubbleClose'></div></div>"; $("body").append(n); $('#Bubble').show(); if (i !== undefined) { $('#Bubble #BubbleContent #BubbleInner').load(i) } else { var o = $("#" + b).attr('contents'); $('#Bubble #BubbleContent #BubbleInner').html(o) } } function getElementWidth(a) { x = document.getElementById(a); return x.offsetWidth } function getAbsoluteLeft(a) { o = document.getElementById(a); oLeft = o.offsetLeft; while (o.offsetParent != null) { oParent = o.offsetParent; oLeft += oParent.offsetLeft; o = oParent } return oLeft } function getAbsoluteTop(a) { o = document.getElementById(a); oTop = o.offsetTop; while (o.offsetParent != null) { oParent = o.offsetParent; oTop += oParent.offsetTop; o = oParent } return oTop } function parseQuery(a) { var b = new Object(); if (!a) { return b } var c = a.split(/[;&]/); for (var i = 0; i < c.length; i++) { var d = c[i].split('='); if (!d || d.length != 2) { continue } var e = unescape(d[0]); var f = unescape(d[1]); f = f.replace(/\+/g, ' '); b[e] = f } return b } function blockEvents(a) { if (a.target) { a.preventDefault() } else { a.returnValue = false } } $(document).ready(JQuery_init);
