Index: empty.html =================================================================== --- empty.html (revision 766) +++ empty.html (revision 767) @@ -46,6 +46,7 @@ // --------------------------------------------------------------------------------- // Default options +var saveUsingTiddlyWikiSaver = false; var options = {}; options.chkRegExp = false; options.chkCaseSens = false; @@ -1345,7 +1346,12 @@ // Create backup filename // DISABLED DATESTAMPED BACKUPS | Nathan Edit // var backupPath = localPath.substr(0,localPath.lastIndexOf(".")) + "." + ConvertToYYYYMMDDHHMMSSMMM(new Date()) + ".html"; var backupPath = localPath.substr(0,localPath.lastIndexOf(".")) + "_" + "backup" + ".html"; // NON-DATE STAMPED BACKUPS | Nathan Edit // - var original = loadFile(localPath); + var original; + if (saveUsingTiddlyWikiSaver) { + original = safariLoadFile(originalPath); + } else { + original = loadFile(localPath); + } if(original == null) { alert("It's not possible to save changes using this browser. Use FireFox if you can"); @@ -1360,9 +1366,17 @@ alert("Doesn't appear to be a TiddlyWiki"); else { - backup = saveFile(backupPath,original); //COMMENT THIS LINE OUT TO DISABLE ALL BACKUPS | Nathan Edit // - var revised = original.substr(0,posOpeningDiv + startSaveArea.length) + convertUnicodeToUTF8(allTiddlersAsHtml()) + original.substr(posClosingDiv); - var save = saveFile(localPath,revised) + var save; + if (saveUsingTiddlyWikiSaver) { + // We don't need to convert to UTF8 since the plugin + // works with unicode strings natively + var revised = original.substr(0,posOpeningDiv + startSaveArea.length) + allTiddlersAsHtml() + original.substr(posClosingDiv); + save = safariSaveFile(originalPath,revised); + } else { + backup = saveFile(backupPath,original); //COMMENT THIS LINE OUT TO DISABLE ALL BACKUPS | Nathan Edit // + var revised = original.substr(0,posOpeningDiv + startSaveArea.length) + convertUnicodeToUTF8(allTiddlersAsHtml()) + original.substr(posClosingDiv); + save = saveFile(localPath,revised) + } if(save) { // alert("Saved successfully as '" + localPath + "'"); // Disabled save success alert | Nathan Edit // @@ -1551,6 +1565,52 @@ return(null); } +function safariLoadFile(url) +{ + var plugin = document.embeds["tiddlyWikiSafariSaver"]; + return plugin.readURL(url); +} + +function safariSaveFile(url,content) +{ + var plugin = document.embeds["tiddlyWikiSafariSaver"]; + return plugin.writeStringToURL(content,url); +} + +// Lifted from http://developer.apple.com/internet/webcontent/detectplugins.html +function detectPlugin() { + // allow for multiple checks in a single pass + var daPlugins = detectPlugin.arguments; + // consider pluginFound to be false until proven true + var pluginFound = false; + // if plugins array is there and not fake + if (navigator.plugins && navigator.plugins.length > 0) { + var pluginsArrayLength = navigator.plugins.length; + // for each plugin... + for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) { + // loop through all desired names and check each against the current plugin name + var numFound = 0; + for(namesCounter=0; namesCounter < daPlugins.length; namesCounter++) { + // if desired plugin name is found in either plugin name or description + if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) || + (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) { + // this name was found + numFound++; + } + } + // now that we have checked all the required names against this one plugin, + // if the number we found matches the total number provided then we were successful + if(numFound == daPlugins.length) { + pluginFound = true; + // if we've found the plugin, we can stop looking through at the rest of the plugins + break; + } + } + } + return pluginFound; +} // detectPlugin + + // --------------------------------------------------------------------------------- // Event handlers // --------------------------------------------------------------------------------- @@ -1663,8 +1723,10 @@ function onClickToolbarDelete(e) { hideMessage(); - if(this.parentNode.id) + if(this.parentNode.id) { deleteTiddler(this.parentNode.id.substr(7)); + saveChanges(); + } } // Event handler for clicking on the toolbar backlink @@ -1675,7 +1737,7 @@ searchTiddlers(this.parentNode.id.substr(7),true,false); } -// Event handler for clicking on toolbar close +// Event handler for clicking on toolbar edit function onClickToolbarEdit(e) { hideMessage(); @@ -1686,12 +1748,13 @@ // Event handler for clicking on toolbar save function onClickToolbarSave(e) { - if(this.parentNode.id) + if(this.parentNode.id) { saveTiddler(this.parentNode.id.substr(7)); saveChanges(); // Added save all on edit finish. Suggested by members at http://tinyurl.com/89qhc | Nathan Edit + } } -// Event handler for clicking on toolbar save +// Event handler for clicking on toolbar undo function onClickToolbarUndo(e) { if(this.parentNode.id) @@ -2684,6 +2747,12 @@ +