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;k<133;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;k<133;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;k<132;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(){
Effect.Appear('system'+system_index+'');
Effect.Appear('system'+system_index+'_sysmenu_buttons');
display_mb_system_modules(system_index);
var monkeysays_sys_div =
'system'+system_index+'_monkeysays'+'';
new Effect.Appear(monkeysays_sys_div, { duration: 3.0 });
Effect.Fade(monkeysays_sys_div, { duration: 15.0 });
//Effect.Appear('system'+system_index+'monkeyerrors');
//Effect.Appear('system'+system_index+'_monkeytasks');
set_system_state(system_index,"O");
} });
return false;
}
</code>
Using the getElementsbyClassName could work, thanks for the suggestion. I
might attempt to simplify and try to do that.
I will be replying with my finished code once it works, and i hope it does.
I'm having errors with handling the convention text that I specified as
default,
some sort of error with "split" not defined.? hrmph..
On Monday, October 15, 2012 3:38:56 PM UTC-4, Jason wrote:
>
>
> If $("id") returns null (like in this instance) then the id does not exist
> on the page
>
> This might be handled better using a class on each of the panels and
> simply holding which is the open/minimized index that way you don't have to
> worry about what ids exist
>
>
>
--
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/-/zZ4NRk-G_OAJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.