Re: [Proto-Scripty] Re: Hi, new to group. Having an issue with visible() method. any suggestions?
Thanks Dave, I'm still not sure why my visible() comparison wrapper was registering as null when i originally first attempted to perform the functions, because that looks something like what I first tried. Thanks again to Jason suggestions to use a Hash, I have since modified the interface to utilize two hashes, one for the systems, and one for the 8 modules of each system. the relatively stable navigational interface is working mostly how I want it now. http://monkeypanelcom/demo Sm:)e On Tuesday, October 16, 2012 1:30:17 AM UTC-4, DaveK wrote: To answer your OP directly (not sure if it has been, I didn't notice it). open_div = 'system'+k+''; ... if ($(open_div).visible()==true) { if there is no item with id 'system'+k then $(open_div) returns null (correctly) and so $(open_div).visible() throws an error. (for example if nothing has id='system123' then when k-123 the error wiil throw) You can avoid it with: if ($(open_div)) { if ($(open_div).visible()==true) { Dave -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/k3nbGQ3PkhgJ. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] Re: Hi, new to group. Having an issue with visible() method. any suggestions?
http://monkeypanel.com/demo http://monkeypanel.com/demo oops.. a dot usually works before the 'com' hehe -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/MOTNWle-MywJ. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Hi, new to group. Having an issue with visible() method. any suggestions?
I love prototype and scriptacualous. I don't combine with jquery so i know i am not having a noclonflict headache, and I am just trying to get the visible() function ( http://prototypejs.org/api/element/visible) to not throw null type error exceptions: here is the function I need to fix, syntactically: the function creates an associative array to track which of 33 system panels are either open, unopen, or minimized*: **(the systems are indexed from 100 to 132)* function get_system_states() { var k=0; var sys_array = new Array(); var open_div=''; var min_div=''; for(k=100;k132;k++){ open_div = 'system'+k+''; min_div = open_div+'_minimized'; if ($(open_div).visible()==true) { sys_array[k] = o; // o = open } if ($(min_div).visible()==true) { sys_array[k] = m; // m = minimized } if (($(open_div).visible()==false)($(min_div).visible()==false)) { sys_array[k] = c;// u = unopen } } return sys_array; } Javscript console error says : 1. Uncaught TypeError: Cannot call method 'visible' of null 1. the first IF statement in the for loop is throwing the exception, but I assume I am not assigning the div values correctly? i have found no answers in this group from a text search and from a general google search. is this a single quotation reference? my div id's are dynamically written in php codeignite, which shouldnt really matter. any suggestions for how to properly get the visibility of each div in each current state? thanks!! -pete -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/s8MPSAK2FwMJ. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] Hi, new to group. Having an issue with visible() method. any suggestions?
Yes that's what I am tryingto do but it must be done on a client side, and i want to avoid cookies, I have written some functions for the handling of innerHTML of a hidden div that would hold this index, and will be parsed using string.split method. It should work in theory, I have no desire for the server to handle anything related to helping a client navigate through the system panels. here's the HTML on the page (with linebreaks added for legibility)(: div id=mb_system_state_references style=display:none; 100=U:101=U:102=U:103=U:104=U:105=U:106=U:107=U:108=U:109=U: 110=U:111=U:112=U:113=U:114=U:115=U:116=U:117=U:118=U:119=U: 120=U:121=U:122=U:123=U:124=U:125=U:126=U:127=U:128=U:129=U: 130=U:131=U:132=U/div and here are the functions relevant to how I am handling the current states of the indexes: (sorry if too much code to read): code function get_system_states() { var ref = document.getElementById('mb_system_state_references').innerHTML.toString(); var systemz = split.ref(:); var mb_statez = new Array(); for(k=100;k133;k++) { var n = k-100; var system_statez = systemz[n].split(=); var state = system_statez[1]; mb_statez[n] = state; } // end loop return mb_statez; } // end function function get_system_state(system_index) { system_index+=''; var sys_states = get_system_states(); var n = (parseInt(system_index)-100); return sys_states[n]; } function set_system_state(system_index,state){ var sys_states = get_system_states(); var new_ref_string=; for(k=100;k133;k++) { system_index+=''; //if not the setting we are setting, write its current state and skip to the next iteration if (parseInt(system_index)!=parseInt(k)){ new_ref_string+=''+k+'='+get_system_state(k)+':'; continue; } else { // else, write the new one new_ref_string+=''+k+'='+state+':'; } // end else } // end loop document.getElementById('mb_system_state_references').innerHTML=new_ref_string; return false; } // function function minimize_mb_system(system_index) { if (get_system_state(system_index)=!M) { system_index+=''; var sp_div_id = 'system'+system_index+''; var min_div_id = 'system'+system_index+'_minimized'; Effect.SwitchOff(sp_div_id); Effect.Appear(min_div_id); set_system_state(system_index,M); return false; } else { var warning = system display state is already minimized. did not collapse.; return warning; } } function restore_mb_system(system_index) { if (get_system_state(system_index)=!O) { system_index+=''; var sp_div_id = 'system'+system_index; var min_div_id = 'system'+system_index+'_minimized'; Effect.Appear(''+sp_div_id+''); Effect.SwitchOff(''+min_div_id+''); set_system_state(system_index,O); return false; } else { var warning = system display state is already open. did not restore.; return warning; } } function open_mb_system(system_index) { system_index+='';var k=0; var state = get_system_states(); // if system we are opening is minimized, restore it if (state[parseInt(system_index)]==M) { var restore = restore_mb_system(system_index); if (restore!=false) { alert(restore); } } // for every other system that might be open, minimize it for(k=100;k132;k++){ if (k+''==system_index) { continue; } if (state[k] == O) { var minimize = minimize_mb_system(k); if (minimize!=false) { alert(minimize); } } } // end for loop //preload module image rollovers for the system we are opening MM_preloadImages('../../../img/mb_module/black/'+system_index+'_01_MO.jpg', '../../../img/mb_module/black/'+system_index+'_02_MO.jpg', '../../../img/mb_module/black/'+system_index+'_03_MO.jpg', '../../../img/mb_module/black/'+system_index+'_04_MO.jpg', '../../../img/mb_module/black/'+system_index+'_05_MO.jpg', '../../../img/mb_module/black/'+system_index+'_06_MO.jpg', '../../../img/mb_module/black/'+system_index+'_07_MO.jpg', '../../../img/mb_module/black/'+system_index+'_08_MO.jpg'); // get the system HTML from the monkeypanel server new Ajax.Updater({ success: 'system'+system_index+'_container', failure: 'system'+system_index+'_messages' }, '../demo/system_panel/'+system_index+'', { method: 'get' , onComplete: function(){
[Proto-Scripty] Re: Hi, new to group. Having an issue with visible() method. any suggestions?
Thanks for the suggestion, Jason. Most people don't run into this problem because they do not deal with dynamically assigned div ids from javascript variables. I found for what i am doing it was the most efficient way to go about referencing the divs. otherwise, switch statements with 33 cases would have to do, and that was pretty intensive. It does appear that the $(element) wrapper doesn't play nice at all with javascript variables, you actually have to put the quotes exactly as they appear on the div. (unless I am still doing it wrong).. i tried .toString functions, parseInt's, double quotes, single quotes, with and without the $wrapers, etc.. and finally I looked into the prototype.js script and the visible method is really simple, just checks if the display: property of the style attribute is set to none and returns a boolean value, so the workaround is to get the element with the document.getElementbyID (which*does *work fine with javasscript variable as the ID), and do the conditional statement custom. In the process of researching this bug I made a series of alternative functions as a different way to skin the cat. Currently they keep track of which systems are closed, minimized or unopen with some innerHTML in a hidden div that references the index (100-133) with the letter U, M or O, then rewrites the entire string when it changes. the initial div looks like this: (all systems unopened): div id=mb_system_state_references style=display:none;100=U:101=U:102=U:103=U:104=U:105=U:106=U:107=U:108=U:109=U:110=U:111=U:112=U:113=U:114=U:115=U:116=U:117=U:118=U:119=U:120=U:121=U:122=U:123=U:124=U:125=U:126=U:127=U:128=U:129=U:130=U:131=U:132=U/div I have got half of the functions working, you can see what I am working on here: http://monkeypanel.com/demo -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/OHJUzayk4UAJ. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Hi, new to group. Having an issue with visible() method. any suggestions?
whoa i had no idea you could do that with javascript array. i just didn't think the data persistence was possible, even if the window was still open. but it makes perfect sense, and much simpler than what i'm doing now. I will have to give it a shot tomorrow, thank you! On Monday, October 15, 2012 2:15:23 PM UTC-4, Peter Sysko wrote: I love prototype and scriptacualous. I don't combine with jquery so i know i am not having a noclonflict headache, and I am just trying to get the visible() function ( http://prototypejs.org/api/element/visible) to not throw null type error exceptions: here is the function I need to fix, syntactically: the function creates an associative array to track which of 33 system panels are either open, unopen, or minimized*: **(the systems are indexed from 100 to 132)* function get_system_states() { var k=0; var sys_array = new Array(); var open_div=''; var min_div=''; for(k=100;k132;k++){ open_div = 'system'+k+''; min_div = open_div+'_minimized'; if ($(open_div).visible()==true) { sys_array[k] = o; // o = open } if ($(min_div).visible()==true) { sys_array[k] = m; // m = minimized } if (($(open_div).visible()==false)($(min_div).visible()==false)) { sys_array[k] = c;// u = unopen } } return sys_array; } Javscript console error says : 1. Uncaught TypeError: Cannot call method 'visible' of null 1. the first IF statement in the for loop is throwing the exception, but I assume I am not assigning the div values correctly? i have found no answers in this group from a text search and from a general google search. is this a single quotation reference? my div id's are dynamically written in php codeignite, which shouldnt really matter. any suggestions for how to properly get the visibility of each div in each current state? thanks!! -pete -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/dodF3TNhKR0J. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] Re: Hi, new to group. Having an issue with visible() method. any suggestions?
right, i found it: http://api.prototypejs.org/language/dollar-H/ i am used to the idea of assuming zero data persistence in a runtime environment so i'm not sure how this works outside the function scope. in php you have to serialize variables, use a global or superglobal array, use database, files, etc. on a client im used to seeing cookies being used, I am just wondering what the scope limit of this use is, as i am used to treating javacsript variables scope at function level only, passing them being required with get and setter methods I'll try the $H idea and see how it works. Thanks again -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/lqdbv0kJ5NoJ. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] Re: Hi, new to group. Having an issue with visible() method. any suggestions?
fpr what its worth, these are some the handler functions I have created. the logic s fine, but your suggestion is much less work, it seems, and there are a few bugs which i commented out. i am not an expert in JS, its not veryintuitive for me function get_system_states() { var ref = document.getElementById('mb_system_state_references'); var systemz = []; systemz = ref.innerHTML.split(:,33); // innerHTML default state reference (U=Unopen, O=Open, M=Minimized) : //100=U:101=U:102=U:103=U:104=U:105=U:106=U:107=U:108=U:109=U: //110=U:111=U:112=U:113=U:114=U:115=U:116=U:117=U:118=U:119=U: //120=U:121=U:122=U:123=U:124=U:125=U:126=U:127=U:128=U:129=U: //130=U:131=U:132=U var mb_statez = []; for(k=100;k133;k++) { var n = k-100; // system 100 should be index 0, system 132 should be index 32 var sys_string = systemz[n]; var system_statez = sys_string.split(=,2); var state = system_statez[1]; // index 0 should be the system number, index 1 is the letter U, M or O mb_statez[n] = state; } // end loop return mb_statez; } // end function function get_system_state(system_index) { system_index+=''; var s = get_system_states(); var n = (parseInt(system_index)-100); return s[n]; } function set_system_state(system_index,new_state){ var s = []; s=get_system_states(); var n = 0; system_index+=''; var new_ref_string=; //alert('setting new system state: '+new_state); for(k=100;k133;k++) { n = k-100; //if not the setting we are setting, write its current state if ((system_index)==k.toString()) { new_ref_string+=k+'='+new_state; } else { // else, write the new one new_ref_string+=k+'='+s[n]; } // end else new_ref_string+=:; } // end for loop document.getElementById('mb_system_state_references').innerHTML=new_ref_string; //alert('writing new innerHTML as: '+new_ref_string); return false; } // function function minimize_mb_system(system_index) { //if (get_system_state(system_index)==M) //{ system_index+=''; var sp_div_id = 'system'+system_index+''; var min_div_id = 'system'+system_index+'_minimized'; Effect.SwitchOff(sp_div_id); Effect.Appear(min_div_id); set_system_state(system_index,M); return false; //} //else { var warning = system display state is already minimized. did not collapse.; return warning; } } function restore_mb_system(system_index) { //if (get_system_state(system_index)==O) //{ system_index+=''; var sp_div_id = 'system'+system_index; var min_div_id = 'system'+system_index+'_minimized'; Effect.Appear(''+sp_div_id+''); Effect.SwitchOff(''+min_div_id+''); set_system_state(system_index,O); return false; //} //else { var warning = system display state is already open. did not restore.; return warning; } } -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/dQqsVP_C75wJ. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Hi, new to group. Having an issue with visible() method. any suggestions?
for what its worth, these are some the handler functions I have created. the logic is fine, but your suggestion is much less work, it seems, and there are a few bugs which i commented out. there are other functions which will utilize the current state of system panels, namely opening a module that is in a system panel that is not currently open, requires first opening the panel via ajax.updater i am not an expert in JS, its not very intuitive for me. function get_system_states() { var ref = document.getElementById('mb_system_state_references'); var systemz = []; systemz = ref.innerHTML.split(:,33); // innerHTML default state reference (U=Unopen, O=Open, M=Minimized) : //100=U:101=U:102=U:103=U:104=U:105=U:106=U:107=U:108=U:109=U: //110=U:111=U:112=U:113=U:114=U:115=U:116=U:117=U:118=U:119=U: //120=U:121=U:122=U:123=U:124=U:125=U:126=U:127=U:128=U:129=U: //130=U:131=U:132=U var mb_statez = []; for(k=100;k133;k++) { var n = k-100; // system 100 should be index 0, system 132 should be index 32 var sys_string = systemz[n]; var system_statez = sys_string.split(=,2); var state = system_statez[1]; // index 0 should be the system number, index 1 is the letter U, M or O mb_statez[n] = state; } // end loop return mb_statez; } // end function function get_system_state(system_index) { system_index+=''; var s = get_system_states(); var n = (parseInt(system_index)-100); return s[n]; } function set_system_state(system_index,new_state){ var s = []; s=get_system_states(); var n = 0; system_index+=''; var new_ref_string=; //alert('setting new system state: '+new_state); for(k=100;k133;k++) { n = k-100; //if not the setting we are setting, write its current state if ((system_index)==k.toString()) { new_ref_string+=k+'='+new_state; } else { // else, write the new one new_ref_string+=k+'='+s[n]; } // end else new_ref_string+=:; } // end for loop document.getElementById('mb_system_state_references').innerHTML=new_ref_string; //alert('writing new innerHTML as: '+new_ref_string); return false; } // function function minimize_mb_system(system_index) { //if (get_system_state(system_index)==M) //{ system_index+=''; var sp_div_id = 'system'+system_index+''; var min_div_id = 'system'+system_index+'_minimized'; Effect.SwitchOff(sp_div_id); Effect.Appear(min_div_id); set_system_state(system_index,M); return false; //} //else { var warning = system display state is already minimized. did not collapse.; return warning; } } function restore_mb_system(system_index) { //if (get_system_state(system_index)==O) //{ system_index+=''; var sp_div_id = 'system'+system_index; var min_div_id = 'system'+system_index+'_minimized'; Effect.Appear(''+sp_div_id+''); Effect.SwitchOff(''+min_div_id+''); set_system_state(system_index,O); return false; //} //else { var warning = system display state is already open. did not restore.; return warning; } } function open_mb_system(system_index) { system_index+='';var k=0; var state = get_system_states(); // if system we are opening is minimized, restore it var n = parseInt(system_index); if (state[n]==M) { var restore = restore_mb_system(system_index); if (restore!=false) { alert(restore); } } // for every other system taht might be open above it, minimize it for(k=n-1;k=0;k--){ if (k+''==system_index) { continue; } if (state[k] == O) { var minimize = minimize_mb_system(k); if (minimize!=false) { alert(minimize); } } } // end for loop //preload module image rollovers for the system we are opening MM_preloadImages('../../../img/mb_module/black/'+system_index+'_01_MO.jpg', '../../../img/mb_module/black/'+system_index+'_02_MO.jpg', '../../../img/mb_module/black/'+system_index+'_03_MO.jpg', '../../../img/mb_module/black/'+system_index+'_04_MO.jpg', '../../../img/mb_module/black/'+system_index+'_05_MO.jpg', '../../../img/mb_module/black/'+system_index+'_06_MO.jpg', '../../../img/mb_module/black/'+system_index+'_07_MO.jpg', '../../../img/mb_module/black/'+system_index+'_08_MO.jpg'); // get the system HTML from the monkeypanel server