Class: RWDWindow
Direct Known Subclasses
Constant Summary collapse
- @@windows =
Kind of caching.
{}
- @@helpwindows =
Kind of caching.
{}
Instance Method Summary collapse
-
#initialize(rwd, window = nil) ⇒ RWDWindow
constructor
A new instance of RWDWindow.
- #render(pda, action = nil, vars = Hash.new, switches = Hash.new, help = false, tab = "") ⇒ Object
Constructor Details
#initialize(rwd, window = nil) ⇒ RWDWindow
Returns a new instance of RWDWindow.
654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 |
# File 'lib/rwd/rwd.rb', line 654 def initialize(rwd, window=nil) rwd = rwd.join("\n") if rwd.kind_of?(Array) if @@windows[rwd].nil? @@windows[rwd] = {} @@helpwindows[rwd] = {} tree = XML.new(rwd) tree.parse(OpenTag, "window") do |type, obj| $rwd_appvars.each{|k, v| obj.args[k] = v} @@windows[rwd][obj.args["name"]] = obj.to_h end tree.parse(OpenTag, "helpwindow") do |type, obj| $rwd_appvars.each{|k, v| obj.args[k] = v} @@helpwindows[rwd][obj.args["name"]] = obj.to_h end end @rwd = (@@windows[rwd][window] or "").dup @helprwd = (@@helpwindows[rwd][window] or "").dup end |
Instance Method Details
#render(pda, action = nil, vars = Hash.new, switches = Hash.new, help = false, tab = "") ⇒ Object
678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 |
# File 'lib/rwd/rwd.rb', line 678 def render(pda, action=nil, vars=Hash.new, switches=Hash.new, help=false, tab="") varshtml = Hash.new varsstring = Hash.new oneormorefields = "" firstaction = "" html = [] vars = vars.deep_dup begin # error wrap vars.each do |key, value| if not key.empty? if value.respond_to? "to_s" @rwd.gsub!(/%%#{key}%%/, value.to_s) @rwd.gsub!(/%#{key}%/, value.to_s.to_html) @helprwd.gsub!(/%%#{key}%%/, value.to_s) @helprwd.gsub!(/%#{key}%/, value.to_s.to_html) varshtml[key] = value.to_s.to_html varsstring[key] = value.to_s end end end windowobject = RWDTree.new(@rwd).children.dup.delete_if{|obj| obj.subtype != "window"}[0] helpobject = RWDTree.new(@helprwd).children.dup.delete_if{|obj| obj.subtype != "helpwindow"}[0] tabsobj = windowobject.children.dup.delete_if{|obj| obj.subtype != "tabs"}[0] if not tabsobj.nil? tabs = tabsobj.children.dup.delete_if{|obj| (not obj.kind_of?(OpenTag)) or (obj.subtype != "tab")} if tab.empty? tab = tabs[0].args["name"] end tabsobj.children.delete_if{|obj| (obj.kind_of?(OpenTag)) and (obj.subtype == "tab") and obj.args["name"] != tab} end if help helpobject.parsetree("prechildren", "postchildren", html, [""], [""], varshtml, varsstring, switches, false, oneormorefields, firstaction, tabs, tab, pda) else windowobject.parsetree("prechildren", "postchildren", html, [""], [""], varshtml, varsstring, switches, (not @helprwd.empty?), oneormorefields, firstaction, tabs, tab, pda) end html = html.join("") # ??? html.gsub!(/%%*[[:alnum:]_\-]+%%*/, "") if not $rwd_debug html.gsub!(/%%/, "%") html.gsub!(/\n\n*/, "\n") if oneormorefields.empty? focus = "" else focus = "document.bodyform.elements[0].focus();" end firstaction = action if windowobject.args.keys.include?("refresh") unless action.nil? html.gsub!(/\$RWD_FIRSTACTION\$/ , firstaction) html.gsub!(/\$RWD_FOCUS\$/ , focus) html end rescue $rwdtinkerlog.error "error in RWDWindow - render method" end |