Template:RecentChanges

  • You do not have permissions to view this page - please try logging in.
Table of contents
No headers
// + PREREQUISITES
// --- DekiAPI Extension
DekiApi();

// + PARAMETERS
var par = { 
  path: ( __request.args.path ?? args.path ?? page.path ),
  special_search: (__request.args.special_search  ?? args.special_search ?? null),
  number: Num.Int( __request.args.number ?? args.number ?? 5),
  avatar: String.ToLower( __request.args.avatar ?? args.avatar ??  'true'),
  ajax_action: String.tolower( __request.args.ajax_action ?? args.ajax_action ?? 'load'),
  hslice_title: __request.args.hslice_title ?? args.hslice_title ?? "Cambios Recientes" 
};

/*
<div id='rdummy'>
 <span>
  'DUMMY DEBUG INFO:'; <BR />
  'ARGS:'; <BR />
  args; <BR />
  '__request.args:'; <BR />
  __request.args; <BR />
  'END DEBUG INFO:'; <BR />
 </span>
</div>
*/

if ((par.ajax_action=='load') || (par.ajax_action=='reload_cambiosrecientes')) {


// + CONSTANTS
var NO_AVATAR = Site.Api..'/files/2/=logo_adri-noc_wiki.jpg';

// + VARS
var cache_avatars = {};
var avatar,source,n,a,un;

//var path=(#args.path!=0 ? 'path:'..args.path..'/*':'');/*path;*/
var path = String.Replace('path:'..par.path..'*','User:','User\\:');
if (par.path=='/') { let path = null; }

var search_criteria = '(type:wiki OR type:document OR type:image OR type:comment)';
if (par.special_search) { let search_criteria ..= ' AND ('..par.special_search..')'; }
var result = wiki.GetSearch(search_criteria, par.number + 1, '-date',path);
//var result = wiki.GetSearch(search_criteria, 2000, '-date',path);

// -- In Theory it has to return de same number that you put on the wiki.search parameter, but it allways returns less, for this reason
// -- I skipped the last page check
//var lastpage = (#result<=par.number);
var lastpage = false;

// -- Dummy line, otherwise the RecentChanges template doesn't reload on Mindtouch v10.
<script type="text/javascript">"
"</script>


<div id='CambiosRecientes' class='hslice'>
<div class='entry-title' style='display: none'>par.hslice_title</div>
<div class='entry-content'>

<div id='reload_cr'>
/*
'DEBUG INFO:'; <BR />
'ARGS:'; <BR />
args; <BR />
'__request.args:'; <BR />
__request.args; <BR />
'END DEBUG INFO:'; <BR />
*/

 if (#result==(par.number+1)) {
  let result = list.Splice(result,(#result)-1,1);
 }

 foreach (var pa in result ) {
  if (#pa!=0)   {
   var name = pa.title; // -- If it's a page
   var edit_summary = '';
   var ppath = '';
   if (pa.id) { let edit_summary = pa.editsummary; let ppath = pa.parent.path; };
   if (!name) { let name = pa.name; let edit_summary = "File Added"; let ppath = pa.page.path; } // -- If it's a file
   if (!name) { let name = pa.page.title; let edit_summary = "Comment Added"; let ppath = pa.page.path; } // -- If it's a comment

   var puri;
   var pborrada = 0;
   var div_entry = 'CambiosRecientes-entry';
   if (pa.page) { 
     if (!pa.page['api']) { 
       let pborrada = 1; 
       let div_entry ..= '-deleted';
      } 
    }
   if (!pborrada) { let puri = pa.uri; };

   <div class=(div_entry)>
    let un = pa.author.name;
 
    if (!Map.Contains(cache_avatars,un) && (par.avatar=='true')) {
          let avatar = wiki.getuser(un).homepage.files['avatar.jpg'].api ?? pa.author.gravatar;
          let cache_avatars ..= {(un): ("<img src='"..avatar.."' width='30px' valing='top' />") };
     }


    if (par.avatar=='true') {
       <div class='CambiosRecientes-entry-izq'>
        web.html(cache_avatars[un]);
       </div>
      }
    <div class=('CambiosRecientes-entry-der'..(par.avatar=='true'?'':'-nizq'))>
     web.link(pa.author.uri,pa.author.name);
     <span>" at "..date.format(date.changetimezone(pa.date,user.timezone),"dd/MM/yy - HH:mm")</span>
     //<span>" a "..date.parse{text: pa.date, format: "dd/MM/yy - HH:mm", timezone: '+01:00'}</span>
     // <span>" a "..date.format(date.addhours(pa.date,1),'dd/MM/yyyy - HH:mm')</span>

     <br />

     if( puri!=page.uri) 
        { 
         if (puri)  { <a href=(puri) red="internal">(name)</a> }
            else { <B>"Deleted page"..name</B> }
         }
       else { "On this document: "; }

     <span>(" "..edit_summary)</span><br />
     <span><font style="font-size: 9px; font-style: italic">(ppath)</font></span>

   </div>
  </div>
  <BR />
  }
 }

 if (!lastpage) { 
   <a href="#" id='CambiosRecientes_mas' next_number=(par.number+5)>"More..."</a> 
   <BR />
   <div id="cambiosrecientes_loading" style="display:none;margin:auto;width:16px;height:16px;background-repeat: no-repeat; background-image:url('/skins/common/icons/anim-wait-circle.gif');" />
  }

</div>

// global script code
<script type="text/jem">"
function CambiosRecientes_Control() {
    Deki.$('#CambiosRecientes_mas').bind('click', function() {
        $('#CambiosRecientes_mas').hide();
        $('#cambiosrecientes_loading').show();
        MindTouch.Deki.Reload(#reload_cr, { number: Deki.$(this).attr('next_number'), ajax_action: 'reload_cambiosrecientes' }, function() { CambiosRecientes_Control(); });
        return false;
    });
}

CambiosRecientes_Control();
"</script>

<style type="text/css">"
  #reload_cr { width: 100%; }
  #rdummy { width: 100%; border: 1px solid red; }
  div.CambiosRecientes-entry {
                width: 100%; 		
                overflow: auto;
		padding: 1px;
                /*border-top: 1px solid red;*/
 }
  div.CambiosRecientes-entry-deleted {
                width: 100%; 		
                overflow: auto;
		padding: 1px;
                border: 1px solid red;
 }

  div.CambiosRecientes-entry-izq { 
		width: 35px; 
		float: left;
 }
  div.CambiosRecientes-entry-der {
 		padding-left: 40px;
  }

  div.CambiosRecientes-entry-der-nizq {
 		padding-left: 0px;
  }

"</style>

</div> /** DIV: entry-content **/
</div> /** DIV: CambiosRecientes **/


} // -- if ((par.ajax_action=='load') || (par.ajax_action=='reload_cambiosrecientes'))..
Tag page
You must login to post a comment.

Copyright © 2011 MindTouch, Inc. Powered by