this.str2a = function(elems,compact=true,class_exp_file='dir|path') {
$(elems).each(function(){
- html = $(this).html();
- if (html == '') return;
+ var text = $(this).text();
+ if (text == '') return;
// Search /home
- url = html
- if (html.match(/^~/)) {
- ua = navigator.userAgent
+ var url = text
+ if (text.match(/^~/)) {
+ var ua = navigator.userAgent
if (ua.match(/Macintosh/)) { url = url.replace(/^~/,'/Users/') }
else { url = url.replace(/^~/,'/home/') }
//console.log(url);
if (this.className.match(re) && !url.match(/^\w+:/)) url = 'file://'+encodeURI(url);
}
- if (compact) html = html.replace(/^((?:\w+:\/+)?[^\/]+\/)(.*?)(\/?[^\/]+)$/,'$1..$3');
+ if (compact) {
+ //text = text.replace(/^((?:\w+:\/+)?[^\/]+\/)(.*?)(\/?[^\/]+\/?)$/,'$1..$3');
+ var max = 30;
+ if (text.length>max) text = text.substring(0,(max/2)+1) + '.. ' + text.substring(text.length-(max/2),text.length);
+ /*
+ text = text.replace(/^((?:\w+:\/+)?[^\/]+\/)(.*?)(\/?[^\/]+\/?)$/,function(match,p1,p2,p3){
+ if (p1.length>max) p1 = p1.substring(0,max);
+ if (p3.length>max) p3 = p3.substring(p3.length-max,p3.length);
+ return p1+' ..'+p3;
+ console.log(p1+' | '+p2+' | '+p3);
+ return match;
+ return p1+p2.substring(0,10);
+ });
+ */
+ }
+ //console.log(text);
- $(this).html('<a href="'+url+'" class="small" target="_blank">'+html+'</a>');
+ $(this).html('<a href="'+url+'" class="small" target="_blank">'+text+'</a>');
});