rejetto forum

Author Topic: Función Copiar  (Read 49013 times)

Offline LeoNeeson

  • Tireless poster
  • ****
  • Posts: 876
  • Status: On hiatus       (sporadically here)
    • View Profile
    • twitter.com/LeoNeeson
Re: Función Copiar
« on: May 28, 2016, 07:53:58 AM »
Muy bueno!, gracias, lo voy a probar este fin de semana.
Saludos....

EDITO: Lo probé apenas un poco y me pareció un trabajo muy bueno (no tuve tiempo de probar si funciona bien, pero el 'concepto' es bueno). :) Si funciona bien, posiblemente el código sea "candidato" a ser agregado en la próxima versión, si es que no tiene ningún error y a Rejetto le gusta. A continuación voy a comentar en inglés y postear los cambios que trae tu nueva plantilla, para que los demás la vean más fácilmente y digan que les parece.



"Copy" function by Tharless.

The user Tharless added the "copy" function to the default template. Mainly, these are the changes (marked in red):
Quote
[+special:strings]
option.copy=1

[box actions]
   {.if|{.and|{.!option.copy.}|{.can copy.}.}| <button id='copyBtn' onclick='copyClicked()'>{.!Copy.}</button> .}
   </fieldset>

[ajax.copy|no log]
{.check session.}
{.set|dst|{.force ansi|{.postvar|dst.}.}.}
{.break|if={.not|{.and|{.can move.}|{.get|can delete.}|{.get|can upload|path={.^dst.}.}/and.}.} |result={.!forbidden.}.}
{.set|log|{.!Copying items to.} {.^dst.}.}
{.for each|fn|{.replace|:|{.no pipe||.}|{.force ansi|{.postvar|files.}.}.}|{:
   {.break|if={.is file protected|var=fn.}|result=forbidden.}
    {.set|x|{.force ansi|%folder%.}{.^fn.}.}
    {.set|y|{.^dst.}/{.^fn.}.}
    {.if not |{.exists|{.^x.}.}|{.^x.}: {.!not found.}|{:
        {.if|{.exists|{.^y.}.}|{.^y.}: {.!already exists.}|{:
            {.if|{.length|{.copy|{.^x.}|{.^y.}.}.} |{:
                {.set|log|{.chr|13.}{.^fn.}|mode=append.}
                {.move|{.^x.}.md5|{.^y.}.md5.}
                {.move|{.^x.}.comment|{.^y.}.comment.}
            :} | {:
                {.set|log|{.chr|13.}{.^fn.} (failed)|mode=append.}
                {.maybe utf8|{.^fn.}.}: {.!not copied.}
            :}/if.}
        :}/if.}
    :}.}
    ;
:}.}
{.add to log|{.^log.}.}


[special:alias]
can copy=and|{.get|can upload.}

function copyClicked() {
    ezprompt("{.!Enter the destination folder.}", {type:'text'}, function(s){
        ajax('copy', {dst:s, files:selectedFilesAsStr()}, function(res){
            var a = res.split(";");
            if (a.length < 2)
                return alert($.trim(res));
            var failed = 0;
            var ok = 0;
            var msg = "";
            for (var i=0; i<a.length-1; i++) {
                var s = $.trim(a);
                if (!s.length) {
                    ok++;
                    continue;
                }
                failed++;
                msg += s+"\n";
            }
            if (failed)
                msg = "{.!We met the following problems:.}\n"+msg;
            msg = (ok ? ok+" {.!files were copied..}\n" : "{.!No file was copied..}\n")+msg;
            alert(msg);
            if (ok) location = location; // reload
        });
    });
}//copyClicked

I didn't have enough time to thoroughly test it, but it seems to be interesting (I haven't tested it yet). If this works well and Rejetto like it (and finds it useful), maybe this can be added as default in the next version. Anyone can test it, and report back if finds any error (or if has a better syntax).
« Last Edit: May 28, 2016, 09:40:40 AM by LeoNeeson »
• HFS in Spanish (HFS en Español) / How to compile HFS (Tutorial)
» My posts don't imply endorsement.
   Always build from source code!

Follow members gave a thank to your post:


Thank-o-Matic 3.0 By Adk Team