PageSourceSearch

https://secure.lafoodbank.org/js/don_premium_elements.js

js lafoodbank.org collected 2026-09-24 08:46:38 UTC 10,941 bytes, 125 lines download raw bytes

1/* Compressed by the perl version of jsmin. */
2/* JavaScript::Minifier 0.02 */
3
4var DON_PS_PREM_SELECT_LIST_CLASS='PremiumSelectorSelect';var DON_PS_PREM_RADIO_BUTTON_CLASS='PremiumSelectorRadio';var DON_PS_PREM_NONE_AVAIL_ROW_ID='don_prem_none_avail_row';var DON_PS_PREM_AVAIL_FOR_USER_SPECIFIED_AMT_ROW_ID='don_prem_avail_for_user_specified_amt_row';var DON_PS_NO_SELECTION_PREM_PRODUCT_ID=-1;var DON_PS_PREM_AVAIL_FOR_USER_SPECIFIED_AMT_PRODUCT_ID=-2;var don_ps_premiumInfos=new Array();var don_ps_radio_buttons;var don_ps_searched_for_radios=false;var don_ps_select_list;var don_ps_select_list_clone;var don_ps_searched_for_select=false;var don_premium_map=new Object();var don_ps_value_map=new Object();var don_ps_level_id=0;var don_ps_user_specified_level_id=0;var don_ps_user_specified_value=0;function DonLevelPremiums(_levelId,_levelValue)
5{this.levelId=_levelId;this.levelValue=_levelValue;this.premiumIDs=new Array();}
6DonLevelPremiums.prototype.addPremium=function(_premId)
7{this.premiumIDs[_premId]=_premId;}
8DonLevelPremiums.prototype.hasPremium=function(_premId)
9{return this.premiumIDs[_premId]?true:false;}
10function don_ps_map_premium_to_level(_levelId,_levelValue,_premId)
11{var lvlInfo=don_premium_map[_levelId];if(!lvlInfo){var levelValue=parseInt(_levelValue);lvlInfo=new DonLevelPremiums(_levelId,_levelValue);don_premium_map[_levelId]=lvlInfo;don_ps_value_map[levelValue]=lvlInfo;}
12lvlInfo.addPremium(_premId);}
13function don_ps_getHighestDonLevelPremiums(_userSpecifiedValue)
14{var result=null;var resultValue=0;for(var value in don_ps_value_map){var intValue=parseInt(value);if(intValue>resultValue&&intValue<=_userSpecifiedValue){result=don_ps_value_map[value];resultValue=intValue;}}
15return result;}
16function don_ps_set_selected_level_id(_levelId)
17{don_ps_level_id=_levelId;}
18function don_ps_set_user_specified_level(_levelId)
19{don_ps_user_specified_level_id=_levelId;}
20function don_ps_set_user_specified_value(_value)
21{don_ps_user_specified_value=_value;}
22function don_ps_getRadioButtons()
23{if(!don_ps_radio_buttons&&!don_ps_searched_for_radios){don_ps_searched_for_radios=true;var inputs=document.getElementsByTagName('INPUT');don_ps_radio_buttons=filterByClass(inputs,DON_PS_PREM_RADIO_BUTTON_CLASS);}
24return don_ps_radio_buttons;}
25function don_ps_getSelectList()
26{if(!don_ps_select_list&&!don_ps_searched_for_select){don_ps_searched_for_select=true;var sels=document.getElementsByTagName('SELECT');for(var i=0;(!don_ps_select_list&&(i<sels.length));i++)
27if(isOfClass(sels[i],DON_PS_PREM_SELECT_LIST_CLASS))
28don_ps_select_list=sels[i];if(don_ps_select_list)
29don_ps_select_list_clone=don_ps_select_list.cloneNode(true);}
30return don_ps_select_list;}
31function don_ps_getOrigSelectList()
32{if(!don_ps_select_list_clone)
33don_ps_getSelectList();return don_ps_select_list_clone;}
34function don_ps_reset_select_list()
35{var sel=don_ps_getSelectList();var origSel=don_ps_getOrigSelectList();if(sel&&origSel){don_ps_select_list=origSel.cloneNode(true);don_ps_select_list.selectedIndex=sel.selectedIndex;don_ps_select_list.value=sel.value;Utils.addEvent(don_ps_select_list,'change',don_ps_premiumSelected);sel.parentNode.replaceChild(don_ps_select_list,sel);}
36return don_ps_select_list;}
37function don_ps_filter_by_level(_levelId)
38{var map=don_premium_map[_levelId];var sel=don_ps_reset_select_list();if(sel)
39don_ps_filter_select_by_level(map,sel,_levelId);else{var radios=don_ps_getRadioButtons();if(radios&&radios.length)
40don_ps_filter_radios_by_level(map,radios,_levelId);}}
41function don_ps_filter_by_string_value(_sAmount)
42{var amount=parseCurrency(_sAmount);if(isNaN(amount))amount=0;don_ps_filter_by_value(amount);}
43function don_ps_filter_by_value(_amount)
44{var donLevelPremiums=don_ps_getHighestDonLevelPremiums(_amount);if(donLevelPremiums){var levelId=donLevelPremiums.levelId;don_ps_filter_by_level(levelId);}
45else{don_ps_filter_by_level(don_ps_user_specified_level_id);}}
46function don_ps_filter_radios_by_level(_map,_radios,_levelId)
47{var firstVisible;var lastVisible;var numVis=0;for(var r=0;(r<_radios.length);r++){var id=don_ps_get_premium_id(_radios[r].value);if(don_ps_hide_or_show_premium_radio(_map,_radios[r],id,_levelId,numVis)){numVis++;lastVisible=_radios[r];if(!firstVisible)
48firstVisible=_radios[r];}}
49var unavail=document.getElementById(DON_PS_PREM_NONE_AVAIL_ROW_ID);var availForAmt=document.getElementById(DON_PS_PREM_AVAIL_FOR_USER_SPECIFIED_AMT_ROW_ID);var userSpecifiedSelected=_levelId==don_ps_user_specified_level_id;if((numVis==1)&&firstVisible&&unavail){if(userSpecifiedSelected){hide_element
49(unavail);show_element(availForAmt);}
50else{hide_element(availForAmt);show_element(unavail);}
51hide_element(fc_getFormRow(firstVisible));firstVisible.checked=false;}
52else{hide_element(unavail);hide_element(availForAmt);if(lastVisible){var row=fc_getFormRow(lastVisible);row.className=(firstVisible==lastVisible)?'FormRow':'FormRowLast';}}}
53function don_ps_hide_or_show_premium_radio(_map,_element,_id,_levelId,_numVisible)
54{var showIt=((_id<=0)||(_map&&_map.hasPremium(_id)));if(showIt){var row=fc_getFormRow(_element);show_element(row);row.className=_numVisible?'FormRowMiddle':'FormRowFirst';}
55else{hide_element(fc_getFormRow(_element));if(_element.checked)
56_element.checked=false;}
57return showIt;}
58function don_ps_filter_select_by_level(_map,_select,_levelId)
59{for(var op=(_select.options.length-1);(op>=0);op--){var opt=_select.options[op];var id=don_ps_get_premium_id(opt.value);don_ps_hide_or_show_premium_option(_map,opt,id,_levelId);if(op>_select.options.length)
60op=_select.options.length;}
61if(_select.selectedIndex>0){var opt=_select.options[_select.selectedIndex];if(opt.style.display=='none'){_select.options[0].selected=true;_select.selectedIndex=0;_select.value=_select.options[0].value;}}
62don_ps_simulateSelection(_select);}
63function don_ps_hide_or_show_premium_option(_map,_element,_id,_levelId)
64{if(_id>0){if((!_map||!_map.hasPremium(_id))){removeOptionElement(_element);}}
65else{if(_id==DON_PS_NO_SELECTION_PREM_PRODUCT_ID&&_levelId==don_ps_user_specified_level_id)
66removeOptionElement(_element);else if(_id==DON_PS_PREM_AVAIL_FOR_USER_SPECIFIED_AMT_PRODUCT_ID&&_levelId!=don_ps_user_specified_level_id)
67removeOptionElement(_element);}}
68function removeOptionElement(_element)
69{if(_element.tagName=='OPTION'){if(_element.parentNode.tagName=='OPTGROUP')
70_element.parentNode.parentNode.removeChild(_element.parentNode);else
71_element.parentNode.removeChild(_element);}}
72function don_ps_PremiumInfo(_select,_contentHolder)
73{subclass(this,new FCDynamicMessageInfo(_select,_contentHolder));}
74function don_ps_addPremiumInfo(_pi)
75{don_ps_premiumInfos.push(_pi);}
76function don_ps_findPremiumInfoDiv(select,premiumID)
77{var divID="donation_premium_info."+premiumID;var api=don_ps_findPremiumInfoDivs(select);for(var i=0;i<api.length;i++){if(api[i].id==divID)
78return api[i];}
79return null;}
80function don_ps_findPremiumInfoDivs(select)
81{var premiumInfos=new Array();var cell=getAncestor('TD',select);if(cell){var divs=cell.getElementsByTagName('DIV');for(var i=0;i<divs.length;i++){var div=divs[i];if(isOfClass(div,'DonationPremiumInfo')){premiumInfos.push(div);}}}
82return premiumInfos;}
83function don_ps_get_premium_id(_value)
84{var idxDot=_value.indexOf('.');return(idxDot!=-1)?_value.substring(0,idxDot):_value;}
85function don_ps_showPremiumMessage(el)
86{var div;var value=get_input_value(el);if(value){var id=don_ps_get_premium_id(value);div=don_ps_findPremiumInfoDiv(el,id);}
87fc_showOtherMessage(el,div,'PremiumInfoBlock');}
88function don_ps_configSelected(_evt)
89{_evt=_evt?_evt:event;var el=_evt.target?_evt.target:_evt.srcElement;var radio=fc_getPeerByClass(el,DON_PS_PREM_RADIO_BUTTON_CLASS);if(radio)
90radio.checked=true;}
91function don_ps_premiumSelected(_evt)
92{_evt=_evt?_evt:event;var el=_evt.target?_evt.target:_evt.srcElement;don_ps_showPremiumMessage(el);}
93function don_ps_initPremiumInfo()
94{var select=don_ps_getSelectList();if(select){hide_element(DON_PS_PREM_NONE_AVAIL_ROW_ID);hide_element(DON_PS_PREM_AVAIL_FOR_USER_SPECIFIED_AMT_ROW_ID);var premiumInfos=don_ps_findPremiumInfoDivs(select);for(var j=0;j<premiumInfos.length;j++){var premiumInfo=premiumInfos[j];var premiumID=premiumInfo?premiumInfo.id:'';don_ps_addPremiumInfo(new don_ps_PremiumInfo(select,premiumInfo));}
95var row=fc_getFormRow(select);if(row){show_element(row);var submit=fc_getChildByClass(row,'DonPremiumSubmit');if(submit)
96submit.value='true';}
97Utils.addEvent(select,'change',don_ps_premiumSelected);}
98var radios=don_ps_getRadioButtons();for(var r=0;(radios&&(r<radios.length));r++){var cfgList=fc_getPeerByClass(radios[r],'PremiumSelectorConfigSelect');if(cfgList&&(cfgList.tagName=='SELECT')){Utils.addEvent(cfgList,'change',don_ps_configSelected);}}
99var spans=document.getElementsByTagName('SPAN');for(var i=0;i<spans.length;i++){if(isOfClass(spans[i],'DonPremiumDeleteThisRow'))
100hide_element(fc_getFormRow(spans[i]));}}
101function don_ps_checkInitial()
102{var select=don_ps_getSelectList();if(select)
103don_ps_simulateSelection(select);}
104function don_ps_simulateSelection(_select)
105{var event=new Object();event.target=_select;don_ps_premiumSelected(event);}
106var timerID=0;function don_ps_queue_filter_by_string_value(_component)
107{var sAmount=_component.get();var code="don_ps_filter_by_string_value ('"+sAmount+"')";timerID=setTimeout(code,1000);}
108function don_ps_dequeue_filter_by_value()
109{if(timerID!=0)clearTimeout(timerID);timerID=0;}
110function don_ps_immediate_filter_by_value(_component)
111{var sAmount=_component.get();don_ps_filter_by_string_value(sAmount);}
112function don_ps_LevelChangeObserver()
113{this.observe=function(_event)
114{if(_event.component){don_ps_dequeue_filter_by_value();var levelId=_event.component.get();don_ps_filter_by_level(levelId);if(levelId==don_ps_user_specified_level_id){var amountComp=get_observable_component(_event.component.prefix+levelId+"amount");if(amountComp){don_ps_immediate_filter_by_value(amountComp);}}}}}
115function don_ps_OtherAmountChangeObserver()
116{this.observe=function(_event)
117{var component=_event.component;if(component){var evt=_event.evt;if(evt){var isKeyupEvent=evt.type=="keyup";var isClickEvent=evt.type=="click";var isFocusEvent=evt.type=="focus";if(don_ps_getSelectList()){if(isKeyupEvent||isClickEvent||isFocusEvent){don_ps_immediate_filter_by_value(component);}}
118else{don_ps_dequeue_filter_by_value();if(isKeyupEvent){don_ps_queue_filter_by_string_value(component);}
119else{don_ps_immediate_filter_by_value(component);}}}}}}
120function don_ps_init()
121{don_ps_initPremiumInfo();fc_setDimensions(don_ps_premiumInfos,'PremiumInfoBlock');dl_observeLevelChange(new don_ps_LevelChangeObserver());dl_observeOtherAmountChange(new don_ps_OtherAmountChangeObserver());if(don_ps_level_id>0){if(don_ps_level_id!=don_ps_user_specified_level_id)
122don_ps_filter_by_level(don_ps_level_id);else{don_ps_dequeue_filter_by_value();don_ps_filter_by_value(don_ps_user_specified_value);}}
123don_ps_checkInitial();}
124if(!dl_onload||!dl_onload(don_ps_init))
125Utils.addEvent(window,'load',don_ps_init);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.