4c4 < Javascript Object Oriented Next Tutorial --- > Javascript Object Oriented Primer Tutorial 7c7 < var ok = 1; --- > var cur_book = 0; 10,197d9 < var tableObject; < var cur_book = 0; < var lastrow = ""; < var lrow = ""; < var lasttrow = ""; < < var TableSpreadsheet = { < init: function(name, collist, rowdata) { < this.name = name; < var tcol = collist.replace(/ /g,"_"); < this.precollist = tcol; < this.collist = []; < this.collist = tcol.split(","); < this.rowlist = []; < this.rlist = []; < this.rlist[0] = rowdata; < this.rowlist[0] = tcol; < this.selnumberoptions = ""; < this.selstringoptions = ""; < this.seloption = []; < this.sqlinfo = []; < this.sqltype = []; < var ijk; < for (ijk=0; ijk" + this.selnumberoptions + this.selstringoptions + ""; < var oxform = document.getElementById('xform'); < oxform.innerHTML = oxform.innerHTML + selc; < }, < getCList: function(rdata) { < var ij, clist="", pref="", thj; < var rest2 = rdata.replace(/<\/th>/g,"~"); < if (rdata.indexOf("&") !== -1) rest2 = rdata.replace(/<\/th>/g,"~"); < var xx, thi = rest2.split("~"); < if (thi.length > 1) { < for (ij=1; ij","").replace("</tr>","") != "") clist = clist + pref + thi[ij].replace("","").replace("","").replace("","").replace("","").replace("</th>","").replace("</tr>",""); < pref = ","; < } < } else { < var rest3 = rdata.replace(/<\/td>/g,"~"); < if (rdata.indexOf("&") != -1) rest3 = rdata.replace(/<\/td>/g,"~"); < thi = rest3.split("~"); < if (thi.length > 1) { < for (ij=1; ij") != -1) thj = thi[ij].split(">"); < if (thi[ij].indexOf(">") == -1) thj = thi[ij].split(";"); < clist = clist + pref + thj[thj.length - 1]; < pref = ","; < } < } < } < return clist; < }, < mincol: function(colnum) { < var one=0; < var ccolmin = '', ncolmin = 0, prefix = '', canbenumber = 1; < var ij, thiscollist = []; < if (this.rowlist.length >= 2) { < ccolmin = this.rowlist[1]; < if (this.rowlist.length >= 3) { < for (ij=1; ij= 2) { < ccolmax = this.rowlist[1]; < if (this.rowlist.length >= 3) { < for (ij=1; ij ccolmax) ccolmax = thiscollist[colnum - one]; < prefix = ", "; < try { < if (thiscollist[colnum - one] > ncolmax || ij == 1) ncolmax = thiscollist[colnum - one]; < } catch (eee) { < canbenumber = 0; < } < } < } < if (canbenumber == 1) return ncolmax; < } < return ccolmax; < }, < avgcol: function(colnum) { < var one=0; < var ccolavg = '', ncolavg = 0.0, prefix = '', canbenumber = 1, lr = ""; < var ij, ji=1, thiscollist = []; < for (ij=1; ijAverage " + this.collist[colnum - one].replace("_"," ") + ""; < this.seloption[colnum - one] = this.seloption[colnum - one] + ""; < this.selnumberoptions = this.selnumberoptions + this.seloption[colnum - one]; < this.selstringoptions = this.selstringoptions + ""; < this.selstringoptions = this.selstringoptions + ""; < this.seloption[colnum - one] = this.seloption[colnum - one] + ""; < this.seloption[colnum - one] = this.seloption[colnum - one] + ""; < } < } < } catch (eee) { < canbenumber = 0; < } < } < } < if (this.seloption[colnum - one] == " ") { < this.seloption[colnum - one] = ""; < this.selstringoptions = this.selstringoptions + ""; < this.selstringoptions = this.selstringoptions + ""; < this.seloption[colnum - one] = this.seloption[colnum - one] + ""; < this.seloption[colnum - one] = this.seloption[colnum - one] + ""; < } < if (canbenumber == 1) return ncolsum; < return ccolsum; < }, < addrow: function(rowdata) { < if (rowdata != lastrow) { < this.rlist[this.rlist.length] = rowdata; < this.rowlist[this.rowlist.length] = this.getCList(rowdata); < var ij, xx; < if (this.seloption[0] == "") { < for (ij=0; ij init: function(title, subtitle, total_pages, total_chapters, author, publishing_date, published, comments) { 202a15,16 > this.total_pages = total_pages; > this.total_chapters = total_chapters; 206,207d19 < this.total_pages = total_pages; < this.total_chapters = total_chapters; 209d20 < this.tablename = 'book_table'; 211,223c22 < getCList: function(rdata) { < var ij, clist="", pref=""; < var rest2 = rdata.replace(//g,"~"); < var thi = rest2.split("~"); < if (thi.length > 1) { < for (ij=1; ij","").replace("",""); < pref = ","; < } < } < return clist; < }, < showInfo: function(andmore, tObj) { --- > showInfo: function(andmore) { 225,230c24 < if (cur_book == 1 && andmore == "more") { < tObj.init(this.tablename, this.getCList(bookb.innerHTML), bookb.innerHTML); < } < var trow = "" + cur_book + "" + this.title + "" + this.subtitle + "" + this.author + "" + this.published + "" + this.publishing_date + "" + this.total_pages + "" + this.total_chapters + "" + this.comments + "" < tObj.addrow(trow); < if (bookb != null) bookb.innerHTML = bookb.innerHTML + trow; --- > bookb.innerHTML = bookb.innerHTML + "" + cur_book + "" + this.title + "" + this.subtitle + "" + this.author + "" + this.published + "" + this.publishing_date + "" + this.total_pages + "" + this.total_chapters + "" + this.comments + ""; 233a28,29 > total_pages: this.total_pages, > total_chapters: this.total_chapters, 237,238d32 < total_pages: this.total_pages, < total_chapters: this.total_chapters, 241,243c35 < var obbih = document.getElementById('bbih'); < if (obbih != null) obbih.value = bookb.innerHTML; < if (andmore == 'more') this.book_ask(tObj); --- > if (andmore == 'more') this.book_ask(); 251a44 > //alert(book_array[(whichone - 1)].title); 253,262c46 < book_set: function(inb, ldata, tableObj) { < if (lrow != ldata) { < cur_book = inb; < var cdata = ldata.split(","); < this.init(cdata[0], cdata[1], cdata[2], cdata[3], cdata[4], cdata[5], cdata[6], cdata[7]); < this.showInfo('nomore', tableObj); < lrow = ldata; < } < }, < book_ask: function(tObj) { --- > book_ask: function() { 275,297c59,60 < this.init(title, subtitle, author, published, publishing_date, total_pages, total_chapters, comments); < this.showInfo('more', tObj); < } else { < var formx = document.getElementById('xform'); < formx.style.display = 'block'; < } < }, < piecetogether: function(header, rest, myTs) { < var bookb = document.getElementById('book_body'); < this.init('','','','','','','',''); < if (bookb != null) { < bookb.innerHTML = header; < } < var obbih = document.getElementById('bbih'); < if (obbih != null) obbih.value = header; < myTs.init(myObject.tablename, myTs.getCList(header), header); < if (rest != "") { < var rest2 = rest.replace(/<\/tr>/g,"~"); < var ij, rows = rest2.split("~"); < for (ij=1; ij<=rows.length; ij++) { < myTs.rlist[this.rlist.length] = "<tr>" + rows[ij - 1]; < myTs.rowlist[this.rowlist.length] = this.getCList("<tr>" + rows[ij - 1]); < this.book_set(ij, myTs.getCList("<tr>" + rows[ij - 1]), this); --- > this.init(title, subtitle, total_pages, total_chapters, author, publishing_date, published, comments); > this.showInfo('more'); 299,309c62 < } < }, < pieceonerow: function(rest, myTs) { < var rest2 = rest.replace(/<\/tr>/g,"~"); < var ij, rows = rest2.split("~"); < for (ij=1; ij<=rows.length; ij++) { < myTs.rlist[myTs.rlist.length] = "<tr>" + rows[ij - 1]; < myTs.rowlist[myTs.rowlist.length] = myTs.getCList("<tr>" + rows[ij - 1]); < this.book_set(ij, myTs.getCList("<tr>" + rows[ij - 1]), myTs); < } < }, --- > } 311,321d63 < < < < myObject = Object.create(Book); < tableObject = Object.create(TableSpreadsheet); < < < function atstart() { < myObject.book_ask(tableObject); < } < 324c66 < --- > 326c68 <

Your Book List (more OOP) goes below ...

--- >

Your Book List (towards OOP) goes below ...

333d74 <