/**
 * Use gjslint lib/*.js to check coding rules
 * Use fixjsstyle lib/*.js to fix coding rules
 *
 */

 /**
  * Constant
  */
var DEBUG = 1;

/**
 * @private
 * @constructor
 */
function Sosimplist() {
    /** @private */
    this.viewId_ = 'body';
    this.mapOfList_ = {};

}

/** @private */
Sosimplist.prototype.buildView_ = function() {
    try {
        document.getElementById(this.viewId_).innerHTML = '';
        for (var listId in this.mapOfList_) {
//             window.location.pathname += '?'+this.mapOfList_[listId].serialize();
//             document.getElementById(this.viewId_).innerHTML += this.mapOfList_[listId].serialize();
            document.getElementById(this.viewId_).innerHTML += this.mapOfList_[listId].getView();
        }

        document.getElementById(this.viewId_).innerHTML += "<button onclick='sosimplist.addList()'>Add list</button>";
    }
    catch (e) {
        console.error(e.name + ': ' + e.message);
    }
};

/**
 * @public
 * @param {string} viewId
 */
Sosimplist.prototype.setViewId = function(viewId) {
    this.viewId_ = viewId;
    this.buildView_();
};

/**
 * @public
 */
Sosimplist.prototype.addList = function() {
    var myList = new List();
    this.mapOfList_[myList.getListId()] = myList;
    this.buildView_();
};

/**
 * @public
 * @param {string} listId
 */
Sosimplist.prototype.addItem = function(listId) {
    try {
        this.mapOfList_[listId].addItem();
    }
    catch (e) {
        console.error(e.name + ': ' + e.message);
    }
    this.buildView_();
};

/**
 * @private
 * @return {Object}
 */
function Sosimplist_create() {
    return new Sosimplist();
}

var sosimplist = Sosimplist_create();




@@ -241,12 +241,8 @@
  = '
-body
 ';%0A 
@@ -266,16 +266,167 @@
 _ = %7B%7D;%0A
+    %0A    //load data from URI%0A    var hrefArray = window.location.href.split('#');%0A    if(hrefArray%5B1%5D) %7B%0A        this.unserialize(hrefArray%5B1%5D);%0A    %7D
 %0A%7D%0A%0A/** 
@@ -601,20 +601,16 @@
 List_) %7B
-%0A// 
         
@@ -617,40 +617,72 @@
     
-window.location.pathname += '?'+
+%0A            document.getElementById(this.viewId_).innerHTML += 
 this
@@ -705,28 +705,30 @@
 Id%5D.
-serialize
+getView
 ();%0A
-//
+   
      
+%7D%0A%0A
     
@@ -782,39 +782,161 @@
 HTML += 
-this.mapOfList_%5BlistId%5D
+%22%3Cbutton onclick='sosimplist.addList()'%3EAdd list%3C/button%3E%22;%0A        %0A        window.location.href = window.location.href.split('#')%5B0%5D + '#'+this
 .seriali
@@ -949,65 +949,376 @@
     
+%7D%0A
     
-    document.getElementById(this.viewId_).innerHTML +
+catch (e) %7B%0A        console.error(e.name + ': ' + e.message);%0A    %7D%0A%7D;%0A%0A/**%0A * @public%0A * @return %7Bstring%7D return content serialize in a base64 string %0A */%0ASosimplist.prototype.serialize = function() %7B%0A    var content = %7B%0A        viewId_ : this.viewId_,%0A        mapOfList_ : %7B%7D%0A    %7D;%0A    for (var listId in this.mapOfList_) %7B%0A        content.mapOfList_%5BlistId%5D 
 = th
@@ -1343,231 +1343,509 @@
 Id%5D.
-getView();%0A    
+serialize();%0A
     %7D%0A
+    
 %0A    
-    document.getElementById(this.viewId_).innerHTML += %22%3Cbutton onclick='sosimplist.addList()'%3EAdd list%3C/button%3E%22;%0A    %7D%0A    catch (e) %7B%0A        console.error(e.name + ': ' + e.message)
+return btoa(JSON.stringify(content));%0A%7D;%0A%0A/**%0A * @public%0A * @param %7Bstring%7D str content serialized in a base64 string to decode%0A */%0ASosimplist.prototype.unserialize = function(str) %7B%0A    var content = JSON.parse(atob(str));%0A    this.viewId_ = content.viewId_;%0A    this.mapOfList_ = %7B%7D%0A    for (var listId in content.mapOfList_) %7B%0A        var myList = new List();%0A        myList.unserialize(content.mapOfList_%5BlistId%5D);%0A        this.mapOfList_%5BlistId%5D = myList
 ;%0A    %7D
+;
 %0A%7D;%0A%0A
+%0A
 /**%0A

Improve serialize/unserialize