Vergleich jscripts/usercp.js - 1.8.1 - 1.8.30

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 1Zeile 1
var UserCP = {
init: function()
{

var UserCP = {
init: function()
{

 
		$(function()
{
$(document).on('keydown', function(e)
{
if (e.keyCode == 27 && $('#buddyselect_container').is(':visible'))
{
$('#buddyselect_container').hide();
}
});
});
},

regenBuddySelected: function()
{
var selectedBuddies = [];
$('input[id^=checkbox_]').each(function()
{
if($(this).is(':checked'))
{
selectedBuddies.push($(this).parent().text().trim());
}
})
$("#buddyselect_buddies").text(selectedBuddies.join(', '));

	},

openBuddySelect: function(field)
{

	},

openBuddySelect: function(field)
{

		if(!$("#"+field))

		if(!$("#"+field).length)

		{
return false;
}
this.buddy_field = '#'+field;

		{
return false;
}
this.buddy_field = '#'+field;

		if($("#buddyselect_container").length > 0)

		if($("#buddyselect_container").length)

		{
UserCP.buddySelectLoaded();
return false;

		{
UserCP.buddySelectLoaded();
return false;

Zeile 36Zeile 59
		if(request)
{
try {

		if(request)
{
try {

				var json = $.parseJSON(request.responseText);

				var json = JSON.parse(request.responseText);

				if(json.hasOwnProperty("errors"))
{
$.each(json.errors, function(i, message)
{

				if(json.hasOwnProperty("errors"))
{
$.each(json.errors, function(i, message)
{

					  $.jGrowl(lang.buddylist_error+message);

					  $.jGrowl(lang.buddylist_error + message, {theme:'jgrowl_error'});

					});
return false;
}
} catch (e) {
if(request.responseText)

					});
return false;
}
} catch (e) {
if(request.responseText)

				{
if(buddyselect_container.length > 0)
{

				{
if(buddyselect_container.length)
{

						buddyselect_container.remove();
}
var container = $("<div />");

						buddyselect_container.remove();
}
var container = $("<div />");

					container.attr("id", "buddyselect_container");
container.css("display", "none");
container.html(request.responseText);

					container.attr("id", "buddyselect_container").html(request.responseText).hide();



					$("body").append(container);
}
}
}

					$("body").append(container);
}
}
}

		else
{
buddyselect_container.hide();
$("#buddyselect_container input:checked").each(function()










// Center it on the page (this should be in usercp.css)
$("#buddyselect_container").css({"top": "50%", "left": "50%", "position": "fixed", "display": "block", "z-index": "1000", "text-align": "left", "transform": "translate(-50%, -50%)"});

// Reset all checkboxes initially
$('input[id^=checkbox_]').prop('checked', false);

var listedBuddies = $(this.buddy_field).select2("data");
$.each(listedBuddies, function()
{
var username = this.text;
$('input[id^=checkbox_]').each(function()

			{

			{

				$(this).attr("checked", false);




				if($(this).parent().text().trim() == username)
{
$(this).prop('checked', true);
}

			});

			});

			$("#buddyselect_buddies").html("");
container = buddyselect_container;
}

		});







		// Clone off screen
var clone = container.clone(true);
$("body").append(clone);
clone.css("width", "300px")
.css("top", "-10000px")
.css("display", "block")
.remove();

		UserCP.regenBuddySelected();
},










		// Center it on the page
$("#buddyselect_container").css("top", "50%")
.css("left", "50%")
.css("position", "fixed")
.css("display", "block")
.css("z-index", "1000")
.css("text-align", "left")
.css("margin-left", -$("#buddyselect_container").outerWidth() / 2 + 'px')
.css("margin-top", -$("#buddyselect_container").outerHeight() / 2 + 'px');

	// Deprecated function since MyBB 1.8.27
selectBuddy: function(uid, username)
{
UserCP.regenBuddySelected();






	},


	},


	selectBuddy: function(uid, username)

	closeBuddySelect: function(canceled)

	{

	{

		var checkbox = $("#checkbox_"+uid);
var buddyselect_buddies_uid = $("#buddyselect_buddies_"+uid);
var buddyselect_buddies = $("#buddyselect_buddies");
// Buddy already in list - remove
if(buddyselect_buddies_uid.length > 0)

		if(canceled != true)





		{

		{

			buddyselect_buddies_uid.remove();
var buddies = buddyselect_buddies.text();
if(buddies.charAt(0) == ",")

			var buddies = $("#buddyselect_buddies").text().split(","), newbuddies = [];
$.each(buddies, function(index, buddy)


			{

			{

				first_buddy = buddyselect_buddies.children()[0];
first_buddy.innerHTML = first_buddy.innerHTML.substr(1, first_buddy.innerHTML.length);
}
}
// Add buddy to list
else
{
var buddies = buddyselect_buddies.text();
if(buddies != "")
{
username = ", "+username;
}
var buddy = $("<span />");
buddy.attr("id", "buddyselect_buddies_"+uid)
.html(username);
buddyselect_buddies.append(buddy);
}
},

closeBuddySelect: function(canceled)
{
if(canceled != true)
{
var buddies = $("#buddyselect_buddies").text();
existing_buddies = $(this.buddy_field).select2("data");
if(existing_buddies.length > 0)
{
// We already have stuff in our text box we must merge it with the new array we're going to create from the selected buddies
// We don't need to care about having dupes because Select2 treats items by ID and we two items have the same ID, there are no dupes because only one exists
// ^At least according to my tests :D (Pirata Nervo - so blame me for that if something goes wrong)
var newbuddies = [];
exp_buddies = buddies.split(",");
$.each(exp_buddies, function(index, buddy)

				buddy = buddy.trim();
if(buddy !== "")
































				{

				{

					buddy = buddy.replace(/^\s+|\s+$/g, "");

var newbuddy = { id: buddy, text: buddy };
newbuddies.push(newbuddy);
});

// Merge both
var newarray = $.merge(existing_buddies, newbuddies);

// Update data
$(this.buddy_field).select2("data", newarray);

}
else
{
var newbuddies = [];
exp_buddies = buddies.split(",");
$.each(exp_buddies, function(index, value ){
var newbuddy = { id: value.replace(/,\s?/g, ", "), text: value.replace(/,\s?/g, ", ") };
newbuddies.push(newbuddy);
});
$(this.buddy_field).select2("data", newbuddies);
}
$(this.buddy_field).select2("focus");

					newbuddies.push({ id: buddy, text: buddy });
}
});
$(this.buddy_field).select2("data", newbuddies).select2("focus");





















		}
$("#buddyselect_container").hide();
},

		}
$("#buddyselect_container").hide();
},

Zeile 182Zeile 146

type_add_username.attr("disabled", true);
type_submit.attr("disabled", true);


type_add_username.attr("disabled", true);
type_submit.attr("disabled", true);


if(type == "ignored")
{


if(type == "ignored")
{

			type_submit.attr("value", lang.adding_ignored);
var list = "ignore";

			type_submit.attr("value", lang.adding_ignored);
var list = "ignore";

		}

		}

		else
{
type_submit.attr("value", lang.adding_buddy);

		else
{
type_submit.attr("value", lang.adding_buddy);

Zeile 199Zeile 163
			type: 'post',
url: 'usercp.php?action=do_editlists&my_post_key='+my_post_key+'&manage='+type,
data: { ajax: 1, add_username: type_add_username.val() },

			type: 'post',
url: 'usercp.php?action=do_editlists&my_post_key='+my_post_key+'&manage='+type,
data: { ajax: 1, add_username: type_add_username.val() },

			async: false,

			async: true,

	        complete: function (request)
{
if(request.responseText.indexOf("buddy_count") >= 0 || request.responseText.indexOf("ignored_count") >= 0)

	        complete: function (request)
{
if(request.responseText.indexOf("buddy_count") >= 0 || request.responseText.indexOf("ignored_count") >= 0)

Zeile 207Zeile 171
					 $("#"+list+"_list").html(request.responseText);
}
else

					 $("#"+list+"_list").html(request.responseText);
}
else

				{

				{

					$("#sentrequests").html(request.responseText);
}


					$("#sentrequests").html(request.responseText);
}


		        type_submit.removeAttr("disabled");
type_add_username.removeAttr("disabled");

		        type_submit.prop("disabled", false);
type_add_username.prop("disabled", false);

		        type_submit.attr("value", old_value);
type_add_username.val("");

		        type_submit.attr("value", old_value);
type_add_username.val("");

		        type_add_username.focus();

		        type_add_username.trigger('focus');

				type_add_username.select2('data', null);
}
});

				type_add_username.select2('data', null);
}
});

Zeile 234Zeile 198
			var message = lang.remove_buddy;
}


			var message = lang.remove_buddy;
}


		$.prompt(message, {

		MyBB.prompt(message, {

			buttons:[
{title: yes_confirm, value: true},
{title: no_confirm, value: false}

			buttons:[
{title: yes_confirm, value: true},
{title: no_confirm, value: false}

Zeile 247Zeile 211
						type: 'post',
url: 'usercp.php?action=do_editlists&my_post_key='+my_post_key+'&manage='+type+'&delete='+uid,
data: { ajax: 1 },

						type: 'post',
url: 'usercp.php?action=do_editlists&my_post_key='+my_post_key+'&manage='+type+'&delete='+uid,
data: { ajax: 1 },

						async: false

						async: true

					});
}
}

					});
}
}

Zeile 256Zeile 220
		return false;
}
};

		return false;
}
};

 

UserCP.init();