var hided = 0; var base_url = "https://www.legis.md/"; var current_page = 1; var total_pages = 0; var next_page = 2; var prev_page = 1; var current_page = 0; $.urlParam = function(url, field){ if(url.indexOf('?' + field + '=') != -1) return true; else if(url.indexOf('&' + field + '=') != -1) return true; return false } function showadvancedsearch(str, strhide) { if (hided == 0) { hided = 1; } else { hided = 0; } if (hided == 1) { $('.cautare').html(str); $('.cautare-avansata').show(); $('html, body').animate({ scrollTop: $(".text-center").offset().top}, 'slow'); } else { $('.cautare').html(strhide); $('.cautare-avansata').hide(); $("html, body").animate({ scrollTop : 0 }, "slow"); } } var sel = new Array(); sel['.f0class'] = 0; sel['.f8class'] = 0; sel['.f13class'] = 0; function selectall(classi) { if (sel[classi] == 0) { $(classi).prop('checked', true); sel[classi] = 1; } else { $(classi).prop('checked', false); sel[classi] = 0; } } function showcontent(title, filtru) { f0 = ""; f1 = ""; f2 = ""; f3 = ""; f4 = ""; f5 = ""; f6 = ""; f7 = ""; f8 = ""; f9 = ""; f10 = ""; f11 = ""; f12 = ""; f13 = ""; f14 = ""; f15 = ""; f16 = ""; f17 = ""; f18 = ""; f19 = ""; f20 = ""; mi = ""; ag = ""; al = ""; if (filtru != "") { f0 = $('#f0').prop('checked') ? $('#f0').val() : ""; f1 = $('#f1').prop('checked') ? $('#f1').val() : ""; f2 = $('#f2').prop('checked') ? $('#f2').val() : ""; f3 = $('#f3').prop('checked') ? $('#f3').val() : ""; f4 = $('#f4').prop('checked') ? $('#f4').val() : ""; f5 = $('#f5').prop('checked') ? $('#f5').val() : ""; f6 = $('#f6').prop('checked') ? $('#f6').val() : ""; f7 = $('#f7').prop('checked') ? $('#f7').val() : ""; f8 = $('#f8').prop('checked') ? $('#f8').val() : ""; f9 = $('#f9').prop('checked') ? $('#f9').val() : ""; f10 = $('#f10').prop('checked') ? $('#f10').val() : ""; f11 = $('#f11').prop('checked') ? $('#f11').val() : ""; f12 = $('#f12').prop('checked') ? $('#f12').val() : ""; f13 = $('#f13').prop('checked') ? $('#f13').val() : ""; f14 = $('#f14').prop('checked') ? $('#f14').val() : ""; f15 = $('#f15').prop('checked') ? $('#f15').val() : ""; f16 = $('#f16').prop('checked') ? $('#f16').val() : ""; f17 = $('#f17').prop('checked') ? $('#f17').val() : ""; f18 = $('#f18').prop('checked') ? $('#f18').val() : ""; f19 = $('#f19').prop('checked') ? $('#f19').val() : ""; f20 = $('#f20').prop('checked') ? $('#f20').val() : ""; mi = $('#ministere').val(); ag = $('#agentii').val(); al = $('#alte').val(); } extra = '&f0=' + f0 + '&f1=' + f1 + '&f2=' + f2 + '&f3=' + f3 + '&f4=' + f4 + '&f5=' + f5 + '&f6=' + f6 + '&f7=' + f7 + '&f8=' + f8 + '&f9=' + f9 + '&f10=' + f10 + '&f11=' + f11 + '&f12=' + f12 + '&f13=' + f13 + '&f14=' + f14 + '&f15=' + f15 + '&f16=' + f16 + '&f17=' + f17 + '&f18=' + f18 + '&f19=' + f19 + '&f20=' + f20 + '&mi=' + mi + '&ag=' + ag + '&al=' + al; getval = 'filter_title=' + title + '&filtru=' + filtru + extra; $('#response').show(); $.ajax({ url : 'https://www.legis.md/cautare/getAjaxContent', type : 'get', data : getval, success : function (json) { $.ajax({ url : 'https://www.legis.md/cautare/getTotal', type : 'get', data : '', beforeSend : function () {}, success : function (total) { //$('.contentload').show(); $('#totalresults').html(total); $('#response').fadeOut(); //if(total > 1000) { // alert ("Conform criteriilor dvs. au fost găsite un număr mare de documente, vor fi vizualizate doar citeva, scimbați criteriul de cautare"); //} total_pages = Math.round(total / 10); } }); $('#contentload').html(json); } }); //code } var setat = 0; function removeParameter(cururl, clearparam){ var url = cururl; var uri = url.split("?"); var vars = uri[1].split("&"); var newurl = ""; // = "https://www.legis.md/"; for (var i = 0; i < vars.length; i++) { var pair = vars[i].split("="); var key = decodeURIComponent(pair[0]); var value = decodeURIComponent(pair[1]); if(key != clearparam){ newurl = newurl + key + "=" + value; if(i < (vars.length-1)){ newurl = newurl + "&"; } } } newurl = "https://www.legis.md/" + "cautare/continueReload" + "?" + newurl; return newurl; } function removeParameterByValue(cururl, clearparam, clearvalue){ var url = cururl; var uri = url.split("?"); var vars = uri[1].split("&"); var newurl = ""; // = "https://www.legis.md/"; for (var i = 0; i < vars.length; i++) { var pair = vars[i].split("="); var key = decodeURIComponent(pair[0]); var value = decodeURIComponent(pair[1]); if(key != clearparam || value != clearvalue){ var data = {}; data[key]=value; newurl = newurl + $.param(data); if(i < (vars.length-1)){ newurl = newurl + "&"; } } } newurl = "https://www.legis.md/" + "cautare/continueReload" + "?" + newurl; return newurl; } jQuery(document).ready(function () { $("#search_val").val(''); $("#search_val2").val(''); $("#search_val").keyup(function () { $('.loadx').hide(); $('#response').css('background', 'none'); /* $("#search_val").autocomplete({ minLength : 0, source : 'https://www.legis.md/cautare/getSuggest/?title=' + $('#search_val').val(), focus : function (event, ui) { $("#project").val(ui.item.label); return false; }, select : function (event, ui) { $("#search_val").val(ui.item.value); $('#formsearch').submit(); return false; } }) .data("ui-autocomplete")._renderItem = function (ul, item) {*/ /*AGH if (setat==0) { $('html, body').animate({ scrollTop: $(document).height()-$(window).height()-80}, 1400, "easeOutQuint" ); } */ /* setat = 1; return $("
  • ") .append("" + item.desc + "") .appendTo(ul); };*/ }); $("#search_val2").keyup(function () { $('.loadx').hide(); $('#response').css('background', 'none'); $("#search_val2").autocomplete({ minLength : 0, source : 'https://www.legis.md/cautare/getSuggest/?title=' + $('#search_val2').val(), focus : function (event, ui) { $("#project").val(ui.item.label); return false; }, select : function (event, ui) { $("#search_val2").val(ui.item.value); showcontent($('#search_val2').val()); return false; } }) .data("ui-autocomplete")._renderItem = function (ul, item) { /*AGH if (setat==0) { $('html, body').animate({ scrollTop: $(document).height()-$(window).height()-80}, 1400, "easeOutQuint" ); } */ setat = 1; return $("
  • ") .append("" + item.desc + "") .appendTo(ul); }; }); $("#logo-link").click(function(event){ window.location = base_url; //window.location = "clean"; }); $("#clear-sel").click(function(event){ window.location = "clean"; }); $("#clearstatus").click(function(event){ var newurl = removeParameter( window.location.href, 'document_status'); if(!$.urlParam(newurl, 'lang')) { newurl = newurl + '&lang=' + 'ro'; } location.href = newurl; }); /* $("#clearemitent").click(function(event){ var newurl = removeParameter( window.location.href, 'emitent'); location.href = newurl; });*/ /* $("#cleartip").click(function(event){ var newurl = removeParameter( window.location.href, 'tip'); location.href = newurl; });*/ $('[id^="cleartip_"]').click(function(event){ cleartip_id = event.target.id.substring(event.target.id.indexOf("_")+1); newurl = removeParameterByValue( window.location.href, 'tip[]', cleartip_id); // console.log(newurl); if(!$.urlParam(newurl, 'lang')) { newurl = newurl + '&lang=' + 'ro'; } location.href = newurl; }); $('[id^="clearemitent_"]').click(function(event){ clearemitent_id = event.target.id.substring(event.target.id.indexOf("_")+1); newurl = removeParameterByValue( window.location.href, 'emitent[]', clearemitent_id); if(!$.urlParam(newurl, 'lang')) { newurl = newurl + '&lang=' + 'ro'; } location.href = newurl; }); $("#cleardate").click(function(event){ var newurl = removeParameter( window.location.href, 'datepicker1'); if(!$.urlParam(newurl, 'lang')) { newurl = newurl + '&lang=' + 'ro'; } location.href = newurl; }); $("#clearpubdate").click(function(event){ var newurl = removeParameter( window.location.href, 'publish_date'); if(!$.urlParam(newurl, 'lang')) { newurl = newurl + '&lang=' + 'ro'; } location.href = newurl; }); $("#cleardocnr").click(function(event){ var newurl = removeParameter( window.location.href, 'nr_doc'); if(!$.urlParam(newurl, 'lang')) { newurl = newurl + '&lang=' + 'ro'; } location.href = newurl; }); $("#clearpublstatus").click(function(event){ var newurl = removeParameter( window.location.href, 'publication_status'); if(!$.urlParam(newurl, 'lang')) { newurl = newurl + '&lang=' + 'ro'; } location.href = newurl; }); $("#clearpubnr").click(function(event){ var newurl = removeParameter( window.location.href, 'nr'); if(!$.urlParam(newurl, 'lang')) { newurl = newurl + '&lang=' + 'ro'; } location.href = newurl; }); $("#clearstring").click(function(event){ var newurl = removeParameter( window.location.href, 'search_string'); if(!$.urlParam(newurl, 'lang')) { newurl = newurl + '&lang=' + 'ro'; } location.href = newurl; }); }); var closef = 0; function closePage() { if (closef == 0) { // window.location = base_url; // SK@1217 window.top.close(); } else { pageurl = base_url + 'cautare/rezultate'; window.history.pushState({ path : pageurl }, '', pageurl); $('#results').show(); $('#details').html(''); } } var slideform = 0; function showslideform() { if (slideform == 0) { $('.slide-form').show(); slideform = 1; //code } else { $('.slide-form').hide(); slideform = 0; } } var next_page = 1; var current_page = 1; function changePagination(id, total) { $('.active').removeClass('active'); current_page = id; next_page = id + 1; var onid = "#page" + id; $(onid).addClass('active'); if (id > 1) prev_page = id - 1; else prev_page = 0; $('.table').hide(); $('.d' + current_page).show(); displayPageNumbers(id, total); } function IncreasePagination(total) { $('.active').removeClass('active'); if (parseInt(current_page) != total) current_page = parseInt(current_page) + 1; id = current_page; var onid = "#page" + id; $(onid).addClass('active'); $('.table').hide(); $('.d' + current_page).show(); displayPageNumbers(id, total); } function DecreasePagination(total) { $('.active').removeClass('active'); if (parseInt(current_page) != 1) current_page = parseInt(current_page) - 1; id = current_page; var onid = "#page" + id; $(onid).addClass('active'); $('.table').hide(); $('.d' + current_page).show(); displayPageNumbers(id, total); } function displayPageNumbers(id, total) { for (i = 1; i <= total; i++) { if ((i < 10 && id <= i) || Math.abs(id - i) <= 4 || (total - 9 < i && id >= i)) { $("#lid" + i).show(); } else { $("#lid" + i).hide(); } } if (id > 5) { $("#lid0").show(); } else { $("#lid0").hide(); } if (total - id > 4) { $("#lid9999").show(); } else { $("#lid9999").hide(); } } var idyear = ""; var classyear = ""; function showversions(year, ch) { classyear = ".classyear" + year; $(idyear).removeClass('active'); idyear = "#year" + year; $(idyear).addClass('active'); $('.versions').hide(); if (ch == 1) $('.versions').removeClass('active'); $(classyear).show(); } /* add favorite */ /* SK@1217 2112 */ function updateFavorite(userID, docID){ $.post( "https://www.legis.md//users/addfavorite", { userID: userID, docID: docID }, function(data, status){ $("#fav").addClass("itsfavorite"); } ); } function showDetails(pageurl, id) { $('#response2').show(); // Primul pas, ascumdem pagina cu detalii $('#results').hide(); if (pageurl != null) closef = 1; //Schimbam in Pagina URL si Titlu // pageurl = "https://www.legis.md/cautare/rezultate/" + id; pageurl = "https://www.legis.md/cautare/getResults?doc_id=" + id + "&lang=" + "ro"; if (pageurl != null) { window.history.pushState({ path : pageurl }, '', pageurl); } else closef = 0; // Umplem pagina cu continutul corect $.ajax({ url : 'https://www.legis.md/cautare/showdetails/' + id, type : 'get', success : function (html) { $('#details').html(html); $('[title]').qtip({ style : { classes : 'qtip-light' } }); $('#response2').hide(); $("html, body").animate({ scrollTop : 0 }, 600); //document.title = title; $('.init-affix').affix({}); initBlocksHeight(); } }); } $(function () { $('.self-submit-edit, .self-submit-add').on('click', function () { if ($('#Details').length > 0) { var $this = $('#Details'); if ($('#Details').val() == '') { $this.addClass('red-bord'); return false; } } var form = $(this).closest('.ajax-form-type'); var head_text = ""; var req_fields = $('input[data-required="yes"]'); var is_valid = true; var reload = false; var redirect = ""; var ret = ""; if (req_fields.length) { $.each(req_fields, function (index, item) { var el = $(item); if (!el.val()) { el.focus(); alert(el.attr('data-msg')); is_valid = false; return false; } if (el.attr('data-head')) head_text += ' ' + el.val(); }); } if (!(typeof($(this).attr('reload')) === "undefined")) { reload = true; } if (!(typeof($(this).attr('redirect')) === "undefined")) { redirect = $(this).attr('redirect'); } if (!(typeof($(this).attr('return')) === "undefined")) { ret = $(this).attr('return'); } if (!is_valid) return false; $.ajax({ url : form.attr('action'), data : form.serialize(), type : 'POST', dataType : 'json', success : function (result) { $.ambiance({ message : result.message, title : result.title, type : result.type }); var upd = $('.updateable'); if (upd.length) upd.text(head_text); if (redirect != '') { if (result.id != '' && !result.type.Equals("Error")) { //window.location = redirect + result.id; return; } } if (result.ret) { if (result.ret != '') { ret = result.ret; } } if (ret != '') { window.location = ret; return; } if (reload) { window.location.reload(); return; } }, error : function () { alert('AJAX ERROR!'); } }); $('.popup_test').empty(); $('.grayed').fadeOut('fast'); return false; }); }); $(document).ready(function () { var search_type = ""; $.ajax({ url : 'https://www.legis.md/search_type/getlist', dataType : 'json', type : 'GET', success : function (result) { $('#search_type').empty(); $.each(result.results, function (index, item) { /* if(search_type != "" && search_type == item.id){ $('#search_type').append(""); } else {*/ $('#search_type').append(""); /* }*/ }); $('#search_type').trigger('update'); } }); $.ajax({ url : 'https://www.legis.md/document_status/getlist', dataType : 'json', type : 'GET', success : function (result) { $('#document_status').empty(); $.each(result.results, function (index, item) { selected = ""; if ($('#saved_publication_status')[0]) { if ($('#saved_document_status').val() == item.id) { $('#document_status').append(""); } else { $('#document_status').append(""); } } else { $('#document_status').append(""); } }); $('#document_status').trigger('update'); } }); var status_doc = ""; $.ajax({ url : 'https://www.legis.md/publication_status/getlist', dataType : 'json', type : 'GET', success : function (result) { $('#publication_status').empty(); $.each(result.results, function (index, item) { /* if(status_doc != "" && status_doc == item.name_ro) { $('#publication_status').append(""); } else {*/ $('#publication_status').append(""); /* }*/ }); $('#publication_status').trigger('update'); } }); $.ajax({ url : 'https://www.legis.md/emitent/getlist', dataType : 'json', type : 'GET', success : function (result) { // var sEmitent = "null"; var optEmitent = []; $.each(result.results, function (index, item) { /* if(sEmitent && sEmitent != "") { var arEmitent = JSON.parse(sEmitent); if(arEmitent && arEmitent.includes(item.id)) { // not selected optEmitent.push({name: item.name_ro, value: item.id, checked: true}); } else { optEmitent.push({name: item.name_ro, value: item.id, checked: false}); } } else {*/ optEmitent.push({name: item.name_ro, value: item.id, checked: false}); /*}*/ }); $('select[multiple].active.1col.emitent').multiselect('loadOptions', optEmitent ); } }); $.ajax({ url : 'https://www.legis.md/tip/getlist', dataType : 'json', type : 'GET', success : function (result) { $('#tip_list').empty(); $tip_pattern = ""; // var sTip = "null"; var options = []; $.each(result.results, function (index, item) { /*if(sTip && sTip != "") { var arTip = JSON.parse(sTip); if(arTip && arTip.includes(item.id)) { // not selected options.push({name: item.name_ro, value: item.id, checked: true}); } else { options.push({name: item.name_ro, value: item.id, checked: false}); } } else {*/ options.push({name: item.name_ro, value: item.id, checked: false}); /*}*/ }); $('select[multiple].active.1col.tip').multiselect('loadOptions', options ); } }); }); $(function () { $('select[multiple].active.1col.tip').multiselect({ columns: 1, placeholder: 'TOATE', search: true, selectAll: false }); $('select[multiple].active.1col.emitent').multiselect({ columns: 1, placeholder: 'TOATE', search: true, selectAll: false }); });