Hide block with validation message
351029
function resetValidationMessage() {
  var domCache = privateProps.domCache.get(this);

  if (domCache.validationMessage) {
    hide(domCache.validationMessage);
  }

  var input = this.getInput();

  if (input) {
    input.removeAttribute('aria-invalid');
    input.removeAttribute('aria-describedBy');
    removeClass(input, swalClasses.inputerror);
  }
}
1040874
def validate_uncle(cls, block: BaseBlock, uncle: BaseBlock, uncle_parent: BaseBlock) -> None:
        
        if uncle.block_number >= block.number:
            raise ValidationError(
                "Uncle number ({0}) is higher than block number ({1})".format(
                    uncle.block_number, block.number))

        if uncle.block_number != uncle_parent.block_number + 1:
            raise ValidationError(
                "Uncle number ({0}) is not one above ancestor's number ({1})".format(
                    uncle.block_number, uncle_parent.block_number))
        if uncle.timestamp < uncle_parent.timestamp:
            raise ValidationError(
                "Uncle timestamp ({0}) is before ancestor's timestamp ({1})".format(
                    uncle.timestamp, uncle_parent.timestamp))
        if uncle.gas_used > uncle.gas_limit:
            raise ValidationError(
                "Uncle's gas usage ({0}) is above the limit ({1})".format(
                    uncle.gas_used, uncle.gas_limit))
282649
function Validation(config) {
    
    var w = config.writer;
    
    var id = 'validation';
    
    $('#'+config.parentId).append('<div id="'+id+'">'+
            '<div id="'+id+'_buttons"><button type="button">Validate</button><button type="button">Clear</button><button type="button">Help</button></div>'+
            '<ul class="validationList"></ul>'+
        '</div>');
    
    w.event('documentLoaded').subscribe(function() {
        validation.clearResult();
    });
    
    w.event('validationInitiated').subscribe(function() {
        var list = $('#'+id+' > ul');
        list.empty();
        list.append(''+
        '<li class="ui-state-default">'+
            '<span class="loading"></span> Validating...'+
        '</li>');
        showValidation();
    });
    
    w.event('documentValidated').subscribe(function(valid, resultDoc, docString) {
        $('#'+id+'_indicator').hide();
        validation.showValidationResult(resultDoc, docString);
    });
    
    // TODO decouple
    function showValidation() {
        w.layout.ui.center.children.layout1.open('south');
        $('#southTabs').tabs('option', 'active', 0);
    }
    
    /**
     * @lends Validation.prototype
     */
    var validation = {};
    
    /**
     * Processes a validation response from the server.
     * @param resultDoc The actual response
     * @param docString The doc string sent to the server for validation  
     */
    validation.showValidationResult = function(resultDoc, docString) {
        var list = $('#'+id+' > ul');
        list.empty();
        
        docString = docString.split('\n')[1]; // remove the xml header
        
        var status = $('status', resultDoc).text();
        
        if (status == 'pass') {
            list.append(''+
                '<li class="ui-state-default">'+
                    '<span class="ui-icon ui-icon-check" style="float: left; margin-right: 4px;"></span>Your document is valid!'+
                '</li>');
        }
        
        $('warning', resultDoc).each(function(index, el) {
            var id = '';
            
            var type = el.nodeName;
            var message = $(this).find('message').text();
            var path = $(this).find('path').text();
            var elementId = $(this).find('elementId').text();
            var column = parseInt($(this).find('column').text());
            
            if (elementId != '') {
                id = elementId;
            } else if (path != '') {
                var editorPath = '';
                var tags = path.split('/');
                for (var i = 0; i < tags.length; i++) {
                    var tag = tags[i];
                    var tagName = tag.match(/^\w+(?=\[)?/);
                    if (tagName != null) {
                        var index = tag.match(/\[(\d+)\]/);
                        if (index === null) {
                            index = 0;
                        } else {
                            index = parseInt(index[1]);
                            index--; // xpath is 1-based and "eq()" is 0-based
                        }
                        editorPath += '*[_tag="'+tagName[0]+'"]:eq('+index+') > ';
                    }
                }
                editorPath = editorPath.substr(0, editorPath.length-3);
                var docEl = $(editorPath, w.editor.getBody());
                id = docEl.attr('id');
            } else if (!isNaN(column)) {
                var docSubstring = docString.substring(0, column);
                var tags = docSubstring.match(/<.*?>/g);
                if (tags != null) {
                    var tag = tags[tags.length-1];
                    id = tag.match(/id="(.*?)"/i);
                    if (id == null) {
                        if (message.search('text not allowed here') != -1) {
                            // find the parent tag
                            var level = 0;
                            for (var i = tags.length-1; i > -1; i--) {
                                tag = tags[i];
                                if (tag.search('/') != -1) {
                                    level++; // closing tag, add a level
                                } else {
                                    level--; // opening tag, remove a level
                                }
                                if (level == -1) {
                                    var match = tag.match(/id="(.*?)"/i);
                                    if (match != null && match[1]) id = match[1];
                                    break;
                                }
                            }
                        } else {
                            var tagMatch = tag.match(/<\/(.*)>/);
                            if (tagMatch != null) {
                                // it's and end tag, so find the matching start tag
                                var tagName = tagMatch[1];
                                for (var i = tags.length-1; i > -1; i--) {
                                    tag = tags[i];
                                    var startTagName = tag.match(/<(.*?)\s/);
                                    if (startTagName != null && startTagName[1] == tagName) {
                                        id = tag.match(/id="(.*?)"/i)[1];
                                        break;
                                    }
                                }
                            } else {
                                // probably entity tag
                            }
                        }
                    } else {
                        id = id[1];
                    }
                } else {
                    // can't find any tags!
                }
            }
            
            var messageParts;
            var messageDivLoc = message.indexOf(';');
            if (messageDivLoc != -1) {
                messageParts = [message.slice(0, messageDivLoc+1), message.slice(messageDivLoc+2)];
            } else {
                messageParts = [message];
            }
            
            var messageHtml = '<li class="'+(type=='warning'?'ui-state-error':'ui-state-highlight')+'">'+
                '<span class="ui-icon '+(type=='warning'?'ui-icon-alert':'ui-icon-info')+'" style="float: left; margin-right: 4px;"></span>'+
                'Path: '+path+'<br/>'+
                'Message: '+messageParts[0];
            if (messageParts[1] !== undefined) {
                messageHtml += ' <span class="message_more">more...</span><span style="display: none;">'+messageParts[1]+'</span>';
            }
            messageHtml += '</li>';
            
            var item = list.append(messageHtml).find('li:last');
            item.find('[class="message_more"]').click(function() {
                $(this).next('span').show();
                $(this).hide();
            });
            
            item.data('id', id);
        });
        
        list.find('li').click(function() {
            var id = $(this).data('id');
            if (id) {
                w.selectStructureTag(id);
            }
        });
        
        showValidation();
    };
    
    validation.clearResult = function() {
        $('#'+id+'_indicator').hide();
        $('#'+id+' > ul').empty();
    };
    

    $('#'+id+'_buttons button:eq(0)').button().click(function() {
        w.delegator.validate();
    });
    $('#'+id+'_buttons button:eq(1)').button().click(function() {
        validation.clearResult();
    });
    $('#'+id+'_buttons button:eq(2)').button({icons: {primary: 'ui-icon-help'}}).click(function() {
        w.dialogManager.show('help', {
            id: 'validation',
            title: 'Validation Help'
        });
    });
    
    // add to writer
    w.validation = validation;
    
    return validation;
}
129001
function validateModeMsg(node, msg) {
    var validMsg = true;
    var modeProperty = ["mode"];
    var modes = ["Summer", "Winter"];
    var i;

    for (i in modeProperty) {
      if (!(modeProperty[i] in msg.payload)) {
        node.error(
          RED._("blindcontroller.error.mode.missing-property") +
            modeProperty[i],
          msg
        );
        validMsg = false;
      }
    }
    if (validMsg) {
      if (
        msg.payload.mode &&
        (typeof msg.payload.mode != "string" ||
          modes.indexOf(msg.payload.mode) == -1)
      ) {
        node.error(
          RED._("blindcontroller.error.mode.invalid-mode") + msg.payload.mode,
          msg
        );
        validMsg = false;
      }
    }
    return validMsg;
  }
738812
function (blockDef, blockIdx) {
                var block = blockStats[blockIdx];

                /**
                 * 'if' for start block check
                 */
                if (blockDef.start.test(line) === true) {

                    block.lastStartLine = lineNum;

                    if (block.startCount > block.endCount) {
                        generateMessage({
                            pattern: line.trim(),
                            lineNum: block.lastStartLine,
                            caseNum: 1
                        });
                    }

                    block.startCount++;
                }


                /**
                 * 'if' for end block check
                 */
                if (blockDef.end.test(line) === true) {

                    block.lastEndLine = lineNum;

                    if (block.endCount >= block.startCount) {
                        generateMessage({
                            pattern: line.trim(),
                            lineNum: block.lastEndLine,
                            caseNum: 2
                        });
                    }

                    block.endCount++;
                }
            }
15385
function markLoneBlock() {
            if (loneBlocks.length === 0) {
                return;
            }

            const block = context.getAncestors().pop();

            if (loneBlocks[loneBlocks.length - 1] === block) {
                loneBlocks.pop();
            }
        }
1124794
def _make_text_block(name, content, content_type=None):
    """"""
    if content_type == 'xhtml':
        return u'<%s type="xhtml"><div xmlns="%s">%s</div></%s>\n' % \
               (name, XHTML_NAMESPACE, content, name)
    if not content_type:
        return u'<%s>%s</%s>\n' % (name, escape(content), name)
    return u'<%s type="%s">%s</%s>\n' % (name, content_type,
                                         escape(content), name)
898002
function () {
            if (this.validate()) {
                if (this.beforeSubmitEvent.fire()) {
                    this.doSubmit();
                    this.submitEvent.fire();
    
                    if (this.cfg.getProperty("hideaftersubmit")) {
                        this.hide();
                    }
    
                    return true;
                } else {
                    return false;
                }
            } else {
                return false;
            }
        }
1081701
function processBlocks(textString, options, data) {

	var replacer = function replacer(match, $1, $2, $3, $4, $5, $6, offset, input) {
		var out = '',
			dataValue,
			type = String($2),
			key = String($3 || '').trim(),
			blockText = String($5),
			nestedBlocks;

		dataValue = _extract(key, data);

		if (options && typeof options === 'object' && options.strictKeys) {
			if(Number.isNaN(dataValue)) {
				return match;
			}
		}

		nestedBlocks = blockText.match(pattern);
		if (nestedBlocks) {
			blockText = blockText.replace(pattern, function(match, $1, $2, $3, $4, $5, $6, offset, input) {
				var index = match.indexOf($5);
				var length = $5.length;
				var body = $5.replace(/(?:\\*)\[(.+?)(?:\\*)\]/g, "\\[$1]");
				return match.substr(0, index) + body + match.substr(index + length);
			});
		}

		var obj = {}, proto = {}, KEY;
		if (typeof dataValue === 'object' && type === '#') {
			for(KEY in dataValue) {
				obj = {}, proto = {};
				proto.KEY = proto.INDEX = KEY;
				obj[KEY] = proto.VALUE = dataValue[KEY];
				obj.__proto__ = proto;
				if (typeof dataValue[KEY] === 'object' && !isNaN(parseInt(KEY))) {
					obj = dataValue[KEY];
					obj.__proto__ = proto;
				}
				out += renderData(blockText, options, obj, Boolean(options.prefix));
			}
			if (nestedBlocks) {
				out = processBlocks(out, options, data);
			}
		} else if (dataValue && (type === '~' || type === '#')) {
			// block logical truthy
			proto.KEY = proto.INDEX = key;
			proto.VALUE = Boolean(dataValue);
			obj = data;
			obj.__proto__ = proto;

			out += renderData(blockText, options, obj, Boolean(options.prefix));
			if (nestedBlocks) {
				out = processBlocks(out, options, data);
			}
		} else if (!dataValue && (type === '^' || type === '!')) {
			// block logical falsy
			proto.KEY = proto.INDEX = key;
			proto.VALUE = Boolean(dataValue);
			obj = data;
			obj.__proto__ = proto;

			out += renderData(blockText, options, obj, Boolean(options.prefix));
			if (nestedBlocks) {
				out = processBlocks(out, options, data);
			}
		}
		return out;
	};

	var pattern = new RegExp('(\\[\\s*(~|\\^|\\!|#)([^\\r\\n]+)\\s*\\])([\\s]?)([\\s\\S]*?)(\\[\\s*\\/\\3\\s*\\]\\4?)', 'mg');

	if(typeof data === 'object' && data !== null) {
		if (options && typeof options === 'object' && options.prefix) {
			pattern = new RegExp('(\\[\\s*(~|\\^|\\!|#)'+rxquote(String(options.prefix))+'[\\.\\-\\_]([^\\r\\n]+)\\s*\\])(\\s?)([\\s\\S]*?)(\\[\\s*\\/'+rxquote(String(options.prefix))+'[\\.\\-\\_]\\3\\s*\\]\\4?)', 'mg');
		}
		textString = textString.replace(pattern, replacer);
	}

	return textString;
}
545406
function(view, message){
      $('#error_' + view).css({display: 'inline-block'}).text('Error! ' + message);
      setTimeout(function(){
        $('#error_' + view).fadeOut(500);
      }, 3500);
    }
1367364
function hide(element) {
    if (!element || !element.style || typeof element.style.display !== 'string') {
        return;
    }
    element.style.display = "";
}
631886
public void setHidden(final boolean hidden) {
        if (hidden)
            attrMixin.setAttribute(HIDDEN, Boolean.toString(true));
        else
            attrMixin.removeAttribute(HIDDEN);
    }
32563
function formatChange() {
  var mask = document.getElementById('blocklyMask');
  var languagePre = document.getElementById('languagePre');
  var languageTA = document.getElementById('languageTA');
  if (document.getElementById('format').value == 'Manual') {
    Blockly.hideChaff();
    mask.style.display = 'block';
    languagePre.style.display = 'none';
    languageTA.style.display = 'block';
    var code = languagePre.textContent.trim();
    languageTA.value = code;
    languageTA.focus();
    updatePreview();
  } else {
    mask.style.display = 'none';
    languageTA.style.display = 'none';
    languagePre.style.display = 'block';
    updateLanguage();
  }
  disableEnableLink();
}
1000097
protected void onHideComplete() {

        m_animation = null;
        m_messages.clear();
        setBlocking(false);
        setBusy(false);
        restore();
    }
8698
def cut_from_block(html_message):
    """"""
    # handle the case when From: block is enclosed in some tag
    block = html_message.xpath(
        ("//*[starts-with(mg:text_content(), 'From:')]|"
         "//*[starts-with(mg:text_content(), 'Date:')]"))

    if block:
        block = block[-1]
        parent_div = None
        while block.getparent() is not None:
            if block.tag == 'div':
                parent_div = block
                break
            block = block.getparent()
        if parent_div is not None:
            maybe_body = parent_div.getparent()
            # In cases where removing this enclosing div will remove all
            # content, we should assume the quote is not enclosed in a tag.
            parent_div_is_all_content = (
                maybe_body is not None and maybe_body.tag == 'body' and
                len(maybe_body.getchildren()) == 1)

            if not parent_div_is_all_content:
                parent = block.getparent()
                next_sibling = block.getnext()

                # remove all tags after found From block
                # (From block and quoted message are in separate divs)
                while next_sibling is not None:
                    parent.remove(block)
                    block = next_sibling
                    next_sibling = block.getnext()

                # remove the last sibling (or the
                # From block if no siblings)
                if block is not None:
                    parent.remove(block)

                return True
        else:
            return False

    # handle the case when From: block goes right after e.g. <hr>
    # and not enclosed in some tag
    block = html_message.xpath(
        ("//*[starts-with(mg:tail(), 'From:')]|"
         "//*[starts-with(mg:tail(), 'Date:')]"))
    if block:
        block = block[0]

        if RE_FWD.match(block.getparent().text or ''):
            return False
        
        while(block.getnext() is not None):
            block.getparent().remove(block.getnext())
        block.getparent().remove(block)
        return True
865239
def hide(
    input_image_file,
    img_enc,
    secret_message=None,
    secret_file=None,
    img_format=None,
):
    
    from zlib import compress
    from base64 import b64encode

    if secret_file != None:
        with open(secret_file, "r") as f:
            secret_message = f.read()

    try:
        text = compress(b64encode(bytes(secret_message, "utf-8")))
    except:
        text = compress(b64encode(secret_message))

    img = tools.open_image(input_image_file)

    if img_format is None:
        img_format = img.format

    if "exif" in img.info:
        exif_dict = piexif.load(img.info["exif"])
    else:
        exif_dict = {}
        exif_dict["0th"] = {}
    exif_dict["0th"][piexif.ImageIFD.ImageDescription] = text
    exif_bytes = piexif.dump(exif_dict)
    img.save(img_enc, format=img_format, exif=exif_bytes)
    img.close()
    return img
632032
def show(cls, msg=None):
        
        if msg:
            cls.add(msg)

        cls.overlay.show()
        cls.overlay.el.bind("click", lambda x: cls.hide())

        cls.el.style.display = "block"
        cls.bind()