hypersonicplus 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/hdatastructures/hfieldtable.rb +285 -0
- data/lib/hdatastructures/hhash.rb +9 -0
- data/lib/hdatastructures/hlist.rb +100 -0
- data/lib/hdatastructures/hrecord.rb +75 -0
- data/lib/hdatastructures/hspreadfieldtable.rb +129 -0
- data/lib/hdb/hdataloader.rb +75 -0
- data/lib/hdb/hdb.rb +357 -0
- data/lib/hdb/hdb_test.rb +248 -0
- data/lib/hdb/hdbgenerator.rb +211 -0
- data/lib/hdb/hdbi.rb +63 -0
- data/lib/hdb/hdbi_test.rb +133 -0
- data/lib/hdb/hfield.rb +180 -0
- data/lib/hdb/hmysql.rb +99 -0
- data/lib/hdb/hmysql2.rb +96 -0
- data/lib/hdb/hodb.rb +948 -0
- data/lib/hdb/hpgsql.rb +54 -0
- data/lib/hengine/application_controller.rb +204 -0
- data/lib/hengine/hconfiguration.rb +40 -0
- data/lib/hengine/hhotlogger.rb +13 -0
- data/lib/hengine/hlogger.rb +119 -0
- data/lib/hengine/hmalloc.rb +275 -0
- data/lib/hengine/hmoduleloader.rb +15 -0
- data/lib/hengine/hsessiondata.rb +79 -0
- data/lib/hengine/hshareddata.rb +60 -0
- data/lib/hengine/htranslate.rb +40 -0
- data/lib/hengine/hviewloader.rb +99 -0
- data/lib/hinit/hinit.rb +3 -0
- data/lib/hmisc/hcolorize.rb +100 -0
- data/lib/hmisc/hdecoratorfunctions.rb +15 -0
- data/lib/hmisc/hdir.rb +19 -0
- data/lib/hmisc/hhtmlnode.rb +27 -0
- data/lib/hmisc/hinputvalidator.rb +95 -0
- data/lib/hmisc/hio.rb +142 -0
- data/lib/hmisc/hjson.rb +16 -0
- data/lib/hsqlmanager/hpgsqldatabasemanager.rb +76 -0
- data/lib/hsqlmanager/hsqldatabasemanager.rb +349 -0
- data/lib/hsqlmanager/hsqltable.rb +16 -0
- data/lib/husermanager/husermanager.rb +122 -0
- data/lib/hwidgets/haccordionmenu.rb +117 -0
- data/lib/hwidgets/hcheckboxtag.rb +33 -0
- data/lib/hwidgets/hdbactionbuttons.rb +26 -0
- data/lib/hwidgets/hdbcombobox.rb +71 -0
- data/lib/hwidgets/hdbdialogview.rb +190 -0
- data/lib/hwidgets/hdbfilterview.rb +28 -0
- data/lib/hwidgets/hdbtableview.rb +213 -0
- data/lib/hwidgets/hdbview.rb +63 -0
- data/lib/hwidgets/hdivtag.rb +9 -0
- data/lib/hwidgets/hdropdown.rb +44 -0
- data/lib/hwidgets/hformfield.rb +91 -0
- data/lib/hwidgets/hgrouptag.rb +65 -0
- data/lib/hwidgets/hhiddeninputtag.rb +12 -0
- data/lib/hwidgets/hinputtag.rb +55 -0
- data/lib/hwidgets/hlabeltag.rb +30 -0
- data/lib/hwidgets/hmainview.rb +37 -0
- data/lib/hwidgets/hpagination.rb +65 -0
- data/lib/hwidgets/hradiobuttontag.rb +30 -0
- data/lib/hwidgets/hselecttag.rb +32 -0
- data/lib/hwidgets/htableview.rb +262 -0
- data/lib/hwidgets/htabview.rb +84 -0
- data/lib/hwidgets/htextareatag.rb +20 -0
- data/lib/hwidgets/htopnav.rb +85 -0
- data/lib/hwidgets/hwidget.rb +423 -0
- data/lib/hypersonic.rb +9 -0
- metadata +276 -0
@@ -0,0 +1,84 @@
|
|
1
|
+
require "hwidgets/hdivtag"
|
2
|
+
|
3
|
+
class HTabView < HDivTag
|
4
|
+
|
5
|
+
def initialize(tabs, header = nil)
|
6
|
+
super("tabs")
|
7
|
+
@header = header
|
8
|
+
@tabs = tabs
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
def newTab(tabName, tabCaption, selected = false)
|
13
|
+
className = "class='active'" if(selected)
|
14
|
+
return HIO.htmlEcholn("<li #{className}><a data-toggle='tab' href='##{tabName}'>#{tabCaption}</a></li>")
|
15
|
+
end
|
16
|
+
|
17
|
+
def newContain(tabName, text, selected = false)
|
18
|
+
|
19
|
+
active = "in active" if(selected)
|
20
|
+
|
21
|
+
containerDiv = HDivTag.new(class: "tab-pane fade #{active}")
|
22
|
+
containerDiv.set(id: tabName)
|
23
|
+
containerDiv.setInnerHTML(text)
|
24
|
+
return containerDiv.html()
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
def checkSelected()
|
29
|
+
|
30
|
+
isSelected = false
|
31
|
+
@tabs.each do |key, value|
|
32
|
+
if(value.key?(:selected))
|
33
|
+
isSelected = true
|
34
|
+
break
|
35
|
+
end
|
36
|
+
end
|
37
|
+
@tabs[@tabs.keys[0]][:selected] = true if(!isSelected) and @tabs.any?
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
def html()
|
42
|
+
|
43
|
+
self.checkSelected()
|
44
|
+
|
45
|
+
ul = HWidget.new("ul").set(class: "nav nav-tabs")
|
46
|
+
|
47
|
+
content = ""
|
48
|
+
@tabs.each do |key, value|
|
49
|
+
tabName = key
|
50
|
+
tabCaption = value[:tabCaption]
|
51
|
+
content += self.newTab(tabName, tabCaption, value[:selected] == true)
|
52
|
+
end
|
53
|
+
ul.setInnerHTML(content)
|
54
|
+
|
55
|
+
content = HIO.htmlEcholn("<h3>#{@header}</h3>")
|
56
|
+
|
57
|
+
tabContentDiv = HDivTag.new(class: "tab-content")
|
58
|
+
|
59
|
+
@tabs.each do |key, value|
|
60
|
+
tabContain = value[:tabContain]
|
61
|
+
tabContain = tabContain.html() if(tabContain.class <= HWidget)
|
62
|
+
content += self.newContain(key, tabContain, value[:selected] == true)
|
63
|
+
end
|
64
|
+
tabContentDiv.setInnerHTML(content)
|
65
|
+
self << ul << tabContentDiv
|
66
|
+
return super()
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.test1()
|
71
|
+
|
72
|
+
tabs = { :tab1 => {:tabCaption =>"Tab 1", :tabContain => "Tab1 Contain"},
|
73
|
+
:tab2 => {:tabCaption =>"Tab 2", :tabContain => "Tab2 Contain"},
|
74
|
+
:tab3 => {:tabCaption =>"Tab 3", :tabContain => "Tab3 Contain", :selected => true},
|
75
|
+
:tab4 => {:tabCaption =>"Tab 4", :tabContain => "Tab4 Contain"},
|
76
|
+
:tab5 => {:tabCaption =>"Tab 5", :tabContain => "Tab5 Contain"},
|
77
|
+
:tab6 => {:tabCaption =>"Tab 6", :tabContain => "Tab6 Contain"},
|
78
|
+
}
|
79
|
+
return HTabView.new(tabs, "Tabs Controller").html()
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "hwidgets/hinputtag"
|
4
|
+
|
5
|
+
class HTextAreaTag < HInputTag
|
6
|
+
|
7
|
+
attr_accessor
|
8
|
+
|
9
|
+
def initialize(name = "", modelName = "", placeholder = "", label = nil)
|
10
|
+
super(name, modelName, placeholder, label, nil)
|
11
|
+
@tag = "textarea"
|
12
|
+
@type = nil
|
13
|
+
self.setClosedTag()
|
14
|
+
end
|
15
|
+
|
16
|
+
def setSelected(value)
|
17
|
+
set(value: value)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
class HTopNav < HDivTag
|
2
|
+
|
3
|
+
def initialize(items = [])
|
4
|
+
super(class: "hpriority-nav")
|
5
|
+
@items = items
|
6
|
+
end
|
7
|
+
|
8
|
+
def addItem(value)
|
9
|
+
@items << value
|
10
|
+
return self
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
def a(innerHTML = '', icon: nil, **args)
|
15
|
+
|
16
|
+
a = HWidget.new("a", "", args)
|
17
|
+
a << HWidget.new('span', class: icon) if icon
|
18
|
+
a << HWidget.new('span', innerHTML)
|
19
|
+
return a
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
def html()
|
24
|
+
|
25
|
+
@items.each do |value|
|
26
|
+
if(value[:type] == 'link')
|
27
|
+
self << self.a(value[:name], icon: value[:icon], href: value[:href])
|
28
|
+
elsif (value[:type].include? 'menu')
|
29
|
+
type = value[:type].sub('menu', '')
|
30
|
+
containerDiv = HDivTag.new(class: "#{type}container")
|
31
|
+
containerDiv << self.a(value[:name], icon: value[:icon], class: "#{type}item")
|
32
|
+
self << containerDiv
|
33
|
+
menuDiv = HDivTag.new(class: 'menu')
|
34
|
+
value[:content].each do |menuValue|
|
35
|
+
menuDiv << self.a(menuValue[:name], icon: menuValue[:icon], href: menuValue[:href])
|
36
|
+
end
|
37
|
+
containerDiv << menuDiv
|
38
|
+
end
|
39
|
+
end
|
40
|
+
return super
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.test1()
|
44
|
+
|
45
|
+
items = [
|
46
|
+
{type: 'link', name: 'QuickManager', href:'#quickmanager'},
|
47
|
+
{type: 'link', name: 'QuickOrder', href:'#quickorder'},
|
48
|
+
{type: 'link', name: 'Item3', href:'#3'},
|
49
|
+
{type: 'link', name: 'Item4', href:'#4'},
|
50
|
+
{type: 'link', name: 'Item5', href:'#5'},
|
51
|
+
{type: 'link', name: 'Item6', href:'#6'},
|
52
|
+
{type: 'link', name: 'Item7', href:'#7'},
|
53
|
+
{type: 'link', name: 'Item8', href:'#8'},
|
54
|
+
{type: 'link', name: 'Item9', href:'#9'},
|
55
|
+
{type: 'link', name: '', href:'#', icon: 'glyphicon glyphicon-user'},
|
56
|
+
{type: 'more-menu', name: 'More', content: [] },
|
57
|
+
{type: 'other-menu', name: 'Administrator', content: [{type: 'link', name: 'User', href:'#'}] }
|
58
|
+
]
|
59
|
+
return HTopNav.new(items).html()
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.test2()
|
64
|
+
|
65
|
+
items = [
|
66
|
+
{type: 'link', href:'#', icon: 'glyphicon glyphicon-home'},
|
67
|
+
{type: 'link', name: 'Item1', href:'#1'},
|
68
|
+
{type: 'link', name: 'Item2', href:'#2'},
|
69
|
+
{type: 'link', name: 'Item3', href:'#3'},
|
70
|
+
{type: 'link', name: 'Item4', href:'#4'},
|
71
|
+
{type: 'link', name: 'Item5', href:'#5'},
|
72
|
+
{type: 'link', name: 'Item6', href:'#6'},
|
73
|
+
{type: 'link', name: 'Item7', href:'#7'},
|
74
|
+
{type: 'link', name: 'Item8', href:'#8'},
|
75
|
+
{type: 'link', name: 'Item9', href:'#9'},
|
76
|
+
{type: 'more-menu', name: '', icon: 'glyphicon glyphicon-menu-hamburger',
|
77
|
+
content: [{type: 'link', name: 'moreItem', href:'#', icon: 'glyphicon glyphicon-refresh'}] },
|
78
|
+
{type: 'other-menu', name: 'Administrator', icon: 'glyphicon glyphicon-print',
|
79
|
+
content: [{type: 'link', name: 'User', href:'#', icon: 'glyphicon glyphicon-user'}] }
|
80
|
+
]
|
81
|
+
return HTopNav.new(items).html()
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
@@ -0,0 +1,423 @@
|
|
1
|
+
|
2
|
+
class HWidget
|
3
|
+
|
4
|
+
attr_reader :tag
|
5
|
+
|
6
|
+
def setTag(tag)
|
7
|
+
@tag = tag
|
8
|
+
return self
|
9
|
+
end
|
10
|
+
|
11
|
+
def setProperties(properties)
|
12
|
+
@properties = properties
|
13
|
+
return self
|
14
|
+
end
|
15
|
+
|
16
|
+
def setSystemProperties(systemProperties)
|
17
|
+
@systemProperties = systemProperties
|
18
|
+
return self
|
19
|
+
end
|
20
|
+
|
21
|
+
def setPlaceholders(placeholders)
|
22
|
+
@placeholders = placeholders
|
23
|
+
return self
|
24
|
+
end
|
25
|
+
|
26
|
+
def setInnerHTML(innerHTML)
|
27
|
+
@innerHTML = innerHTML
|
28
|
+
return self
|
29
|
+
end
|
30
|
+
|
31
|
+
def setParent(parent)
|
32
|
+
@parent = parent
|
33
|
+
return self
|
34
|
+
end
|
35
|
+
|
36
|
+
def setChilds(childs)
|
37
|
+
@childs = childs
|
38
|
+
return self
|
39
|
+
end
|
40
|
+
|
41
|
+
def getChilds()
|
42
|
+
return @childs
|
43
|
+
end
|
44
|
+
|
45
|
+
def setStyles(styles)
|
46
|
+
@styles = styles
|
47
|
+
return self
|
48
|
+
end
|
49
|
+
|
50
|
+
def setEnablePlaceholder(enablePlaceholder = true)
|
51
|
+
@enablePlaceholder = enablePlaceholder
|
52
|
+
return self
|
53
|
+
end
|
54
|
+
|
55
|
+
def setCloseTag(closeTag)
|
56
|
+
@closeTag = closeTag
|
57
|
+
return self
|
58
|
+
end
|
59
|
+
|
60
|
+
def setSlots(slots)
|
61
|
+
@slots = slots
|
62
|
+
return self
|
63
|
+
end
|
64
|
+
|
65
|
+
def initialize(tag = nil, innerHTML = "", **args)
|
66
|
+
@tag = tag
|
67
|
+
@properties = {}
|
68
|
+
@systemProperties = {}
|
69
|
+
@placeholders = {}
|
70
|
+
@innerHTML = innerHTML
|
71
|
+
@parent = nil
|
72
|
+
@childs = []
|
73
|
+
@styles = {}
|
74
|
+
@enablePlaceholder = false # va automaticamente a true con setPlaceholder
|
75
|
+
@closeTag = true # se false il tag non viene chiuso - serve ad es. per input
|
76
|
+
@slots = {}
|
77
|
+
|
78
|
+
self.set(args)
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
def copyConstructor
|
83
|
+
return Marshal.load(Marshal.dump(self))
|
84
|
+
end
|
85
|
+
"""
|
86
|
+
def method_missing(sym, *args)
|
87
|
+
if sym =~ /^(\w+)=$/
|
88
|
+
self.set($1, args[0])
|
89
|
+
else
|
90
|
+
return self.get(sym.to_s)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
"""
|
94
|
+
# searchType 0: serch only among childs
|
95
|
+
# searchType 1: search top down starting from childs
|
96
|
+
|
97
|
+
def getElementBy(property, value, searchType)
|
98
|
+
|
99
|
+
result = (self.properties.key?(property) and self.properties[properties] == value) ? [self] : nil
|
100
|
+
@childs.each do |child|
|
101
|
+
result << child if child.properties.key?(property) and child.properties[property] == value
|
102
|
+
end
|
103
|
+
@childs.each { |child| result += child.getElementBy(property, value, searchType) } if searchType == 1
|
104
|
+
return result
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
def appendChilds(widgets)
|
109
|
+
widgets.each { |widget| self.appendChild(widget) }
|
110
|
+
return self
|
111
|
+
end
|
112
|
+
|
113
|
+
def appendChild(widget)
|
114
|
+
return self.appendChilds(widget) if widget.class == Array
|
115
|
+
widget.setParent(self)
|
116
|
+
@childs << widget
|
117
|
+
return self
|
118
|
+
end
|
119
|
+
alias_method :<<, :appendChild
|
120
|
+
|
121
|
+
def unset(property)
|
122
|
+
@properties.delete(property)
|
123
|
+
end
|
124
|
+
|
125
|
+
def _set(property, value, overwrite = false)
|
126
|
+
@properties[property] = value if (!@properties.key?(property) || overwrite)
|
127
|
+
#@properties.delete(property) unless (value)
|
128
|
+
return self
|
129
|
+
end
|
130
|
+
|
131
|
+
# set property
|
132
|
+
def set(overwrite: false, **properties)
|
133
|
+
|
134
|
+
properties.each do |property, value|
|
135
|
+
self._set(property, value, overwrite)
|
136
|
+
end
|
137
|
+
return self
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
def buildSignature(function, functionName, *args)
|
142
|
+
|
143
|
+
params = ['this']
|
144
|
+
args.each do |arg|
|
145
|
+
if(arg.class == Symbol)
|
146
|
+
params << arg # se passo un simbolo ad es. event
|
147
|
+
else
|
148
|
+
params << arg.to_js_format
|
149
|
+
end
|
150
|
+
end
|
151
|
+
return "#{function}#{functionName}(#{params.join(",")})"
|
152
|
+
|
153
|
+
end
|
154
|
+
|
155
|
+
|
156
|
+
def addJsFunction(eventName, functionName, *args)
|
157
|
+
|
158
|
+
function = ""
|
159
|
+
if(@properties[eventName])
|
160
|
+
function = "#{@properties[eventName]}; "
|
161
|
+
end
|
162
|
+
|
163
|
+
function = self.buildSignature(function, functionName, *args)
|
164
|
+
|
165
|
+
return self.set("#{eventName}": function, overwrite: true)
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
def storeSlots
|
170
|
+
|
171
|
+
@slots.each do |key, elem|
|
172
|
+
elem.each do |value|
|
173
|
+
self.addJsFunction(key, value[:functionName], *value[:args])
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
178
|
+
|
179
|
+
# supporta piu' funzioni per lo stesso evento
|
180
|
+
# @slots e' un hash di array di hash
|
181
|
+
def _addJsSlot(eventName, functionName, overwrite = false, *args)
|
182
|
+
|
183
|
+
@slots.delete(eventName) if overwrite
|
184
|
+
@slots[eventName] = Array.new() unless(@slots[eventName])
|
185
|
+
@slots[eventName] << {functionName: functionName, args: args}
|
186
|
+
return self
|
187
|
+
|
188
|
+
end
|
189
|
+
|
190
|
+
# addJsSlot is a very powerful function with many options. Example:
|
191
|
+
# - def self.myFunction(id)
|
192
|
+
# return "hello #{id}"
|
193
|
+
# - end
|
194
|
+
# 1) addJsSlot(:ondblclick, :null, {}, "#id", "MyClass.myFunction") # the easiest example
|
195
|
+
# 1) addJsSlot(:ondblclick, "id", {}, "#id", "MyClass.myFunction")
|
196
|
+
# WARNING: the first id is only the parameter passed to myFunction
|
197
|
+
# i can write: addJsSlot(:ondblclick, "name", {}, "#id", "MyClass.myFunction")
|
198
|
+
#
|
199
|
+
# 2) tr.addJsSlot(:ondblclick, "id", {before: "alert('hello')"}, "#id", "HDBTableView.myFunction")
|
200
|
+
# 3) tr.addJsSlot(:ondblclick, "id", {after: "elem.style.color = 'red'; alert('hello')"}, "#id", "HDBTableView.myFunction")
|
201
|
+
# - def self.myFunction(values)
|
202
|
+
# return "hello #{values[:id]} - #{values[:class]}"
|
203
|
+
# - end
|
204
|
+
# 4) tr.addJsSlot(:ondblclick, ["id", "class"], {}, "#id", "HDBTableView.myFunction")
|
205
|
+
#
|
206
|
+
# - def self.myFunction(id, surname)
|
207
|
+
# return "hello #{id]} - #{surname}"
|
208
|
+
# - end
|
209
|
+
# 5) tr.addJsSlot(:ondblclick, "id", {}, "#id", "HDBTableView.myFunction", "Von Karajan")
|
210
|
+
#
|
211
|
+
# - def self.myFunction(id, values)
|
212
|
+
# return "hello #{id]} - #{values[:name]} - #{values[:surname]}"
|
213
|
+
# - end
|
214
|
+
# 6) tr.addJsSlot(:ondblclick, "id", {}, "#id", "HDBTableView.myFunction", {name: "herbert", surname: "Von Karajan"})
|
215
|
+
#
|
216
|
+
# - def self.myFunction(id, values, array)
|
217
|
+
# return "hello #{id} - #{values[:name]} - #{values[:surname]} - #{array}"
|
218
|
+
# - end
|
219
|
+
# 7) tr.addJsSlot(:ondblclick, "id", {}, "#id", "HDBTableView.myFunction", {name: "herbert", surname: "Von Karajan"}, [1,2,3,4,5])
|
220
|
+
# 8) addJsSlot(:ondblclick, ':obj.value', {}, "#id", "MyClass.myFunction") # # mettendo i : il codice js sara' => values = eval('obj.value');
|
221
|
+
|
222
|
+
|
223
|
+
# 1) In this example the element with id = #id is replaced by "hello #{value}"
|
224
|
+
# Warning: if i want replaced the element with name = 'pippo' i must write:
|
225
|
+
# - addJsSlot(:ondblclick, "id", {getElem: "byName"}, "pippo", "MyClass.myFunction")
|
226
|
+
# - addJsSlot(:ondblclick, "id", {getElem: "byName", mode: "set"}, "pippo", "MyClass.myFunction")
|
227
|
+
# other options are: getElem: byId | byName | body - mode: set | add
|
228
|
+
# 2) The same of the previous with alert('hello') at end
|
229
|
+
# 3) The same of the previous with the change the color at end
|
230
|
+
|
231
|
+
# id deve essere un oid
|
232
|
+
def connect(event, receiver, method, attributes: :null, id: "#id", args: nil, overwrite: false, **options)
|
233
|
+
oid = hm().malloc({receiver: receiver, method: method, args: args}, id).obj.object_id.to_s
|
234
|
+
options[:getElem] = "byId" unless options[:getElem]
|
235
|
+
options[:mode] = "set" unless options[:mode]
|
236
|
+
|
237
|
+
cks = Digest::SHA256.hexdigest oid + hc.value("secret_token")
|
238
|
+
cks += "-" + Time.now.to_i.to_s # serve (forse) in caso di riallocazione dello stesso indirizzo di memoria
|
239
|
+
hotLog( "HWidget::connect(id: #{id}, oid: #{oid} - #{options[:hotLog].green}" ) if options[:hotLog]
|
240
|
+
return self._addJsSlot(event, :'return hajax.signalManager', overwrite, attributes, options, id, oid, cks)
|
241
|
+
end
|
242
|
+
|
243
|
+
def get(property)
|
244
|
+
return @properties[property]
|
245
|
+
end
|
246
|
+
|
247
|
+
def replacePlaceholder(str)
|
248
|
+
|
249
|
+
return str unless @enablePlaceholder
|
250
|
+
@placeholders.each do |key, value|
|
251
|
+
str = str.gsub(key, value.to_s)
|
252
|
+
end
|
253
|
+
|
254
|
+
return str
|
255
|
+
|
256
|
+
end
|
257
|
+
|
258
|
+
def hotLog(str)
|
259
|
+
HHotLogger.append(str, "log4widgets")
|
260
|
+
end
|
261
|
+
|
262
|
+
def strProperties()
|
263
|
+
|
264
|
+
propertiesTmp = Marshal.load(Marshal.dump(@properties))
|
265
|
+
self.storeSlots()
|
266
|
+
self.storeStyle()
|
267
|
+
return "" if @properties.empty?
|
268
|
+
|
269
|
+
result = ""
|
270
|
+
@properties.each do |key, value|
|
271
|
+
if(value)
|
272
|
+
value = self.replacePlaceholder(value)
|
273
|
+
result += "#{key}=\"#{value}\" "
|
274
|
+
else
|
275
|
+
result += "#{key} "
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
@properties = propertiesTmp
|
280
|
+
return result
|
281
|
+
|
282
|
+
end
|
283
|
+
|
284
|
+
def openTag()
|
285
|
+
|
286
|
+
return "" unless (@tag)
|
287
|
+
|
288
|
+
slash = (@closeTag) ? "" : "/"
|
289
|
+
result = self.strProperties()
|
290
|
+
return HIO.htmlEcholnOpenBlock("<#{@tag} #{result}#{slash}>")
|
291
|
+
|
292
|
+
end
|
293
|
+
|
294
|
+
def closeTag()
|
295
|
+
return "" unless (@tag)
|
296
|
+
return (@closeTag) ? HIO.htmlEcholnCloseBlock("</#{@tag}>") : ""
|
297
|
+
end
|
298
|
+
|
299
|
+
def reset()
|
300
|
+
@parent = nil
|
301
|
+
@childs = []
|
302
|
+
end
|
303
|
+
|
304
|
+
def html()
|
305
|
+
|
306
|
+
html = @innerHTML
|
307
|
+
@childs.each { |child| html += child.html() }
|
308
|
+
return self.openTag() + HIO.htmlEcholn(html) + self.closeTag()
|
309
|
+
|
310
|
+
end
|
311
|
+
|
312
|
+
def _setStyle(property, value)
|
313
|
+
|
314
|
+
unless (value)
|
315
|
+
@styles.delete(property)
|
316
|
+
return self
|
317
|
+
end
|
318
|
+
@styles[property] = value
|
319
|
+
return self
|
320
|
+
|
321
|
+
end
|
322
|
+
|
323
|
+
# set style
|
324
|
+
def setStyle(**properties)
|
325
|
+
properties.each do |property, value|
|
326
|
+
self._setStyle(property, value)
|
327
|
+
end
|
328
|
+
return self
|
329
|
+
end
|
330
|
+
|
331
|
+
def storeStyle()
|
332
|
+
|
333
|
+
return "" if @styles.empty?
|
334
|
+
|
335
|
+
result = ""
|
336
|
+
@styles.each do |key, value|
|
337
|
+
result += "#{key}:#{value}; "
|
338
|
+
end
|
339
|
+
|
340
|
+
self.set(style: result)
|
341
|
+
|
342
|
+
end
|
343
|
+
|
344
|
+
def setPlaceholder(placeholder, value)
|
345
|
+
|
346
|
+
@enablePlaceholder = true
|
347
|
+
unless (value)
|
348
|
+
@placeholders.delete(placeholder)
|
349
|
+
return self
|
350
|
+
end
|
351
|
+
@placeholders[placeholder] = value
|
352
|
+
return self
|
353
|
+
|
354
|
+
end
|
355
|
+
|
356
|
+
def setSystemProperty(property, value)
|
357
|
+
unless (value)
|
358
|
+
@systemProperties.delete(property)
|
359
|
+
return self
|
360
|
+
end
|
361
|
+
@systemProperties[property] = value
|
362
|
+
return self
|
363
|
+
end
|
364
|
+
|
365
|
+
def getSystemProperty(property)
|
366
|
+
return @systemProperties[property]
|
367
|
+
end
|
368
|
+
|
369
|
+
def setClosedTag(bool=true)
|
370
|
+
@closeTag = bool
|
371
|
+
return self
|
372
|
+
end
|
373
|
+
|
374
|
+
def self.test()
|
375
|
+
widget = HWidget.new('div', "new_div")
|
376
|
+
widget.set(title1: 't1',
|
377
|
+
title2: 't2',
|
378
|
+
title3: 't3',
|
379
|
+
title4: '')
|
380
|
+
widget.set(title2: nil)
|
381
|
+
widget.setStyle(color: 'red')
|
382
|
+
puts widget.openTag
|
383
|
+
puts widget.html
|
384
|
+
puts widget.closeTag
|
385
|
+
end
|
386
|
+
|
387
|
+
|
388
|
+
def self.widgetSpace()
|
389
|
+
|
390
|
+
puts "###########################################################".hight_white
|
391
|
+
puts "# #".hight_white
|
392
|
+
puts "# Hypersonic Object Space #".hight_white
|
393
|
+
puts "# #".hight_white
|
394
|
+
puts "###########################################################".hight_white
|
395
|
+
|
396
|
+
objs = []
|
397
|
+
ObjectSpace.each_object() {|obj| objs << obj if obj.class <= HWidget }
|
398
|
+
objs.each do |obj|
|
399
|
+
puts "#{obj.object_id.to_s.hight_purple}: #{obj.class.to_s.yellow} - #{obj.tag.hight_cyan} #{obj.get(:class)}"
|
400
|
+
end
|
401
|
+
|
402
|
+
#puth ObjectSpace.count_objects
|
403
|
+
|
404
|
+
return "Total Widgets: #{objs.length}".green
|
405
|
+
|
406
|
+
end
|
407
|
+
|
408
|
+
|
409
|
+
end
|
410
|
+
|
411
|
+
def htag(name, properties)
|
412
|
+
|
413
|
+
return HWidget.new(name).set(properties).html()
|
414
|
+
|
415
|
+
end
|
416
|
+
|
417
|
+
def htag2(name, properties)
|
418
|
+
|
419
|
+
return HWidget.new(name).set(properties).setClosedTag(false).html()
|
420
|
+
|
421
|
+
end
|
422
|
+
|
423
|
+
|