Template:MakeMoveLinks

<%
function tree(kuma, page, path, depth, self) {
        var pages = page.subpages(path, depth, self);
        var numPages = 0;
        
        var html = process_array(kuma, pages);
        
        html = "<p><strong>" + numPages + " pages</strong></p>" + html;
         
        return html;
 
        function chunkify(t) {
            var tz = [], x = 0, y = -1, n = 0, i, j;
 
            while (i = (j = t.charAt(x++)).charCodeAt(0)) {
                var m = (i == 46 || (i >=48 && i <= 57));
                if (m !== n) {
                    tz[++y] = "";
                    n = m;
                }
                tz[y] += j;
            }
            return tz;
        }
 
        function alphanumForward(a, b) {
 
            var aa = chunkify(a.title);
            var bb = chunkify(b.title);
 
            for (x = 0; aa[x] && bb[x]; x++) {
                if (aa[x] !== bb[x]) {
                    var c = Number(aa[x]), d = Number(bb[x]);
                    if (c == aa[x] && d == bb[x]) {
                        return c - d;
                    } else return (aa[x] > bb[x]) ? 1 : -1;
                }
            }
            return aa.length - bb.length;
        }
 
        function process_array(kuma, arr) {
            var result = '';
            if(arr.length) {
                result += '<ul>';
                arr.forEach(function(item) {
                    numPages++;
                    if (!item) { return; }
                    result += '<li><a href="' + item.url + '">' + kuma.htmlEscape(item.title) + '</a>' +
                              '<a href="' + item.url + '$move"> [MOVE]</a>' + 
                              process_array(kuma, item.subpages || []) + '</li>';
                     
                });
                result += '</ul>';
            }
            return result;
        }   
    }

var html = tree(kuma, page, $0, 8, 0);
%>
<%-html%>
Search for pages that use Template:MakeMoveLinks to see example use cases and how many pages use this macro.

Document Tags and Contributors

Contributors to this page: Sheppy, lmorchard
Last updated by: Sheppy,