Search:
Template:News/Forums/Polls/Q&A > Template:CommentsToMe

Template:CommentsToMe

    Table of contents
    No headers
    // includes
    //dekiapi();
    //jquery.ui('smoothness');
    
    // 8-March-2010  neilw         Added "avatars" and "collapse" options
    // 9-March-2010  carles.coll   Added some styling on the content text ( mantain original comment structure ), and also autolinks on http links.
    
    // + PARAMETERS
    var par = {     
        username:  $0 ?? __request.args.user ?? args.user ?? string.substr(page.path, 5),
        max: $1 ?? $max ?? __request.args.max ?? args.max ?? 30,
        skip: $2 ?? $skip ?? __request.args.skip ?? args.skip ?? 0,
        collapse: $collapse ?? __request.args.collapse ?? false,
        avatars: $avatars ?? __request.args.avatars ?? true,
        language: __request.args.language ?? args.language ?? ( page.language != '' ? page.language : ( site.language !=''?site.language:'en-us') ),
        ajax_action: String.tolower( __request.args.ajax_action ?? args.ajax_action ?? 'load')   
       };
    
    if ((par.ajax_action=='preload') || (par.ajax_action=='load') || (par.ajax_action=='reload_UsuarioLineaTemporal')) {
    
    if ((par.ajax_action=='load') || (par.ajax_action=='reload_UsuarioLineaTemporal')) {
    // + CONSTANTS
    var NO_AVATAR = '';
    
    // + VARS
    var cache_avatars = {};
    var avatar,source,n,a;
    var username = par.username;
    
    <div id='MensajesWiki' class='hslice'>
    <div class='entry-title' style='display: none'>"Wiki Messages"</div>
    <div class='entry-content'>
    // <a href='/User:carles_coll/Web_Slices/Usuario_Linea_Temporal#MensajesWiki' rel='feedurl' style='display:none'></a>
    <div id="timeline_block">
    
     <div id="deki-timeline" class="deki-timeline">
       var max = par.max; 
       var skip = par.skip;
        foreach (var entry in wiki.getsearch('type:comment AND ( @'..username..' )', max, '-date') ) {
          //       var user = entry.user, p= entry.page; 
          var user = entry.author, p= entry.page;
          let un = user.name;
            if (par.avatars && !Map.Contains(cache_avatars,un)) {
               let source=wiki.getpage('/User:' .. un).files;
               let avatar=NO_AVATAR;
               foreach (var f in source) {
                  let n=f.name;
                  let a=f.api;
                  if (String.tolower(n) == 'avatar.jpg') { let avatar=f.api; }
                 }
               if (avatar==NO_AVATAR) { let avatar = user.gravatar; }
               let cache_avatars ..= {(un): ("<img src='"..avatar.."' width='30px' valing='top' />") };
              }
     
         <div class="dekitl-item" id=(un)>
           <div class="dekitl-user">
            <a href=('/user:'..un) rel="internal" target="_blank">
              if (par.avatars) {
                 web.html(cache_avatars[un]);
                 <br />;
              }
              un;
            </a>
           </div>
           <div class="dekitl-message">
            var id = @msg .. __index;
            var timestamp = <span class='dekitl-timestamp'>(date.changetimezone(entry.date, user.timezone))</span>;
    
            <span class="dekitl-title">
             if (par.collapse) collapseitem(id, _,_, "slide");
             "Message on ";
             <a href=(p.uri) title=(p.title) rel="internal" target="_blank">(p.title)</a>;
             if (par.collapse) {
               " ";
               timestamp;
             }
            </span>
            <br />
    
            var comhref=entry.text;        
            var imov=0;
            foreach (var ihl in String.IndexesOf(comhref,"http")) { // #mod @carles.coll 2010/02/15
              let ihl+=imov;
              var href=String.SubStr(comhref,ihl);            
              var endpos=List.Min(List.Select([String.IndexOf(href," "),String.IndexOf(href,"\n"),String.Length(href)],"$>0"));
              var shltxt=String.SubStr(href,0,endpos);
              var shlref="<a href='"..shltxt.."'>"..shltxt.."</a>";
              let imov+=String.Length(shlref)-String.Length(shltxt);
              let comhref=String.SubStr(comhref,0,ihl)..shlref..String.SubStr(comhref,ihl+String.Length(shltxt));
             }   
    
            <span class='dekitl-content' id=(id) style=(par.collapse ? "display:none" : "")>
             web.html(String.Replace(comhref,'@'..username,'').." ");
             if (!par.collapse) timestamp;
            </span>
          </div>
         </div>
        }
      </div>
    
    </div>
    
    </div>
    </div>
     } // -- if ((par.ajax_action=='load') || (par.ajax_action=='reload_UsuarioLineaTemporal')) ..
    
    if ( (par.ajax_action=='load') || (par.ajax_action=='preload') ) {
     
    <style type="text/css">"
    	#deki-timeline {
    		font-size: 12px;		
    		margin: 12px 0;
    	}
    	div.dekitl-item {
    		overflow: auto;
    		padding: 8px;
                    border-top: 1px solid;
    	}
    	div.dekitl-at {
    		background-color: #ffffce;
    	}
    	div.dekitl-user {
    		width: 60px; 
    		float: left;
    		text-align: ;left;
    		font-weight: strong;
    	}
    	div.dekitl-user a img {
    		border: none;
    	}
    	div.dekitl-message {
    		padding-left: 70px;
    	}
    	div.dekitl-message span {
    		font-size: 11px;
    		color: #666;
    	}
    
    	div.dekitl-message span.dekitl-title,
    	div.dekitl-message span.dekitl-title a {
    		color: #333;
    	}
    
    	div.dekitl-message span.dekitl-timestamp {
    		font-style: italic;
                    float:right;
    	}
    
    	div.dekitl-message span.dekitl-content {
                   white-space:pre-line;
                   line-height: auto;
    	       overflow: visible;
     	       margin: 0px;
    		padding: 4px 0;	
    		font-size: 14px;
                    color: black;
    	}
    "</style>
    }
    
    } // -- if ((par.ajax_action=='preload') || (par.ajax_action=='load') || (par.ajax_action=='reload_UsuarioLineaTemporal')) ..
    

    Files (0)

     

    Comments (0)

    You must login to post a comment.