"; var regExp = new RegExp( st, "ig"); decoratedTerm = item.text; decoratedTerm = decoratedTerm.replace( regExp, "" + st + ""); return { text: decoratedTerm, id: item.id } }), } } }, cache: false, minimumInputLength: 3, "language": { "noResults": function(){return "Nessun risultato trovato";}, "inputTooShort": function(args){return "Digitare almeno 3 caratteri";} }, }).on('select2:select', function(event) { //var url = window.location.protocol + '//' + window.location.host + window.location.pathname; var curl = window.location.href; var url = curl.substr(0, curl.indexOf(".php") +4 ); console.log(url); si = event.params.data; var tts = si.text.replace("", "").replace("", "").replaceAll("'","_27_").replaceAll("/","_2F_"); console.log( tts); url += '/L/EN'; url += '/swords/' + encodeURIComponent(tts); //si.text.replace(/(<([^>]+)>)/gi, ""); window.location.href = url; }); //$("#select2-swords-container").html("AAA"); $('#swords-add').on('click', function() { if (si !== null) { data[ si.id ] = si; data2table(); datael.val(JSON.stringify(data)); si = null; } return false; }); var datael = $('#swords-data'); var data = JSON.parse(datael.val()); var datatable = $('#data-table'); if (data.length === 0) data = {}; function data2table() { var h = ["