TiddlyWiki.org

Changeset 2713

Show
Ignore:
Timestamp:
24/10/07 11:18:39 (11 months ago)
Author:
JeremyRuston
Message:

Added ability to specify filename for getBackupPath (ticket #226)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Trunk/core/js/Saving.js

    r2135 r2713  
    127127function saveBackup(localPath,original) 
    128128{ 
    129         // Save the backup 
     129        //# Save the backup 
    130130        if(config.options.chkSaveBackups) { 
    131131                var backupPath = getBackupPath(localPath); 
     
    221221} 
    222222 
    223 function getBackupPath(localPath
    224 { 
    225         var backSlash = true
     223function getBackupPath(localPath,title,extension
     224{ 
     225        var slash = "\\"
    226226        var dirPathPos = localPath.lastIndexOf("\\"); 
    227227        if(dirPathPos == -1) { 
    228228                dirPathPos = localPath.lastIndexOf("/"); 
    229                 backSlash = false
     229                slash = "/"
    230230        } 
    231231        var backupFolder = config.options.txtBackupFolder; 
    232232        if(!backupFolder || backupFolder == "") 
    233233                backupFolder = "."; 
    234         var backupPath = localPath.substr(0,dirPathPos) + (backSlash ? "\\" : "/") + backupFolder + localPath.substr(dirPathPos); 
    235         backupPath = backupPath.substr(0,backupPath.lastIndexOf(".")) + "." + (new Date()).convertToYYYYMMDDHHMMSSMMM() + ".html"; 
     234        var backupPath = localPath.substr(0,dirPathPos) + slash + backupFolder + localPath.substr(dirPathPos); 
     235        backupPath = backupPath.substr(0,backupPath.lastIndexOf(".")) + "."; 
     236        //# replace illegal filename characters(// \/:*?"<>|) and space with underscore  
     237        if(title) 
     238                backupPath += title.replace(/[\\\/\*\?\":<> ]/g,"_") + "."; 
     239        backupPath += (new Date()).convertToYYYYMMDDHHMMSSMMM() + "." + (extension ? extension : "html"); 
    236240        return backupPath; 
    237241}