{"id":26,"date":"2009-11-13T12:00:54","date_gmt":"2009-11-13T20:00:54","guid":{"rendered":"https:\/\/blogs.ubc.ca\/henrylo\/?p=26"},"modified":"2009-11-13T15:43:22","modified_gmt":"2009-11-13T23:43:22","slug":"customize-vista-edit","status":"publish","type":"post","link":"https:\/\/blogs.ubc.ca\/henrylo\/2009\/11\/13\/customize-vista-edit\/","title":{"rendered":"Customize Vista Edit"},"content":{"rendered":"<p style=\"text-align: right;\"><a href=\"https:\/\/blogs.ubc.ca\/henrylo\/files\/2009\/11\/Customize-Vista-Edit.docx\">Customize Vista Edit<\/a><\/p>\n<p align=\"center\"><strong>Customize Vista Edit<\/strong><\/p>\n<p align=\"center\">\n<p align=\"center\">\n<p align=\"center\">\n<p align=\"center\">\n<p align=\"center\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-39\" title=\"Title Image\" src=\"https:\/\/blogs.ubc.ca\/henrylo\/files\/2009\/11\/Title-Image1.JPG\" alt=\"Title Image\" width=\"273\" height=\"177\" \/><\/p>\n<p align=\"center\">\n<p align=\"center\">Prepared By:<\/p>\n<p align=\"center\">Henry Lo<\/p>\n<p><strong><br \/>\n<\/strong><\/p>\n<h1 style=\"text-align: center;\">ABSTRACT<\/h1>\n<p style=\"text-align: justify;\">The Customize Vista Edit is a script that adds to the features found when editing a course in the Build mode of UBC Vista courses. When installed onto Greasemonkey, the Customize Vista Edit allows course builders to: quick or full preview their HTML code, revert to previous code, and expand the textbox for better viewing. This report is focused on the design and development of the Customize Vista Edit script, and will elaborate on its included features.<\/p>\n<p><strong>Table of  Contents<\/strong><\/p>\n<p>ABSTRACT. 2<\/p>\n<p>1.0 INTRODUCTION.. 5<\/p>\n<p>2.0 BACKGROUND.. 6<\/p>\n<p>3.0 CODING.. 7<\/p>\n<p>3.1 FormParams. 7<\/p>\n<p>3.2 Quick Preview.. 8<\/p>\n<p>3.3 Save Code. 9<\/p>\n<p>3.4 Revert 10<\/p>\n<p>3.5 Resize. 10<\/p>\n<p>3.6 Full Preview.. 13<\/p>\n<p>3.7 Layout 13<\/p>\n<p>4.0 CONCLUSION.. 15<\/p>\n<p>APPENDIX I 16<\/p>\n<p><strong>Table of Figures<\/strong><\/p>\n<p>Figure 1. Greasemonkey &#8211; Manage Script 5<\/p>\n<p>Figure 2. Customize Vista Edit layout 5<\/p>\n<p>Figure 3. Quick Preview.. 8<\/p>\n<p>Figure 4. Save Buttons. 9<\/p>\n<p>Figure 5. Revert Prompt 10<\/p>\n<p>Figure 6. Revert Button. 10<\/p>\n<p>Figure 7. Textbox: Expand. 12<\/p>\n<p>Figure 8. Textbox: Reset 12<\/p>\n<p>Figure 9. Layout 14<\/p>\n<h1 style=\"text-align: center;\">1.0\u00a0 INTRODUCTION<\/h1>\n<p style=\"text-align: justify;\">The Customize Vista Edit script is an intuitive addition to the course editor found in the build mode of UBC Vista. To use it, the user must have the Mozilla Firefox add-on Greasemonkey already running on their browser. Greasemonkey is a program that allows users to install scripts that make on-the-fly changes to HTML webpage content on the DOMContentLoaded event, which happens immediately after it is loaded in the browser. For example, downloading a text area size adjuster onto Greasemonkey will allow users to adjust any textboxes found in any website.<\/p>\n<p style=\"text-align: justify;\">To download the Customize Vista Edit, use the following link:<\/p>\n<p><a href=\"http:\/\/oltubc.com\/customizevistaedit.user.js\">http:\/\/oltubc.com\/customizevistaedit.user.js<\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-30\" title=\"Greasemonkey Manage Script\" src=\"https:\/\/blogs.ubc.ca\/henrylo\/files\/2009\/11\/Greasemonkey-Manage-Script1.JPG\" alt=\"Greasemonkey Manage Script\" width=\"413\" height=\"357\" srcset=\"https:\/\/blogs.ubc.ca\/henrylo\/files\/2009\/11\/Greasemonkey-Manage-Script1.JPG 413w, https:\/\/blogs.ubc.ca\/henrylo\/files\/2009\/11\/Greasemonkey-Manage-Script1-300x259.jpg 300w\" sizes=\"auto, (max-width: 413px) 100vw, 413px\" \/><\/p>\n<p align=\"center\">\n<p align=\"center\">Figure 1. Greasemonkey &#8211; Manage Script<\/p>\n<p style=\"text-align: justify;\">After completing the installation, enabling the script will activate it. From now on, whenever the user enters the build mode and edits a course report, for example, the Customize Vista Edit toolbar will appear with new options for the user that will allow for more convenient editing.<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-28\" title=\"Customize Vista Toolbar\" src=\"https:\/\/blogs.ubc.ca\/henrylo\/files\/2009\/11\/Customize-Vista-Toolbar.JPG\" alt=\"Customize Vista Toolbar\" width=\"500\" height=\"27\" \/><\/p>\n<p align=\"center\">\n<p align=\"center\">Figure 2. Customize Vista Edit layout<\/p>\n<h1 style=\"text-align: center;\">2.0\u00a0 BACKGROUND<\/h1>\n<p style=\"text-align: justify;\">The Customize Vista Edit script is mostly developing with JavaScript coding.<\/p>\n<p style=\"text-align: justify;\">JavaScript is an <a title=\"Object-oriented\" href=\"http:\/\/en.wikipedia.org\/wiki\/Object-oriented\">object-oriented<\/a><sup> <\/sup><a title=\"Scripting language\" href=\"http:\/\/en.wikipedia.org\/wiki\/Scripting_language\">scripting language<\/a> used to enable <a title=\"Computer programming\" href=\"http:\/\/en.wikipedia.org\/wiki\/Computer_programming\">programmatic<\/a> access to objects within both the <a title=\"Client (computing)\" href=\"http:\/\/en.wikipedia.org\/wiki\/Client_%28computing%29\">client application<\/a> and other <a title=\"Application software\" href=\"http:\/\/en.wikipedia.org\/wiki\/Application_software\">applications<\/a>. It is primarily used as an integrated component of the <a title=\"Web browser\" href=\"http:\/\/en.wikipedia.org\/wiki\/Web_browser\">web browser<\/a>, allowing the development of enhanced <a title=\"User interface\" href=\"http:\/\/en.wikipedia.org\/wiki\/User_interface\">user interfaces<\/a> and dynamic <a title=\"Website\" href=\"http:\/\/en.wikipedia.org\/wiki\/Website\">websites<\/a>.<\/p>\n<h1 style=\"text-align: center;\">3.0\u00a0 CODING<\/h1>\n<p style=\"text-align: justify;\">This section of the report will begin discussing the development of the Customize Vista Edit script. Each section will focus on the features added by Customize Vista Edit and will take an in-depth analysis and explain how each feature was developed and help you better understand the code behind it. (Refer to Appendix I)<\/p>\n<h2>3.1 FormParams<\/h2>\n<p style=\"text-align: justify;\">The FormParams function is developed to take a form and translates the elements into an AJAX ready sequence of parameters. The reason for implementing this function is to allow the save function, discussed later, to save changes without having to exit the page every time. This would allow the user to make quick changes and preview the code and make changes conveniently.\u00a0 The inputs that the FormParams function scans are separated into two types, regular form inputs (title), and text areas (HTML textbox). The code for retrieving the inputs are as follows:<\/p>\n<p>\/\/ Get all Inputs<\/p>\n<p>var finputs = form.getElementsByTagName(&#8216;input&#8217;);<\/p>\n<p>var farray = new Array();<\/p>\n<p>for(var i = 0; i &lt; finputs.length; i++){<\/p>\n<p>if(finputs[i].name.length &gt; 0){<\/p>\n<p>farray[i] = finputs[i].name + &#8220;=&#8221; + encodeURI(finputs[i].value);<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>The function first assigns the input tag to the variable finputs. Then, it will enter a \u2018for\u2019 loop in which it will scan each character of the input and translates the elements into AJAX. Scanning the text areas is the same.<\/p>\n<p>\/\/ Get all Textareas<\/p>\n<p>var farray2 = new Array();<\/p>\n<p>var ftextarea = form.getElementsByTagName(&#8216;textarea&#8217;);<\/p>\n<p>for(var i = 0; i &lt; ftextarea.length; i++){<\/p>\n<p>if(ftextarea[i].name.length &gt; 0){<\/p>\n<p>farray2[i] = ftextarea[i].name + &#8220;=&#8221; + encodeURIComponent(ftextarea[i].value);<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<h2>3.2 Quick Preview<\/h2>\n<p style=\"text-align: justify;\">The preview button found on the Customize Vista Edit layout is used to generate a demo page. This allows users to quickly view their current page and make changes. The function starts out by scanning the HTML textbox using the method getElementById(). This method returns a reference to the first object with the specified ID, which in this case is \u2018htmlText\u2019. Next, it takes the values inside the textbox using textarea.value and stores it, as values, into ttransfer.<\/p>\n<p>\/\/ Get the html source from textarea<\/p>\n<p>var textarea = document.getElementById(&#8216;htmlText&#8217;);<\/p>\n<p>var semiwrap = document.createElement(&#8216;div&#8217;);<\/p>\n<p>var ttransfer = textarea.value;<\/p>\n<p style=\"text-align: justify;\">Then it transfers the values in ttransfer and\u00a0sets the HTML syntax describing the element&#8217;s descendants into the variable semiwrap using .innerHTML. This method takes the text and converts it into HTML format:<\/p>\n<p>semiwrap.innerHTML = ttransfer;<\/p>\n<p>document.getElementById(&#8216;wrap&#8217;).innerHTML = semiwrap.innerHTML;<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-32\" title=\"Quick Preview\" src=\"https:\/\/blogs.ubc.ca\/henrylo\/files\/2009\/11\/Quick-Preview.JPG\" alt=\"Quick Preview\" width=\"500\" height=\"213\" \/><\/p>\n<p align=\"center\">Figure 3. Quick Preview<\/p>\n<p style=\"text-align: justify;\">Due to the nature of Vista&#8217;s addressing issues, much of the source code from the textbox is different; therefore some measures have been taken to fix links and images before preview. The below code implements this:<\/p>\n<p>\/\/ Replace image and link paths for local view<\/p>\n<p>ttransfer = ttransfer.replace(\/(src=(\\&#8221;|\\&#8217;))(\\.\\.\\\/)?([0-9a-zA-Z\\\/_?+-.]+)(\\&#8221;|\\&#8217;)\/g, &#8220;$1&#8221; + newroot + folder + &#8220;\/$3$4$5&#8221;);<\/p>\n<p>ttransfer = ttransfer.replace(\/(href=(\\&#8221;|\\&#8217;))(\\.\\.\\\/)?([0-9a-zA-Z\\\/_?+-.]+)(\\&#8221;|\\&#8217;)\/g, &#8220;$1&#8221; + newroot + folder + &#8220;\/$3$4$5&#8221;);<\/p>\n<h2>3.3 Save Code<\/h2>\n<p style=\"text-align: justify;\">The save code function is a simple algorithm that allows the user to save their current source code by means of AJAX http protocols. By using AJAX, preventions allow Vista from redirecting back to the item menu allowing further changes if the last edits were not satisfactory. The code start by requesting the http protocol:<\/p>\n<p>var http = new XMLHttpRequest();<\/p>\n<p>if(http.overrideMimeType)<\/p>\n<p>{<\/p>\n<p>http.overrideMimeType(&#8216;text\/html&#8217;);<\/p>\n<p>}<\/p>\n<p style=\"text-align: justify;\">Next, it retrieves the parameters and initializes the header utilizing the formparams function discussed earlier. Now space has been created to save the current code. The following code sends the header information and waits for the http to respond, letting the user know that their code has been successfully saved.<\/p>\n<p>\/\/ Get form parameters and action<\/p>\n<p>var params = unsafeWindow.formparams(document.forms[0]);<\/p>\n<p>var url = unsafeWindow.formaction(document.forms[0]);<\/p>\n<p>\/\/ Initialize a header<\/p>\n<p>http.open(&#8220;POST&#8221;, root + url, true);<\/p>\n<p>\/\/ Send Header Information<\/p>\n<p>http.setRequestHeader(&#8220;Content-type&#8221;, &#8220;application\/x-www-form-urlencoded&#8221;);<\/p>\n<p>http.setRequestHeader(&#8220;Content-length&#8221;, params.length);<\/p>\n<p>http.setRequestHeader(&#8220;User-Agent&#8221;, &#8220;Mozilla\/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko\/20071127 Firefox\/2.0.0.11&#8221;);<\/p>\n<p>http.setRequestHeader(&#8220;Accept-Charset&#8221;, &#8220;ISO-8859-1,utf-8;q=0.7,*;q=0.7&#8221;);<\/p>\n<p>http.setRequestHeader(&#8220;Keep-Alive&#8221;, &#8220;300&#8221;);<\/p>\n<p>http.setRequestHeader(&#8220;Connection&#8221;, &#8220;close&#8221;);<\/p>\n<p>\/\/ Wait for a http response<\/p>\n<p>http.onreadystatechange = function() {\/\/Call a function when the state changes.<\/p>\n<p>if(http.readyState == 4 &amp;&amp; http.status == 200) {<\/p>\n<p>alert(&#8220;Changes Saved&#8221;);<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>\/\/ end onreadystatechange<\/p>\n<p>http.send(params);<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-35\" title=\"Save Button\" src=\"https:\/\/blogs.ubc.ca\/henrylo\/files\/2009\/11\/Save-Button.JPG\" alt=\"Save Button\" width=\"500\" height=\"28\" \/><\/p>\n<p align=\"center\">\n<p align=\"center\">Figure 4. Save Buttons<\/p>\n<h2>3.4 Revert<\/h2>\n<p style=\"text-align: justify;\">The \u201cRevert\u201d button is to allow users that have made a mistake when writing the HTML source code to go back to the version of the source code that first appeared in the current session. The code is very simple for the implementation of this feature. First, the function scans the HTML textbox using the method getElementById(). This method returns a reference to the first object with the specified ID, which in this case is \u2018htmlText\u2019.<\/p>\n<p>\/\/ oCode = Original Code<\/p>\n<p>var rtextarea = document.getElementById(&#8216;htmlText&#8217;);<\/p>\n<p style=\"text-align: justify;\">Then it prompts a warning message asking &#8220;Are you sure you want to revert the document&#8221;, if the user clicks yes, the code will return to the code present at the start of the current session, where oCode is the original source code.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-34\" title=\"Revert Prompt\" src=\"https:\/\/blogs.ubc.ca\/henrylo\/files\/2009\/11\/Revert-Prompt.JPG\" alt=\"Revert Prompt\" width=\"330\" height=\"125\" srcset=\"https:\/\/blogs.ubc.ca\/henrylo\/files\/2009\/11\/Revert-Prompt.JPG 330w, https:\/\/blogs.ubc.ca\/henrylo\/files\/2009\/11\/Revert-Prompt-300x113.jpg 300w\" sizes=\"auto, (max-width: 330px) 100vw, 330px\" \/><\/p>\n<p align=\"center\">\n<p align=\"center\">Figure 5. Revert Prompt<\/p>\n<p>\/\/ Make sure the user really wants to undo ALL the modifications<\/p>\n<p>var answer = confirm(&#8220;Are you sure you want to revert the document?&#8221;, 2, 2);<\/p>\n<p>\/\/ I think the answer comes in binary \/ bool<\/p>\n<p>if(answer){<\/p>\n<p>rtextarea.value = oCode; }<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-33\" title=\"Revert Bar\" src=\"https:\/\/blogs.ubc.ca\/henrylo\/files\/2009\/11\/Revert-Bar.JPG\" alt=\"Revert Bar\" width=\"500\" height=\"27\" \/><\/p>\n<p align=\"center\">\n<p align=\"center\">Figure 6. Revert Button<\/p>\n<h2>3.5 Resize<\/h2>\n<p style=\"text-align: justify;\">The resize function is a more complex algorithm as it utilizes both javascript and CSS coding in the expansion of the HTML textbox. CSS, Cascading Style Sheets, is designed primarily to enable the separation of document content (written in HTML or a similar markup language) from document presentation, including elements such as the <a title=\"Color\" href=\"http:\/\/en.wikipedia.org\/wiki\/Color\">colors<\/a>, <a title=\"Typeface\" href=\"http:\/\/en.wikipedia.org\/wiki\/Typeface\">fonts<\/a>, and <a title=\"Layout\" href=\"http:\/\/en.wikipedia.org\/wiki\/Layout\">layout<\/a>. This separation can improve content <a title=\"Accessibility\" href=\"http:\/\/en.wikipedia.org\/wiki\/Accessibility\">accessibility<\/a> and provide more flexibility and control. The reason for using CSS is to improve the layout. When using JavaScript coding for the expansion of the textbox, the box collides with other items on the page, causing unwanted obstructions. As CSS is designed for improving page layout, its usefulness in this case is unquestionable. First, initialization of CSS to be used within Greasemonkey is required, this is demonstrated by the below code:<\/p>\n<p>\/\/ inserts the ability to use CSS stylex<\/p>\n<p>\/\/ =====================================<\/p>\n<p>function addGlobalStyle(css) {<\/p>\n<p>var head, style;<\/p>\n<p>head = document.getElementsByTagName(&#8216;head&#8217;)[0];<\/p>\n<p>if(!head) {return;}<\/p>\n<p>style = document.createElement(&#8216;style&#8217;);<\/p>\n<p>style.type = &#8216;text\/css&#8217;;<\/p>\n<p>style.innerHTML = css;<\/p>\n<p>head.appendChild(style);\u00a0 }<\/p>\n<p style=\"text-align: justify;\">This code allows the use of CSS styles within the script. Next we can adjust the height and width of the textbox by first specifying its class and then adjust the size accordingly.<\/p>\n<p>unsafeWindow.resizefcn = function (){<\/p>\n<p>\/\/ Inserts the ability to edit the style of the page with CSS<\/p>\n<p>addGlobalStyle(&#8216;.descForm {height: 500px; width: 700px;}&#8217;);<\/p>\n<p>}<\/p>\n<p style=\"text-align: justify;\">In addition, the feature to change back to the original size was implemented. After the user resizes the textbox, the button will change from Textbox: Expand to Textbox: Reset. This is accomplished by including the following code in the resize function:<\/p>\n<p>resize.value = &#8220;Textbox: Reset&#8221;;<\/p>\n<p>resize.setAttribute(&#8220;onClick&#8221;, &#8220;resetfcn()&#8221;);<\/p>\n<p>thediv.appendChild(reset);<\/p>\n<p>And the following code in the reset function, which resets the textbox size back to the original:<br \/>\n\/\/ Inserts the ability to edit the style of the page with CSS<\/p>\n<p>addGlobalStyle(&#8216;.descForm {height: 120px; width: 400px;}&#8217;);<\/p>\n<p>resize.value = &#8220;Textbox: Expand&#8221;;<\/p>\n<p>resize.setAttribute(&#8220;onClick&#8221;, &#8220;resizefcn()&#8221;);<\/p>\n<p>thediv.appendChild(resize);<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-36\" title=\"Textbox Expand 1\" src=\"https:\/\/blogs.ubc.ca\/henrylo\/files\/2009\/11\/Textbox-Expand-1.JPG\" alt=\"Textbox Expand 1\" width=\"500\" height=\"303\" \/><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-37\" title=\"Textbox Expand 2\" src=\"https:\/\/blogs.ubc.ca\/henrylo\/files\/2009\/11\/Textbox-Expand-2.JPG\" alt=\"Textbox Expand 2\" width=\"500\" height=\"27\" \/><\/p>\n<p align=\"center\">\n<p align=\"center\">\n<p align=\"center\">\n<p align=\"center\">\n<p align=\"center\">Figure 7. Textbox: Expand<\/p>\n<p align=\"center\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-38\" title=\"Textbox Reset\" src=\"https:\/\/blogs.ubc.ca\/henrylo\/files\/2009\/11\/Textbox-Reset.JPG\" alt=\"Textbox Reset\" width=\"460\" height=\"413\" srcset=\"https:\/\/blogs.ubc.ca\/henrylo\/files\/2009\/11\/Textbox-Reset.JPG 460w, https:\/\/blogs.ubc.ca\/henrylo\/files\/2009\/11\/Textbox-Reset-300x269.jpg 300w\" sizes=\"auto, (max-width: 460px) 100vw, 460px\" \/><\/p>\n<p align=\"center\">\n<p align=\"center\">Figure 8. Textbox: Reset<\/p>\n<h2>3.6 Full Preview<\/h2>\n<p style=\"text-align: justify;\">This function generates a full popup window preview of the current page. This function first grabs the current page ID and then gets the page address along with its parameters followed by opening the popup window. These steps are implemented by the following code:<\/p>\n<p>\/\/ Grab the current page ID<\/p>\n<p>var pageid = document.getElementsByName(&#8216;pageID&#8217;)[0].value;<\/p>\n<p>var page = document.getElementsByName(&#8216;linkedToFilePath&#8217;)[0];<\/p>\n<p>\/\/ Get the page link along with it&#8217;s parameters<\/p>\n<p>var viewer = &#8220;https:\/\/www.vista.ubc.ca\/webct\/ContentPageServerServlet\/&#8221; + page.value + &#8220;?pageID=&#8221; + pageid;<\/p>\n<p>\/\/ Open the popup window<\/p>\n<p>window.open(viewer,&#8217;popup_preview&#8217;,&#8217;width=800,height=640,menubar=1,toolbar=1,scrollbars=1,status=1,location=1,resizable=1&#8242;)<\/p>\n<h2>3.7 Layout<\/h2>\n<p style=\"text-align: justify;\">Now, we need buttons for the features we implemented above. To create these buttons using JavaScript, we first start by initializing variables and values according to each button.<\/p>\n<p>var preview = cancel.cloneNode(true);<\/p>\n<p>preview.value = &#8220;Full Preview&#8221;;<\/p>\n<p>var save = cancel.cloneNode(true);<\/p>\n<p>save.value = &#8220;Save Changes&#8221;;<\/p>\n<p>var revert = cancel.cloneNode(true);<\/p>\n<p>revert.value = &#8220;Revert&#8221;;<\/p>\n<p>var resize = cancel.cloneNode(true);<\/p>\n<p>resize.value = &#8220;Textbox: Expand&#8221;;<\/p>\n<p>Next, we assign the functions to their respective buttons:<\/p>\n<p>preview.setAttribute(&#8220;onClick&#8221;, &#8220;fullPreview()&#8221;);<\/p>\n<p>save.setAttribute(&#8220;onClick&#8221;, &#8220;saveCode()&#8221;);<\/p>\n<p>revert.setAttribute(&#8220;onClick&#8221;, &#8220;revert(originalCode)&#8221;);<\/p>\n<p>resize.setAttribute(&#8220;onClick&#8221;, &#8220;resizefcn(originalCode)&#8221;);<\/p>\n<p>With the buttons created, we now create the layout. To have spaces between each button, we use the following code:<\/p>\n<p>\/\/ aspan is just a little gap I use to separate<\/p>\n<p>\/\/ the custom buttons I created<\/p>\n<p>for(var i = 0; i &lt; 2; i++){<\/p>\n<p>aspan = aspan.cloneNode(true);<\/p>\n<p>thediv.appendChild(aspan);}<\/p>\n<p>The final product is:<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-28\" title=\"Customize Vista Toolbar\" src=\"https:\/\/blogs.ubc.ca\/henrylo\/files\/2009\/11\/Customize-Vista-Toolbar.JPG\" alt=\"Customize Vista Toolbar\" width=\"500\" height=\"27\" \/><\/p>\n<p align=\"center\">\n<p align=\"center\">Figure 9. Layout<\/p>\n<p align=\"center\">\n<h1 style=\"text-align: center;\">4.0\u00a0 CONCLUSION<\/h1>\n<p style=\"text-align: justify;\">The Customize Vista Edit script is an intuitive and convenient addition to the course editor in UBC Vista. With its addition, users can quick preview their source code, save their current code without needing to exit the page, resize and rest the textbox,\u00a0\u00a0 and revert to the original source code. The development of the script utilized both JavaScript and CSS languages to implement the features of the Customize Vista Edit. The Customize Vista Edit script is aimed to convenient web designer in UBC Vista, and additional features are being considered to allow users a more streamline experience during web development.<\/p>\n<h2>APPENDIX I<\/h2>\n<p>\/\/ ==UserScript==<\/p>\n<p>\/\/ @name\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Customize Vista Edit<\/p>\n<p>\/\/ @namespace\u00a0\u00a0\u00a0\u00a0\u00a0 Customize Vista Edit<\/p>\n<p>\/\/ @include\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 https:\/\/www.*.ubc.ca\/webct*editOrganizerResource.dowebct?*selectedResourceType=PAGE_TYPE*<\/p>\n<p>\/\/ @include\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 https:\/\/www.*.ubc.ca\/webct*viewCourseMapItemDispatcher.dowebct?*&amp;tab=build&amp;targetFrame=RIGHTTOOLFRAME*<\/p>\n<p>\/\/ @include\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0 https:\/\/www.*.ubc.ca\/webct*linkedToResource.dowebct?*&amp;selectedResourceType=PAGE_TYPE&amp;selectedResourceID=*<\/p>\n<p>\/\/ ==\/UserScript==<\/p>\n<p>\/\/ Last Edit: April 28th, 2008<\/p>\n<p>\/\/ ===========================<\/p>\n<p>\/\/ Thoughts&#8230;<\/p>\n<p>\/\/ :: Some possible functions to implement &#8211; Detect when target site doesn&#8217;t really save any changes to document<\/p>\n<p>\/\/ :: Modify to use AJAX frameworks (eg, jQuery) for easy upgrade<\/p>\n<p>\/\/ :: Port this code to a Safari\/Greasekit for the stupid Macs, main modifictions would be to change unsafeWindow element<\/p>\n<p>\/\/\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0 to GreaseKit compliant object<\/p>\n<p>\/\/ Active Editing<\/p>\n<p>\/\/ ==============<\/p>\n<p>\/\/ If turned onto true, quick preview changes will be updated<\/p>\n<p>\/\/ in real time, however, it&#8217;s fairly slow. Turned off for efficiency<\/p>\n<p>var active = false;<\/p>\n<p>var h = 500 + &#8220;px&#8221;;<\/p>\n<p>var w = 500 + &#8220;px&#8221;;<\/p>\n<p>var count=0;<\/p>\n<p>\/\/ Vista Server<\/p>\n<p>var root = &#8220;https:\/\/www.vista.ubc.ca&#8221;;<\/p>\n<p>\/\/ File Root Folder Declaration<\/p>\n<p>var folder = document.getElementById(&#8216;folderPath&#8217;).value.split(&#8220;\/&#8221;)[1];<\/p>\n<p>\/\/ Create an invisible DIV Wrapper for easy js access later<\/p>\n<p>var wrap = document.createElement(&#8220;div&#8221;);<\/p>\n<p>wrap.setAttribute(&#8220;id&#8221;, &#8220;wrap&#8221;);<\/p>\n<p>\/\/ inserts the ability to use CSS styles<\/p>\n<p>\/\/ =====================================<\/p>\n<p>function addGlobalStyle(css) {<\/p>\n<p>var head, style;<\/p>\n<p>head = document.getElementsByTagName(&#8216;head&#8217;)[0];<\/p>\n<p>if(!head) {return;}<\/p>\n<p>style = document.createElement(&#8216;style&#8217;);<\/p>\n<p>style.type = &#8216;text\/css&#8217;;<\/p>\n<p>style.innerHTML = css;<\/p>\n<p>head.appendChild(style);<\/p>\n<p>}<\/p>\n<p>\/*<\/p>\n<p>\/\/ Custom Function getElementsByClassName<\/p>\n<p>\/\/ ======================================<\/p>\n<p>\/\/ &#8211; This should&#8217;ve been prototyped for elements but<\/p>\n<p>\/\/ for the purposes, this should be okay<\/p>\n<p>\/\/ Takes in the name from the &#8220;class=&#8221; attribute<\/p>\n<p>document.getElementsByClassName = function(clsName){<\/p>\n<p>var retVal = new Array();<\/p>\n<p>var elements = document.getElementsByTagName(&#8220;*&#8221;);<\/p>\n<p>for(var i = 0;i &lt; elements.length;i++){<\/p>\n<p>if(elements[i].className.indexOf(&#8221; &#8220;) &gt;= 0){<\/p>\n<p>var classes = elements[i].className.split(&#8221; &#8220;);<\/p>\n<p>for(var j = 0;j &lt; classes.length;j++){<\/p>\n<p>if(classes[j] == clsName)<\/p>\n<p>retVal.push(elements[i]);<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>else if(elements[i].className == clsName)<\/p>\n<p>retVal.push(elements[i]);<\/p>\n<p>}<\/p>\n<p>return retVal;<\/p>\n<p>}<\/p>\n<p>*\/<\/p>\n<p>\/\/ unsafeWindow :: FormParams<\/p>\n<p>\/\/ ==========================<\/p>\n<p>\/\/ Takes a form and translates the elements into a AJAX<\/p>\n<p>\/\/ ready sequence of parameters (eg, name=jack&amp;age=18&amp;comment=&#8230;)<\/p>\n<p>\/\/ Separated into two types, regular form inputs and textareas<\/p>\n<p>\/\/ Class unsafeWindow due to user-action property<\/p>\n<p>unsafeWindow.formparams = function(form){<\/p>\n<p>\/\/ Get all Inputs<\/p>\n<p>var finputs = form.getElementsByTagName(&#8216;input&#8217;);<\/p>\n<p>var farray = new Array();<\/p>\n<p>for(var i = 0; i &lt; finputs.length; i++){<\/p>\n<p>if(finputs[i].name.length &gt; 0){<\/p>\n<p>farray[i] = finputs[i].name + &#8220;=&#8221; + encodeURI(finputs[i].value);<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>\/\/ Get all Textareas<\/p>\n<p>var farray2 = new Array();<\/p>\n<p>var ftextarea = form.getElementsByTagName(&#8216;textarea&#8217;);<\/p>\n<p>for(var i = 0; i &lt; ftextarea.length; i++){<\/p>\n<p>if(ftextarea[i].name.length &gt; 0){<\/p>\n<p>farray2[i] = ftextarea[i].name + &#8220;=&#8221; + encodeURIComponent(ftextarea[i].value);<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>return farray.join(&#8220;&amp;&#8221;) + &#8220;&amp;&#8221; + farray2.join(&#8220;&amp;&#8221;);;<\/p>\n<p>}<\/p>\n<p>\/\/ unsafeWindow :: FormAction<\/p>\n<p>\/\/ ==========================<\/p>\n<p>\/\/ Takes a form and retrieves the &#8220;action=&#8221; parameter<\/p>\n<p>\/\/ Once again, it&#8217;s for AJAX calls later<\/p>\n<p>\/\/ Class unsafeWindow due to user-action property<\/p>\n<p>unsafeWindow.formaction = function(form){<\/p>\n<p>return form.getAttribute(&#8220;action&#8221;);<\/p>\n<p>}<\/p>\n<p>\/\/ unsafeWindow :: PreviewCode<\/p>\n<p>\/\/ ===========================<\/p>\n<p>\/\/ Function called by preview code button to generate a demo page<\/p>\n<p>\/\/ Due to the nature of Vista&#8217;s addressing issues, much of the source<\/p>\n<p>\/\/ code from textarea is different, therefore some measures have been<\/p>\n<p>\/\/ taken place to fix these links before previewed (src for images,<\/p>\n<p>\/\/ href for links and frames, etc)<\/p>\n<p>\/\/ Class unsafeWindow due to user-action property<\/p>\n<p>unsafeWindow.previewCode = function (){<\/p>\n<p>\/\/ Get the html source from textarea<\/p>\n<p>var textarea = document.getElementById(&#8216;htmlText&#8217;);<\/p>\n<p>var semiwrap = document.createElement(&#8216;div&#8217;);<\/p>\n<p>var ttransfer = textarea.value;<\/p>\n<p>\/\/ Make a local root to avoid auto path prefix from browser<\/p>\n<p>var newroot = &#8220;https:\/\/www.vista.ubc.ca\/webct\/RelativeResourceManager\/Template\/&#8221;;<\/p>\n<p>\/\/ Replace image and link paths for local view<\/p>\n<p>ttransfer = ttransfer.replace(\/(src=(\\&#8221;|\\&#8217;))(\\.\\.\\\/)?([0-9a-zA-Z\\\/_?+-.]+)(\\&#8221;|\\&#8217;)\/g, &#8220;$1&#8221; + newroot + folder + &#8220;\/$3$4$5&#8221;);<\/p>\n<p>ttransfer = ttransfer.replace(\/(href=(\\&#8221;|\\&#8217;))(\\.\\.\\\/)?([0-9a-zA-Z\\\/_?+-.]+)(\\&#8221;|\\&#8217;)\/g, &#8220;$1&#8221; + newroot + folder + &#8220;\/$3$4$5&#8221;);<\/p>\n<p>semiwrap.innerHTML = ttransfer;<\/p>\n<p>document.getElementById(&#8216;wrap&#8217;).innerHTML = semiwrap.innerHTML;<\/p>\n<p>}<\/p>\n<p>\/\/ unsafeWindow :: saveCode<\/p>\n<p>\/\/ Save the source code by means of AJAX http protocols<\/p>\n<p>\/\/ This prevents Vista from redirecting back to the item menu<\/p>\n<p>\/\/ allowing further changes if the last edits were not satisfactory<\/p>\n<p>\/\/ ** Important :: If for some peculiar reason the file is not saved<\/p>\n<p>\/\/ it will still say &#8220;Changes Saved&#8221;, one way to fix this is to<\/p>\n<p>\/\/ to scan the http.responseText for any error messages<\/p>\n<p>\/\/ Class unsafeWindow due to user-action property<\/p>\n<p>unsafeWindow.saveCode = function (){<\/p>\n<p>var http = new XMLHttpRequest();<\/p>\n<p>if(http.overrideMimeType){<\/p>\n<p>http.overrideMimeType(&#8216;text\/html&#8217;);<\/p>\n<p>}<\/p>\n<p>\/\/ Get form parameters and action<\/p>\n<p>var params = unsafeWindow.formparams(document.forms[0]);<\/p>\n<p>var url = unsafeWindow.formaction(document.forms[0]);<\/p>\n<p>\/\/ Initialize a header<\/p>\n<p>http.open(&#8220;POST&#8221;, root + url, true);<\/p>\n<p>\/\/ Send Header Information<\/p>\n<p>http.setRequestHeader(&#8220;Content-type&#8221;, &#8220;application\/x-www-form-urlencoded&#8221;);<\/p>\n<p>http.setRequestHeader(&#8220;Content-length&#8221;, params.length);<\/p>\n<p>http.setRequestHeader(&#8220;User-Agent&#8221;, &#8220;Mozilla\/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko\/20071127 Firefox\/2.0.0.11&#8221;);<\/p>\n<p>http.setRequestHeader(&#8220;Accept-Charset&#8221;, &#8220;ISO-8859-1,utf-8;q=0.7,*;q=0.7&#8221;);<\/p>\n<p>http.setRequestHeader(&#8220;Keep-Alive&#8221;, &#8220;300&#8221;);<\/p>\n<p>http.setRequestHeader(&#8220;Connection&#8221;, &#8220;close&#8221;);<\/p>\n<p>\/\/ Wait for a http response<\/p>\n<p>http.onreadystatechange = function() {\/\/Call a function when the state changes.<\/p>\n<p>if(http.readyState == 4 &amp;&amp; http.status == 200) {<\/p>\n<p>alert(&#8220;Changes Saved&#8221;);<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>\/\/ end onreadystatechange<\/p>\n<p>http.send(params);<\/p>\n<p>}<\/p>\n<p>\/\/ unsafeWindow :: Revert<\/p>\n<p>\/\/ ======================<\/p>\n<p>\/\/ Session based revert function. This reverts any changes to the original<\/p>\n<p>\/\/ source code that was first opened in the current session. This does Not<\/p>\n<p>\/\/ revert to the last &#8220;working&#8221; save&#8221;.<\/p>\n<p>\/\/ Class unsafeWindow due to user-action property<\/p>\n<p>unsafeWindow.revert = function (oCode){<\/p>\n<p>\/\/ oCode = Original Code<\/p>\n<p>var rtextarea = document.getElementById(&#8216;htmlText&#8217;);<\/p>\n<p>\/\/ Make sure the user really wants to undo ALL the modifications<\/p>\n<p>var answer = confirm(&#8220;Are you sure you want to revert the document?&#8221;, 2, 2);<\/p>\n<p>\/\/ I think the answer comes in binary \/ bool<\/p>\n<p>if(answer){<\/p>\n<p>rtextarea.value = oCode;<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>\/\/ unsafeWindow :: Resize<\/p>\n<p>\/\/ ======================<\/p>\n<p>\/\/ Expands the textarea<\/p>\n<p>\/\/ Class unsafeWindow due to user-action property<\/p>\n<p>unsafeWindow.resizefcn = function (){<\/p>\n<p>\/\/ Inserts the ability to edit the style of the page with CSS<\/p>\n<p>addGlobalStyle(&#8216;.descForm {height: 500px; width: 700px;}&#8217;);<\/p>\n<p>resize.value = &#8220;Textbox: Reset&#8221;;<\/p>\n<p>resize.setAttribute(&#8220;onClick&#8221;, &#8220;resetfcn()&#8221;);<\/p>\n<p>thediv.appendChild(reset);<\/p>\n<p>}<\/p>\n<p>\/\/ unsafeWindow :: Reset<\/p>\n<p>\/\/ ======================<\/p>\n<p>\/\/ Resets the textarea<\/p>\n<p>\/\/ Class unsafeWindow due to user-action property<\/p>\n<p>unsafeWindow.resetfcn = function (){<\/p>\n<p>\/\/ Inserts the ability to edit the style of the page with CSS<\/p>\n<p>addGlobalStyle(&#8216;.descForm {height: 120px; width: 400px;}&#8217;);<\/p>\n<p>resize.value = &#8220;Textbox: Expand&#8221;;<\/p>\n<p>resize.setAttribute(&#8220;onClick&#8221;, &#8220;resizefcn()&#8221;);<\/p>\n<p>thediv.appendChild(resize);<\/p>\n<p>}<\/p>\n<p>\/\/ unsafeWindow :: FullPreview<\/p>\n<p>\/\/ ===========================<\/p>\n<p>\/\/ This function generates a full (popup) preview of the current<\/p>\n<p>\/\/ page as if the user were to click on action menu -&gt; preview page<\/p>\n<p>\/\/ Class unsafeWindow due to user-action property<\/p>\n<p>\/\/ User Prompted Action, must be of class unsafeWindow<\/p>\n<p>unsafeWindow.fullPreview = function (){<\/p>\n<p>\/\/ Grab the current page ID<\/p>\n<p>var pageid = document.getElementsByName(&#8216;pageID&#8217;)[0].value;<\/p>\n<p>var page = document.getElementsByName(&#8216;linkedToFilePath&#8217;)[0];<\/p>\n<p>\/\/ Get the page link along with it&#8217;s parameters<\/p>\n<p>var viewer = &#8220;https:\/\/www.vista.ubc.ca\/webct\/ContentPageServerServlet\/&#8221; + page.value + &#8220;?pageID=&#8221; + pageid;<\/p>\n<p>\/\/ Open the popup window<\/p>\n<p>window.open(viewer,&#8217;popup_preview&#8217;,&#8217;width=800,height=640,menubar=1,toolbar=1,scrollbars=1,status=1,location=1,resizable=1&#8242;)<\/p>\n<p>}<\/p>\n<p>\/\/\u00a0 ==================================================================================<\/p>\n<p>\/\/ Figure out where we are and what we need<\/p>\n<p>\/\/ Get the current address (to get the ID of the current page<\/p>\n<p>var address = document.location.toString();<\/p>\n<p>var rawid;<\/p>\n<p>\/\/ Check which page we are in and get rawID<\/p>\n<p>if(address.indexOf(&#8220;viewCourseMapItemDispatcher.dowebct&#8221;)!=-1){<\/p>\n<p>rawid = address.split(&#8220;componentId=&#8221;)[1];}<\/p>\n<p>else{<\/p>\n<p>rawid = address.split(&#8220;selectedResourceID=&#8221;)[1];}<\/p>\n<p>\/\/ &#8230; get rawID<\/p>\n<p>var id = rawid.split(&#8220;&amp;&#8221;)[0];<\/p>\n<p>\/\/ For Active Editing Only<\/p>\n<p>var textarea = document.getElementById(&#8216;htmlText&#8217;);<\/p>\n<p>\/\/ Activate real-time preview<\/p>\n<p>\/\/ Warning :: Slow<\/p>\n<p>if(active){<\/p>\n<p>textarea.setAttribute(&#8220;onKeyUp&#8221;, &#8220;previewCode()&#8221;);}<\/p>\n<p>\/\/ Adjust the differences between the annoying MAC<\/p>\n<p>\/\/ and the awesome PC. For some reason, Vista renders<\/p>\n<p>\/\/ differently on a MAC and PC<\/p>\n<p>var div_size = 350;<\/p>\n<p>var tdiv;<\/p>\n<p>\/\/ Fix the Textarea Size;<\/p>\n<p>if(navigator.appVersion.indexOf(&#8220;Win&#8221;)!=-1){<\/p>\n<p>tdiv = document.getElementById(&#8216;formTag&#8217;);<\/p>\n<p>tdiv.style.height = div_size + &#8220;px !important&#8221;;<\/p>\n<p>}<\/p>\n<p>textarea.style.height = (div_size-15) + &#8220;px !important&#8221;;<\/p>\n<p>textarea.style.width = &#8220;800px !important&#8221;;<\/p>\n<p>\/\/ Expand the textarea to a bigger size for better editing<\/p>\n<p>document.forms.namedItem(&#8220;editPageForm&#8221;).elements.namedItem(&#8220;htmlText&#8221;).setAttribute(&#8216;rows&#8217;, 50);<\/p>\n<p>\/\/ Fix the Page Squeeze Problem<\/p>\n<p>mystyle = document.styleSheets[0];<\/p>\n<p>\/\/ Save a copy of the original code before any modifications<\/p>\n<p>unsafeWindow.originalCode = textarea.value;<\/p>\n<p>\/\/ Create a break and insert our Quick Preview<\/p>\n<p>document.body.appendChild(document.createElement(&#8220;br&#8221;));<\/p>\n<p>document.body.appendChild(wrap);<\/p>\n<p>\/\/ Start adding buttons from previous buttons<\/p>\n<p>\/\/ supplied by Vista.<\/p>\n<p>\/\/ Create &amp; insert Exit button, this button does not<\/p>\n<p>\/\/ save any changes.<\/p>\n<p>var theform = document.forms[0];<\/p>\n<p>var inputs = document.getElementsByTagName(&#8216;input&#8217;);<\/p>\n<p>var cancel = inputs[inputs.length-1];<\/p>\n<p>cancel.value = &#8220;Exit&#8221;;<\/p>\n<p>\/\/ Create &amp; insert our Save button<\/p>\n<p>\/\/ Rename our save and exit button<\/p>\n<p>var oSave = inputs[inputs.length-2];<\/p>\n<p>oSave.value = &#8220;Save and Exit&#8221;;<\/p>\n<p>var preview = cancel.cloneNode(true);<\/p>\n<p>var save = cancel.cloneNode(true);<\/p>\n<p>var revert = cancel.cloneNode(true);<\/p>\n<p>var thediv = cancel.parentNode;<\/p>\n<p>\/\/ Create &amp; insert our FullPreview button<\/p>\n<p>preview.value = &#8220;Full Preview&#8221;;<\/p>\n<p>save.value = &#8220;Save Changes&#8221;;<\/p>\n<p>revert.value = &#8220;Revert&#8221;;<\/p>\n<p>var aspan = document.createElement(&#8220;span&#8221;);<\/p>\n<p>aspan.innerHTML = &#8220;&amp;nbsp;&#8221;;<\/p>\n<p>\/\/ Assign the buttons their functions<\/p>\n<p>preview.setAttribute(&#8220;onClick&#8221;, &#8220;fullPreview()&#8221;);<\/p>\n<p>save.setAttribute(&#8220;onClick&#8221;, &#8220;saveCode()&#8221;);<\/p>\n<p>revert.setAttribute(&#8220;onClick&#8221;, &#8220;revert(originalCode)&#8221;);<\/p>\n<p>\/\/ aspan is just a little gap I use to separate<\/p>\n<p>\/\/ the custom buttons I created<\/p>\n<p>for(var i = 0; i &lt; 2; i++){<\/p>\n<p>aspan = aspan.cloneNode(true);<\/p>\n<p>thediv.appendChild(aspan);<\/p>\n<p>}<\/p>\n<p>thediv.appendChild(save);<\/p>\n<p>\/\/ Add the Quick Preview Button<\/p>\n<p>if(!active){<\/p>\n<p>var quickpreview = cancel.cloneNode(true);<\/p>\n<p>quickpreview.value = &#8220;Quick Preview&#8221;;<\/p>\n<p>quickpreview.setAttribute(&#8220;onClick&#8221;, &#8220;previewCode()&#8221;);<\/p>\n<p>for(var i = 0; i &lt; 2; i++){<\/p>\n<p>aspan = aspan.cloneNode(true);<\/p>\n<p>thediv.appendChild(aspan);<\/p>\n<p>}<\/p>\n<p>thediv.appendChild(quickpreview);<\/p>\n<p>}<\/p>\n<p>\/\/ Add some Spaces<\/p>\n<p>for(var i = 0; i &lt; 2; i++){<\/p>\n<p>aspan = aspan.cloneNode(true);<\/p>\n<p>thediv.appendChild(aspan);<\/p>\n<p>}<\/p>\n<p>\/\/ Add the Full Preview Button<\/p>\n<p>thediv.appendChild(preview);<\/p>\n<p>\/\/ Add some extra Spaces<\/p>\n<p>for(var i = 0; i &lt; 2; i++){<\/p>\n<p>aspan = aspan.cloneNode(true);<\/p>\n<p>thediv.appendChild(aspan);<\/p>\n<p>}<\/p>\n<p>\/\/ Add the Revert Button<\/p>\n<p>thediv.appendChild(revert);<\/p>\n<p>\/\/ Add some extra Spaces<\/p>\n<p>for(var i = 0; i &lt; 2; i++){<\/p>\n<p>aspan = aspan.cloneNode(true);<\/p>\n<p>thediv.appendChild(aspan);<\/p>\n<p>}<\/p>\n<p>var resize = cancel.cloneNode(true);<\/p>\n<p>resize.value = &#8220;Textbox: Expand&#8221;;<\/p>\n<p>resize.setAttribute(&#8220;onClick&#8221;, &#8220;resizefcn()&#8221;);<\/p>\n<p>thediv.appendChild(resize);<\/p>\n<p>\/\/ Initialize a first Preview Code<\/p>\n<p>unsafeWindow.previewCode();<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Customize Vista Edit is a script that adds to the features found when editing a course in the Build mode of UBC Vista courses. When installed onto Greasemonkey, the Customize Vista Edit allows course builders to: quick or full preview their HTML code, revert to previous code, and expand the textbox for better viewing. This report is focused on the design and development of the Customize Vista Edit script, and will elaborate on its included features.<\/p>\n","protected":false},"author":1449,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6433],"tags":[],"class_list":["post-26","post","type-post","status-publish","format-standard","hentry","category-customize-vista-edit"],"_links":{"self":[{"href":"https:\/\/blogs.ubc.ca\/henrylo\/wp-json\/wp\/v2\/posts\/26","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.ubc.ca\/henrylo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.ubc.ca\/henrylo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.ubc.ca\/henrylo\/wp-json\/wp\/v2\/users\/1449"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.ubc.ca\/henrylo\/wp-json\/wp\/v2\/comments?post=26"}],"version-history":[{"count":11,"href":"https:\/\/blogs.ubc.ca\/henrylo\/wp-json\/wp\/v2\/posts\/26\/revisions"}],"predecessor-version":[{"id":105,"href":"https:\/\/blogs.ubc.ca\/henrylo\/wp-json\/wp\/v2\/posts\/26\/revisions\/105"}],"wp:attachment":[{"href":"https:\/\/blogs.ubc.ca\/henrylo\/wp-json\/wp\/v2\/media?parent=26"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.ubc.ca\/henrylo\/wp-json\/wp\/v2\/categories?post=26"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.ubc.ca\/henrylo\/wp-json\/wp\/v2\/tags?post=26"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}