/* returns a jquery deferred object, .done() means an invite was sent (or attempted), .fail() indicates they dismissed the modal */
function PresentGroupInviteOptions( rgFriendsToInvite )
{
// this deferred will succeed if an invite is succesfully sent, fail if the user dismisses the modal or the invite AJAX fails
var deferred = new jQuery.Deferred();
var Modal = ShowDialog( '自分のグループに招待', '
' );
var $ListElement = $J('', {'class': 'newmodal_content_innerbg'} );
var bBulkFriendInvite = false;
var steamIDInvitee = g_rgProfileData['steamid'];
var strProfileURL = g_rgProfileData['url'];
// see if this is a request to bulk invite a group of friends
if ( rgFriendsToInvite && rgFriendsToInvite instanceof Array )
{
if ( rgFriendsToInvite.length == 1 )
{
steamIDInvitee = rgFriendsToInvite[0];
strProfileURL = 'https://steamcommunity.com/profiles/' + steamIDInvitee + '/';
}
else
{
// true bulk invite
steamIDInvitee = rgFriendsToInvite;
bBulkFriendInvite = true;
}
}
// if the modal is dismissed , we'll cancel the deferred object. We capture this in a closure so that we can dismiss the modal without affecting
// the deferred object if the user actually picks something (in which case the deferred object will be the success of the AJAX invite action)
var fnOnModalDismiss = function() { deferred.reject() };
$J.get( strProfileURL + 'ajaxgroupinvite?new_profile=1' + ( bBulkFriendInvite ? '&bulk=1' : '' ), function( html ) {
Modal.GetContent().find( '.newmodal_content').html(''); // erase the throbber
Modal.GetContent().find( '.newmodal_content').append( $ListElement );
$ListElement.html( html );
Modal.AdjustSizing();
$ListElement.children( '.group_list_results' ).children().each( function () {
var groupid = this.getAttribute( 'data-groupid' );
if ( groupid )
{
$J(this).click( function() {
fnOnModalDismiss = function () {;}; // don't resolve the deferred on modal dismiss anymore, user has picked something
InviteUserToGroup( Modal, groupid, steamIDInvitee)
.done( function() { deferred.resolve(); } )
.fail( function() { deferred.reject(); } );
} );
}
});
});
Modal.done( function() {fnOnModalDismiss();} );
return deferred.promise();
}
function InviteUserToGroup( Modal, groupID, steamIDInvitee )
{
var params = {
json: 1,
type: 'groupInvite',
group: groupID,
sessionID: g_sessionID
};
if ( steamIDInvitee instanceof Array )
params.invitee_list = V_ToJSON( steamIDInvitee );
else
params.invitee = steamIDInvitee;
return $J.ajax( { url: 'https://steamcommunity.com/actions/GroupInvite',
data: params,
type: 'POST'
} ).done( function( data ) {
Modal && Modal.Dismiss();
var strMessage = '招待を送信しました!';
ShowAlertDialog( '自分のグループに招待', strMessage );
}).fail( function( data ) {
Modal && Modal.Dismiss();
var rgResults = data.responseJSON;
var strAccountListTable = '';
if ( rgResults.rgAccounts )
{
strAccountListTable = '招待されたプレイヤー | エラー |
';
$J.each( rgResults.rgAccounts, function( accountid, rgError ){
strAccountListTable += '';
strAccountListTable += '' + rgError.persona + ' | ';
strAccountListTable += '' +rgError.strError + " | ";
strAccountListTable += '
';
} );
strAccountListTable += '
';
}
ShowAlertDialog( 'エラー', rgResults.results ? rgResults.results + strAccountListTable : 'リクエストを処理中にエラーが発生しました。もう一度お試しください。' );
});
}
function RemoveFriend()
{
var steamid = g_rgProfileData['steamid'];
var strPersonaName = g_rgProfileData['personaname'];
ShowConfirmDialog( 'フレンドを削除',
'%s をフレンドリストから削除しますがよろしいですか?'.replace( /%s/, strPersonaName ),
'フレンドを削除'
).done( function() {
$J.post(
'https://steamcommunity.com/actions/RemoveFriendAjax',
{sessionID: g_sessionID, steamid: steamid }
).done( function() {
ShowAlertDialog( 'フレンドを削除',
'%s がフレンドリストから削除されました。'.replace( /%s/, strPersonaName )
).done( function() {
// reload the page when they click OK, so we update friend state
window.location.reload();
} );
} ).fail( function() {
ShowAlertDialog( 'フレンドを削除',
'リクエストを処理中にエラーが発生しました。もう一度お試しください。'
);
} );
} );
}
// also used for accepting friend invites
function AddFriend( bRespondingToInvite, steamid_friend, strPersonaName_friend )
{
var steamid = steamid_friend ? steamid_friend : g_rgProfileData['steamid'];
var strPersonaName = strPersonaName_friend ? strPersonaName_friend : g_rgProfileData['personaname'];
$J.post(
'https://steamcommunity.com/actions/AddFriendAjax',
{sessionID: g_sessionID, steamid: steamid, accept_invite: bRespondingToInvite ? 1 : 0 }
).done( function() {
if ( !bRespondingToInvite )
{
ShowAlertDialog( 'フレンドに追加' + ' - ' + strPersonaName,
'フレンドの招待を送りました。相手が招待を受け入れたら、フレンドとして表示されます。'
);
}
else
{
ShowAlertDialog( 'フレンドリクエストを承認',
'フレンドリクエストは承認されました'
).done( function() { window.location.reload(); } );
}
} ).fail( function( jqXHR ) {
var failedInvites = jqXHR.responseJSON['failed_invites_result'];
if ( failedInvites === undefined )
{
ShowAlertDialog( 'フレンドに追加',
'フレンドの追加時にエラーが発生しました。 もう一度お試しください。'
);
return;
}
// defaults
var strTitle = 'フレンドに追加';
var strMessage = 'フレンドの追加時にエラーが発生しました。 もう一度お試しください。';
switch ( failedInvites[0] )
{
case 25:
strMessage = '%sを招待できませんでした。あなたはフレンドリスト上限に達しています。';
break;
case 15:
strMessage = '%sを招待できませんでした。フレンドはフレンドリスト上限に達しています。';
break;
case 40:
strMessage = 'フレンドに追加する際にエラーが発生しました。あなたとこのユーザー間のコミュニケーションがブロックされています。';
break;
case 11:
strMessage = 'このユーザーとのすべてのコミュニケーションをブロックしています。 ブロックしているユーザーとコミュニケーションを取る場合は、Steam コミュニティページにアクセスして対象ユーザーのブロックを解除してください。';
break;
case 84:
strMessage = '短時間にあまりにも多くの招待を送信しています。1,2日後にもう一度お試しください。';
break;
case 24:
strMessage = 'あなたのアカウントはこの機能を使用するための要件を満たしていません。詳細についてはSteam サポートをご覧ください。';
break;
default:
// default text is above
break;
}
strMessage = strMessage.replace( /%s/, strPersonaName );
ShowAlertDialog( strTitle, strMessage );
} );
}
// ignore an invite; do not block the inviter
function IgnoreFriendInvite( steamid_friend, strPersonaName_friend )
{
var steamid = steamid_friend ? steamid_friend : g_rgProfileData['steamid'];
var strPersonaName = strPersonaName_friend ? strPersonaName_friend : g_rgProfileData['personaname'];
$J.post(
'https://steamcommunity.com/actions/IgnoreFriendInviteAjax',
{sessionID: g_sessionID, steamid: steamid }
).done( function() {
ShowAlertDialog( 'フレンドリクエストを無視',
'フレンドリクエストは無視されました'
).done( function() { window.location.reload(); } );
} ).fail( function() {
ShowAlertDialog( 'フレンドリクエストを無視',
'フレンドリクエストを無視する際にエラーが発生しました。もう一度お試しください。'
);
} );
}
// block a user, with confirmation
function ConfirmBlock()
{
var steamid = g_rgProfileData['steamid'];
var strPersonaName = g_rgProfileData['personaname'];
ShowConfirmDialog( 'すべての連絡をブロック',
'%sとのすべての連絡をブロックしようとしています'.replace( /%s/, strPersonaName ),
'はい、ブロックします'
).done( function() {
$J.post(
'https://steamcommunity.com/actions/BlockUserAjax',
{sessionID: g_sessionID, steamid: steamid, block: 1 }
).done( function() {
ShowAlertDialog( 'すべての連絡をブロック',
'このプレイヤーとのすべてのコミュニケーションをブロックしました。'
).done( function() {
location.reload();
} );
} ).fail( function() {
ShowAlertDialog( 'すべての連絡をブロック',
'リクエストを処理中にエラーが発生しました。もう一度お試しください。'
);
} );
} );
}
// unblock a user, with confirmation
function ConfirmUnblock()
{
var steamid = g_rgProfileData['steamid'];
var strPersonaName = g_rgProfileData['personaname'];
ShowConfirmDialog( '全てのコミュニケーションのブロックを解除',
'%s との全てのコミュニケーションのブロックを解除しようとしています。'.replace( /%s/, strPersonaName ),
'はい、ブロックを解除します'
).done( function() {
$J.post(
'https://steamcommunity.com/actions/BlockUserAjax',
{sessionID: g_sessionID, steamid: steamid, block: 0 }
).done( function() {
ShowAlertDialog( '全てのコミュニケーションのブロックを解除',
'このプレイヤーとの全てのコミュニケーションのブロックを解除しました。'
).done( function() {
location.reload();
} );
} ).fail( function() {
ShowAlertDialog( '全てのコミュニケーションのブロックを解除',
'リクエストを処理中にエラーが発生しました。もう一度お試しください。'
);
} );
} );
}
function InitProfileSummary( strSummary )
{
var $Summary = $J( '.profile_summary' );
var $SummaryFooter = $J( '.profile_summary_footer' );
if ( $Summary[0].scrollHeight <= 76 )
{
$Summary.addClass( 'noexpand' );
$SummaryFooter.hide();
}
else
{
var $ModalSummary = $J('', {'class': 'profile_summary_modal'}).html( strSummary );
$SummaryFooter.find( 'span' ).click( function() {
var Modal = ShowDialog( '情報', $ModalSummary );
window.setTimeout( function() { Modal.AdjustSizing(); }, 1 );
} );
}
}
function ShowFriendsInCommon( unAccountIDTarget )
{
ShowPlayerList( '共通のフレンド', 'friendsincommon', unAccountIDTarget );
}
function ShowFriendsInGroup( unClanIDTarget )
{
ShowPlayerList( 'グループ内のフレンド', 'friendsingroup', unClanIDTarget );
}
function ShowPlayerList( title, type, unAccountIDTarget, rgAccountIDs )
{
var Modal = ShowAlertDialog( title, '
' );
var $ListElement = $J('', {'class': 'player_list_ctn'} );
var $Buttons = Modal.GetContent().find('.newmodal_buttons').detach();
Modal.GetContent().css( 'min-width', 268 );
var rgParams = {};
if ( type )
rgParams['type'] = type;
if ( unAccountIDTarget )
rgParams['target'] = unAccountIDTarget;
if ( rgAccountIDs )
rgParams['accountids'] = rgAccountIDs.join( ',' );
$J.get( 'https://steamcommunity.com/actions/PlayerList/', rgParams, function( html ) {
$ListElement.html( html );
var $Content = Modal.GetContent().find( '.newmodal_content');
$Content.html(''); // erase the throbber
$Content.append( $ListElement );
$Content.append( $Buttons );
Modal.AdjustSizing();
$ListElement.append();
});
}
function ToggleManageFriends()
{
if ( $J('#manage_friends_actions_ctn').is( ':hidden' ) )
{
$J('#manage_friends_btn').find( '.btn_details_arrow').removeClass( 'down').addClass( 'up' );
$J('#manage_friends_actions_ctn').slideDown( 'fast' );
$J('div.manage_friend_checkbox').show();
$J('a.friendBlockLinkOverlay' ).on( 'click.manage_friends', function( event ) {
if ( !event.which || event.which == 1 )
{
event.preventDefault();
$J(this ).siblings('.manage_friend_checkbox' ).find('input[type=checkbox]' ).prop( 'checked', function( i, v ) { return !v; } );
}
});
}
else
{
$J('#manage_friends_btn').find( '.btn_details_arrow').removeClass( 'up').addClass( 'down' );
$J('#manage_friends_actions_ctn').slideUp( 'fast' );
$J('div.manage_friend_checkbox').hide();
$J('a.friendBlockLinkOverlay' ).off( 'click.manage_friends' );
}
}
function ManageFriendsInviteToGroup( $Form, groupid )
{
$Form.find('input[type="checkbox"]');
var rgFriendSteamIDs = [];
$Form.find( 'input[type=checkbox]' ).each( function() {
if ( this.checked )
rgFriendSteamIDs.push( $J(this).attr( 'data-steamid' ) );
} );
if ( rgFriendSteamIDs.length > 0 )
{
if ( groupid )
{
// specific group
InviteUserToGroup( null /* no modal window */, groupid, rgFriendSteamIDs ).done( function() {
$Form.find('input[type=checkbox]').prop( 'checked', false );
});
}
else
{
// ask the user which group to invite to
PresentGroupInviteOptions( rgFriendSteamIDs).done( function() {
$Form.find('input[type=checkbox]').prop( 'checked', false );
});
}
}
else
{
ShowAlertDialog( '自分のグループに招待', 'フレンドが選択されていません。' );
}
}
function ManageFriendsExecuteBulkAction( $Form, strActionName )
{
if ( $Form.find('input[type=checkbox]:checked').length == 0 )
{
ShowAlertDialog( '', 'フレンドが選択されていません。' );
return;
}
$Form.find('input[name=action]').val( strActionName );
$Form.submit();
}
function ManageFriendsConfirmBulkAction( $Form, strActionName, strTitle, strSingluarDescription, strPluralDescription )
{
var cFriendsSelected = $Form.find('input[type=checkbox]:checked').length;
if ( cFriendsSelected == 0 )
{
ShowAlertDialog( strTitle, 'フレンドが選択されていません。' );
return;
}
var strDescription = strSingluarDescription;
if ( cFriendsSelected != 1 )
strDescription = strPluralDescription.replace( /%s/, cFriendsSelected );
ShowConfirmDialog( strTitle, strDescription).done( function() {
ManageFriendsExecuteBulkAction( $Form, strActionName );
});
}
function ManageFriendsBlock( $Form )
{
ManageFriendsConfirmBulkAction( $Form, 'ignore', 'ブロック',
'このフレンドをブロックしますか?' + ' ' + 'ブロックすると、このプレイヤーに対するメッセージの送受信/ゲームへの招待ができなくなります。',
'これら %s 人のフレンドをブロックしますか?' + ' ' + 'ブロックすると、このプレイヤーに対するメッセージの送受信/ゲームへの招待ができなくなります。');
}
function ManageFriendsRemove( $Form )
{
ManageFriendsConfirmBulkAction( $Form, 'remove', 'フレンドを削除',
'このフレンドを削除しますか?' + ' ' + 'このプレイヤーは今後フレンドリストに表示されなくなり、また一切のコミュニケーションができなくなります。',
'本当に%s人のフレンドを削除しますか?' + ' ' + 'これらのプレイヤーは今後フレンドリストに表示されなくなり、また一切のコミュニケーションができなくなります。');
}
function ManageFollowingRemove( $Form )
{
ManageFriendsConfirmBulkAction( $Form, 'removefollowing', 'フォローリストから削除しますか?',
'本当にこのユーザーのフォローを中止しますか?',
'本当に%s 人のユーザーのフォローを中止しますか?');
}
function ManageFriendsAddFriends( $Form )
{
ManageFriendsConfirmBulkAction( $Form, 'addfriend', 'フレンドリストに追加',
'選択したプレイヤーにフレンドの招待を送信しますか? ',
'選択したプレイヤーにフレンドの招待を送信しますか? ' );
}
var AliasesLoaded = false;
function ShowAliasPopup(e)
{
ShowMenu( e, 'NamePopup', 'left' );
if( AliasesLoaded )
return true;
var aliasContainer = $( 'NamePopupAliases' );
var throbber = document.createElement( 'img' );
throbber.src = 'https://steamcommunity-a.akamaihd.net/public/images/login/throbber.gif';
aliasContainer.appendChild( throbber );
new Ajax.Request( g_rgProfileData['url'] + 'ajaxaliases/', {
method: 'post',
parameters: { },
onSuccess: function( transport ) {
var Aliases = transport.responseJSON;
if( !aliasContainer )
return;
aliasContainer.update('');
if( !Aliases || Aliases.length == 0 )
Aliases.push( {newname: "このユーザーは使用しているエイリアスがありません"} );
for( var x=0; x 2;
}
function ShowNicknameModal( )
{
// Show the dialogue
ShowPromptDialog( "\u30cb\u30c3\u30af\u30cd\u30fc\u30e0\u3092\u8ffd\u52a0", "\u3053\u306e\u30d7\u30ec\u30a4\u30e4\u30fc\u306b\u6c38\u7d9a\u7684\u306a\u30cb\u30c3\u30af\u30cd\u30fc\u30e0\u3092\u3064\u3051\u308c\u3070\u3001\u8ab0\u3067\u3042\u308b\u304b\u5e38\u306b\u8ffd\u8de1\u3059\u308b\u4e8b\u304c\u3067\u304d\u307e\u3059\u3002", "\u30cb\u30c3\u30af\u30cd\u30fc\u30e0\u3092\u8ffd\u52a0", "\u30ad\u30e3\u30f3\u30bb\u30eb" )
.done( function( nickname, other ) {
// User clicked 'OK', so we have a value; need to send it to the server
$J.ajax( { url: g_rgProfileData['url'] + "ajaxsetnickname/",
data: { nickname: nickname, sessionid: g_sessionID },
type: 'POST',
dataType: 'json'
} ).done( function( data ) {
// Got request result back, show it on the page
if(data.nickname != undefined && data.nickname.length > 0)
{
$target = $J('.persona_name .nickname');
// Add the nickname element if we don't already have one.
if( $target.length == 0 )
$target = $J('').insertBefore( '.namehistory_link' );
$target.text( "(" + data.nickname + ") " );
$target.show();
} else
$J('.persona_name .nickname').hide();
}).fail( function( data ) {
ShowAlertDialog( '', data.results ? data.results : 'リクエストを処理中にエラーが発生しました。もう一度お試しください。' );
});
}
);
}
function SetFollowing( bFollowing, fnOnSuccess )
{
var url = bFollowing ? g_rgProfileData['url'] + "followuser/" : g_rgProfileData['url'] + "unfollowuser/";
$J.ajax( { url: url,
data: { sessionid: g_sessionID },
type: 'POST',
dataType: 'json'
} ).done( function( data ) {
fnOnSuccess( bFollowing );
}).fail( function( data ) {
ShowAlertDialog( '', data.results ? data.results : 'リクエストを処理中にエラーが発生しました。もう一度お試しください。' );
});
}
function ShowFriendSelect( title, fnOnSelect )
{
var Modal = ShowAlertDialog( title, '', 'キャンセル' );
var $ListElement = $J('', {'class': 'player_list_ctn'} );
var $Buttons = Modal.GetContent().find('.newmodal_buttons').detach();
Modal.GetContent().css( 'min-width', 268 );
var rgParams = {type: 'friends'};
$J.get( 'https://steamcommunity.com/actions/PlayerList/', rgParams, function( html ) {
$ListElement.html( html );
$ListElement.find( 'a' ).remove();
$ListElement.find( '[data-miniprofile]').each( function() {
var $El = $J(this);
$El.click( function() { Modal.Dismiss(); fnOnSelect( $El.data('miniprofile') ); } );
} );
var $Content = Modal.GetContent().find( '.newmodal_content');
$Content.html(''); // erase the throbber
$Content.append( $ListElement );
$Content.append( $Buttons );
Modal.AdjustSizing();
});
}
function StartTradeOffer( unAccountID, rgParams )
{
var params = rgParams || {};
params['partner'] = unAccountID;
ShowTradeOffer( 'new', params );
}
function CancelTradeOffer( tradeOfferID )
{
ShowConfirmDialog(
'トレードオファーをキャンセル',
'本当にこのトレードオファーをキャンセルしますか?',
'はい',
'いいえ'
).done( function() {
ActOnTradeOffer( tradeOfferID, 'cancel', 'トレードオファーをキャンセルしました', 'トレードオファーをキャンセル' );
} );
}
function DeclineTradeOffer( tradeOfferID )
{
ShowConfirmDialog(
'トレードを断る',
'本当にこのトレードオファーを断りますか?アイテムを修正して、カウンターオファーを送信することもできます。',
'トレードを断る',
null,
'カウンターオファーを行う'
).done( function( strButton ) {
if ( strButton == 'OK' )
ActOnTradeOffer( tradeOfferID, 'decline', 'トレードを拒否しました', 'トレードを断る' );
else
ShowTradeOffer( tradeOfferID, {counteroffer: 1} );
} );
}
function ActOnTradeOffer( tradeOfferID, strAction, strCompletedBanner, strActionDisplayName )
{
var $TradeOffer = $J('#tradeofferid_' + tradeOfferID);
$TradeOffer.find( '.tradeoffer_footer_actions').hide();
return $J.ajax( {
url: 'https://steamcommunity.com/tradeoffer/' + tradeOfferID + '/' + strAction,
data: { sessionid: g_sessionID },
type: 'POST',
crossDomain: true,
xhrFields: { withCredentials: true }
}).done( function( data ) {
AddTradeOfferBanner( tradeOfferID, strCompletedBanner, false );
RefreshNotificationArea();
}).fail( function() {
ShowAlertDialog( strActionDisplayName, 'このトレードオファーの修正中にエラーが発生いたしました。後でもう一度お試しください。' );
$TradeOffer.find( '.tradeoffer_footer_actions').show();
});
}
function AddTradeOfferBanner( tradeOfferID, strCompletedBanner, bAccepted )
{
var $TradeOffer = $J('#tradeofferid_' + tradeOfferID);
$TradeOffer.find( '.tradeoffer_footer_actions').hide();
$TradeOffer.find( '.link_overlay' ).hide();
$TradeOffer.find( '.tradeoffer_items_ctn').removeClass( 'active' ).addClass( 'inactive' );
var $Banner = $J('', {'class': 'tradeoffer_items_banner' } );
if ( bAccepted )
$Banner.addClass( 'accepted' );
$Banner.text( strCompletedBanner );
$TradeOffer.find( '.tradeoffer_items_rule').replaceWith( $Banner );
}