<commit_before>package org.jenkinsci.plugins.p4.console;

import hudson.MarkupText;
import hudson.console.ConsoleAnnotator;

public class P4ConsoleAnnotator extends ConsoleAnnotator<Object> {

	private static final long serialVersionUID = 1L;
	private int id = 0;
	private int depth = 0;

	private static String COMMAND = "(p4):cmd:";
	private static String STOP = "(p4):stop:";

	@Override
	public ConsoleAnnotator<Object> annotate(Object context, MarkupText text) {

		String line = text.getText();
		if (line.startsWith(COMMAND)) {
			push(text);
		}

		if (line.startsWith(STOP)) {
			pop(text);
		}

		return this;
	}

	private void push(MarkupText text) {
		text.hide(0, COMMAND.length());

		String head = "<div class=\"titleDiv\">";
		text.addMarkup(COMMAND.length(), head);

		StringBuffer sb = new StringBuffer();
		sb.append(" <a class=\"linkDiv\" id=\"");
		sb.append("p4title" + id);
		sb.append("\" href=\"javascript:toggle('");
		sb.append("p4content" + id);
		sb.append("','");
		sb.append("p4title" + id);
		sb.append("');\">");
		sb.append("+");
		sb.append("</a>");
		sb.append("</div>");

		sb.append("<div class=\"contentDiv\">");
		sb.append("<div id=\"");
		sb.append("p4content" + id);
		sb.append("\" style=\"display: none;\">");
		text.addMarkup(text.length() - 1, sb.toString());

		text.hide(text.length() - 1, text.length());
		id++;
		depth++;
	}

	private void pop(MarkupText text) {
		text.hide(0, text.length());

		if (depth > 0) {
			StringBuffer sb = new StringBuffer();<commit_msg>Toggle not work on two pages: "Perforce Software Polling Log" of job and  "Polling Log" of build<commit_after>package org.jenkinsci.plugins.p4.console;

import hudson.MarkupText;
import hudson.console.ConsoleAnnotator;

public class P4ConsoleAnnotator extends ConsoleAnnotator<Object> {

	private static final long serialVersionUID = 1L;
	private int id = 0;
	private int depth = 0;

	private static String COMMAND = "(p4):cmd:";
	private static String STOP = "(p4):stop:";

	@Override
	public ConsoleAnnotator<Object> annotate(Object context, MarkupText text) {

		String line = text.getText();
		if (line.startsWith(COMMAND)) {
			push(text);
		}

		if (line.startsWith(STOP)) {
			pop(text);
		}

		return this;
	}

	private void push(MarkupText text) {
		text.hide(0, COMMAND.length());

		String head = "<div class=\"titleDiv\">";
		text.addMarkup(COMMAND.length(), head);

		StringBuffer sb = new StringBuffer();

		sb.append("<script>\n");
		sb.append("function toggle(showHideDiv, switchTextDiv) {\n");
		sb.append("\tvar tog = document.getElementById(showHideDiv);\n");
		sb.append("\tvar text = document.getElementById(switchTextDiv);\n");
		sb.append("\tif(tog.style.display == \"block\") {\n");
		sb.append("    \ttog.style.display = \"none\";\n");
		sb.append("\t\ttext.innerHTML = \"+\";\n");
		sb.append("  \t}\n");
		sb.append("\telse {\n");
		sb.append("\t\ttog.style.display = \"block\";\n");
		sb.append("\t\ttext.innerHTML = \"-\";\n");
		sb.append("\t}\n");
		sb.append("}\n");
		sb.append("</script>");

		sb.append(" <a class=\"linkDiv\" id=\"");
		sb.append("p4title" + id);
		sb.append("\" href=\"javascript:toggle('");
		sb.append("p4content" + id);
		sb.append("','");
		sb.append("p4title" + id);
		sb.append("');\">");
		sb.append("+");
		sb.append("</a>");
		sb.append("</div>");

		sb.append("<div class=\"contentDiv\">");
		sb.append("<div id=\"");
		sb.append("p4content" + id);
		sb.append("\" style=\"display: none;\">");
		text.addMarkup(text.length() - 1, sb.toString());

		text.hide(text.length() - 1, text.length());
		id++;
		depth++;
	}

	private void pop(MarkupText text) {
		text.hide(0, text.length());

		if (depth > 0) {
			StringBuffer sb = new StringBuffer();
{'fraction_non_alphanumeric': 0.20853462157809985, 'fraction_numerical': 0.008588298443370907, 'mean_word_length': 4.0845839017735335, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2144815', 'n_tokens_mistral': 1443, 'n_tokens_neox': 1310, 'n_words': 277}