widgets: generate unique hash at widget instanciation to make it usable by the widgets
This commit is contained in:
parent
9ad8f3320b
commit
62010b7c1b
2 changed files with 9 additions and 7 deletions
|
|
@ -43,12 +43,6 @@ var WidgetManager = function(){
|
|||
}
|
||||
|
||||
|
||||
WidgetManager.prototype.createHash = function(widget) {
|
||||
|
||||
return String(Math.random()).split("").reduce(function(a,b){a=((a<<5)-a)+b.charCodeAt(0);return a&a},0);
|
||||
|
||||
}
|
||||
|
||||
WidgetManager.prototype.createAddressRef = function(widget) {
|
||||
|
||||
return widget.widgetData.preArgs && widget.widgetData.preArgs.length ?
|
||||
|
|
@ -59,7 +53,7 @@ WidgetManager.prototype.createAddressRef = function(widget) {
|
|||
|
||||
WidgetManager.prototype.addWidget = function(widget) {
|
||||
|
||||
var hash = this.createHash(),
|
||||
var hash = widget.hash,
|
||||
address = this.createAddressRef(widget),
|
||||
id = widget.widgetData.id,
|
||||
linkId = widget.widgetData.linkId
|
||||
|
|
|
|||
|
|
@ -8,11 +8,19 @@ module.exports = class _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
static createHash() {
|
||||
|
||||
return String(Math.random()).split("").reduce(function(a,b){a=((a<<5)-a)+b.charCodeAt(0);return a&a},0);
|
||||
|
||||
}
|
||||
|
||||
constructor(widgetData, widgetContainer, widgetHtml) {
|
||||
|
||||
this.container = widgetContainer
|
||||
this.widget = $(widgetHtml)
|
||||
this.widgetData = widgetData
|
||||
this.hash = _widgets_base.createHash()
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue