welcome: please sign in
location: Diff for "zzo38"
Differences between revisions 4 and 5
Revision 4 as of 2008-12-18 00:21:23
Size: 11216
Editor: zzo38
Comment:
Revision 5 as of 2013-11-08 17:05:34
Size: 0
Editor: retroj
Comment: deleting personal pages
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
##master-page:HomepageTemplate
#format wiki
#language en
== zzo38 ==

Find vonkeror at: http://zzo38computer.cjb.net/vonkeror/

If you like some of the codes in vonkeror then you can merge it into conkeror as well.

Here is some of the codes in this wiki page, in case you don't want to download and unzip it:

=== Bookmark management ===

{{{
/*
 Part of Vonkeror
 License by GNU GPL v3 or later version
*/

require("special-buffer.js");
require("interactive.js");

interactive("bookmark-management","Bookmark Management",function(I){
    create_buffer(I.buffer.window, buffer_creator(bookmark_management_buffer,
         $configuration = I.buffer.configuration), I.browse_target("bookmark-management"));
});
default_browse_targets["bookmark-management"] = "find-url-new-buffer";

function bookmark_management_buffer(window, element) {
    this.constructor_begin();
    keywords(arguments);
    special_buffer.call(this, window, element, forward_keywords(arguments));
    this.constructor_end();
}

bookmark_management_buffer.prototype = {

    get keymap() {
        return bookmark_management_keymap;
    },

    title : "Bookmark management",

    description : "*bookmark-management*",

    generate : function () {
        var d = this.document.open("text/html","replace");
        var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].getService(Ci.nsINavBookmarksService);
        var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
        var ht="<HTML><i>ROOT FOLDER</i> <b>["+bmsvc.unfiledBookmarksFolder+"]</b><ol start=0>";
        ht+=this.htmlforfolder(bmsvc,ios,bmsvc.unfiledBookmarksFolder)+"</ol>";
        d.write(ht);
        d.close();
    },

    htmlforfolder : function (bmsvc,ios,fldr) {
        var ht="";
        var i;
        var id;
        try {
            for(i=0;;i++) {
                id=bmsvc.getIdForItemAt(fldr,i);
                ht+="<li>";
                if(bmsvc.getItemType(id)==1) { //normal bookmark
                    ht+=bmsvc.getItemTitle(id);
                } else if(bmsvc.getItemType(id)==2) { //folder
                    ht+="<i>"+bmsvc.getItemTitle(id)+"</i>";
                } else { //others
                    ht+="<s>"+bmsvc.getItemTitle(id)+"</s>";
                }
                ht+=" <b>["+id+"]</b>";
                if(bmsvc.getItemType(id)==2) ht+="<ol start=0>"+this.htmlforfolder(bmsvc,ios,id)+"</ol>";
            }
        } finally {
            return ht;
        }
    },

    __proto__: special_buffer.prototype
};

interactive("bookmark-management-add","Bookmark Management (add)",function(I){
    var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].getService(Ci.nsINavBookmarksService);
    var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
    var p=parseInt(yield I.minibuffer.read($prompt="parent?",$initial_value=bmsvc.unfiledBookmarksFolder));
    var o=parseInt(yield I.minibuffer.read($prompt="order?",$initial_value=-1));
    var n=yield I.minibuffer.read($prompt="name?");
    if(n=="") return;
    var u=yield I.minibuffer.read($prompt="uri?");
    if(u=="") return;
    bmsvc.insertBookmark(p,ios.newURI(u,null,null),o,n);
    I.buffer.generate();
});

interactive("bookmark-management-delete","Bookmark Management (delete)",function(I){
    var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].getService(Ci.nsINavBookmarksService);
    var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
    var id=parseInt(yield I.minibuffer.read($prompt="id?"));
    if(bmsvc.getItemType(id)==2) bmsvc.removeFolder(id);
    else bmsvc.removeItem(id);
    I.buffer.generate();
});

interactive("bookmark-management-name","Bookmark Management (name)",function(I){
    var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].getService(Ci.nsINavBookmarksService);
    var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
    var id=parseInt(yield I.minibuffer.read($prompt="id?"));
    var n=yield I.minibuffer.read($prompt="name?",$initial_value=bmsvc.getItemTitle(id));
    bmsvc.setItemTitle(id,n);
    I.buffer.generate();
});

interactive("bookmark-management-uri","Bookmark Management (uri)",function(I){
    var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].getService(Ci.nsINavBookmarksService);
    var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
    var id=parseInt(yield I.minibuffer.read($prompt="id?"));
    var u=yield I.minibuffer.read($prompt="uri?",$initial_value=bmsvc.getBookmarkURI(id).spec);
    bmsvc.changeBookmarkURI(id,ios.newURI(u,null,null));
    I.buffer.generate();
});

interactive("bookmark-management-move","Bookmark Management (move)",function(I){
    var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].getService(Ci.nsINavBookmarksService);
    var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
    var id=parseInt(yield I.minibuffer.read($prompt="id?"));
    var p=parseInt(yield I.minibuffer.read($prompt="parent?",$initial_value=bmsvc.getFolderIdForItem(id)));
    var o=parseInt(yield I.minibuffer.read($prompt="order?",$initial_value=-1));
    bmsvc.moveItem(id,p,o);
    I.buffer.generate();
});

interactive("bookmark-management-addfolder","Bookmark Management (addfolder)",function(I){
    var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].getService(Ci.nsINavBookmarksService);
    var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
    var p=parseInt(yield I.minibuffer.read($prompt="parent?",$initial_value=bmsvc.unfiledBookmarksFolder));
    var o=parseInt(yield I.minibuffer.read($prompt="order?",$initial_value=-1));
    var n=yield I.minibuffer.read($prompt="name?");
    if(n=="") return;
    bmsvc.createFolder(p,n,o);
    I.buffer.generate();
});

interactive("bookmark-management-keyword","Bookmark Management (keyword)",function(I){
    var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].getService(Ci.nsINavBookmarksService);
    var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
    var id=parseInt(yield I.minibuffer.read($prompt="id?"));
    var k=yield I.minibuffer.read($prompt="keyword?",$initial_value=bmsvc.getKeywordForBookmark(id));
    bmsvc.setKeywordForBookmark(id,"");
    bmsvc.setKeywordForBookmark(id,k);
    I.buffer.generate();
});

interactive("bookmark-management-goto","Bookmark Management (goto)",function(I){
    var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].getService(Ci.nsINavBookmarksService);
    var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
    var id=parseInt(yield I.minibuffer.read($prompt="id?"));
    var b=I.buffer;
    open_in_browser(b,I.browse_target("find-url-new-buffer"),bmsvc.getBookmarkURI(id).spec);
    kill_buffer(b,false);
});
default_browse_targets["bookmark-management-goto"] = "find-url-new-buffer";
}}}


=== Printing ===
{{{
/*
 Part of Vonkeror
 License by GNU GPL v3 or later version
*/

require("special-buffer.js");
require("interactive.js");

define_keywords("$printwindow");

interactive("print-preview","Print preview",function(I) {
    var pss=Cc["@mozilla.org/gfx/printsettings-service;1"].getService(Ci.nsIPrintSettingsService);
    var ps=pss.globalPrintSettings;
    var p=I.buffer.top_frame.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebBrowserPrint);
    if(!p.doingPrintPreview) {
        if(!ps.printerName) ps.printerName=pss.defaultPrinterName;
        pss.initPrintSettingsFromPrinter(ps.printerName,ps); // load setting of printer
        pss.initPrintSettingsFromPrefs(ps,true,-1); // load any saved settings (if any)
        I.buffer.doing_printpreview=I.minibuffer.element;
        I.minibuffer.element.collapsed=true; // to fix the bug
        p.printPreview(ps,null,I.buffer);
        printpreview_input_mode(I.buffer,true);
        I.minibuffer.message("Enter print preview");
    } else {
        I.buffer.doing_printpreview=null;
        I.minibuffer.element.collapsed=false;
        p.exitPrintPreview();
        normal_input_mode(I.buffer,true);
        I.minibuffer.message("Exit print preview");
    }
});

interactive("print-preview-goto-pagenum","Print preview goto page number",function(I) {
    var p=I.buffer.top_frame.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebBrowserPrint);
    p.printPreviewNavigate(0,parseInt(yield I.minibuffer.read($prompt="Page?")));
});

interactive("print-preview-count-pages","Print preview count pages",function(I) {
    var p=I.buffer.top_frame.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebBrowserPrint);
    I.minibuffer.message(p.printPreviewNumPages);
});

interactive("print-current-file","Print the current file",function(I) {
    var p=I.buffer.top_frame.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebBrowserPrint);
    var ps=p.currentPrintSettings;
    try {
        p.print(ps,null);
        I.minibuffer.message("printing OK");
    } catch(e) {
        stored_last_error=e;
        I.minibuffer.message("failed to print");
    }
});

interactive("print-setup","Page setup",function(I) {
    var pss=Cc["@mozilla.org/gfx/printsettings-service;1"].getService(Ci.nsIPrintSettingsService);
    var p=I.buffer.top_frame.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebBrowserPrint);
    var ps=p.currentPrintSettings;
    var pp=Cc["@mozilla.org/embedcomp/printingprompt-service;1"].getService(Ci.nsIPrintingPromptService);
    pp.showPageSetup(I.window,ps,null);
    pss.savePrintSettingsToPrefs(ps,false,ps.kInitSaveNativeData);
    if(p.doingPrintPreview) {
        p.exitPrintPreview();
        I.minibuffer.element.collapsed=true; // to fix the bug
        p.printPreview(ps,null,I.buffer);
    }
});
}}}
(Note: To use this print-preview codes you have to program the buffer's progress observer to uncollapse the minibuffer. The print-preview will initially collapse the minibuffer in order to resize the content area. When the progress observer uncollapse the minibuffer it will resize it again, causing the print preview area to resize correctly. A bug in Mozilla makes the print preview area the wrong size initially unless it is resized after it appears on the screen)

=== New license for Vonkeror ===
I have updated the license for Vonkeror to the following, so that the codes can be merged with Conkeror if you want to:

Most of the new files added to Vonkeror are now licensed by GNU GPL v3 or
later version (it is permitted because the LGPL v2.1 permits it). I am
making a exception: Anyone who is making Conkeror software may relicense
under the Conkeror license, in order to be added into Conkeror. Anyone
can remove this exception from your own copy of the codes if they want
to, but it is not required to remove this exception. However, this
exception only grants additional permission to the workers of Conkeror.

----
CategoryHomepage