summaryrefslogtreecommitdiff
path: root/my-foxmarks.js
diff options
context:
space:
mode:
Diffstat (limited to 'my-foxmarks.js')
-rw-r--r--my-foxmarks.js65
1 files changed, 65 insertions, 0 deletions
diff --git a/my-foxmarks.js b/my-foxmarks.js
new file mode 100644
index 0000000..1b085bd
--- /dev/null
+++ b/my-foxmarks.js
@@ -0,0 +1,65 @@
+function setup_foxmarks() {
+ $.getJSON("bookmarks.json",
+ create_html_display
+ );
+};
+
+var default_icon={'src':'folder-item.png'};
+
+var templates={
+ "separator": function() {
+ return [
+ 'li',{},['hr',{}]
+ ];
+ },
+ "folder" : function() {
+ if (this.args.pnid!=null) {
+ return [
+ 'li',{"class":"folder"},[
+ 'p',{"class":"folder-name"},this.args.name,
+ 'ul',{ "id":this.nid, "class":"folder" },''
+ ]
+ ];
+ }
+ else {
+ return [
+ 'h1',{},this.args.name,
+ 'ul',{ "id":this.nid },''
+ ];
+ }
+ },
+ "bookmark" : function() {
+ return [
+ 'li',{},[
+ 'img',(this.args.icon ? {"src": this.args.icon} : default_icon),[],
+ 'a',{"href":this.args.url},this.args.name
+ ]
+ ];
+ }
+};
+
+function create_html_display(marks) {
+ jQuery.each(marks["commands"],function() {
+ if (this.action == "insert" && this.nid != undefined) {
+ if (templates.hasOwnProperty(this.args.ntype)) {
+ var parent;
+ if (this.args.pnid!=null) {
+ parent=$("#"+this.args.pnid);
+ }
+ else {
+ parent=$("body");
+ }
+ //console.debug("applying template for %s to %o on %o",this.args.ntype,this,parent);
+ parent.tplAppend(this,templates[this.args.ntype]);
+ }
+ }
+ });
+ $('li.folder').children('p,ul').andSelf().addClass('collapsed');
+ $('li.folder').click(function(event){
+ event.preventDefault();
+ event.stopPropagation();
+ $(this).children('p,ul').andSelf().toggleClass('collapsed');
+ });
+};
+
+$(document).ready(setup_foxmarks);