#fixed bugs not handling some special cases in code diff view including subversionmodel.

# partially changed the project catalog view to use ajax to load the project list
This commit is contained in:
hyung-hwan 2015-04-16 15:08:46 +00:00
parent d3b7e8c43e
commit 434a1f8f3f
43 changed files with 849 additions and 240 deletions

View File

@ -103,6 +103,8 @@ class Project extends Controller
{ {
$this->pagination->initialize ($pagecfg); $this->pagination->initialize ($pagecfg);
$data['page_links'] = $this->pagination->create_links (); $data['page_links'] = $this->pagination->create_links ();
$data['req_page_offset'] = $offset;
$data['req_page_size'] = CODEPOT_MAX_PROJECTS_PER_PAGE;
$data['total_num_projects'] = $num_entries; $data['total_num_projects'] = $num_entries;
$data['projects'] = $projects; $data['projects'] = $projects;
$this->load->view ($this->VIEW_CATALOG, $data); $this->load->view ($this->VIEW_CATALOG, $data);
@ -208,9 +210,12 @@ class Project extends Controller
// if ok, take action // if ok, take action
$result = ($mode == 'update')? $result = ($mode == 'update')?
$this->projects->update ($login['id'], $project): $this->projects->update ($login['id'], $project):
$this->projects->create ($login['id'], $project, $api_base_url); $this->projects->create ($login['id'], $project, $api_base_url, $repo_error);
if ($result === FALSE) if ($result === FALSE)
{ {
if ($repo_error)
$data['message'] = 'REPOSITORY ERROR';
else
$data['message'] = 'DATABASE ERROR'; $data['message'] = 'DATABASE ERROR';
$data['project'] = $project; $data['project'] = $project;
$this->load->view ($this->VIEW_EDIT, $data); $this->load->view ($this->VIEW_EDIT, $data);
@ -463,10 +468,100 @@ class Project extends Controller
} }
} }
function search_json ($needle = '') function catalog_json ($filter = '', $offset = '')
{ {
$this->load->model ('ProjectModel', 'projects'); $this->load->model ('ProjectModel', 'projects');
$login = $this->login->getUser ();
if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '')
{
$status = 'signin';
$projects = array();
}
else
{
if ($filter == '')
{
$search->id = '';
$search->name = '';
$search->summary = '';
}
else
{
parse_str ($this->converter->HexToAscii($filter), $search);
if (!array_key_exists ('id', $search)) $search['id'] = '';
if (!array_key_exists ('name', $search)) $search['name'] = '';
if (!array_key_exists ('summary', $search)) $search['summary'] = '';
$search = (object) $search;
}
if ($filter == '' && $offset == '')
{
$offset = 0;
}
else if ($filter != '' && $offset == '')
{
if (is_numeric($filter))
{
$offset = (integer)$filter;
}
else
{
$offset = 0;
}
}
else
{
$offset = (integer) $offset;
}
// get the total number of entries available
$num_entries = $this->projects->getNumEntries ($login['id'], $search);
if ($num_entries === FALSE)
{
$status = 'dberr';
$projects = array ();
}
else
{
// get project entries staring from the offset.
$projects = $this->projects->getEntries ($login['id'], $offset, CODEPOT_MAX_PROJECTS_PER_PAGE, $search);
if ($projects === FALSE)
{
$status = 'dberr';
$projects = array ();
}
else
{
$status = 'ok';
// exclude the description column
foreach ($projects as $p) unset ($p->description);
}
}
}
$result = array (
'status' => $status,
'total_num_projects' => $num_entries,
'req_page_offset' => $offset,
'req_page_size' => CODEPOT_MAX_PROJECTS_PER_PAGE,
'projects' => $projects
);
print codepot_json_encode ($result);
}
function quickfind_json ($needle = '')
{
// this function is to serve the intermediate search
// by the quick project finder in the task bar.
// it returns the array of {id: XXX, value: YYY} in the
// json format.
$this->load->model ('ProjectModel', 'projects');
$login = $this->login->getUser (); $login = $this->login->getUser ();
if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '')
{ {
@ -479,17 +574,16 @@ class Project extends Controller
} }
else else
{ {
$projects = $this->projects->findIDsAndNames ($login['id'], $needle); $needle = $this->converter->HexToAscii($needle);
if ($projects === FALSE) $projects = $this->projects->quickfindEntries ($login['id'], $needle);
{ if ($projects === FALSE) $projects = array ();
$projects = array ();
}
} }
foreach ($projects as &$p) foreach ($projects as &$p)
{ {
$p->value = $p->id . ' - ' . $p->value; if ($p->id != $p->value) $p->value = $p->id . ' - ' . $p->value;
} }
print codepot_json_encode ($projects); print codepot_json_encode ($projects);
} }
} }

View File

@ -29,7 +29,6 @@ if ( ! function_exists('codepot_merge_path'))
} }
if ( !function_exists ('codepot_json_encode')) if ( !function_exists ('codepot_json_encode'))
{ {
function codepot_json_encode( $data ) function codepot_json_encode( $data )

View File

@ -58,9 +58,9 @@ class ProjectModel extends Model
$this->db->select ('count(id) as count'); $this->db->select ('count(id) as count');
$this->db->order_by ('name', 'asc'); $this->db->order_by ('name', 'asc');
if ($search->id != '') $this->db->like ('id', $search->id); if (!empty($search->id)) $this->db->like ('id', $search->id);
if ($search->name != '') $this->db->like ('name', $search->name); if (!empty($search->name)) $this->db->like ('name', $search->name);
if ($search->summary != '') $this->db->like ('summary', $search->summary); if (!empty($search->summary)) $this->db->like ('summary', $search->summary);
$query = $this->db->get ('project'); $query = $this->db->get ('project');
if ($this->db->trans_status() === FALSE) if ($this->db->trans_status() === FALSE)
@ -83,16 +83,16 @@ class ProjectModel extends Model
{ {
$this->db->trans_start (); $this->db->trans_start ();
$this->db->order_by ('name', 'asc'); $this->db->order_by ('name', 'asc');
if ($search->id != '') $this->db->like ('id', $search->id); if (!empty($search->id)) $this->db->like ('id', $search->id);
if ($search->name != '') $this->db->like ('name', $search->name); if (!empty($search->name)) $this->db->like ('name', $search->name);
if ($search->summary != '') $this->db->like ('summary', $search->summary); if (!empty($search->summary)) $this->db->like ('summary', $search->summary);
$query = $this->db->get ('project', $limit, $offset); $query = $this->db->get ('project', $limit, $offset);
$this->db->trans_complete (); $this->db->trans_complete ();
if ($this->db->trans_status() === FALSE) return FALSE; if ($this->db->trans_status() === FALSE) return FALSE;
return $query->result (); return $query->result ();
} }
function findIDsAndNames ($userid, $needle) function quickfindEntries ($userid, $needle)
{ {
$this->db->trans_start (); $this->db->trans_start ();
$this->db->select(array('id', 'name as value')); // jquery ui autocomplete seems to require 'value'. $this->db->select(array('id', 'name as value')); // jquery ui autocomplete seems to require 'value'.
@ -105,9 +105,10 @@ class ProjectModel extends Model
return $query->result (); return $query->result ();
} }
function create ($userid, $project, $api_base_url) function create ($userid, $project, $api_base_url, &$repo_error)
{ {
// TODO: check if userid can do this.. // TODO: check if userid can do this..
$repo_error = FALSE;
$this->db->trans_begin (); // manual transaction. not using trans_start(). $this->db->trans_begin (); // manual transaction. not using trans_start().
@ -169,6 +170,7 @@ class ProjectModel extends Model
if (@svn_repos_create ("{$repodir}/{$project->id}") === FALSE) if (@svn_repos_create ("{$repodir}/{$project->id}") === FALSE)
{ {
$this->db->trans_rollback (); $this->db->trans_rollback ();
$repo_error = TRUE;
return FALSE; return FALSE;
} }
@ -190,6 +192,7 @@ class ProjectModel extends Model
{ {
$this->deleteDirectory ("{$repodir}/{$project->id}"); $this->deleteDirectory ("{$repodir}/{$project->id}");
$this->db->trans_rollback (); $this->db->trans_rollback ();
$repo_error = TRUE;
return FALSE; return FALSE;
} }
@ -199,6 +202,7 @@ class ProjectModel extends Model
{ {
$this->deleteDirectory ("{$repodir}/{$project->id}"); $this->deleteDirectory ("{$repodir}/{$project->id}");
$this->db->trans_rollback (); $this->db->trans_rollback ();
$repo_error = TRUE;
return FALSE; return FALSE;
} }
@ -208,6 +212,7 @@ class ProjectModel extends Model
{ {
$this->deleteDirectory ("{$repodir}/{$project->id}"); $this->deleteDirectory ("{$repodir}/{$project->id}");
$this->db->trans_rollback (); $this->db->trans_rollback ();
$repo_error = TRUE;
return FALSE; return FALSE;
} }
} }

View File

@ -299,22 +299,44 @@ class SubversionModel extends Model
rewind($nfile); rewind($nfile);
} }
// Ignore the 4 header lines $abort = FALSE;
$line = fgets($diff);
$line = fgets($diff);
$line = fgets($diff);
$line = fgets($diff);
// Get the first real line
$line = fgets($diff);
$index = 0; $index = 0;
$listing = array(); $listing = array();
$curoline = 1; $curoline = 1;
$curnline = 1; $curnline = 1;
$abort = FALSE; // Ignore the 4 header lines. AFter that, it get the first real line
// which is the 5th line. The header lines look like this:
//
// Index: test1.txt
// ===================================================================
// --- test1.txt (revision 20)
// +++ test1.txt (revision 22)
//
// The fifth line should look like this:
// @@ -2,5 +2,7 @@
//
for ($i = 0; $i < 5 && !feof($diff); $i++)
{
$line = fgets($diff);
if ($line === FALSE || $line == "\n")
{
// the first line can be empty if there is no contents changes.
// property changes may be following but this function is
// not interested in it.
$abort = TRUE;
break;
}
}
if (!feof($diff) && !$abort)
{
// santy check on the fifth line. something bad must have
// happened if it doesn't begin with @@.
if (strncmp($line, "@@", 2) != 0) $abort = TRUE;
}
while (!feof($diff) && !$abort) while (!feof($diff) && !$abort)
{ {
// Get the first line of this range // Get the first line of this range
@ -437,9 +459,10 @@ class SubversionModel extends Model
{ {
case "\\": case "\\":
// ignore it . // ignore it .
// subversion seems to procude a like like this: // subversion seems to procude a line like this:
// \ No newline at the end of file // \ No newline at the end of file
// //
unset ($listing[$index]); // unset the data filled partially above.
$index--; $index--;
break; break;
@ -447,7 +470,8 @@ class SubversionModel extends Model
$listing[$index]["rev1diffclass"] = "diffdeleted"; $listing[$index]["rev1diffclass"] = "diffdeleted";
$listing[$index]["rev2diffclass"] = "diff"; $listing[$index]["rev2diffclass"] = "diff";
if ($all) { if ($all)
{
fgets($ofile); fgets($ofile);
$curoline++; $curoline++;
} }
@ -493,7 +517,6 @@ class SubversionModel extends Model
$listing[$index]["rev1diffclass"] = "diff"; $listing[$index]["rev1diffclass"] = "diff";
$listing[$index]["rev2diffclass"] = "diffadded"; $listing[$index]["rev2diffclass"] = "diffadded";
//$listing[$index]["rev1line"] = "&nbsp;"; //$listing[$index]["rev1line"] = "&nbsp;";
$listing[$index]["rev1line"] = ''; $listing[$index]["rev1line"] = '';
$listing[$index]["rev2line"] = $text; $listing[$index]["rev2line"] = $text;
@ -525,9 +548,7 @@ class SubversionModel extends Model
} }
} }
if (!$fin) { if (!$fin) $index++;
$index++;
}
} }
} }
@ -537,7 +558,6 @@ class SubversionModel extends Model
while (1) while (1)
{ {
if (feof($ofile) && feof($nfile)) break; if (feof($ofile) && feof($nfile)) break;
$listing[$index]["rev1diffclass"] = "diff"; $listing[$index]["rev1diffclass"] = "diff";
$listing[$index]["rev2diffclass"] = "diff"; $listing[$index]["rev2diffclass"] = "diff";
@ -545,13 +565,12 @@ class SubversionModel extends Model
{ {
$line = rtrim(fgets($ofile), "\r\n"); $line = rtrim(fgets($ofile), "\r\n");
if ($ent) $line = replaceEntities($line, $rep); if ($ent) $line = replaceEntities($line, $rep);
}
if (!feof($ofile)) {
//$listing[$index]["rev1line"] = hardspace($line); //$listing[$index]["rev1line"] = hardspace($line);
$listing[$index]["rev1line"] = $line; $listing[$index]["rev1line"] = $line;
} }
else { else
{
//$listing[$index]["rev1line"] = "&nbsp;"; //$listing[$index]["rev1line"] = "&nbsp;";
$listing[$index]["rev1line"] = ''; $listing[$index]["rev1line"] = '';
} }
@ -560,13 +579,12 @@ class SubversionModel extends Model
{ {
$line = rtrim(fgets($nfile), "\r\n"); $line = rtrim(fgets($nfile), "\r\n");
if ($ent) $line = replaceEntities(rtrim(fgets($nfile), "\r\n"), $rep); if ($ent) $line = replaceEntities(rtrim(fgets($nfile), "\r\n"), $rep);
}
if (!feof($nfile)) {
//$listing[$index]["rev2line"] = hardspace($line); //$listing[$index]["rev2line"] = hardspace($line);
$listing[$index]["rev2line"] = $line; $listing[$index]["rev2line"] = $line;
} }
else { else
{
//$listing[$index]["rev2line"] = "&nbsp;"; //$listing[$index]["rev2line"] = "&nbsp;";
$listing[$index]["rev2line"] = ''; $listing[$index]["rev2line"] = '';
} }

View File

@ -3,8 +3,10 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/code.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/code.css')?>" />
<script type="text/javascript" src="<?php print base_url_make('/js/prettify/prettify.js')?>"></script> <script type="text/javascript" src="<?php print base_url_make('/js/prettify/prettify.js')?>"></script>
<script type="text/javascript" src="<?php print base_url_make('/js/prettify/lang-ada.js')?>"></script> <script type="text/javascript" src="<?php print base_url_make('/js/prettify/lang-ada.js')?>"></script>
<script type="text/javascript" src="<?php print base_url_make('/js/prettify/lang-basic.js')?>"></script> <script type="text/javascript" src="<?php print base_url_make('/js/prettify/lang-basic.js')?>"></script>

View File

@ -3,8 +3,10 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/code.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/code.css')?>" />
<script type="text/javascript" src="<?php print base_url_make('/js/prettify/prettify.js')?>"></script> <script type="text/javascript" src="<?php print base_url_make('/js/prettify/prettify.js')?>"></script>
<script type="text/javascript" src="<?php print base_url_make('/js/prettify/lang-css.js')?>"></script> <script type="text/javascript" src="<?php print base_url_make('/js/prettify/lang-css.js')?>"></script>
<script type="text/javascript" src="<?php print base_url_make('/js/prettify/lang-lisp.js')?>"></script> <script type="text/javascript" src="<?php print base_url_make('/js/prettify/lang-lisp.js')?>"></script>
@ -383,35 +385,32 @@ else
$http_user_agent = $_SERVER['HTTP_USER_AGENT']; $http_user_agent = $_SERVER['HTTP_USER_AGENT'];
$is_msie = (stristr($http_user_agent, 'MSIE') !== FALSE && $is_msie = (stristr($http_user_agent, 'MSIE') !== FALSE &&
stristr($http_user_agent, 'Opera') === FALSE); stristr($http_user_agent, 'Opera') === FALSE);
if (!$is_msie) if (!$is_msie) $is_msie = (preg_match ("/^Mozilla.+\(Windows.+\) like Gecko$/", $http_user_agent) !== FALSE);
{
$is_msie = (preg_match ("/^Mozilla.+\(Windows.+\) like Gecko$/", $http_user_agent) !== FALSE); $diff_view = $fullview? 'fulldiff': 'diff';
}
print '<div style="width: 100%; overflow: hidden;" id="code_diff_mainarea_result_fullview">'; print '<div style="width: 100%; overflow: hidden;" id="code_diff_mainarea_result_fullview">';
if (empty($file['content'])) //
{ // SHOW THE OLD FILE
print htmlspecialchars ($this->lang->line('MSG_NO_DIFF')); //
}
else
{
print ("<div style='float:left; width: 49%;'>"); print ("<div style='float:left; width: 49%;'>");
print "<div class='navigator'>"; print "<div class='navigator'>";
$currev = $file['created_rev']; $currev = $file['created_rev'];
$prevrev = $file['against']['prev_rev']; $prevrev = $file['against']['prev_rev'];
$prevanc = "code/fulldiff/{$project->id}/{$xpar}/{$currev}/{$prevrev}"; $prevanc = "code/{$diff_view}/{$project->id}/{$xpar}/{$currev}/{$prevrev}";
print anchor ($prevanc, '<<'); print anchor ($prevanc, '<<');
print '&nbsp;&nbsp;&nbsp;'; print '&nbsp;&nbsp;&nbsp;';
print $this->lang->line('Revision'); // show the history details of the previous revision at the root directory
print ' '; $revanc = "code/revision/{$project->id}/!/{$prevrev}";
print $file['against']['created_rev']; print anchor ($revanc, ($this->lang->line('Revision') . ' ' . $file['against']['created_rev']));
$currev = $file['created_rev']; $currev = $file['created_rev'];
$nextrev = $file['against']['next_rev']; $nextrev = $file['against']['next_rev'];
$nextanc = "code/fulldiff/{$project->id}/{$xpar}/{$currev}/{$nextrev}"; $nextanc = "code/{$diff_view}/{$project->id}/{$xpar}/{$currev}/{$nextrev}";
print '&nbsp;&nbsp;&nbsp;'; print '&nbsp;&nbsp;&nbsp;';
print anchor ($nextanc, '>>'); print anchor ($nextanc, '>>');
print "</div>"; print "</div>";
@ -449,22 +448,25 @@ else
printf ("</div>"); printf ("</div>");
print '</pre>'; print '</pre>';
//
// SHOW THE NEW FILE
//
print ("<div style='float:left; width: 49%;'>"); print ("<div style='float:left; width: 49%;'>");
print "<div class='navigator'>"; print "<div class='navigator'>";
$currev = $file['against']['created_rev']; $currev = $file['against']['created_rev'];
$prevrev = $file['prev_rev']; $prevrev = $file['prev_rev'];
$prevanc = "code/fulldiff/{$project->id}/{$xpar}/{$prevrev}/{$currev}"; $prevanc = "code/{$diff_view}/{$project->id}/{$xpar}/{$prevrev}/{$currev}";
print anchor ($prevanc, '<<'); print anchor ($prevanc, '<<');
print '&nbsp;&nbsp;&nbsp;'; print '&nbsp;&nbsp;&nbsp;';
print $this->lang->line('Revision'); // show the history details of the current revision at the root directory
print ' '; $revanc = "code/revision/{$project->id}/!/{$currev}";
print $file['created_rev']; print anchor ($revanc, ($this->lang->line('Revision') . ' ' . $file['created_rev']));
$currev = $file['against']['created_rev']; $currev = $file['against']['created_rev'];
$nextrev = $file['next_rev']; $nextrev = $file['next_rev'];
$nextanc = "code/fulldiff/{$project->id}/{$xpar}/{$nextrev}/{$currev}"; $nextanc = "code/{$diff_view}/{$project->id}/{$xpar}/{$nextrev}/{$currev}";
print '&nbsp;&nbsp;&nbsp;'; print '&nbsp;&nbsp;&nbsp;';
print anchor ($nextanc, '>>'); print anchor ($nextanc, '>>');
print "</div>"; print "</div>";
@ -502,7 +504,6 @@ else
print '</pre>'; print '</pre>';
printf ("</div>"); printf ("</div>");
}
print '</div>'; print '</div>';
} }
?> ?>

View File

@ -3,8 +3,10 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/code.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/code.css')?>" />
<script type="text/javascript" src="<?php print base_url_make('/js/prettify/prettify.js')?>"></script> <script type="text/javascript" src="<?php print base_url_make('/js/prettify/prettify.js')?>"></script>
<script type="text/javascript" src="<?php print base_url_make('/js/prettify/lang-ada.js')?>"></script> <script type="text/javascript" src="<?php print base_url_make('/js/prettify/lang-ada.js')?>"></script>
<script type="text/javascript" src="<?php print base_url_make('/js/prettify/lang-basic.js')?>"></script> <script type="text/javascript" src="<?php print base_url_make('/js/prettify/lang-basic.js')?>"></script>

View File

@ -5,6 +5,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/code.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/code.css')?>" />

View File

@ -3,6 +3,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/code.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/code.css')?>" />

View File

@ -3,6 +3,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/code.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/code.css')?>" />
@ -205,7 +206,7 @@ function hide_unneeded_divs()
} }
$(function() { $(function() {
hide_unnddeded_divs (); hide_unneeded_divs ();
render_wiki (); render_wiki ();
}); });

View File

@ -5,6 +5,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/code.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/code.css')?>" />

View File

@ -4,6 +4,8 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/project.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/project.css')?>" />

View File

@ -3,6 +3,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/file.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/file.css')?>" />

View File

@ -3,6 +3,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/file.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/file.css')?>" />

View File

@ -5,6 +5,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/file.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/file.css')?>" />

View File

@ -3,6 +3,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/file.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/file.css')?>" />

View File

@ -7,6 +7,7 @@
<meta name="keywords" content="<?php print $project->id?>" /> <meta name="keywords" content="<?php print $project->id?>" />
<meta name="description" content="<?php print htmlspecialchars($project->summary)?>" /> <meta name="description" content="<?php print htmlspecialchars($project->summary)?>" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/project.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/project.css')?>" />

View File

@ -3,6 +3,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/issue.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/issue.css')?>" />

View File

@ -3,6 +3,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/issue.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/issue.css')?>" />

View File

@ -5,6 +5,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/issue.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/issue.css')?>" />

View File

@ -2,6 +2,8 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/issue.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/issue.css')?>" />

View File

@ -3,6 +3,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/log.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/log.css')?>" />
@ -144,7 +145,7 @@ $this->load->view (
<?php endif; ?> <?php endif; ?>
<div id="log_mainarea_result"> <div id="log_mainarea_result" class="result">
<table id="log_mainarea_result_table"> <table id="log_mainarea_result_table">
<?php <?php

View File

@ -2,6 +2,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<script type="text/javascript" src="<?php print base_url_make('/js/jquery.min.js')?>"></script> <script type="text/javascript" src="<?php print base_url_make('/js/jquery.min.js')?>"></script>

View File

@ -3,6 +3,8 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/project.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/project.css')?>" />
@ -11,18 +13,120 @@
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/jquery-ui.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/jquery-ui.css')?>" />
<script type="text/javascript"> <script type="text/javascript">
function AsciiToHex (x) {
var r=""; var site_url = "<?php print site_url(); ?>";
for(i=0; i<x.length; i++) var total_num_avail = <?php print $total_num_projects; ?>;
var total_num_shown = <?php print count($projects); ?>;
var req_page_offset = <?php print $req_page_offset; ?>;
var req_page_size = <?php print $req_page_size; ?>;
function prepare_page_button (i, req_size)
{ {
var tmp = x.charCodeAt(i).toString(16); var id = "#project_catalog_mainarea_result_list_page_" + i;
if (tmp.length == 1) r += "0"; var b = $(id).button();
r += tmp;
b.click (
function ()
{
var filter = codepot_ascii_to_hex($('#project_search_form').serialize());
var offset = parseInt($(this).text());
$.ajax({
url: "<?php print site_url(); ?>/project/catalog_json/" + filter + "/" + ((offset - 1) * req_size),
dataType: "json",
success: function(data) { render_project_list (data); }
});
} }
return r; );
return b;
}
function render_project_pages (total, shown, req_offset, req_size)
{
var pages = "";
if (req_size <= 0) req_size = 1;
var num_pages = parseInt((total + req_size - 1) / req_size);
var page_no = parseInt(req_offset / req_size) + 1;
var max_page_buttons = 10;
var page_no_start = page_no, page_no_stop = page_no;
var button_count = 1;
while (button_count < max_page_buttons)
{
var j = button_count;
if (page_no_start > 1 && button_count < max_page_buttons)
{
page_no_start--;
button_count++;
}
if (page_no_stop < num_pages && button_count < max_page_buttons)
{
page_no_stop++;
button_count++;
} }
if (j == button_count) break; // no change
}
if (page_no_start > 1)
{
pages = pages + "<a href='#' id='project_catalog_mainarea_result_list_page_1'>1</a>";
if (page_no_start > 2) pages = pages + " ... ";
}
for (i = page_no_start; i <= page_no_stop; i++)
{
pages = pages + " <a href='#' id='project_catalog_mainarea_result_list_page_" + i + "'>" + i + "</a>";
}
if (page_no_stop < num_pages)
{
if (page_no_stop + 1 < num_pages) pages = pages + " ... ";
pages = pages + " <a href='#' id='project_catalog_mainarea_result_list_page_" + num_pages + "'>" + num_pages + "</a>";
}
$("#project_catalog_mainarea_result_pages").empty();
$("#project_catalog_mainarea_result_pages").append(pages);
if (page_no_start > 1) prepare_page_button (1, req_size);
for (i = page_no_start; i <= page_no_stop; i++)
{
var b = prepare_page_button (i, req_size);
if (i == page_no) b.addClass ("ui-state-active");
}
if (page_no_stop < num_pages) prepare_page_button (num_pages);
}
function render_project_list (json)
{
if (json.status == 'ok')
{
var status = json.status;
var list = $("#project_catalog_mainarea_result_list");
list.empty (); // empty the list first.
for (i = 0; i < json.projects.length; i++)
{
var p = json.projects[i];
var cap = p.name + " (" + p.id + ")";
var li = codepot_sprintf ("<li><a href='%s/project/home/%s'>%s</a> - %s</li>", site_url, p.id, cap, p.summary);
list.append (li); // TODO: html escaping of p.id and p.name
}
render_project_pages (parseInt(json.total_num_projects), parseInt(json.projects.length), parseInt(json.req_page_offset), parseInt(json.req_page_size));
}
else
{
/* TODO: show error */
}
}
$(function () { $(function () {
/*
$("#project_catalog_mainarea_search_form").dialog ({ $("#project_catalog_mainarea_search_form").dialog ({
title: '<?php print $this->lang->line('Search')?>', title: '<?php print $this->lang->line('Search')?>',
autoOpen: false, autoOpen: false,
@ -31,7 +135,7 @@ $(function () {
buttons: { buttons: {
'<?php print $this->lang->line('OK')?>': function () { '<?php print $this->lang->line('OK')?>': function () {
$(this).dialog('close'); $(this).dialog('close');
var filter = AsciiToHex($('#project_search_form').serialize()); var filter = codepot_ascii_to_hex($('#project_search_form').serialize());
var url='<?php print site_url()?>/project/catalog/' + filter; var url='<?php print site_url()?>/project/catalog/' + filter;
$('body').append('<form id="magic_form" method="get" action="'+url+'"></form>'); $('body').append('<form id="magic_form" method="get" action="'+url+'"></form>');
@ -44,13 +148,31 @@ $(function () {
close: function() {} close: function() {}
}); });
$("#project_catalog_mainarea_search_button").button().click ( $("#project_catalog_mainarea_search_button").button().click (
function () { function () {
$('#project_catalog_mainarea_search_form').dialog('open'); $('#project_catalog_mainarea_search_form').dialog('open');
return false; return false;
} }
); );
*/
// Empty the page indicators generated by the server side.
// as i want the next page or the previous page to be loaded dynamically
// without killing the original pagination available.
$("#project_catalog_mainarea_result_pages").empty();
$("#project_catalog_mainarea_search_button").button().click (
function () {
var filter = codepot_ascii_to_hex($('#project_search_form').serialize());
$.ajax({
url: "<?php print site_url(); ?>/project/catalog_json/" + filter,
dataType: "json",
success: function(data) { render_project_list (data); }
});
}
);
render_project_pages (total_num_avail, total_num_shown, req_page_offset, req_page_size);
}); });
</script> </script>
@ -92,36 +214,36 @@ $this->load->view (
<div class="mainarea" id="project_catalog_mainarea"> <div class="mainarea" id="project_catalog_mainarea">
<div class="infostrip"> <div class="infostrip">
<?php printf ($this->lang->line('PROJECT_MSG_TOTAL_NUM_PROJECTS'), $total_num_projects); ?> | <?php
<a id="project_catalog_mainarea_search_button" href='#'><?php print $this->lang->line('Search')?></a> printf ($this->lang->line('PROJECT_MSG_TOTAL_NUM_PROJECTS'), $total_num_projects);
print ' | ';
printf ('<a id="project_catalog_mainarea_search_button" href="#">%s</a>', $this->lang->line('Search'));
?>
</div> </div>
<div id="project_catalog_mainarea_search_form"> <div id="project_catalog_mainarea_search_form">
<form id="project_search_form"> <form id="project_search_form">
<div> <div id="project_search_form_id">
<?php print form_label ($this->lang->line('ID'), 'id') <?php
?> print form_label($this->lang->line('ID'), 'id');
<?php print form_input('id', print ' ';
set_value('owner', $search->id), print form_input('id', set_value('owner', $search->id), 'id="project_search_id"');
'id="project_search_id"')
?> ?>
</div> </div>
<div> <div id="project_search_form_name">
<?php print form_label ($this->lang->line('Name'), 'name') <?php
?> print form_label($this->lang->line('Name'), 'name');
<?php print form_input('name', print ' ';
set_value('owner', $search->name), print form_input('name', set_value('owner', $search->name), 'id="project_search_name"');
'id="project_search_name"')
?> ?>
</div> </div>
<div> <div id="project_search_form_summary">
<?php print form_label ($this->lang->line('Summary'), 'summary') <?php
?> print form_label($this->lang->line('Summary'), 'summary');
<?php print form_input('summary', print ' ';
set_value('summary', $search->summary), print form_input('summary', set_value('summary', $search->summary), 'id="project_search_summary" size="50"');
'id="project_search_summary" size="50"')
?> ?>
</div> </div>
@ -137,44 +259,7 @@ if (empty($projects))
} }
else else
{ {
/* print '<ul id="project_catalog_mainarea_result_list">';
print '<table id="project_catalog_mainarea_result_table">';
print '<tr class="heading">';
print '<th class="id">' . $this->lang->line('ID') . '</th>';
print '<th class="name">' . $this->lang->line('Name') . '</th>';
print '<th class="summary">' . $this->lang->line('Summary') . '</th>';
print '</tr>';
$rowclasses = array ("even", "odd");
$rownum = 0;
foreach ($projects as $project)
{
$rowclass = $rowclasses[++$rownum % 2];
print "<tr class='{$rowclass}'>";
print '<td class="id">';
print anchor ("project/home/{$project->id}",
htmlspecialchars($project->id));
print '</td>';
print '<td class="name">';
print htmlspecialchars($project->name);
print '</td>';
print '<td class="summary">';
print htmlspecialchars($project->summary);
print '</td>';
print '</tr>';
}
print '<tr class="foot">';
print "<td colspan='3' class='pages'>{$page_links}</td>";
print '</tr>';
print '</table>';
*/
print '<ul>';
foreach ($projects as $project) foreach ($projects as $project)
{ {
$cap = "{$project->name} ({$project->id})"; $cap = "{$project->name} ({$project->id})";
@ -183,7 +268,8 @@ else
print "<li>{$anc} - {$sum}</li>"; print "<li>{$anc} - {$sum}</li>";
} }
print '</ul>'; print '</ul>';
print "<span class='pages'>{$page_links}</span>";
print "<div class='pages' id='project_catalog_mainarea_result_pages'>{$page_links}</div>";
} }
?> ?>
</div> <!-- project_catalog_mainarea_result --> </div> <!-- project_catalog_mainarea_result -->

View File

@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="keywords" content="<?php print $project->id?>" /> <meta name="keywords" content="<?php print $project->id?>" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/project.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/project.css')?>" />

View File

@ -3,6 +3,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/project.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/project.css')?>" />

View File

@ -7,6 +7,7 @@
<meta name="keywords" content="<?php print $project->id?>" /> <meta name="keywords" content="<?php print $project->id?>" />
<meta name="description" content="<?php print htmlspecialchars($project->summary)?>" /> <meta name="description" content="<?php print htmlspecialchars($project->summary)?>" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/project.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/project.css')?>" />

View File

@ -3,6 +3,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/site.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/site.css')?>" />

View File

@ -3,6 +3,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/site.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/site.css')?>" />

View File

@ -3,6 +3,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/site.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/site.css')?>" />

View File

@ -5,6 +5,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="keywords" content="codepot" /> <meta name="keywords" content="codepot" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/site.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/site.css')?>" />

View File

@ -3,6 +3,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/site.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/site.css')?>" />

View File

@ -158,15 +158,18 @@ $(function () {
$("#taskbar_project_to_find").button().autocomplete({ $("#taskbar_project_to_find").button().autocomplete({
minLength: 1, // is this too small? minLength: 1, // is this too small?
source: function (request, response) { source: function (request, response) {
var term = codepot_string_to_hex(request.term);
$.ajax({ $.ajax({
url: "<?php print site_url(); ?>/project/search_json/" + request.term, url: "<?php print site_url(); ?>/project/quickfind_json/" + term,
dataType: "json", dataType: "json",
success: function(data) { response(data); }, success: function(data) { response(data); },
}); });
}, },
select: function( event, ui ) { select: function( event, ui ) {
$(location).attr ('href', "<?php print site_url(); ?>/project/home/" + ui.item.id); $(location).attr ('href', "<?php print site_url(); ?>/project/home/" + ui.item.id);
//ui.item.value , ui.item.id , this.value ); //ui.item.value , ui.item.id , this.value
} }
}); });
}); });

View File

@ -3,6 +3,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/user.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/user.css')?>" />
@ -60,7 +61,7 @@ $num_issues = count($issues);
$num_activities = 0; $num_activities = 0;
?> ?>
<div id="user_home_mainarea_result"> <div id="user_home_mainarea_result" class="result">
<div id="tabs"> <div id="tabs">

View File

@ -3,6 +3,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/user.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/user.css')?>" />
@ -59,7 +60,7 @@ $this->load->view (
print "<div id='user_settings_mainarea_message' class='form_message'>$message</div>"; print "<div id='user_settings_mainarea_message' class='form_message'>$message</div>";
?> ?>
<div id="user_settings_mainarea_result"> <div id="user_settings_mainarea_result" class="result">
<div class="form_container"> <div class="form_container">
<?php print form_open_multipart('user/settings/')?> <?php print form_open_multipart('user/settings/')?>

View File

@ -3,6 +3,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/wiki.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/wiki.css')?>" />

View File

@ -3,6 +3,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/wiki.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/wiki.css')?>" />

View File

@ -5,6 +5,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/wiki.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/wiki.css')?>" />

View File

@ -3,6 +3,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/wiki.css')?>" /> <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/wiki.css')?>" />

View File

@ -57,25 +57,15 @@
overflow: auto; overflow: auto;
} }
#project_catalog_mainarea_result_table { #project_catalog_mainarea_result_list {
width: 100%; margin: 1em;
} padding: 1em;
#project_catalog_mainarea_result_table td {
white-space: nowrap; white-space: nowrap;
vertical-align: top; line-height: 1.5em;
} }
#project_catalog_mainarea_result_table td.id { #project_catalog_mainarea_result_pages {
width: 1px; margin: 1em;
}
#project_catalog_mainarea_result_table td.name {
width: 1px;
}
#project_catalog_mainarea_result_table td.summary {
white-space: pre-wrap;
} }
/*----------------------------------------------- /*-----------------------------------------------

View File

@ -2,6 +2,7 @@ SUBDIRS = prettify
wwwdir=$(WWWDIR)/js wwwdir=$(WWWDIR)/js
www_DATA = \ www_DATA = \
codepot.js \
creole.js \ creole.js \
jquery.min.js \ jquery.min.js \
jquery-ui.min.js \ jquery-ui.min.js \

374
codepot/src/js/codepot.js Normal file
View File

@ -0,0 +1,374 @@
function codepot_utf8_encode(argString) {
// discuss at: http://phpjs.org/functions/utf8_encode/
// original by: Webtoolkit.info (http://www.webtoolkit.info/)
// improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// improved by: sowberry
// improved by: Jack
// improved by: Yves Sucaet
// improved by: kirilloid
// bugfixed by: Onno Marsman
// bugfixed by: Onno Marsman
// bugfixed by: Ulrich
// bugfixed by: Rafal Kukawski
// bugfixed by: kirilloid
// example 1: utf8_encode('Kevin van Zonneveld');
// returns 1: 'Kevin van Zonneveld'
if (argString === null || typeof argString === 'undefined') {
return '';
}
var string = (argString + ''); // .replace(/\r\n/g, "\n").replace(/\r/g, "\n");
var utftext = '',
start, end, stringl = 0;
start = end = 0;
stringl = string.length;
for (var n = 0; n < stringl; n++) {
var c1 = string.charCodeAt(n);
var enc = null;
if (c1 < 128) {
end++;
} else if (c1 > 127 && c1 < 2048) {
enc = String.fromCharCode(
(c1 >> 6) | 192, (c1 & 63) | 128
);
} else if ((c1 & 0xF800) != 0xD800) {
enc = String.fromCharCode(
(c1 >> 12) | 224, ((c1 >> 6) & 63) | 128, (c1 & 63) | 128
);
} else { // surrogate pairs
if ((c1 & 0xFC00) != 0xD800) {
throw new RangeError('Unmatched trail surrogate at ' + n);
}
var c2 = string.charCodeAt(++n);
if ((c2 & 0xFC00) != 0xDC00) {
throw new RangeError('Unmatched lead surrogate at ' + (n - 1));
}
c1 = ((c1 & 0x3FF) << 10) + (c2 & 0x3FF) + 0x10000;
enc = String.fromCharCode(
(c1 >> 18) | 240, ((c1 >> 12) & 63) | 128, ((c1 >> 6) & 63) | 128, (c1 & 63) | 128
);
}
if (enc !== null) {
if (end > start) {
utftext += string.slice(start, end);
}
utftext += enc;
start = end = n + 1;
}
}
if (end > start) {
utftext += string.slice(start, stringl);
}
return utftext;
}
function codepot_utf8_decode(str_data) {
// discuss at: http://phpjs.org/functions/utf8_decode/
// original by: Webtoolkit.info (http://www.webtoolkit.info/)
// input by: Aman Gupta
// input by: Brett Zamir (http://brett-zamir.me)
// improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// improved by: Norman "zEh" Fuchs
// bugfixed by: hitwork
// bugfixed by: Onno Marsman
// bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// bugfixed by: kirilloid
// example 1: utf8_decode('Kevin van Zonneveld');
// returns 1: 'Kevin van Zonneveld'
var tmp_arr = [],
i = 0,
ac = 0,
c1 = 0,
c2 = 0,
c3 = 0,
c4 = 0;
str_data += '';
while (i < str_data.length) {
c1 = str_data.charCodeAt(i);
if (c1 <= 191) {
tmp_arr[ac++] = String.fromCharCode(c1);
i++;
} else if (c1 <= 223) {
c2 = str_data.charCodeAt(i + 1);
tmp_arr[ac++] = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63));
i += 2;
} else if (c1 <= 239) {
// http://en.wikipedia.org/wiki/UTF-8#Codepage_layout
c2 = str_data.charCodeAt(i + 1);
c3 = str_data.charCodeAt(i + 2);
tmp_arr[ac++] = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
} else {
c2 = str_data.charCodeAt(i + 1);
c3 = str_data.charCodeAt(i + 2);
c4 = str_data.charCodeAt(i + 3);
c1 = ((c1 & 7) << 18) | ((c2 & 63) << 12) | ((c3 & 63) << 6) | (c4 & 63);
c1 -= 0x10000;
tmp_arr[ac++] = String.fromCharCode(0xD800 | ((c1 >> 10) & 0x3FF));
tmp_arr[ac++] = String.fromCharCode(0xDC00 | (c1 & 0x3FF));
i += 4;
}
}
return tmp_arr.join('');
}
function codepot_sprintf() {
// discuss at: http://phpjs.org/functions/sprintf/
// original by: Ash Searle (http://hexmen.com/blog/)
// improved by: Michael White (http://getsprink.com)
// improved by: Jack
// improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// improved by: Dj
// improved by: Allidylls
// input by: Paulo Freitas
// input by: Brett Zamir (http://brett-zamir.me)
// example 1: sprintf("%01.2f", 123.1);
// returns 1: 123.10
// example 2: sprintf("[%10s]", 'monkey');
// returns 2: '[ monkey]'
// example 3: sprintf("[%'#10s]", 'monkey');
// returns 3: '[####monkey]'
// example 4: sprintf("%d", 123456789012345);
// returns 4: '123456789012345'
// example 5: sprintf('%-03s', 'E');
// returns 5: 'E00'
var regex = /%%|%(\d+\$)?([-+\'#0 ]*)(\*\d+\$|\*|\d+)?(\.(\*\d+\$|\*|\d+))?([scboxXuideEfFgG])/g;
var a = arguments;
var i = 0;
var format = a[i++];
// pad()
var pad = function (str, len, chr, leftJustify) {
if (!chr) {
chr = ' ';
}
var padding = (str.length >= len) ? '' : new Array(1 + len - str.length >>> 0)
.join(chr);
return leftJustify ? str + padding : padding + str;
};
// justify()
var justify = function (value, prefix, leftJustify, minWidth, zeroPad, customPadChar) {
var diff = minWidth - value.length;
if (diff > 0) {
if (leftJustify || !zeroPad) {
value = pad(value, minWidth, customPadChar, leftJustify);
} else {
value = value.slice(0, prefix.length) + pad('', diff, '0', true) + value.slice(prefix.length);
}
}
return value;
};
// formatBaseX()
var formatBaseX = function (value, base, prefix, leftJustify, minWidth, precision, zeroPad) {
// Note: casts negative numbers to positive ones
var number = value >>> 0;
prefix = prefix && number && {
'2': '0b',
'8': '0',
'16': '0x'
}[base] || '';
value = prefix + pad(number.toString(base), precision || 0, '0', false);
return justify(value, prefix, leftJustify, minWidth, zeroPad);
};
// formatString()
var formatString = function (value, leftJustify, minWidth, precision, zeroPad, customPadChar) {
if (precision != null) {
value = value.slice(0, precision);
}
return justify(value, '', leftJustify, minWidth, zeroPad, customPadChar);
};
// doFormat()
var doFormat = function (substring, valueIndex, flags, minWidth, _, precision, type) {
var number, prefix, method, textTransform, value;
if (substring === '%%') {
return '%';
}
// parse flags
var leftJustify = false;
var positivePrefix = '';
var zeroPad = false;
var prefixBaseX = false;
var customPadChar = ' ';
var flagsl = flags.length;
for (var j = 0; flags && j < flagsl; j++) {
switch (flags.charAt(j)) {
case ' ':
positivePrefix = ' ';
break;
case '+':
positivePrefix = '+';
break;
case '-':
leftJustify = true;
break;
case "'":
customPadChar = flags.charAt(j + 1);
break;
case '0':
zeroPad = true;
customPadChar = '0';
break;
case '#':
prefixBaseX = true;
break;
}
}
// parameters may be null, undefined, empty-string or real valued
// we want to ignore null, undefined and empty-string values
if (!minWidth) {
minWidth = 0;
} else if (minWidth === '*') {
minWidth = +a[i++];
} else if (minWidth.charAt(0) == '*') {
minWidth = +a[minWidth.slice(1, -1)];
} else {
minWidth = +minWidth;
}
// Note: undocumented perl feature:
if (minWidth < 0) {
minWidth = -minWidth;
leftJustify = true;
}
if (!isFinite(minWidth)) {
throw new Error('sprintf: (minimum-)width must be finite');
}
if (!precision) {
precision = 'fFeE'.indexOf(type) > -1 ? 6 : (type === 'd') ? 0 : undefined;
} else if (precision === '*') {
precision = +a[i++];
} else if (precision.charAt(0) == '*') {
precision = +a[precision.slice(1, -1)];
} else {
precision = +precision;
}
// grab value using valueIndex if required?
value = valueIndex ? a[valueIndex.slice(0, -1)] : a[i++];
switch (type) {
case 's':
return formatString(String(value), leftJustify, minWidth, precision, zeroPad, customPadChar);
case 'c':
return formatString(String.fromCharCode(+value), leftJustify, minWidth, precision, zeroPad);
case 'b':
return formatBaseX(value, 2, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
case 'o':
return formatBaseX(value, 8, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
case 'x':
return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
case 'X':
return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad)
.toUpperCase();
case 'u':
return formatBaseX(value, 10, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
case 'i':
case 'd':
number = +value || 0;
// Plain Math.round doesn't just truncate
number = Math.round(number - number % 1);
prefix = number < 0 ? '-' : positivePrefix;
value = prefix + pad(String(Math.abs(number)), precision, '0', false);
return justify(value, prefix, leftJustify, minWidth, zeroPad);
case 'e':
case 'E':
case 'f': // Should handle locales (as per setlocale)
case 'F':
case 'g':
case 'G':
number = +value;
prefix = number < 0 ? '-' : positivePrefix;
method = ['toExponential', 'toFixed', 'toPrecision']['efg'.indexOf(type.toLowerCase())];
textTransform = ['toString', 'toUpperCase']['eEfFgG'.indexOf(type) % 2];
value = prefix + Math.abs(number)[method](precision);
return justify(value, prefix, leftJustify, minWidth, zeroPad)[textTransform]();
default:
return substring;
}
};
return format.replace(regex, doFormat);
}
function codepot_ascii_to_hex (x)
{
var r="";
var i;
/*
for(i=0; i<x.length; i++)
{
var tmp = x.charCodeAt(i).toString(16);
if (tmp.length == 1) r += "0";
r += tmp;
}
*/
r = "!"; // the new style conversion begins with an exclamation mark
for(i = 0; i < x.length; i++)
{
var seg;
var c = x.charAt(i);
if (c == "!")
{
seg = "!!";
}
else if (c == "|")
{
seg = "!|";
}
else if (c == "/")
{
seg = "|";
}
else if (c == "." || c == "_" || c == "-" ||
c == ":" || c == "@" || c == " ")
{
seg = c;
}
else
{
if (/^[A-Za-z0-9]$/.test (c))
{
seg = c;
}
else
{
var seg = x.charCodeAt(i).toString(16);
if (seg.length == 1) seg = "0" + seg;
seg = "!" + seg;
}
}
r += seg;
}
return r;
}
function codepot_string_to_hex (x)
{
var utf8 = codepot_utf8_encode(x);
return codepot_ascii_to_hex(utf8);
}

View File

@ -195,6 +195,8 @@ var asciiToHex = function (x,dir) {
if (dir == "A2H") if (dir == "A2H")
{ {
/* codepot_ascii_to_hex provides the same functionality.
* but let me duplicate the code here for no dependency */
var i; var i;
/* /*
for(i=0; i<x.length; i++) for(i=0; i<x.length; i++)