var objFileReportTranslations = JSON.parse('{"FileReportCancelConfirm":"Vai v\u0113laties atcelt iepriek\u0161\u0113jo zi\u0146ojumu par probl\u0113mu ar \u0161o failu?","FileReportConfirm":"Vai ir probl\u0113ma ar \u0161o saturu vai servisa funkcionalit\u0101ti?","ReasonPlaceholder":"Ievadi probl\u0113mas aprakstu...","PleaseSelectType":"Izv\u0113lies probl\u0113mas veidu:","Type_DoesNotWork":"Nestr\u0101d\u0101","Type_Copyrights":"Autorties\u012bbas","Type_PersonalPrivacy":"Personas priv\u0101tums","Type_Hatred":"Naids","Type_Terrosim":"Terorisms","Type_Malware":"B\u012bstama programmat\u016bra","Type_Spam":"Spams","Type_Adult":"Pieaugu\u0161o saturs","Type_Children":"B\u0113rni","Type_Bug":"K\u013c\u016bda","Type_Other":"Cits","Button_Report":"Zi\u0146ot","Button_Cancel":"Atcelt"}');
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', 'Atsaukt ziņojumu par problēmu' );
fSuccess('Paldies, ziņojums ir iesniegts un tiks izskatīts tuvākajā laikā.');
}
else
{
$( domLink ).removeClass( 'has_reported' ).attr( 'my_title', 'Ziņot par problēmu' );
fSuccess('Jūsu ziņojums par bīstama faila saturu ir atcelts.');
}
}
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' ] );
}
}
} );
}