function formatState (state) {
if (!state.id) {
return state.text;
}
var $state = $(
'<span>' + state.text + ' <small>(' + state.status + ')</small></span>'
);
return $state;
};
$('.itemPerson').select2({
width: '100%',
placeholder: 'Имя персоны',
language: "ru",
theme: "bootstrap",
allowClear: true,
//tags: true,
minimumInputLength: 3,
//closeOnSelect: false,
tokenSeparators: [',',';'],
ajax: {
url: "personList.php?token=123",
dataType: 'json',
delay: 500,
data: function (params, page) {
return {
q: params.term,
};
},
processResults: function (data) {
return {
results: data
};
},
cache: true
},
templateResult: formatState,
templateSelection: formatState
});
$json[] = ['id' => $arFields['ID'], 'text' => $arFields['NAME'], 'status' => $status];
var ni = 1;
$('#addPerson').click(function() {
var newVideoItem = $('#original-person-item').clone();
newVideoItem.find('.control-wrap').each(function(index) {
var newSelectpicker = $(this).find(".selectpicker");
newSelectpicker.prop('name', 'actorsOther['+ ni + '][profession][]');
var personName = $(this).find(".personName");
personName.prop('name', 'actorsOther['+ ni + '][name]');
var personNameEng = $(this).find(".personNameEng");
personNameEng.prop('name', 'actorsOther['+ ni + '][nameEng]');
var personNameOrig = $(this).find(".personNameOrig");
personNameOrig.prop('name', 'actorsOther['+ ni + '][nameOrig]');
if (newSelectpicker.length) {
$(this).html(newSelectpicker)
newSelectpicker.selectpicker();
}
});
newVideoItem.appendTo(".person-list");
ni = ni + 1;
});
function messagePart($message)
{
$smsCountSym = strlen($message);
$arChars = array('[', ']', '{', '}', '|', '^', '~', '€', '№');
foreach($arChars as $query)
{
if (strpos($message, $query) !== false) {$chars = true;}
}
if (preg_match('/[А-Яа-яёЁ]/iu', $message) || $chars == true)
{
if ($smsCountSym <= 70)
{
$smsPart = 1;
}
else
{
$smsPart = ceil($smsCountSym / 67);
}
}
else
{
if ($smsCountSym <= 160)
{
$smsPart = 1;
}
else
{
$smsPart = ceil($smsCountSym / 153);
}
}
return $smsPart;
}