- From: Shane McCarron via cvs-syncmail <cvsmail@w3.org>
- Date: Mon, 22 Feb 2010 23:15:39 +0000
- To: public-dap-commits@w3.org
Update of /sources/public/2009/dap/ReSpec.js/js In directory hutz:/tmp/cvs-serv30928/js Modified Files: respec.js Log Message: Added subtitle parameter for spec subtitle support Changed title handling so it emits an id and class of title Added copyrightStart parameter for copyright range support Added support for data-include and data-oninclude Index: respec.js =================================================================== RCS file: /sources/public/2009/dap/ReSpec.js/js/respec.js,v retrieving revision 1.89 retrieving revision 1.90 diff -u -d -r1.89 -r1.90 --- respec.js 19 Feb 2010 20:28:48 -0000 1.89 +++ respec.js 22 Feb 2010 23:15:36 -0000 1.90 @@ -161,6 +161,10 @@ } this.makeTemplate(); + // This is done early so that if other data gets embedded it will be + // processed + this.includeFiles(); + this.dfn(); this.inlines(); @@ -325,7 +329,31 @@ } this._insertCSS(css, false); }, - + + includeFiles: function() { + var divs = document.querySelectorAll("[data-include]"); + for (var i = 0; i < divs.length; i++) { + var div = divs[i]; + var URI = div.getAttribute('data-include'); + var content = this._readFile(URI) ; + var flist = div.getAttribute('data-oninclude'); + if (flist) { + var methods = flist.split(/\s+/) ; + for (var j = 0; j < methods.length; j++) { + var call = 'content = ' + methods[j] + '(this,content)' ; + try { + eval(call) ; + } catch (e) { + warning('call to ' + call + ' failed with ' + e) ; + } + } + } + if (content) { + div.innerHTML = content ; + } + } + }, + // single function used to display people information for editors, // authors, etc (fjh 2009-12-04) @@ -394,7 +422,11 @@ if (this.specStatus == 'XGR') header += "<a href='http://www.w3.org/2005/Incubator/XGR/'><img alt='W3C Incubator Report' src='http://www.w3.org/2005/Incubator/images/XGR' height='48' width='160'/></a>"; header += - "<h1>" + this.title + "</h1>" + + "<h1 class='title' id='title'>" + this.title + "</h1>" ; + if (this.subtitle) { + header += "<h2 id='subtitle'>" + this.subtitle + "</h2>" ; + } + header += "<h2>" + (this.specStatus == "unofficial" ? "" : "W3C ") + this.status2text[this.specStatus] + " " + this._humanDate(this.publishDate) + "</h2><dl>"; if (!this.isNoTrack) @@ -425,8 +457,11 @@ } else { header += - "<a href='http://www.w3.org/Consortium/Legal/ipr-notice#Copyright'>Copyright</a> © " + - this.publishDate.getFullYear(); + "<a href='http://www.w3.org/Consortium/Legal/ipr-notice#Copyright'>Copyright</a> © " ; + if (this.copyrightStart) { + header += this.copyrightStart + '-'; + } + header += this.publishDate.getFullYear(); if (this.additionalCopyrightHolders) header += " " + this.additionalCopyrightHolders + " &"; header += " <a href='http://www.w3.org/'><acronym title='World Wide Web Consortium'>W3C</acronym></a><sup>®</sup> " + "(<a href='http://www.csail.mit.edu/'><acronym title='Massachusetts Institute of Technology'>MIT</acronym></a>, " + @@ -900,6 +935,22 @@ }, document.documentElement.firstElementChild); } }, + + _readFile: function (URI) { + try { + var xhr = new XMLHttpRequest(); + xhr.open("GET", URI, false); + xhr.send(null); + if (xhr.status == 200) { + return xhr.responseText ; + } else { + error("There appears to have been a problem fetching the file " + URI + "; status=" + xhr.status); + } + } + catch (e) { + warning("There was an error with the request to load " + URI + ", probably that you're working from disk."); + } + }, _humanMonths: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
Received on Monday, 22 February 2010 23:15:40 UTC