Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Snip formatting for documents causing serious lag #14

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions app/funcs/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ function json_format_html($json)
$new_json = "";
$indent_level = 0;
$in_string = false;
$worthItLimit = 4 * 1024;

// If we have to wait forever, it's not worth it.
$worthIt = (strlen($json) > $worthItLimit) ? false : true;

/*
commented out by monk.e.boy 22nd May '08
Expand All @@ -66,7 +70,8 @@ function json_format_html($json)

$json = json_encode($json_obj);
*/
$len = strlen($json);
$len = ($worthIt) ? strlen($json) : $worthItLimit;
// Alternatively, we could show the monochrome version we see when we click on "text" (in the browser)

for($c = 0; $c < $len; $c++)
{
Expand Down Expand Up @@ -144,6 +149,9 @@ function json_format_html($json)
break;
}
}

if (!$worthIt) $new_json.= "<br /><br />---- Trimmed ----";

$new_json = preg_replace_callback("{(<font color=\"blue\">([\da-zA-Z_\.]+)</font>)+}", create_function('$match','
$string = str_replace("<font color=\"blue\">", "", $match[0]);
$string = str_replace("</font>", "", $string);
Expand Down Expand Up @@ -237,4 +245,4 @@ function json_format($json)
return $new_json;
}

?>
?>