Histórico da Página
...
HTML |
---|
<div id="keyWordContainerDiv"></div>
<style>
.Keyword-Container-Wrapper{
width: 100%;
height: auto;
min-height: 30px;
}
.Keyword-Container-Wrapper-Span{
padding: 10px;
background-color: #3572b0;
color: #fff;
margin-right: 10px;
}
.Keyword-Container-Wrapper-Input{
border: 0;
}
</style>
<script>
TOTVS_Keywords = {
Id: 'KeyWord1',
Container: null,
Tags: [],
Init: function(id, nameOfContainer, tags){
this.Id = id;
this.Container = (typeof nameOfContainer === "string") ? document.getElementById(nameOfContainer) : nameOfContainer;
this.Tags = {
Length: 0,
Items: [],
Add: function(item){
if(!item)
return false;
if(!this.Exists(item)){
this.Items[this.Length] = [];
this.Items[this.Length]['Value'] = item;
this.Items[this.Length]['Index'] = this.Length;
this.Items[item] = [];
this.Items[item]['Value'] = item;
this.Items[item]['Index'] = this.Length;
this.Length += 1;
return true;
}
},
AddRange: function(rangeOfItems){
if(!rangeOfItems)
return false;
for(var i = 0; i < rangeOfItems.length; i++){
if(!this.Exists(rangeOfItems[i])){
this.Items[this.Length] = [];
this.Items[this.Length]['Value'] = rangeOfItems[i];
this.Items[this.Length]['Index'] = this.Length;
this.Items[rangeOfItems[i]] = [];
this.Items[rangeOfItems[i]]['Value'] = rangeOfItems[i];
this.Items[rangeOfItems[i]]['Index'] = this.Length;
this.Length += 1;
}
}
return true;
},
Exists: function(item){
if(!item)
return false;
for(var att in this.Items){
if(att == item)
return true;
}
return false;
},
Find: function(item){
if(!item)
return null;
for(var att in this.Items){
if(att == item)
return this.Items[item];
}
return null;
},
IndexOf: function(item){
if(!item)
return null;
var _item = this.Find(item);
if(_item != null)
return _item.Index;
return null;
}
}
this.Tags.AddRange(tags);
},
Build: function(id, nameOfContainer, tags){
this.Init(id, nameOfContainer, tags);
var _keyWordContainerWrapper = document.createElement('div');
_keyWordContainerWrapper.id = this.Id + "_ContainerWrapper";
_keyWordContainerWrapper.className = "Keyword-Container-Wrapper";
var _keyWordContainerWrapperInput = document.createElement('input');
_keyWordContainerWrapperInput.id = _keyWordContainerWrapper.id + "_Input";
_keyWordContainerWrapperInput.name = _keyWordContainerWrapperInput.id;
_keyWordContainerWrapperInput.type = "text";
_keyWordContainerWrapperInput.className = 'Keyword-Container-Wrapper-Input';
_keyWordContainerWrapperInput.onkeypress = function(e){
var _evt = e || window.event;
if (event.which == 13 || event.keyCode == 13) {
var _added = TOTVS_Keywords.Tags.Add(this.value);
if(_added){
var _index = TOTVS_Keywords.Tags.IndexOf(this.value);
var _span = document.createElement('span');
_span.id = this.id + "_" + (_index != null) ? _index : this.value;
_span.name = _span.id;
_span.className = 'Keyword-Container-Wrapper-Span';
_span.innerHTML = this.value;
this.parentNode.insertBefore(_span, this);
this.value = "";
}
return false;
}
}
_keyWordContainerWrapper.appendChild(_keyWordContainerWrapperInput);
this.Container.appendChild(_keyWordContainerWrapper);
for(var i=0; i < this.Tags.Length; i++){
var _span = document.createElement('span');
_span.id = this.id + "_" + this.Tags.Items[i].Index;
_span.name = _span.id;
_span.className = 'Keyword-Container-Wrapper-Span';
_span.innerHTML = this.Tags.Items[i].Value;
_keyWordContainerWrapperInput.parentNode.insertBefore(_span, _keyWordContainerWrapperInput);
}
}
}
window.onload = function() {
var _tagsEl = document.getElementsByClassName('aui-label-split-main');
var _tags = [];
for(var i=0; i < _tagsEl.length; i++){
_tags.push(_tagsEl[i].innerHTML);
}
TOTVS_Keywords.Build('TOTVS_KeyWord', 'keyWordContainerDiv', _tags);
var _interval = setInterval(function(){
if(TOTVS_Keywords.Tags.Length < document.getElementsByClassName('aui-label-split-main').length){
alert('ok');
}
}, 1000);
}
</script> |
Visão Geral
Import HTML Content
Conteúdo das Ferramentas
Tarefas