function str_replace(subject) { var f = Array(" ","/" ,".","]","[","(",")") , r = Array("_","_","_","_","_","_","_"), s = subject; var ra = r instanceof Array, sa = s instanceof Array, f = [].concat(f), r = [].concat(r), i = (s = [].concat(s)).length; while (j = 0, i--) { if (s[i]) { while (s[i] = (s[i]+'').split(f[j]).join(ra ? r[j] || "" : r[0]), ++j in f){}; } }; return sa ? s : s[0]; } var stiriArray; function updatePreview() { generateScript(); var format = $F('formformat'); var div = $('preview'); var table = $('euro_table'); if (table!=null) { table.remove(); } table = new Element('table', { id: 'euro_table'}); tbody = new Element('tbody'); table.insert(tbody); div.insert(table); table.setStyle({ width: $F('formwidth')+'px', height: $F('formheight')+'px', backgroundColor: '#'+ $F('backgroundColor'), fontFamily: $F('formFont') +',sans-serif', fontSize: $F('formFontSize')+'pt', borderColor: '#' + $F('borderColor'), borderWidth: $F('borderThickness')+ 'px' }); //var myArray = Object.values(stiriArray); var tr = new Element('tr'); tbody.insert(tr); var link = new Element('a', { href: 'https://www.euroavocatura.ro/stiri' , target:'_blank'} ).update('  Stiri Juridice'); link.setStyle({color:'#'+$F('titleColor') , fontWeight:'bold'}); var div = new Element('td', { id: 'stire'+index}).update(link); div.setStyle({backgroundColor:'#'+$F('backgroundTitle')}); tr.insert(div); var count = $F('formCount') > stiriArray.length ? stiriArray.length : $F('formCount'); for (var index = 0, len = count; index < len; ++index) { var item = stiriArray[index]; var tr = new Element('tr'); tbody.insert(tr); switch ( format ) { case '1': var link = new Element('a', { href: 'https://www.euroavocatura.ro/stiri/'+item.idStire+'/'+str_replace(item.titluStire), target:'_blank' } ).update(item.titluStire); link.setStyle({color:'#'+$F('titleColor') , fontWeight:'bold'}); var div = new Element('td', { id: 'stire'+index}).update(link); div.setStyle({backgroundColor:'#'+$F('backgroundTitle')}); tr.insert(div); break; case '2': var link = new Element('a', { href: 'https://www.euroavocatura.ro/stiri/'+item.idStire+'/'+str_replace(item.titluStire), target:'_blank'}).update(item.titluStire); link.setStyle({color:'#'+$F('titleColor'),fontWeight:'bold'}); var tr2 = new Element('tr'); tbody.insert(tr2); var div1 = new Element('td', { id: 'stire'+index }).update(link); tr.insert(div1); div1.setStyle({backgroundColor:'#'+$F('backgroundTitle')}); var div2 = new Element('td', { id: 'detaliistire'+index }).update(item.descriereStire); div2.setStyle({color:'#'+$F('textColor')}); tr2.insert(div2); break; case '3': var tr2 = new Element('tr'); tbody.insert(tr2); var link = new Element('a', { href: 'https://www.euroavocatura.ro/stiri/'+item.idStire+'/'+str_replace(item.titluStire), target:'_blank'}).update(item.titluStire); link.setStyle({color:'#'+$F('titleColor'), fontWeight:'bold'}); var div1 = new Element('td', { id: 'stire'+index}).update(link); div1.setStyle({backgroundColor:'#'+$F('backgroundTitle')}); tr.insert(div1); var div2 = new Element('div', { id: 'pozastire'+index }).update(); div2.setStyle({cssFloat:'left',position:'relative',top:'0px',left:'0px'}); var img = new Element('img', { id: 'euroav_poza_stire', src:'https://www.euroavocatura.ro/pictures/stire_'+item.idStire+'.jpg'}); //img.setStyle({}); div2.insert(img); var div3 = new Element('div', { id: 'detaliistire'+index}).update(item.descriereStire); //div3.setStyle({}); var td = new Element('td'); td.setStyle({color:'#'+$F('textColor')}); td.insert(div2); td.insert(div3); tr2.insert(td); break; default: break; } } } function generateScript() { var area = $('euroav_gen_script'); var script = '\n'; script += '\n'; script += '