var is_sync = false;
function SetMode(editorId, mode) {
for (var instanceName in CKEDITOR.instances) {
if (CKEDITOR.instances[instanceName].name == editorId) {
var inst = CKEDITOR.instances[instanceName];
inst.execCommand(mode);
}
}
}
$(document).ready(function(){
$(".foo-activate").fancybox({
'centerOnScroll': true,
'autoScale' : true,
'transitionIn' : 'fade',
'transitionOut' : 'none',
'speedIn' : 100,
'type' : 'inline',
'href' : this.href,
'overlayOpacity': 0.5,
'padding' : 15,
onStart : function()
{
console.log("start");
},
onClosed : function()
{
try
{
store.reload();
}
catch(err)
{
console.log( "No store" );
}
/* if (CKEDITOR.instances.ckeditor) {
CKEDITOR.instances.ckeditor.setData("");
CKEDITOR.instances.ckeditor.destroy(true);
}
*/
}
});
$( ".login-btn" ) . click(function() {
$( ".msg_login" ) . html( "Запрос логина ... " );
$( ".msg_login" ) . show( 1000, "linear", function (){
$.post(
"http://chipmaker.com.ua/softmapps/scanadv/answer.php?act=login_auth",
{
user: $(".login-user") . val(),
pass: $(".login-pass") . val()
},
function(ret) {
if (!ret.success )
{
$( ".msg_login" ) . html( "Ошибка, вы ввели неверный пароль. Попробуйте еще раз." );
Ext . MessageBox . show ({title:"Ошибка",msg:ret.message, width:250, buttons: Ext.MessageBox.OK});
}
else
{
if ( $( "#g_act" ) . val() )
{
location.replace( "admin.php?" + make_url_wgets( "act,lang,sect,cid,prod" ) );
return false;
}
if ( ret.admin )
{
location.href = "admin.php?act=scan";
}
else
{
location.href = "admin.php?act=scan";
}
}
},
'json'
);
});
return false;
});
// logout
$( ".top_logout" ) . click( function(){
act = $( this ) . attr( "act" );
$.post(
"answer.php?act=admin_logout",
{
},
function(ret) {
Ext . MessageBox . show ({title:'Info',msg:"Вы вышли из системы!", width:250, buttons: Ext.MessageBox.OK});
location.href="./admin.php";
},
'json'
);
return false;
});
// Years menu (TODO!)
$( ".lang-selector") . change(function(){
var urls =[]; var g = 0;
$( ".getvars" ) . each(function( idx, el){
var uid = $(this).attr("uid");
if ( uid != "lang" )
urls[g++] = uid + "=" + $(this).val();
});
location.replace( "admin.php?lang=" +selid( "lang-selector" ) + "&" + urls.join( "&" ) );
return false;
});
});
// FUNCTIONS
function selid( name ) //get selected id of select element, or false
{
var id = false;
$("#"+name+" option:selected").each(function () {
id = $(this).val() ;
});
return id;
};
// --- implement IndexOf(), if browser dont have
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (obj, fromIndex) {
if (fromIndex == null) {
fromIndex = 0;
} else if (fromIndex < 0) {
fromIndex = Math.max(0, this.length + fromIndex);
}
for (var i = fromIndex, j = this.length; i < j; i++) {
if (this[i] === obj)
return i;
}
return -1;
};
}
// --- make URL with GET's vars
function make_url_wgets( params_ )
{
var use_elem = params_ . split( "," );
var gets = [];
var g = 0;
//$.log( "make_url_wgets() " );
$( ".getvars" ) . each(function( idx, el){
var uid = $(this).attr("uid");
if ( use_elem.indexOf( uid ) != -1)
{
gets[g++] = uid + "=" + $(this).val();
}
//$.log( "el ", el );
});
return gets.join( "&" );
}
// --- all images
function init_fi()
{
$(".fancy-image-show").fancybox({
'titleShow': true,
'centerOnScroll': true,
'transitionIn' : 'fade',
'transitionOut' : 'none',
'speedIn' : 100,
'type' : 'image',
'href' : this.href,
'overlayOpacity' : 0.2,
'padding' : 5,
onStart : function()
{
},
onClosed : function()
{
// reload model drop down
}
});
}
init_fi();
var month_name_s = [ "Янв","Фев","Мар","Апр","Май","Июн","Июл","Авг","Сен","Окт","Ноя","Дек" ];
var month_name = [ "Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь"];