Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //----------------------------------------------------------------
- //Projeto: Etiquetar Ataques
- //Autor: Nicholas Toby (cheesasaurus@gmail.com)
- //Editor: Marcos Vinicius Dos Santos Marques (Cowboy soberano)
- //Email: marcosvinicius.santosmarques@gmail.com
- //Versão: Br 1.0 - 25/05/2017
- //Changelog:
- // Master > 8.21
- // Br > 8.22
- //------------------------------------
- /*==== Pack Conteudo Tw ====*/
- if(!twcheese)
- var twcheese={};
- twcheese.MassTag = {
- widget: {},
- format: '',
- config: {
- options: [
- {
- name:'Unidade',
- description:'A velocidade unitaria mais lenta estimada',
- defaultLabel:' ',
- enabled: true
- }, {
- name:'Coordenada',
- description:'As coordenadas das tropas de envio da aldeia',
- defaultLabel:' ',
- enabled: true
- }, {
- name:'Jogador',
- description:'O jogador que enviou tropas',
- defaultLabel:' ',
- enabled: true
- }, {
- name:'Duracao',
- description:'A duracao do ataque',
- defaultLabel:' ',
- enabled: false
- }, {
- name:'Distancia',
- description:'A distancia (campos) entre aldeias',
- defaultLabel:' ',
- enabled: false
- }, {
- name:'Retorno',
- description:'A data estimada e as horas que as tropas retornam',
- defaultLabel:' ',
- enabled: false
- }, {
- name:'Enviada',
- description:'A data estimada e a hora em que as tropas foram enviadas',
- defaultLabel:' ',
- enabled: false
- }, {
- name:'Chegada',
- description:'Data e hora da chegada',
- defaultLabel:' ',
- enabled: false
- }, {
- name:'Origem',
- description:'Enviado de Aldeia: Nome (xxx|yyy) KYX',
- defaultLabel:' ',
- enabled: false
- }, {
- name:'Destino',
- description:'Aldeia alvo: Nome (xxx|yyy) KYX',
- defaultLabel:' ',
- enabled: false
- }
- ]
- },
- init: function () {
- this.loadConfig();
- this.widget = this.createWidget();
- this.preview();
- },
- createWidget: function () {
- console.log('opening config widget');
- var widget = document.createElement('div');
- widget.id = 'twcheese_tag_config_container';
- widget.style.display = 'block';
- widget.style.position = 'fixed';
- widget.style.zIndex = 13000;
- widget.style.top = '60px'; //below top menu
- widget.style.left = '50%';
- widget.style.width = '600px';
- widget.style.marginLeft = '-300px';
- widget.style.borderStyle = 'solid';
- widget.style.borderWidth = '1px';
- widget.style.borderRadius = '8px 8px 4px 4px';
- widget.style.borderColor = '#804000 #603000 #402000 #804000';
- widget.style.backgroundColor = '#ffe8cc';
- /*==== title bar ====*/
- var title_bar = document.createElement('div');
- title_bar.style.backgroundColor = '#00FFFF';
- title_bar.style.borderRadius = '8px 8px 0px 0px';
- title_bar.style.cursor = 'move';
- /*==== title ====*/
- var title = document.createElement('span');
- title.innerHTML = "<b><span style=\"color:red;\">ETIQUETAR ATAQUES</span></b>";
- title.style.fontWeight = 700;
- title.style.fontSize = '12px';
- title.marginLeft = '10px';
- title_bar.appendChild(title);
- twcheese.style.popupTitleBar(title_bar, function(){
- twcheese.MassTag.closeWidget();
- });
- /*==== narcissism ====*/
- var contactEle = document.createElement('span');
- contactEle.innerHTML = '<a href="http://www.br.twstats.com/br82/index.php?page=player&id=8270061" target="_blank"><i><span style=\"color:aqua;\">Cowboy Soberano\</span></i><hr><br><span style=\"color:purple;\"> marcosvinicius.santosmarques@gmail.com </span></br><hr></a>';
- contactEle.style.fontSize = '12px';
- contactEle.style.cssFloat = 'right';
- contactEle.style.marginRight = '8px';
- title_bar.appendChild(contactEle);
- widget.appendChild(title_bar);
- $(widget).draggable({handle:'.twcheese_title_bar'});
- var content = document.createElement('div');
- content.id = 'twcheese_tag_config';
- /*==== preview ====*/
- var preview_container = document.createElement('div');
- preview_container.innerHTML = '<b>Pre-visualizacao: </b>';
- preview_container.style.margin = '10px';
- var preview = document.createElement('span');
- preview.id = 'twcheese_MassTag_preview';
- preview.innerHTML = 'blahblahblah';
- preview_container.appendChild(preview);
- content.appendChild(preview_container);
- /*==== config ====*/
- var options = this.config.options;
- var optionsTable = document.createElement('table');
- optionsTable.style.marginLeft = '10px';
- optionsTable.style.width = '580px';
- optionsTable.id = 'twcheese_config_table';
- for(var i=0; i<twcheese.MassTag.config.options.length; i++)
- {
- optionsTable.insertRow(-1);
- optionsTable.rows[i].optionData = options[i];
- optionsTable.rows[i].insertCell(-1);
- optionsTable.className = 'vis';
- /*==== checkbox ====*/
- var checkbox = document.createElement('input');
- checkbox.type = 'checkbox';
- checkbox.checked = options[i].enabled;
- checkbox.onchange = function() {
- twcheese.MassTag.preview();
- this.parentNode.parentNode.optionData.enabled = this.checked;
- twcheese.MassTag.saveConfig();
- };
- optionsTable.rows[i].cells[0].appendChild(checkbox);
- /*==== custom text ====*/
- optionsTable.rows[i].insertCell(-1);
- var label = document.createElement('input');
- label.type = 'text';
- label.size = 10;
- if(options[i].label != null)
- label.value = options[i].label;
- else
- label.value = options[i].defaultLabel;
- label.onkeyup = function(){
- twcheese.MassTag.preview();
- if (!this.value) {
- this.parentNode.parentNode.optionData.label = '';
- } else {
- this.parentNode.parentNode.optionData.label = this.value;
- }
- twcheese.MassTag.saveConfig();
- };
- optionsTable.rows[i].cells[1].appendChild(label);
- /*==== short name ====*/
- optionsTable.rows[i].insertCell(-1);
- optionsTable.rows[i].cells[2].innerHTML = options[i].name;
- /*==== description ====*/
- optionsTable.rows[i].insertCell(-1);
- optionsTable.rows[i].cells[3].innerHTML = options[i].description;
- /*==== handles ====*/
- optionsTable.rows[i].insertCell(-1);
- optionsTable.rows[i].cells[4].innerHTML = '<div style="width: 11px; height:11px; background-image: url(' + image_base + 'sorthandle.png); cursor:move" class="qbhandle" title="Arraste para reordenar"> </div>';
- }
- content.appendChild(optionsTable);
- /*==== buttons ====*/
- var button_container = document.createElement('div');
- button_container.style = 'text-align:center; margin:10px;';
- /*==== label button ====*/
- var label_button = document.createElement('a');
- label_button.className = 'btn';
- label_button.style.marginRight = '5px';
- label_button.innerHTML = "<b><span style=\"color:gold;\">ETIQUETAR</span></b>";
- label_button.onclick = function () {
- twcheese.MassTag.label(twcheese.MassTag.getFormat());
- };
- button_container.appendChild(label_button);
- content.appendChild(button_container);
- widget.appendChild(content);
- document.getElementById('content_value').appendChild(widget);
- $('#twcheese_config_table > tbody').sortable({handle: '.qbhandle', placeholder: 'sortable-placeholder'});
- $('#twcheese_config_table > tbody').on('sortstop', function(){
- twcheese.MassTag.preview();
- twcheese.MassTag.saveConfig();
- });
- return document.getElementById('twcheese_tag_config');
- },
- closeWidget: function () {
- $('#twcheese_tag_config_container').remove();
- },
- getFormat: function () {
- var format = '';
- var inputs = this.widget.getElementsByTagName('input');
- var rows = this.widget.getElementsByTagName('tr');
- for(var i=0; i<twcheese.MassTag.config.options.length; i++){
- if(inputs[i*2].checked)
- {
- format += inputs[i*2+1].value;
- format += '%'+rows[i].optionData.name+'%';
- }
- }
- return format;
- },
- preview: function () {
- document.getElementById('twcheese_MassTag_preview').innerHTML = this.getFormat();
- },
- saveConfig: function () {
- var rows = this.widget.getElementsByTagName('tr');
- var options = new Array();
- for (var i=0; i<twcheese.MassTag.config.options.length; i++) {
- options[i] = rows[i].optionData;
- }
- this.config.options = options;
- localStorage.setItem('twcheese.MassTag.config',JSON.stringify(this.config));
- console.log('config saved');
- },
- loadConfig: function () {
- if (localStorage.getItem('twcheese.MassTag.config')) {
- this.config = JSON.parse(localStorage.getItem('twcheese.MassTag.config'));
- return true;
- } else {
- return false;
- }
- },
- label: function (format) {
- $('#select_all').click();
- $('input[name=label_format]').val(format).parents('form').find('input[name=label]').click();
- }
- };
- /*==== styles ====*/
- if(!twcheese.style)
- twcheese.style = {};
- /**
- * @param element:HTMLElement
- * @param topColor:String
- * @param bottomColor:String
- */
- twcheese.style.bgVertGradient = function(element, topColor, bottomColor)
- {
- element.style.backgroundColor = bottomColor;
- var browser;
- if(/Chrome/.test(navigator.userAgent)|| /AppleWebKit/.test(navigator.userAgent))
- browser = 'webkit';
- else if(/Firefox/.test(navigator.userAgent))
- browser = 'moz';
- else if(window.opera)
- browser = 'o';
- else if(/MSIE/.test(navigator.userAgent))
- browser = 'ms';
- if(browser)
- element.style.background = '-' + browser + '-linear-gradient(top, ' + topColor + ', ' + bottomColor +')';
- };
- /**
- * @param element:HTMLElement
- */
- twcheese.style.popupTitleBar = function (element, exit_function) {
- element.className = 'twcheese_title_bar';
- twcheese.style.bgVertGradient(element, '#52d87e', '#c1517f');
- element.style.height = '22px';
- element.style.padding = '7px';
- /*==== exit button ====*/
- var exit_button = document.createElement('span');
- exit_button.style.backgroundImage = 'url("' + image_base + 'login_close.png")';
- exit_button.style.height = '20px';
- exit_button.style.width = '20px';
- exit_button.style.display = 'inline-block';
- exit_button.style.cssFloat = 'right';
- exit_button.style.cursor = 'pointer';
- exit_button.onclick = exit_function;
- element.appendChild(exit_button);
- };
- /*==== register ====*/
- var script = {
- scriptname: 'Etiquetar Ataques',
- version: 8.21,
- author: 'Nicholas Toby',
- email: 'cheesasaurus@gmail.com',
- broken: false
- };
- $.post(ScriptAPI.url,script);
- /*==== Main ====*/
- if (game_data.screen == 'overview_villages' && game_data.mode == 'incomings') {
- twcheese.MassTag.init();
- } else {
- UI.InfoMessage('Iremos Lhe Redirecionar Para Visualizacoes Gerais...', 3000, 'exito');
- document.location = game_data.link_base_pure + 'overview_villages&mode=incomings';
- };
Add Comment
Please, Sign In to add comment