var objFileReportTranslations = JSON.parse('{"FileReportCancelConfirm":"Do you want to cancel the previous problem report for this file?","FileReportConfirm":"Gibt es ein Problem mit dieser Inhalts- oder Servicefunktionalit\u00e4t?","ReasonPlaceholder":"Geben Sie eine Beschreibung des Problems ein...","PleaseSelectType":"W\u00e4hlen Sie die Art des Problems:","Type_DoesNotWork":"Does not work","Type_Copyrights":"Copyrights","Type_PersonalPrivacy":"Person\u2019s privacy","Type_Hatred":"Hatred","Type_Terrosim":"Terrorismus","Type_Malware":"Malware","Type_Spam":"Spam","Type_Adult":"Inhalte f\u00fcr Erwachsene","Type_Children":"Kinder","Type_Bug":"Fehler","Type_Other":"Andere","Button_Report":"Report","Button_Cancel":"Cancel"}');
function showFileReportModal( domLink, strHash, fnCallback )
{
if ( typeof fnCallback === "undefined" )
{
fnCallback = function () {};
}
if ( $( domLink ).hasClass( 'has_reported' ) )
return showCancelFileReportModal(domLink, strHash, fnCallback);
var strInputs = '';
strInputs += '
';
strInputs += '
';
strInputs += '';
strInputs += '
';
strInputs += '
';
strInputs += '';
strInputs += '
';
fConfirm(
objFileReportTranslations.FileReportConfirm + strInputs,
null,
objFileReportTranslations.Button_Report ,
objFileReportTranslations.Button_Cancel ,
// Submit
function( bolSubmitted, jqModalWindow )
{
if( bolSubmitted === true )
{
var jqReason = $( '.reason', jqModalWindow );
var jqType = $( '.type', jqModalWindow );
makeFileReportRequest( strHash, jqReason.val(), jqType.val(), function ( strActionResponse ) {
finishFileReport( domLink, strActionResponse );
fnCallback( strActionResponse );
});
}
},
// Validate
function ( jqModalWindow )
{
var jqReason = $( '.reason', jqModalWindow );
var jqType = $( '.type', jqModalWindow );
var bolOk = true;
if ( $.trim( jqReason.val() ).length < 4 )
{
jqReason.css({'border-color': 'red'});
bolOk = false;
}
else
{
jqReason.css({'border-color': 'inherit'});
}
if ( $.trim( jqType.val() ) == '' )
{
jqType.css({'border-color': 'red'});
bolOk = false;
}
else
{
jqType.css({'border-color': 'inherit'});
}
return bolOk;
}
);
}
function showCancelFileReportModal(domLink, strHash, fnCallback)
{
if ( typeof fnCallback === "undefined" )
{
fnCallback = function () {};
}
fConfirm(
objFileReportTranslations.FileReportCancelConfirm,
null,
'OK',
objFileReportTranslations.Button_Cancel ,
// Submit
function( bolSubmitted )
{
if( bolSubmitted === true )
{
makeFileReportRequest( strHash, null, null, function ( strActionResponse ) {
finishFileReport( domLink, strActionResponse );
fnCallback( strActionResponse );
});
}
}
);
}
function finishFileReport( domLink, strActionResponse )
{
if ( strActionResponse == 'report' )
{
$( domLink ).addClass( 'has_reported' ).attr( 'my_title', 'Stornieren Sie einen Problembericht' );
fSuccess('Thanks, a problem report has been submitted and will be reviewed shortly.');
}
else
{
$( domLink ).removeClass( 'has_reported' ).attr( 'my_title', 'Ein Problem melden' );
fSuccess('Your message about the dangerous contents of the file has been canceled.');
}
}
function makeFileReportRequest( strHash, strReason, strType, fncCallback )
{
$.ajax( {
type: "POST",
dataType: "json",
url: "/ajax/report_file.php",
data: {
'report': true,
'h': strHash,
'reason': !!strReason ? strReason : null,
'type': !!strType ? strType : null
},
success: function ( data )
{
if ( data[ 'status' ] == 'ok' )
{
fncCallback( data[ 'action' ] );
}
}
} );
}