Vergleich jscripts/usercp.js - 1.8.9 - 1.8.37

  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)

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)

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

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

					container.attr("id", "buddyselect_container");
container.hide();
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()
{
$(this).attr("checked", false);
});
$("#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();

// 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');
},

selectBuddy: function(uid, username)
{
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)
{
buddyselect_buddies_uid.remove();
var buddies = buddyselect_buddies.text();
if(buddies.charAt(0) == ",")
{
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);
}
















// 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()
{
if($(this).parent().text().trim() == username)
{
$(this).prop('checked', true);
}
});
});

UserCP.regenBuddySelected();
},

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

	},

closeBuddySelect: function(canceled)
{
if(canceled != true)
{

	},

closeBuddySelect: function(canceled)
{
if(canceled != true)
{

			var buddies = $("#buddyselect_buddies").text();
existing_buddies = $(this.buddy_field).select2("data");
if(existing_buddies.length)

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


			{

			{

				// 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.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");
}

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

























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

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





	addBuddy: function(type)
{
var type_submit = $("#"+type+"_submit");

	addBuddy: function(type)
{
var type_submit = $("#"+type+"_submit");

Zeile 177Zeile 141
		{
return true;
}

		{
return true;
}





		var old_value = type_submit.val();

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

		var old_value = type_submit.val();

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





		if(type == "ignored")
{
type_submit.attr("value", lang.adding_ignored);

		if(type == "ignored")
{
type_submit.attr("value", lang.adding_ignored);

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 211Zeile 175
					$("#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();