text: var vm;$(function(){$("#search").change(function(){$("#bookmarks").empty();loadVue();dumpBookmarks($("#search").val())});$("#lmfw").on("click","i",function(){if($(this).attr("data-url")){chrome.tabs.create({url:$(this).attr("data-url")})}});$("#lmfw").on("click",".pencil",function(){$("#bookmark_id").val($(this).attr("data-id"));$("#bookmark_title").val($(this).attr("data-title"));if($(this).attr("data-link")){$("#bookmark_link").val($(this).attr("data-link"))}else{$("#bookmark_link").hide()}$(".ui.modal").modal("show")});$(".modal").on("click",".positive",function(){chrome.bookmarks.update($("#bookmark_id").val(),{title:$("#bookmark_title").val(),url:$("#bookmark_link").val()});$(".ui.modal").modal("hide");location.reload()});$("#lmfw").on("click",".details",function(){if($(this).attr("data-url")){chrome.tabs.create({url:$(this).attr("data-url")})}})});var TreeNodesList=[];var isCreating=true;function dumpBookmarks(b){var a=chrome.bookmarks.getTree(function(c){TreeNodesList=dumpTreeNodes(c,b);if(isCreating){loadVue();isCreating=false}hide_child(TreeNodesList[0])});return TreeNodesList[0]}function hide_child(b){b.visible=false;for(var a=0;a<b.children.length;a++){if((typeof b.children[a]["children"]!="undefined")&&(b.children[a]["children"].length>0)){hide_child(b.children[a])}if(b.children[a]["visible"]){b.visible=true}}return true}function dumpTreeNodes(c,e){var d=[];var b;var a;for(b=0;b<c.length;b++){a=dumpNode(c[b],e);if(a){d.push(a)}}return d}var top=[];function dumpNode(c,d){if(!c.title){if(c.url){c.title=c.url}}if(!c.url){c.url=false}var a=[];if(c.url){var b=String(c.url).split("/");b=b[0]+"//"+b[2]}if(c.children&&c.children.length>0){a={id:c.id,name:c.title,link:c.url,favicon:b,visible:true,children:dumpTreeNodes(c.children,d)}}else{if((d)&&((String(c.title).indexOf(d)==-1)&&(String(c.url).indexOf(d)==-1))){a={id:c.id,name:c.title,link:c.url,favicon:b,children:[],visible:false}}else{a={id:c.id,name:c.title,link:c.url,favicon:b,children:[],visible:true}}}return a}function createChild(a){chrome.bookmarks.create({parentId:a,title:"new stuff",url:"http://new-link.com"},function(b){var c=b.id;return c});location.reload()}document.addEventListener("DOMContentLoaded",function(){dumpBookmarks()});function loadVue(){Vue.component("item",{template:"#item-template",props:{model:Object,treeData:Object},data:function(){return{open:false}},computed:{isFolder:function(){if(!this.model.link){return 1}else{return this.model.children&&this.model.children.length}},isVisible:function(){return(this.model.visible)},isOpen:function(){if(this.isFolder){if(this.open){return false}else{return true}}return false}},methods:{toggle:function(){if(this.isFolder){this.open=!this.open}},gotActiveChild:function(){visible=false;if((this.model.children.length>1)){visible=true}return visible},CreateNewChild:function(){return createChild(this.model.id)},addChild:function(){this.newId=createChild(this.model.id);this.$nextTick(function(){this.model.children.push({id:this.newId,name:"new stuff",link:"http://new-link.com",visible:true})})},removeChild:function(){if(this.isFolder){chrome.bookmarks.removeTree(this.model.id)}else{chrome.bookmarks.remove(this.model.id)}this.model=null}}});vm=new Vue({el:"#lmfw",data:{treeData:TreeNodesList[0]},methods:{reload:function(){this.treeData=dumpBookmarks($("#search").val())}}})};