Jump to content

jekillen

Members
  • Posts

    28
  • Joined

  • Last visited

Everything posted by jekillen

  1. I have javascript code that is intended to set two cookies. The first one in this assignment document.cookie = 'TAscrollto=135; path=/; domain=192.168.1.27; max-age=3600; ' and the second in this assignment: document.cookie = 'TAscrollto=135; path=/; domain=192.168.1.27; max-age=3600; CMscrollto=199; path=/ domain=192.168.1.27; max-age=3600; ' The reason the first cookie is reproduced in the second assignment is the way my cookie manager utility works. I am assuming that would not make a difference. Both of these assignments are made just before the page reloads in call to window.location = (self processing php script). It is intended to test setting the div and textarea overflow to the figures registered in the cookies, on reload The first cookie shows up in the browser preferences for viewing cookies. The second one does not, and the behavior expected from the intended second cookie value is not evident. Firefox 34.x on Mac OSX Is there any reason visible in the strings assigned to document.cookie why the second cookie (CMscrollto) was not set?
  2. I have developed a web based text editor that I use for editing text files on a site that are owned by the web server user account (unix type system). These file contains many hundreds of lines of code (including comment blocks). When the contents of the text file is displayed in a textarea for editing of text, it overflows the visible area of the textarea element. I can scroll in the textarea with mouse scroll ball*, but no scroll bars are visible unless I scroll into the overflow area to the right of the textarea. There is a left/right scroll bar on the bottom, but that is part of the div that the textarea is nested in. *using an Apple mouse in Firefox on Mac OSX; Firefox is the primary client used for development. Is there an event type that I can monitor in js code to record the scrollHeight value? Or am I limited to recording it in a blur event handler? The textarea is generally focused when the 'Save' processing is executed. I want to be able to save the scrollHeight value when the user clicks 'Save' to save the edits. The contents of the textarea will be sent to server php code to overwrite the file with the edited version. When the 'Save' processing is done, I want the textarea to auto scroll to the last scrollHeight value recorded when 'Save' was executed.
  3. jekillen

    Help with regex?

    In original post I neglected to include an embedded double quote set around \$_ref I got what I am looking for: $_ref = 'help'; $_testStr = "do you want \" \$_ref \", or do you want $_ref?"; preg_match('/(\".*(\\$).*\")/', $_testStr, $_match); $_alt = str_replace($_match[2], '\\$', $_match[0]); $_testStr .= "\n".str_replace($_match[0], $_alt, $_testStr); in html ... etc.. <pre> <textarea > do you want " $_ref ", or do you want help? do you want " \$_ref ", or do you want help? </textarea> <spam><code> do you want " $_ref ", or do you want help? do you want " \$_ref ", or do you want help? </code></span>
  4. Has a node.js forum category been considered? I have found a node.js specific forum, but the traffic there appears to be mostly nil. As I read the Apress text about it, it does not appear to be to usable accept as a local application server that would be intalled on 'localhost' and used with a localhost browser interface. I don't see how it would be used with a registered domain name, accept via a non standard, high numbered port. Someone did not like my last posts on stackoverflow and I don't know why, so I can't go there. Thanks
  5. jekillen

    Help with regex?

    Hello; I have been doing php for some time and I had initially become somewhat knowledgable on how to use create and use regular expressions (with the old regex funtions). But I have been avoiding regex as slow, in favor of designs that would allow string manipulation functions where and when ever possible. But there are situations where it is un avoidable, as now: I am working on an html base text editor. The text to be edited is loaded into a textarea element in the editors html. If the text to be edited is a php and/or html/javascript code file, there are cases where there are escaped dollar signs inside of double quotes. I want to find instances of escaped dollar signs (\$) inside of double quoted strings only, and add an extra escape to the $, so it becomes "....\\$...." instead of "....\$...." Here is what I have so far, but it seems to be removing everything but the $ in initial testing: $_testStr = "do you want \$_ref, or do you want $_ref?"; $_testStr = preg_replace("/\".*(\\$).*\"/", '\\$', $_testStr); So, in this function, how to I reference and replace only what is matched by the sub pattern? I am having much difficulty understanding the php online manual regarding this. Do I have to do preg_match() first and then use the $n reference as the replacement? Thanks for time and attention
  6. So, if I use 'htmlspecialchars($content)' will I have to contend with the special chars once the file contents are visible and editable in the form textarea? Is TinyMCE a completely html/php text editor? My reason for doing this is because of ownership issues when php is used to create files, directories, edit files, upload content, copy content, etc. My aim is to create a custom content managment system that can be completely used via a web interface, not needing ftp access. Because it is content management it will be strictly limited to registered admin users. The core and foundation of this system is an html/javascript/php app that emulates a terminal, in that it will produce a directory listing base on user specification. The listing will produce a list similar to using ls -la in a unix shell, with the added feature of producing the octal version of rwx perms for owner group and others. It has a set of functions to do things such as change perms remove, move, create files and dirs, edit (the subject of this post), and turn over ( copy ftp user owned content, then remove the user owned version of the copied content). The text editor: can be opened from the terminal app in a javascript window.open call or opened directly from an anchor tag. A file system browser which is both stand alone and also used via call to javascript window.open from terminal app and editor. In the terminal app, the browser can be used to select items that are not visible in the currently listed content. For instance, for moving, one would choose the file or dir to move and the directory to move it to. In the editor, the browser can be used to designate that path to a new file, select a file to open and for use in save as for designating a different directory to place the saved as file. There are other facilities I am working on, such as selecting files to create a zip archive, creating the zip archive, unzipping uploaded zip files and designating what directory to place uploaded files (another use of the file browser), and selecting files and packages to download. The file browser works roughly like an operating system file browser app that would appear when on saves or opens a file in an app running on the host OS. It has two modes of operation. One is to list all the directories in the initial left most column. Each dir listing has a radio button next to it that is make into a submit button via javascript and initiates an ajax request for a listing of only the files in that directory. These secondary listings can be done in any order so a user can compare the contents of one dir with a different dir, side by side. The secondary listings can also be removed one at a time in any order. The second display mode is to display only the top directory with all its contained files and directories. Clicking on a radio next to a directory listing will produce a secondary listing of that directory and all of its file and directory contents. As before the secondary listings can be produce in any order and remove in any order. Am I re inventing the wheel? Or are there features here that don't exist in any other web CMS system? I don't know, I am retired, now, and not having secured work in the development field inspite of over ten years of self guided learning and developing. Instead of alchohol consumption or computer games, I sit around dreaming up reasons to program. I think of apps and features and figure out how I would get them to work. I have nothing to sell or solicit for here: www.jekillen.com
  7. I would think that the interpreter could figure out that this was not productive syntax, as it occures where there is absolutely no sense for it. The interpreter should be able to recognize a conditional statement, branching statement such as switch, and a looping statement; and distinguish it from a function call; and find a semicolon after the closing parenthesis to be adverse to the process of the code. The use of string true or false instead of the boolean is because sometimes it comes from a form field value or similar string representation, such as using php to initiate a javascript variable via a php print statement.
  8. Perhaps this will help someone who is having maddening problems with managing simple true/false conditionals. I have had a problem with the following code: argument 'e' is event being being handled. The user has clicked on an item in the web page. // etc... case 'either': if(heading == 'false') { heading = setFile(e); // if a file is detected, returns 'true', else returns 'false' } if(heading == 'false') { heading = setDir(e); // if a directory is detected, returns 'true', else returns 'false' } break; // etc.... The explanation is: The snippet is from a function that detects user generated event on visible item in the page. The items to select are either directories or files from a file system directory listing. case 'either' means that the user can select either files or directories from the list. If setFile() returns 'true', the user has selected a file listing. So setDir() will not be run The problem I was having is that setFile() would set heading to 'true' but setDir() was still being run. The cause turned out to be in the code below. I had a semicolon after the conditional. I was NOT getting a syntax error. The browser I am using for developement is Firefox v34.0.5 on MacOSX v10.6.8 The presence of the semicolon appears to have had the effect of resetting heading to 'false' when setFile() set it to 'true'. The problem was this: if(heading == 'false'); // <- Notice the semicolon? { heading = setDir(e) }
  9. I have developed a web based file editor that loads text file contents into a textarea element for raw display and editing. However there are problems with this: 1: any closing textarea tag forward slash has to be escaped: <\/textarea> other wise the browser goes berzerk and smears code and markup all over the place. 2: The browser will remove escapes when the content is posted, so all escapes have to be doubled: <\\/textarea>, then the extra escape has to be added by code when the file content is loaded into the textarea for edit. That means: generally inside pre tags and in modal dialogs when the text string is composed by javascript code. Or, in strings precomposed and printed/echoed by php in html markup. new line sequences E.G. '\n' or '\n\r' Also: double quotes E.G. " \" \" " single quotes E.G. ' \'\' ' apostrophes inside of single quotes E.G. ' can\'t ' And regular expressions in code and etc. My question is: How to detect and escape backslashes in any circumstance? Would this be less of a problem with wiki editing? (any developers working on this forum have any tips?) Here is what I have so far: (naming variables with $_varName is just my style) // </textArea> being the only html tag with 'text' in the name $_fileStr = str_replace('</text', '<\\\/text', $_fileStr); $_fileStr = str_replace('\n', '\\\\n', $_fileStr); $_fileStr = str_replace('\"', '\\\\"', $_fileStr); $_fileStr = str_replace('\'', "\\\\'", $_fileStr); But: $_fileStr = str_replace('\', "\\\\", $_fileStr); Appears to cause my BBedit text editor syntax color coding to break down and I assume it will not fly with the php interpreter either.
  10. I have a project that uses javascript window.open to open a window that loads a php enabled html form page. When the window is originally opened, it opens in the expected separate window. BUT, if I use one of the buttons assigned event handlers that call form.submit()* (method is set to post) * in the separate window. This is a self processing html/php form page. The resulting page opens in a new browser tab with the original window still opened but unresponsive to events. I am developing in Firefox 34.0.5. But I am assuming that this would be encountered on any DOM browser type and version. This is the first time I have encountered this phenom, even in this same project. What could be causing Firefox to open a new tab for the same html/php file? Possibly a js var naming conflct with the target attribute in an html element such as <a> or <form>? EDIT: Yes, that was the problem: I had a variable named 'target' that is supposed to hold path information and then refered to it and had some code manipulations to it in a 'with(document.forms.formName)' block. The result seems to have set the target attribute of the form. But it may be useful to know how to program javascript to open windows in a separate tab intentionally. Thanks for time and attention JK
  11. EDITED: While waiting for a reply, I have figured out the solution to this problem: The path info is wrong. All of the sub dirs have an index.php file and '.' and '..' And most have identical sets of directories such as php, js, css, and img. So, I am using scandir() to get the file list but it doesn't provide the necessary path info for each listing. I have to add that for the other functions to find and process the files properly. Maybe some else will see and benefit from this. Hello; I have a project that is run on a FreeBSD server and I am running into problems I can't figure out with code that is supposed to list directory contents in the servers file system, along with user and wrx and octal file perms for each entry. So, the problem is that a directory listing for a directory below the 'home' directory will only successfully list the following: . .. index.php any directory (mostly, there is one dir where sub dirs are also not showing up) all other files return errors for function code I have for getting wrx perms. The same is true for results of calls to stat() and other related function code such as fileperms(). index.php IS a file, so why would the other 'files' fail to produce results? Any ideas? Any similar experience and solutions? Ownership issues? (why would index.php go through with the same ownership and perms?) file corruption? inadequate php ini settings? Sample output follows: Sample of home directory listing (default for the user interface display) Owner type and permissions Octal value Name jekftp d : dir | r w x r w x r w x 0777 . jekftp d : dir | r w x r - x r - x 0755 .. jekftp - : file | r w x r w x r - - 0774 BTO.php jekftp - : file | r w - r - - r - - 0644 B_shebangInCShell.txt jekftp - : file | r w - r - - r - - 0644 adminUPLD.php jekftp - : file | r w - r - - r w - 0646 browserDev.txt jekftp - : file | r w - r - - r - - 0644 clear.php server - : file | r w - r - - r - - 0644 codeSamples.txt jekftp - : file | r w - r - - r - - 0644 console.php jekftp - : file | r w - r w - r w - 0666 consoleTestGrid.txt server - : file | r w - r - - r - - 0644 consoleTestGridCopy.txt jekftp - : file | r w - r - - r - - 0644 console_help.php jekftp d : dir | r w x r - x r - x 0755 css server - : file | r w - r w - r w - 0666 customSelector.php jekftp - : file | r w - r - - r - - 0644 dirIndex.php jekftp - : file | r w - r - - r - - 0644 dirLstDev.php jekftp d : dir | r w x r w x r w x 0777 dist jekftp - : file | r w - r - - r - - 0644 editorComments.txt jekftp - : file | r w - r - - r - - 0644 file_browser.php jekftp - : file | r w - r - - r - - 0644 file_browserEXP.php jekftp - : file | r w - r - - r - - 0644 file_browser_old.php jekftp - : file | r w - r - - r - - 0644 file_editor.php jekftp - : file | r w - r - - r - - 0644 file_editor_help.php jekftp - : file | r w - r - - r - - 0644 getServerName.php jekftp - : file | r w - r - - r w - 0646 goForIt.txt ==================================================== directory listing USING THE SAME CODE with errors: (there were also php related errors appearing in with html above the doctype declaration about fileperms failing that I have supressed with @) Current Directory: dev_lab_current/lab_1 Owner type and permissions Octal value Name jekftp d : dir | r w x r w x r w x 0777 . jekftp d : dir | r w x r - x r - x 0755 .. _CONSOLE -> getWRXPerms error: conf_lab_1.php was not found, or is not a file or directory 0 conf_lab_1.php jekftp d : dir | r w x r - x r - x 0755 css jekftp d : dir | r w x r - x r - x 0755 img jekftp - : file | r w - r - - r - - 0644 index.php jekftp d : dir | r w x r - x r w x 0757 js _CONSOLE -> getWRXPerms error: lab_editor.php was not found, or is not a file or directory 0 lab_editor.php _CONSOLE -> getWRXPerms error: lab_interface.php was not found, or is not a file or directory 0 lab_interface.php _CONSOLE -> getWRXPerms error: lab_reader.php was not found, or is not a file or directory 0 lab_reader.php _CONSOLE -> getWRXPerms error: lab_sampler.php was not found, or is not a file or directory 0 lab_sampler.php jekftp d : dir | r w x r w x r w x 0777 php _CONSOLE -> getWRXPerms error: text was not found, or is not a file or directory 0 text
  12. Thankyou Moderator: I thought that null would remove the property because null is used to remove a select element option. So, it appears that it is not just a value here, at least. I am using O'Reilly's Javascript: the Definitive Guide, 6th ed for guidance where possible but it does not mention delete.
  13. I have this code: if(active[active.id].group.propertyIsEnumerable(selection)) { alert(selection) active[active.id].group[selection] = null; } That is looking for a particular property (selection) and is supposed to remove it from the object. In this case setting it to null, I thought, would remove the specific property so it would no longer be defined and therefore not be enumerable. But it does not seem to, as demonstrated by var test for(var x in active[active.id].group) { test += "n"+x; // new line in DOM browsers } alert(test) // The selection property continues to be listed. Am I doing something wrong, or is there another way to remove the property altogether? I have nit picked through the exact string construction for any differences and have not found any and, in fact the alert in the first code snip does show up, so I know that selection is a valid property. Thanks for time and attention
  14. Thanks for the cntrl-click suggestion, but trying it out, it turns out to be cmd-click on my system. JK
  15. This is something that I have not worked with in the past, though I have often worked with select/option elements in the past. When I set the type attribute to multiple, I have to shift/click to select more than one item. Then I cannot deselect just one item. Am I doing something wrong, or is this typical behavior. The initial development is being done in FIrefox in Mac OSX. I am developing an application where a user can select items from a different list. The select/option element is added to as the user selects items from the list. The select/option element is to allow the user to remove a selection from the list if he/she changes their mind about a selection and wants to remove it. So: the user selects from a group of items in other elements the item is added to a display of selected items It is also added to the select/option list for potential removal. Allowing multiple selections from this would allow the user to remove multiple selections. With XHTML transitional doctype: <select id="remove" name="remove" size="5" multiple="multiple"> <option id="default" value="">Remove:</option> <!-- options are added here by javascript as user makes selections elsewhere --> </select> It is much easier to add/remove options one at a time. I can remove options with an onchange event listener assigned to the select/option element. Thanks for time and attention; JK
  16. Just to clarify (and not to be argumentative) What I meant by 'private' and 'protected' is that a private variable is one that cannot be set or read from outside of the object instance. And a protect variable is one that can only be set or read, if there is code to set or read it, in an enclosing object instance; If I do function example() { var x = 'this is what x is'; this.y = 'this is visible and setable from outside'; } then: var firstExample = new example() Then : for(var x in firstExample) { if(firstExample.propertyIsEnumerable(x)) { alert(x+' in firstExample is '+firstExample[x]) } } 'x' in firstExample won't come up in an alert That is want I understand to be 'private' in a javascript context. Now, since, in the example I originally used, the firstObj instance is used to create a value for a 'private' variable in the secondObj instance. And the second object instance has code to set and read the firsObj instance: it emulates a protected status in firstObj instance. I also do php programming and have written OOP code and have an understanding of private and protected in that context.
  17. Hello: I believe I have established a design pattern that would establish what other oop languages call protected. It would apply to the variable value and functions returned from _firstObj() to first in _secondObj(). I am really a hobbyist who has been learning bit by bit over a number of years. I don't remember seeing anything in texts like O'Reilly's Javascript: The Definitive Guide, or similar Apress publications that specifically address this issue in javascript. I was wondering if anyone here with more extensive knowledge could evalutate this. I have posted this query not only for my own edification, but for anyone who could benefit from this, who might visit for the learning experience. In this I was experimenting to see if I could set the 'private' variable someVal by using the _firstObj function both as an object construtor and as a normal function call. I have also attached a fully standalone html page that can be used to play with this. function _firstObj(a) { var someVal = a; var setVal = function(d) { someVal = d return 0; } var show = function() { return {'value':someVal} } return {'value':someVal,'show':show,'set':setVal}; }function _secondObj() { var first = new _firstObj('This') // object construtor this.setOtherObjProperty = function(a) { return _firstObj(a) // as a normal function call } this.showFirst = function() { first.show() } this.run = function(c,d) { return first[c](d) } } protectedObjects.html
  18. Thank you for info about target property in form object. I was thinking I may have also created another form element with name 'target' and that was being used due to conflict. As it turns out, for some reason the with block opened in that location was masking out the target variable. I moved the opening of the with block to include the two conditional statements within it. Now it works As a commentary about using with(): I have been writing a single eventHandler function that uses e.target.id to figure out what to do, in a switch block. The switch block often contains code to set and revise hidden fields and do other form related processing, so using with() allows me to not have to use literal document.form reference every time a form element has to be accessed. These references may be in the dozens, spread accross involved case labels. True, it makes it abit harder to debug, having to remember that a particular reference is to a form element. Thank you for time and patience. Sometimes I post due to frustration when I should give it a bit more thought
  19. I shouldn't have to do this here but I have written this function as a function for ajax query to run on completion of query. and there is a with(document.forms.formName) block in which a variable should have been set by preceding code and has not. it is marked with comment: 'BLOCK IN QUESTION' in this block target has lost its value. I have done the same thing elsewhere, frequently in the same project with success. I don't see why target is loosing its value inside the with block; Target should be set in the else if block just prior to the with block. This is part of a cms system file editor that would be processing the creation of a save as file from ajax query. This function should execute submit to open the new saved as file. But the hidden field used to find the file on the server needs to be valid. (forum software is putting icons in place of instances of ' B)') var mkSaveAsFile = function(c, d) // c: return from ajax query, d: display element id { if(c && openSaveAsOnReturn == 'true' && c.indexOf('error:') < 0) { var showRes = function(a, { var tar = document.getElementById( if(!tar) { alert('Display element '+b+' not found'); return; } if(a.indexOf('error') >= 0) { tar.style = "color:#cc3333"; } tar.childNodes[0].data = a } var target = ''; // *** SOLUTION: was to open the with block here and include the two conditional blocks //var tst = (saveAsFileName != saveAsOriginalName); //alert('New '+saveAsFileName+' old:'+saveAsOriginalName+' tst: '+tst) // checks out good if(!saveAsFileName && saveAsOriginalName.indexOf(browserVals['Save As'].replace(base, '')) < 0) { var getOldName = new _getPathInfo(saveAsOriginalName, true); var getNewName = new _getPathInfo(saveAsFileName, true); if(getOldName.basename == getNewName.basename && getOldName.dirname != getNewName.dirname) { target = saveAsOriginalName; } } else if(saveAsFileName && (saveAsFileName != saveAsOriginalName)) { target = saveAsFileName; // <<<< target set here alert('1:target: '+target) // checks out } // BLOCK IN QUESTION with(document.forms.script) { act.value = 'getFile'; alert('2:target '+target) // target == '' if(browserVals['Save As'] != '') { doFile.value = 'UED-'+browserVals['Save As'].replace(base, '')+'/'+target; } else { doFile.value = 'UED-/'+target; } if(confirm('doFile: '+doFile.value)) { //alert('should submit now: doFile: '+doFile.value) submit() //showRes(c, d) } else { c += ': submission aborted' showRes(c, d) } } } else { showRes(c, d) } }
  20. It looks like I provoked a good discussion I have since significantly revised and expanded the utility detects if the input has any instances of / and returns empty dirname value filters out instances of ../ and .. removes unnecressary / returns anonymous object literals instead of setting public member variables.
  21. A short example: for a path string like: someDir/anotherDir/someFile should produce basename: someFIle dirname: someDir/anotherDir (without trailing /, IE someDir/anotherDir/ ) the following is the utility itself, for the sake of sharing: function _getPathInfo(a) { // a: string, dir/file path var getDirName = function(path) { var pathArray = [] pathArray = path.split('/'); pathArray[pathArray.length - 1] = ''; // remove last item var pathOut = pathArray.join('/').replace('//', '/'); return pathOut.substring(0, pathOut.length - 1) // doesn't work: // pathArray.join('/').replace('//', '/').substring(0, this.length - 1); } var getBaseName = function(path) { var pathArray = [] pathArray = path.split('/'); return pathArray[pathArray.length - 1] } this.dirname = getDirName(a); this.basename = getBaseName(a); } In the head script: // testCase is the id of a text input element to enter arbitrary path string // getIt is the id of a button input element to run the code. // alert produces 'basename: here dirname:' for test case input: '/going/to/here' // It should produce 'basename: here dirname: /going/to' window.onload = function() { var test = function(e) { var path = document.getElementById('testCase') if(path && path.value) { var pathInfo = new _getPathInfo(path.value) alert('basename: '+pathInfo.basename+' dirname: '+pathInfo.dirname) } } var tester = document.getElementById('getIt') if(tester) { tester.addEventListener('click', function(e){test(e)}, false) } }
  22. I have developed a utility function for extracting path info from a string containing a (Unix style) file path: basename: the last element in the path dirname: the path info minus the last element. replacing '//' with '/ ' solves situations where there may be empty array items from splitting the path string around '/': the last char in the string may be '/', which would produce an empty array item. Also, if the first char is '/', it will produce and empty array element The last line in the function to get dirname is return pathArray.join('/').replace('//', '/').substring(0, this.length - 1); replacing '//' on the end will produce '/', so that is remove in substring call (but as I write this it is evident that it needs a bit of work: do substring call only if the last char is in fact '/') it doesn't work: nothing is returned, not even an error. if I do: var path = pathArray.join('/').replace('//', '/'); return path.substring(0, path.length - 1) I works I would think that since (in the first case) there is no declared variable to receive the results of join() and replace(), that 'this' would refer to the results of join and replace. So, the question is: why wouldn't it? Thanks for time and attention JK
  23. Thank you, Members; I will give it a try. ..... YES.. that did the trick, thanks (using keyup instead of keypress )
  24. I have a project that is primarily a web based text editor. It loads text files from the sites directory structure and puts the contents in a textarea using php on the server side. I want to track changes to the text in the textarea; I assign an event listener to the textarea onload that listens for the onchange event. But when I focus the textarea to begin editing, there doesn's seem to be any of these actions that cause the onchange event. So I change it to onkeypress. Now I get events generated. When the page first loads, the contents in the textarea are copied in a variable that acts like a buffer. So, now I can run code onkeypress that will compare the contents after the keypress to the contents of the buffer and detect a change. That should cause dom insertion of an advice string about unsaved changes. BUT; In the test file, setting the cursor an typing a space does not cause the adice string to appear. Then I backspace over the space I just created. The string should now equal the string in the buffer and remove the advice. But that is not what happens. The unsaved changes string appears. Now, I delete a period at the end of the line, just before the current cursor location. The unsaved changes: the advice string disappears. Then I re-enter the period. Now I see the advice string again. It clearly is not behaving as I would expect it. The following is the relevant js code. It is a portion of a much longer object constructor function: "getButtons()" is run in another public function ( this.init() ) in the window.onload event function _EDITOR() { var getButtons = function() { var buttons = document.getElementsByTagName('INPUT'); if(buttons.length) { for(var i = 0; i < buttons.length; i++) { if(buttons.type == 'button') { buttons.addEventListener('click', function(e){ buttonHandler(e) }, false) } } } var ta = document.getElementById('FT') // textarea id if(ta) { editBuffer = ta.value; ta.addEventListener('keypress', function(e){ setSaveChanges(e)}, false) } } var editBuffer = ""; var setSaveChanges = function(e) { var advise = document.getElementById('SAstat') // span element id if(advise) { if(e.target.value != editBuffer) { advise.style = "color:#cc6666"; advise.childNodes[0].data = "Unsaved changes"; } else if(e.target.value == editBuffer) // if the textarea version == the editBuffer version { advise.style = "color:#000033"; advise.childNodes[0].data = ""; } } } // the following is called the window.onunload event this.clearEditBuffer = function() { editBuffer = ""; } // ....etc ... It appears that maybe the editBuffer variable is also being revised(?) Thanks for time attention and patience. JK
  25. This is the revised version of the code I posted and then took down because it didn't work. This does (just to clearify, this is for finding select/option selection value) argument 'a' would be the document.forms.formName.selectOptionGroupName reference function _getOptSelect(a) { var group = a; var getSelection = function() { return group.options[group.selectedIndex].value; } this.selectVal = getSelection() } This is used to create an instance of the object: var find = new _getOptSelect(<form object reference>) and the value will be in find.selectVal Thanks but I don't use jQuery because it seems to me that to use it effectively, you have to know what it does under the hood. And I am pretty sure that this is what it does under the hood.
×
×
  • Create New...