Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Class = (function () {
- function createClass(properties) {
- var f = function () {
- this.init.apply(this, arguments);
- }
- for (var prop in properties) {
- f.prototype[prop] = properties[prop];
- }
- if (!f.prototype.init) {
- f.prototype.init = function () { }
- }
- return f;
- }
- Function.prototype.inherit = function (parent) {
- var oldPrototype = this.prototype;
- var prototype = new parent();
- this.prototype = Object.create(prototype);
- this.prototype._super = prototype;
- for (var prop in oldPrototype) {
- this.prototype[prop] = oldPrototype[prop];
- }
- }
- return {
- create: createClass,
- };
- }());
- var FSB = (function () {
- var data = [];
- function add(folder) {
- console.log(folder.urls);
- data.push(folder.urls);
- }
- function render() {
- var node = document.getElementById("cont");
- var documentFragmen = document.createDocumentFragment();
- for (folder in data) {
- var ul = document.createElement("ul");
- for (url in data[folder]) {
- var li = document.createElement("li");
- var a = document.createElement("a");
- a.setAttribute("href", data[folder][url].url);
- a.setAttribute("target", "_blank");
- a.innerHTML = data[folder][url].title;
- li.appendChild(a);
- ul.appendChild(li);
- }
- documentFragmen.appendChild(ul);
- }
- node.appendChild(documentFragmen);
- }
- return {
- add: add,
- render: render
- };
- }());
- var Url = Class.create({
- init: function (title, url) {
- this.title = title;
- this.url = url;
- }
- });
- var Folder = Class.create({
- init: function (title, urls) {
- this.title = title;
- this.urls = urls;
- }
- });
- var url1 = new Url("yahoo", "http://www.yahoo.com");
- var url2 = new Url("dir-bg", "http://www.dir.bg/");
- var urlArray = [url1, url2];
- var links1 = new Folder("links", urlArray);
- var url3 = new Url("abv", "http://www.abv.bg");
- var url4 = new Url("hotmail", "http://www.hotmail.com/");
- var urlArray2 = [url3, url4];
- var links2 = new Folder("links", urlArray2);
- //console.log(links);
- FSB.add(links1);
- FSB.add(links2);
- FSB.render();
Advertisement
Add Comment
Please, Sign In to add comment