This commit is contained in:
Catouse
2018-10-12 13:34:52 +08:00
77 changed files with 4299 additions and 152 deletions
+3 -2
View File
@@ -22,8 +22,9 @@ $filter->default->paramValue = 'reg::paramValue';
$filter->default->get['onlybody'] = 'equal::yes';
$filter->default->get['HTTP_X_REQUESTED_WITH'] = 'equal::XMLHttpRequest';
$filter->default->cookie['lang'] = 'reg::lang';
$filter->default->cookie['theme'] = 'reg::word';
$filter->default->cookie['lang'] = 'reg::lang';
$filter->default->cookie['theme'] = 'reg::word';
$filter->default->cookie['fingerprint'] = 'reg::word';
$filter->bug = new stdclass();
$filter->doc = new stdclass();
+1
View File
@@ -0,0 +1 @@
update zt_task set `parent` = -1 where `id` in (select `parent` from zt_task where `parent` > 0 group by `parent`)
+17
View File
@@ -608,6 +608,23 @@ class baseHelper
return $ip;
}
/**
* Restart session.
*
* @param string $sessionID
* @static
* @access public
* @return void
*/
public static function restartSession($sessionID = '')
{
if(empty($sessionID)) $sessionID = sha1(mt_rand());
session_write_close();
session_id($sessionID);
session_start();
}
}
//------------------------------- 常用函数。Some tool functions.-------------------------------//
+13 -1
View File
@@ -311,6 +311,15 @@ class baseRouter
*/
public $cookie;
/**
* 原始SESSIONID
* SESSIONID
*
* @var int
* @access public
*/
public $sessionID;
/**
* 网站代号。
* The code of current site.
@@ -813,8 +822,11 @@ class baseRouter
{
$sessionName = $this->config->sessionVar;
session_name($sessionName);
if(isset($_GET[$this->config->sessionVar])) session_id($_GET[$this->config->sessionVar]);
session_start();
$this->sessionID = session_id();
if(isset($_GET[$this->config->sessionVar]) and $this->sessionID != $_GET[$this->config->sessionVar]) helper::restartSession($_GET[$this->config->sessionVar]);
define('SESSION_STARTED', true);
}
}
+1 -1
View File
@@ -789,7 +789,7 @@ class actionModel extends model
else
{
$action->objectLink = '';
$action->objectLabel = $this->lang->action->objectTypes[$action->objectLabel];
$action->objectLabel = zget($this->lang->action->objectTypes, $action->objectLabel);
}
$action->major = (isset($this->config->action->majorList[$action->objectType]) && in_array($action->action, $this->config->action->majorList[$action->objectType])) ? 1 : 0;
+1 -1
View File
@@ -893,7 +893,7 @@ class block extends control
$tasks = $this->dao->select("project, count(id) as totalTasks, count(status in ('wait','doing','pause') or null) as undoneTasks, count(finishedDate like '{$yesterday}%' or null) as yesterdayFinished, sum(if(status != 'cancel', estimate, 0)) as totalEstimate, sum(consumed) as totalConsumed, sum(if(status != 'cancel', `left`, 0)) as totalLeft")->from(TABLE_TASK)
->where('project')->in($projectIdList)
->andWhere('deleted')->eq(0)
->andWhere('parent')->eq(0)
->andWhere('parent')->lt(1)
->groupBy('project')
->fetchAll('project');
foreach($tasks as $projectID => $task)
+3 -3
View File
@@ -162,12 +162,12 @@ class blockModel extends model
$data['stories'] = (int)$this->dao->select('count(*) AS count')->from(TABLE_STORY)->where('assignedTo')->eq($this->app->user->account)->andWhere('deleted')->eq(0)->fetch('count');
$data['projects'] = (int)$this->dao->select('count(*) AS count')->from(TABLE_PROJECT)
->where("(status='wait' or status='doing')")
->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->projects)
->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->projects)->fi()
->andWhere('deleted')->eq(0)
->fetch('count');
$data['products'] = (int)$this->dao->select('count(*) AS count')->from(TABLE_PRODUCT)
->where('status')->ne('closed')
->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->products)
->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->products)->fi()
->andWhere('deleted')->eq(0)
->fetch('count');
@@ -188,7 +188,7 @@ class blockModel extends model
->fetch('count');
$data['delayProject'] = (int)$this->dao->select('count(*) AS count')->from(TABLE_PROJECT)
->where('status')->in('wait,doing')
->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->projects)
->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->projects)->fi()
->andWhere('end')->lt($today)
->andWhere('deleted')->eq(0)
->fetch('count');
+1 -1
View File
@@ -1490,7 +1490,7 @@ class bug extends control
/* Get related objects title or names. */
$productsType = $this->dao->select('id, type')->from(TABLE_PRODUCT)->where('id')->in($relatedProductIdList)->fetchPairs();
$relatedModules = array('0' => '/') + $this->dao->select('id, name')->from(TABLE_MODULE)->where('id')->in($relatedModuleIdList)->fetchPairs();
$relatedModules = $this->loadModel('tree')->getOptionMenu($productID, 'bug');
$relatedStories = $this->dao->select('id,title')->from(TABLE_STORY) ->where('id')->in($relatedStoryIdList)->fetchPairs();
$relatedTasks = $this->dao->select('id, name')->from(TABLE_TASK)->where('id')->in($relatedTaskIdList)->fetchPairs();
$relatedBugs = $this->dao->select('id, title')->from(TABLE_BUG)->where('id')->in($relatedBugIdList)->fetchPairs();
+6 -2
View File
@@ -1657,10 +1657,10 @@ class bugModel extends model
*/
public function getDataOfBugsPerBuild()
{
$datas = $this->dao->select('openedBuild as name, count(openedBuild) as value')->from(TABLE_BUG)->where($this->reportCondition())->groupBy('openedBuild')->orderBy('value DESC')->fetchAll('name');
$datas = $this->dao->select('openedBuild as name, count(openedBuild) as value')->from(TABLE_BUG)->where($this->reportCondition())->groupBy('openedBuild')->orderBy('openedBuild DESC')->fetchAll('name');
if(!$datas) return array();
ksort($datas);
$builds = $this->loadModel('build')->getProductBuildPairs($this->session->product, $branch = 0, $params = '');
/* Deal with the situation that a bug maybe associate more than one openedBuild. */
foreach($datas as $buildIDList => $data)
{
@@ -2471,6 +2471,10 @@ class bugModel extends model
$class .= ' text-left';
$title = "title='{$bug->title}'";
}
if($id == 'type')
{
$title = "title='" . zget($this->lang->bug->typeList, $bug->type) . "'";
}
if($id == 'assignedTo')
{
$class .= ' has-btn text-left';
+1
View File
@@ -259,6 +259,7 @@ $lang->task = new stdclass();
$lang->build = new stdclass();
$lang->task->menu = $lang->project->menu;
$lang->build->menu = $lang->project->menu;
$lang->build->menu->qa = array('link' => 'Build|project|build|projectID=%s', 'subModule' => 'bug,build,testtask', 'alias' => 'build,testtask', 'class' => 'dropdown dropdown-hover');
/* QA视图菜单设置。*/
$lang->qa = new stdclass();
+1
View File
@@ -259,6 +259,7 @@ $lang->task = new stdclass();
$lang->build = new stdclass();
$lang->task->menu = $lang->project->menu;
$lang->build->menu = $lang->project->menu;
$lang->build->menu->qa = array('link' => '版本|project|build|projectID=%s', 'subModule' => 'bug,build,testtask', 'alias' => 'build,testtask', 'class' => 'dropdown dropdown-hover');
/* QA视图菜单设置。*/
$lang->qa = new stdclass();
+4 -3
View File
@@ -138,11 +138,12 @@ class doc extends control
$actionURL = $this->createLink('doc', 'browse', "lib=$libID&browseType=bySearch&queryID=myQueryID&orderBy=$orderBy&from=$from");
$this->doc->buildSearchForm($libID, $this->libs, $queryID, $actionURL, $type);
$title = '';
$module = $moduleID ? $this->loadModel('tree')->getByID($moduleID) : '';
$title = '';
$module = $moduleID ? $this->loadModel('tree')->getByID($moduleID) : '';
if($module) $title = $module->name;
if($libID) $title = $this->libs[$libID];
if(in_array($browseType, array_keys($this->lang->doc->fastMenuList))) $title = $this->lang->doc->fastMenuList[$browseType];
if($param != 0) $title = $this->doc->buildBreadTitle($libID, $param, $title);
if($browseType == 'fastsearch')
{
if($this->post->searchDoc) $this->session->set('searchDoc', $this->post->searchDoc);
@@ -160,7 +161,7 @@ class doc extends control
$this->view->itemCounts = $this->doc->statLibCounts(array_keys($libs));
}
$this->view->title = $title;
$this->view->breadTitle = $title;
$this->view->libID = $libID;
$this->view->moduleID = $moduleID;
$this->view->modules = $this->doc->getDocMenu($libID, $moduleID, $orderBy == 'title_asc' ? 'name_asc' : 'id_desc', $browseType);
+1
View File
@@ -59,3 +59,4 @@
}
.main-col > .panel > .panel-body {padding-top: 20px;}
.main-col .panel-title a.active{color: #0c64eb}
+1
View File
@@ -46,6 +46,7 @@ $lang->doc->users = 'Users';
$lang->doc->item = ' Items';
$lang->doc->num = 'Docs';
$lang->doc->searchResult = 'Search Result';
$lang->doc->gt = '>';
$lang->doc->moduleDoc = 'By Module';
$lang->doc->searchDoc = 'Search';
+1
View File
@@ -46,6 +46,7 @@ $lang->doc->users = '用户';
$lang->doc->item = '项';
$lang->doc->num = '文档数量';
$lang->doc->searchResult = '搜索结果';
$lang->doc->gt = '>';
$lang->doc->moduleDoc = '按模块浏览';
$lang->doc->searchDoc = '搜索';
+49
View File
@@ -66,6 +66,7 @@ class docModel extends model
$selectHtml .= '<li>' . html::a(helper::createLink('doc', 'allLibs', "type=custom"), "<i class='icon icon-folder-o'></i> {$this->lang->doc->customAB}") . '</li>';
$selectHtml .='</ul></div></div>';
$currentLib = 0;
if(strpos('product,project,custom', $type) !== false)
{
if($type == 'custom') $currentLib = $libID;
@@ -1528,4 +1529,52 @@ class docModel extends model
return $statisticInfo;
}
/**
* Print doc child module.
*
* @access public
*/
public function printChildModule($module, $libID, $methodName, $browseType, $moduleID)
{
if(isset($module->children))
{
foreach($module->children as $childModule)
{
$active = '';
if($methodName == 'browse' && $browseType == 'bymodule' && $moduleID == $childModule->id) $active = "class='active'";
echo '<ul>';
echo "<li $active>";
echo html::a(helper::createLink('doc', 'browse', "libID=$libID&browseType=byModule&param={$childModule->id}"), "<i class='icon icon-folder-outline'></i> " . $childModule->name, '', "class='text-ellipsis' title='{$childModule->name}'");
if(isset($childModule->children)) $this->printChildModule($childModule, $libID, $methodName, $browseType, $moduleID);
echo '</li>';
echo '</ul>';
}
}
}
/**
* Build doc bread title.
*
* @access public
* @return string
*/
public function buildBreadTitle($libID = 0, $param = 0, $title = '')
{
$path = $this->dao->select('path')->from(TABLE_MODULE)->where('id')->eq($param)->fetch('path');
$parantMoudles = $this->dao->select('id, name')->from(TABLE_MODULE)
->where('id')->in($path)
->andWhere('deleted')->eq(0)
->fetchAll('id');
foreach($parantMoudles as $parentID => $moduleName)
{
$active = '';
if($param == $parentID) $active = "class='active'";
$title .= html::a(helper::createLink('doc', 'browse', "libID=$libID&browseType=byModule&param={$parentID}"), " {$this->lang->doc->gt} " . $moduleName->name , '', "$active");
}
return $title;
}
}
+3 -3
View File
@@ -36,7 +36,7 @@ var browseType = '<?php echo $browseType;?>';
<?php else:?>
<i class="icon icon-search text-muted"></i>
<?php endif;?>
<?php echo $title;?>
<?php echo $breadTitle;?>
</div>
<nav class="panel-actions btn-toolbar">
<div class="btn-group">
@@ -121,8 +121,8 @@ var browseType = '<?php echo $browseType;?>';
<td class="c-name"><?php echo html::a(inlink('view', "docID=$doc->id"), "<i class='icon icon-file-text text-muted'></i> &nbsp;" . $doc->title);?></td>
<td class="c-num"><?php echo $doc->fileSize ? $doc->fileSize : '-';?></td>
<td class="c-user"><?php echo zget($users, $doc->addedBy);?></td>
<td class="c-datetime"><?php echo formatTime($doc->addedDate, 'm-d h:i');?></td>
<td class="c-datetime"><?php echo formatTime($doc->editedDate, 'm-d h:i');?></td>
<td class="c-datetime"><?php echo formatTime($doc->addedDate, 'm-d H:i');?></td>
<td class="c-datetime"><?php echo formatTime($doc->editedDate, 'm-d H:i');?></td>
<td class="c-actions">
<a data-url="<?php echo $this->createLink('doc', 'collect', "objectID=$doc->id&objectType=doc");?>" title="<?php echo $collectTitle;?>" class='btn btn-link ajaxCollect'><i class='icon <?php echo $star;?>'></i></a>
<?php common::printLink('doc', 'edit', "docID=$doc->id", "<i class='icon icon-edit'></i>", '', "title='{$lang->edit}' class='btn btn-link'")?>
+11
View File
@@ -6,6 +6,11 @@ $allModules = $this->loadModel('tree')->getDocStructure();
$productSubLibs = $this->doc->getSubLibGroups('product', array_keys($products));
$projectSubLibs = $this->doc->getSubLibGroups('project', array_keys($projects));
if($this->methodName != 'browse')
{
$browseType = '';
$moduleID = '';
}
?>
<div class="side-col" style="width: 220px" data-min-width="220">
<div class="cell">
@@ -62,8 +67,10 @@ $projectSubLibs = $this->doc->getSubLibGroups('project', array_keys($projects));
<?php if(isset($allModules[$subLibID])):?>
<ul>
<?php foreach($allModules[$subLibID] as $module):?>
<?php if($module->parent != 0) continue;?>
<li <?php if($this->methodName == 'browse' && $browseType == 'bymodule' && $moduleID == $module->id) echo "class='active'";?>>
<?php echo html::a($this->createLink('doc', 'browse', "libID=$subLibID&browseType=byModule&param={$module->id}"), "<i class='icon icon-folder-outline'></i> " . $module->name, '', "class='text-ellipsis' title='{$module->name}'");?>
<?php $this->doc->printChildModule($module, $subLibID, $this->methodName, $browseType, $moduleID);?>
</li>
<?php endforeach;?>
</ul>
@@ -106,8 +113,10 @@ $projectSubLibs = $this->doc->getSubLibGroups('project', array_keys($projects));
<?php if(isset($allModules[$subLibID])):?>
<ul>
<?php foreach($allModules[$subLibID] as $module):?>
<?php if($module->parent != 0) continue;?>
<li <?php if($this->methodName == 'browse' && $browseType == 'bymodule' && $moduleID == $module->id) echo "class='active'";?>>
<?php echo html::a($this->createLink('doc', 'browse', "libID=$subLibID&browseType=byModule&param={$module->id}"), "<i class='icon icon-folder-outline'></i> " . $module->name, '', "class='text-ellipsis' title='{$module->name}'");?>
<?php $this->doc->printChildModule($module, $subLibID, $this->methodName, $browseType, $moduleID);?>
</li>
<?php endforeach;?>
</ul>
@@ -130,8 +139,10 @@ $projectSubLibs = $this->doc->getSubLibGroups('project', array_keys($projects));
<?php if(isset($allModules[$subLibID])):?>
<ul>
<?php foreach($allModules[$subLibID] as $module):?>
<?php if($module->parent != 0) continue;?>
<li <?php if($this->methodName == 'browse' && $browseType == 'bymodule' && $moduleID == $module->id) echo "class='active'";?>>
<?php echo html::a($this->createLink('doc', 'browse', "libID=$subLibID&browseType=byModule&param={$module->id}"), "<i class='icon icon-folder-outline'></i> " . $module->name, '', "class='text-ellipsis' title='{$module->name}'");?>
<?php $this->doc->printChildModule($module, $subLibID, $this->methodName, $browseType, $moduleID);?>
</li>
<?php endforeach;?>
</ul>
+5 -4
View File
@@ -30,10 +30,11 @@ $lang->entry->confirmDelete = 'Are you sure delete this entry?';
$lang->entry->help = 'Help';
$lang->entry->note = new stdClass();
$lang->entry->note->name = 'Name';
$lang->entry->note->code = 'Code, should be english and number.';
$lang->entry->note->ip = "Use comma between two IPs. IP segment is supported, e.g. 192.168.1.*";
$lang->entry->note->allIP = 'All';
$lang->entry->note->name = 'Name';
$lang->entry->note->code = 'Code, should be english and number.';
$lang->entry->note->ip = "Use comma between two IPs. IP segment is supported, e.g. 192.168.1.*";
$lang->entry->note->allIP = 'All';
$lang->entry->note->account = 'Account for entry.';
$lang->entry->errmsg['PARAM_CODE_MISSING'] = 'Param code is missing.';
$lang->entry->errmsg['PARAM_TOKEN_MISSING'] = 'Param token is missing.';
+5 -4
View File
@@ -30,10 +30,11 @@ $lang->entry->confirmDelete = '您确认要删除该应用吗?';
$lang->entry->help = '使用说明';
$lang->entry->note = new stdClass();
$lang->entry->note->name = '授权应用名称';
$lang->entry->note->code = '授权应用代号,必须为字母或数字的组合';
$lang->entry->note->ip = "允许访问API的应用ip,多个ip用逗号隔开。支持IP段,如192.168.1.*";
$lang->entry->note->allIP = '无限制';
$lang->entry->note->name = '授权应用名称';
$lang->entry->note->code = '授权应用代号,必须为字母或数字的组合';
$lang->entry->note->ip = "允许访问API的应用ip,多个ip用逗号隔开。支持IP段,如192.168.1.*";
$lang->entry->note->allIP = '无限制';
$lang->entry->note->account = '授权应用账号';
$lang->entry->errmsg['PARAM_CODE_MISSING'] = '缺少code参数';
$lang->entry->errmsg['PARAM_TOKEN_MISSING'] = '缺少token参数';
+1 -1
View File
@@ -34,7 +34,7 @@
</tr>
<tr>
<th><?php echo $lang->entry->account;?></th>
<td><?php echo html::select("account", $users, '', "class='form-control chosen'");?></td>
<td><?php echo html::select("account", $users, '', "class='form-control chosen' data-placeholder='{$lang->entry->note->account}'");?></td>
<td></td>
</tr>
<tr>
+3 -10
View File
@@ -153,15 +153,7 @@ class file extends control
*/
public function download($fileID, $mouse = '')
{
/* When get sid then change session id. */
if(isset($_GET[$this->config->sessionVar]))
{
$sessionID = isset($_COOKIE[$this->config->sessionVar]) ? $_COOKIE[$this->config->sessionVar] : sha1(mt_rand());
session_write_close();
session_id($sessionID);
session_start();
}
if(session_id() != $this->app->sessionID) helper::restartSession($this->app->sessionID);
$file = $this->file->getById($fileID);
/* Judge the mode, down or open. */
@@ -170,7 +162,8 @@ class file extends control
if(stripos($fileTypes, $file->extension) !== false && $mouse == 'left') $mode = 'open';
if($file->extension == 'txt')
{
$extension = end(explode('.', $file->title));
$extension = 'txt';
if(($postion = strrpos($file->title, '.')) !== false)$extension = substr($file->title, $postion + 1);
if($extension != 'txt') $mode = 'down';
$file->extension = $extension;
}
+1 -1
View File
@@ -44,7 +44,7 @@ $lang->file->downloads = 'Downloads';
$lang->file->extra = 'Extra';
$lang->file->dragFile = 'Please drag here.';
$lang->file->childTaskTag = 'It\'s child task where \'>\' before the name.';
$lang->file->childTaskTips = 'It\'s child task where \'>\' before the name.';
$lang->file->errorNotExists = "<span class='text-red'>'%s' is not found.</span>";
$lang->file->errorCanNotWrite = "<span class='text-red'>'%s' is not writable. Please change its permission. Enter <span class='code'>sudo chmod -R 777 '%s'</span></span> in Linux.";
$lang->file->confirmDelete = " Do you want to delete it?";
+1 -1
View File
@@ -44,7 +44,7 @@ $lang->file->downloads = '下载次数';
$lang->file->extra = '备注';
$lang->file->dragFile = '请拖拽文件到此处';
$lang->file->childTaskTag = "任务名称前有'>'标记的为子任务";
$lang->file->childTaskTips = "任务名称前有'>'标记的为子任务";
$lang->file->errorNotExists = "<span class='text-red'>文件夹 '%s' 不存在</span>";
$lang->file->errorCanNotWrite = "<span class='text-red'>文件夹 '%s' 不可写,请改变文件夹的权限。在linux中输入指令: <span class='code'>sudo chmod -R 777 %s</span></span>";
$lang->file->confirmDelete = " 您确定删除该附件吗?";
+1 -1
View File
@@ -22,4 +22,4 @@ foreach($rows as $row)
}
echo '"' . "\n";
}
echo $this->lang->file->childTaskTag;
if($this->post->kind == 'task') echo $this->lang->file->childTaskTips;
+1 -1
View File
@@ -19,7 +19,7 @@ table th,table td{padding:5px;}
</style>
<title><?php echo $fileName;?></title>
<body>
<?php echo "<font color='red'>" . $this->lang->file->childTaskTag . '</font>';?>
<?php if($this->post->kind == 'task') echo "<font color='red'>" . $this->lang->file->childTaskTag . '</font>';?>
<table>
<tr>
<?php
+2 -2
View File
@@ -283,11 +283,11 @@ class gitModel extends model
exec("{$this->client} config core.quotepath false");
if($fromRevision)
{
$cmd = "$this->client log --stat=1024 --name-status $fromRevision..HEAD";
$cmd = "$this->client log --stat=1024 --stat-name-width=1000 --name-status $fromRevision..HEAD";
}
else
{
$cmd = "$this->client log --stat=1024 --name-status";
$cmd = "$this->client log --stat=1024 --stat-name-width=1000 --name-status";
}
exec($cmd, $list, $return);
+1
View File
@@ -13,6 +13,7 @@ $lang->misc = new stdclass();
$lang->misc->common = 'Misc';
$lang->misc->ping = 'Ping';
$lang->misc->api = 'https://api.zentao.net';
$lang->misc->enApi = 'http://api.zentao.pm';
$lang->misc->zentao = new stdclass();
$lang->misc->zentao->version = 'Version %s';
+1
View File
@@ -13,6 +13,7 @@ $lang->misc = new stdclass();
$lang->misc->common = '杂项';
$lang->misc->ping = '防超时';
$lang->misc->api = 'https://api.zentao.net';
$lang->misc->enApi = 'http://api.zentao.pm';
$lang->misc->zentao = new stdclass();
$lang->misc->zentao->version = '版本%s';
+2 -1
View File
@@ -9,8 +9,9 @@
</div>
<div class='panel-body'>
<ul>
<?php $api = $app->getClientLang() == 'en' ? $lang->misc->enApi : $lang->misc->api;?>
<?php foreach($groupItems as $item => $label):?>
<li><?php echo html::a($lang->misc->api . "/goto.php?item=$item&from=about", $label, '_blank', "id='$item'");;?></li>
<li><?php echo html::a($api . "/goto.php?item=$item&from=about", $label, '_blank', "id='$item'");;?></li>
<?php endforeach;?>
</ul>
</div>
+1 -1
View File
@@ -74,7 +74,7 @@
<td class='c-project' title="<?php echo $task->projectName;?>"><?php echo html::a($this->createLink('project', 'browse', "projectid=$task->projectID"), $task->projectName);?></td>
<td class='c-name'>
<?php if(!empty($task->team)) echo '<span class="label label-badge label-light">' . $this->lang->task->multipleAB . '</span> ';?>
<?php if(!empty($task->parent)) echo '<span class="label label-badge label-light">' . $this->lang->task->childrenAB . '</span> ';?>
<?php if($task->parent > 0) echo '<span class="label label-badge label-light">' . $this->lang->task->childrenAB . '</span> ';?>
<?php echo html::a($this->createLink('task', 'view', "taskID=$task->id"), $task->name, null, "style='color: $task->color'");?>
</td>
<td class='c-user'><?php echo zget($users, $task->openedBy);?></td>
+1 -1
View File
@@ -43,7 +43,7 @@ $lang->product->doc = 'Doc';
$lang->product->project = $lang->projectCommon . 'List';
$lang->product->build = 'Build';
$lang->product->currentProject = 'Current Project';
$lang->product->currentProject = "Current {$lang->projectCommon}";
$lang->product->activeStories = 'Activated Story';
$lang->product->changedStories = 'Changed Story';
$lang->product->draftStories = 'Draft Story';
+1 -1
View File
@@ -43,7 +43,7 @@ $lang->product->doc = '文档列表';
$lang->product->project = $lang->projectCommon . '列表';
$lang->product->build = '版本列表';
$lang->product->currentProject = '当前项目';
$lang->product->currentProject = '当前' . $lang->projectCommon;
$lang->product->activeStories = '激活需求';
$lang->product->changedStories = '已变更需求';
$lang->product->draftStories = '草稿需求';
+1 -1
View File
@@ -401,7 +401,7 @@ $(function()
}
var data = $row.data();
checkedEstimate += data.estimate;
checkedCase += data.cases;
if(data.cases > 0) checkedCase += 1;
});
var rate = Math.round(checkedCase / checkedTotal * 10000) / 100 + '' + '%';
return checkedSummary.replace('%total%', checkedTotal)
-12
View File
@@ -179,18 +179,6 @@ class project extends control
/* Get tasks. */
$tasks = $this->project->getTasks($productID, $projectID, $this->projects, $browseType, $queryID, $moduleID, $sort, $pager);
if(strpos('unclosed,all,bymodule,byproduct', $browseType) === false)
{
foreach($tasks as $task)
{
if(isset($task->children))
{
$task->children = true;
unset($task->children);
}
}
}
/* Build the search form. */
$actionURL = $this->createLink('project', 'task', "projectID=$projectID&status=bySearch&param=myQueryID");
$this->config->project->search['onMenuBar'] = 'yes';
+1 -1
View File
@@ -302,7 +302,7 @@ $lang->project->featureBar['task']['unclosed'] = $lang->project->unclosed;
$lang->project->featureBar['task']['assignedtome'] = $lang->project->assignedToMe;
$lang->project->featureBar['task']['myinvolved'] = $lang->project->myInvolved;
$lang->project->featureBar['task']['delayed'] = '已延期';
$lang->project->featureBar['task']['needconfirm'] = '需求变动';
$lang->project->featureBar['task']['needconfirm'] = '需求变更';
$lang->project->featureBar['task']['status'] = $lang->project->statusSelects[''];
$lang->project->treeLevel = array();
+24 -11
View File
@@ -865,7 +865,7 @@ class projectModel extends model
$tasks = $this->dao->select('id, project, estimate, consumed, `left`, status, closedReason')
->from(TABLE_TASK)
->where('project')->in($projectKeys)
->andWhere('parent')->eq(0)
->andWhere('parent')->lt(1)
->andWhere('deleted')->eq(0)
->fetchGroup('project', 'id');
@@ -1055,13 +1055,13 @@ class projectModel extends model
->where('project')->eq((int)$projectID)
->andWhere('status')->ne('cancel')
->andWhere('deleted')->eq(0)
->andWhere('parent')->eq(0)
->andWhere('parent')->lt(1)
->fetch();
$closedTotalLeft= (int)$this->dao->select('SUM(`left`) AS totalLeft')->from(TABLE_TASK)
->where('project')->eq((int)$projectID)
->andWhere('status')->eq('closed')
->andWhere('deleted')->eq(0)
->andWhere('parent')->eq(0)
->andWhere('parent')->lt(1)
->fetch('totalLeft');
$project->days = $project->days ? $project->days : '';
@@ -1309,7 +1309,7 @@ class projectModel extends model
->leftJoin(TABLE_USER)->alias('t3')->on('t1.assignedTo = t3.account')
->where('t1.status')->in('wait, doing, pause, cancel')
->andWhere('t1.deleted')->eq(0)
->andWhere('t1.parent')->eq(0)
->andWhere('t1.parent')->lt(1)
->andWhere('t1.project')->in(array_keys($projects))
->andWhere("(t1.story = 0 OR (t2.branch in ('0','" . join("','", $branches) . "') and t2.product " . helper::dbIN(array_keys($branches)) . "))")
->fetchGroup('project', 'id');
@@ -1399,7 +1399,7 @@ class projectModel extends model
->andWhere('t1.deleted')->eq(0)
->fetch('storyCount');
$taskCount = $this->dao->select('count(id) as taskCount')->from(TABLE_TASK)->where('project')->eq($projectID)->andWhere('parent')->eq(0)->andWhere('deleted')->eq(0)->fetch('taskCount');
$taskCount = $this->dao->select('count(id) as taskCount')->from(TABLE_TASK)->where('project')->eq($projectID)->andWhere('parent')->lt(1)->andWhere('deleted')->eq(0)->fetch('taskCount');
$bugCount = $this->dao->select('count(id) as bugCount')->from(TABLE_BUG)->where('project')->eq($projectID)->andWhere('deleted')->eq(0)->fetch('bugCount');
$statData = new stdclass();
@@ -2009,9 +2009,22 @@ class projectModel extends model
->where('t1.deleted')->eq(0)
->andWhere('t1.id')->in(array_keys($taskIdList))
->orderBy($orderBy)
->fetchAll();
$this->loadModel('task')->processTasks($tasks);
return $tasks;
->fetchAll('id');
if(empty($tasks)) return array();
foreach($tasks as $task)
{
if($task->parent > 0)
{
if(isset($tasks[$task->parent]))
{
$tasks[$task->parent]->children[$task->id] = $task;
unset($tasks[$task->id]);
}
}
}
return $this->loadModel('task')->processTasks($tasks);
}
/**
@@ -2023,7 +2036,7 @@ class projectModel extends model
* @param int $pager
* @param int $orderBy
* @access public
* @return void
* @return mixed
*/
public function getSearchBugs($products, $projectID, $sql, $pager, $orderBy)
{
@@ -2551,7 +2564,7 @@ class projectModel extends model
$tasks = $this->dao->select('*')->from(TABLE_TASK)
->where('project')->eq((int)$projectID)
->andWhere('deleted')->eq(0)
->andWhere('parent')->eq(0)
->andWhere('parent')->lt(1)
->orderBy('id_desc')
->fetchAll();
$childTasks = $this->dao->select('*')->from(TABLE_TASK)
@@ -2784,7 +2797,7 @@ class projectModel extends model
case 'task':
$link = helper::createLink('project', 'treeTask', "taskID={$tree->id}");
$html .= '<li class="item-task">';
$html .= '<a class="tree-link" href="' . $link . '"><span class="label label-type">' . (empty($tree->parent) ? $this->lang->task->common : $this->lang->task->children) . "</span><span class='title' title='{$tree->title}'>" . $tree->title . '</span> <span class="user"><i class="icon icon-person"></i> ' . (empty($tree->assignedTo) ? $tree->openedBy : $tree->assignedTo) . '</span><span class="label label-id">' . $tree->id . '</span></a>';
$html .= '<a class="tree-link" href="' . $link . '"><span class="label label-type">' . ($tree->parent > 0 ? $this->lang->task->children : $this->lang->task->common) . "</span><span class='title' title='{$tree->title}'>" . $tree->title . '</span> <span class="user"><i class="icon icon-person"></i> ' . (empty($tree->assignedTo) ? $tree->openedBy : $tree->assignedTo) . '</span><span class="label label-id">' . $tree->id . '</span></a>';
break;
case 'product':
$this->app->loadLang('product');
+1 -1
View File
@@ -188,7 +188,7 @@
<td class="c-name" title="<?php echo $task->name;?>">
<?php
if(!empty($task->team)) echo '<span class="label label-light label-badge">' . $lang->task->multipleAB . '</span> ';
if(!empty($task->parent)) echo '<span class="label label-light label-badge">' . $lang->task->childrenAB . '</span> ';
if($task->parent > 0) echo '<span class="label label-light label-badge">' . $lang->task->childrenAB . '</span> ';
if(isset($task->children) && $task->children == true) echo '<span class="label">' . $lang->task->parentAB . '</span> ';
if(!common::printLink('task', 'view', "task=$task->id", $task->name)) echo $task->name;
?>
+1 -1
View File
@@ -136,7 +136,7 @@ $account = $this->app->user->account;
<?php foreach($group->tasks[$col] as $task):?>
<div class='board-item' data-id='<?php echo $task->id?>' id='task-<?php echo $task->id?>' data-type='task'>
<?php
$childrenAB = empty($task->parent) ? '' : "<span class='label label-light label-badge'>" . $lang->task->childrenAB . '</span> ';
$childrenAB = $task->parent > 0 ? "<span class='label label-light label-badge'>" . $lang->task->childrenAB . '</span> ' : '';
echo html::a($this->createLink('task', 'view', "taskID=$task->id", '', true), "{$childrenAB}{$task->name}", '', 'class="title kanbaniframe" title="' . $task->name . '"');
?>
<div class='info'>
+1 -1
View File
@@ -3,7 +3,7 @@
<span class="label-id"><?php echo $task->id?></span>
<span class="label label-task"><?php echo $lang->task->common?></span>
<span class="title">
<?php if(!empty($task->parent)) echo '<span class="label no-margin label-badge label-light">' . $this->lang->task->childrenAB . '</span>';?>
<?php if($task->parent > 0) echo '<span class="label no-margin label-badge label-light">' . $this->lang->task->childrenAB . '</span>';?>
<?php if(!empty($task->team)) echo '<span class="label no-margin label-badge label-light">' . $this->lang->task->multipleAB . '</span>';?>
<?php echo isset($task->parentName) ? $task->parentName . '/' : '';?><?php echo $task->name;?>
</span>
+1 -1
View File
@@ -118,7 +118,7 @@
</div>
<div class="panel-body">
<div class="row row-grid">
<?php if(common::hasPriv('project', 'objectLibs')):?>
<?php if(common::hasPriv('doc', 'objectLibs')):?>
<?php $i = 0;?>
<?php foreach($docLibs as $libID => $docLib):?>
<?php if($i > 8) break;?>
+4 -2
View File
@@ -93,8 +93,9 @@ class reportModel extends model
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id')
->where('t1.status')->ne('cancel')
->andWhere('t1.deleted')->eq(0)
->beginIF(!$this->app->user->admin)->andWhere('t2.id')->in($this->app->user->view->projects)->fi()
->andWhere('t2.deleted')->eq(0)
->andWhere('t1.parent')->eq(0)
->andWhere('t1.parent')->lt(1)
->andWhere('t2.status')->eq('closed')
->beginIF($begin)->andWhere('t2.begin')->ge($begin)->fi()
->beginIF($end)->andWhere('t2.end')->le($end)->fi()
@@ -131,6 +132,7 @@ class reportModel extends model
$products = $this->dao->select('id, code, name, PO')->from(TABLE_PRODUCT)
->where('deleted')->eq(0)
->beginIF(strpos($conditions, 'closedProduct') === false)->andWhere('status')->ne('closed')->fi()
->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->products)->fi()
->fetchAll('id');
$plans = $this->dao->select('*')->from(TABLE_PRODUCTPLAN)->where('deleted')->eq(0)->andWhere('product')->in(array_keys($products))
->beginIF(strpos($conditions, 'overduePlan') === false)->andWhere('end')->gt(date('Y-m-d'))->fi()
@@ -300,7 +302,7 @@ class reportModel extends model
$taskGroups = array();
foreach($tasks as $task)
{
if(!empty($task->parent)) $parents[$task->parent] = $task->parent;
if($task->parent > 0) $parents[$task->parent] = $task->parent;
$taskGroups[$task->assignedTo][$task->id] = $task;
}
+8 -14
View File
@@ -68,8 +68,8 @@
<div data-ride='table'>
<table class='table table-condensed table-striped table-bordered table-fixed no-margin' id="workload">
<thead>
<tr class='colhead'>
<th class="w-200px"><?php echo $lang->report->user;?></th>
<tr class='colhead text-center'>
<th class="w-100px"><?php echo $lang->report->user;?></th>
<th><?php echo $lang->report->project;?></th>
<th class="w-100px"><?php echo $lang->report->task;?></th>
<th class="w-100px"><?php echo $lang->report->remain;?></th>
@@ -88,19 +88,13 @@
<?php foreach($load['task'] as $project => $info):?>
<?php $class = $color ? 'rowcolor' : '';?>
<?php if($id != 1) echo '<tr class="text-center">';?>
<td class="<?php echo $class;?>"><?php echo html::a($this->createLink('project', 'view', "projectID={$info['projectID']}"), $project);?></td>
<td class="<?php echo $class;?> text-center"><?php echo $info['count'];?></td>
<td class="<?php echo $class;?> text-center"><?php echo $info['manhour'];?></td>
<td title='<?php echo $project?>' class="<?php echo $class;?> text-left"><?php echo html::a($this->createLink('project', 'view', "projectID={$info['projectID']}"), $project);?></td>
<td class="<?php echo $class;?>"><?php echo $info['count'];?></td>
<td class="<?php echo $class;?>"><?php echo $info['manhour'];?></td>
<?php if($id == 1):?>
<td rowspan="<?php echo count($load['task']);?>" class="text-center">
<?php echo $load['total']['count'];?>
</td>
<td rowspan="<?php echo count($load['task']);?>" class="text-center">
<?php echo $load['total']['manhour'];?>
</td>
<td rowspan="<?php echo count($load['task']);?>" class="text-center">
<?php echo round($load['total']['manhour'] / $allHour * 100, 2) . '%';?>
</td>
<td rowspan="<?php echo count($load['task']);?>"><?php echo $load['total']['count'];?></td>
<td rowspan="<?php echo count($load['task']);?>"><?php echo $load['total']['manhour'];?></td>
<td rowspan="<?php echo count($load['task']);?>"><?php echo round($load['total']['manhour'] / $allHour * 100, 2) . '%';?></td>
<?php endif;?>
<?php if($id != 1) echo '</tr>'; $id ++;?>
<?php $color = !$color;?>
+6 -1
View File
@@ -237,7 +237,12 @@ class scoreModel extends model
if($lastID == 0)
{
$this->dao->query("UPDATE " . TABLE_USER . " SET `score`=0, `scoreLevel`=0");
$this->dao->query("TRUNCATE TABLE " . TABLE_SCORE);
$this->dao->delete()->from(TABLE_SCORE)->exec();
try
{
$this->dbh->exec('ALTER TABLE ' . TABLE_SCORE . ' auto_increment=1');
}
catch(Exception $e){}
}
$actions = $this->dao->select('*')->from(TABLE_ACTION)->where('id')->gt($lastID)->orderBy('id_asc')->limit(100)->fetchAll('id');
+2 -2
View File
@@ -1401,7 +1401,7 @@ class story extends control
}
else
{
$stmt = $this->dbh->query($this->session->storyQueryCondition . ($this->post->exportType == 'selected' ? " AND t1.id IN({$this->cookie->checkedItem})" : '') . " ORDER BY " . strtr($orderBy, '_', ' '));
$stmt = $this->dbh->query($this->session->storyQueryCondition . ($this->post->exportType == 'selected' ? " AND t2.id IN({$this->cookie->checkedItem})" : '') . " ORDER BY " . strtr($orderBy, '_', ' '));
while($row = $stmt->fetch()) $stories[$row->id] = $row;
}
@@ -1440,7 +1440,7 @@ class story extends control
/* Get related objects title or names. */
$productsType = $this->dao->select('id, type')->from(TABLE_PRODUCT)->where('id')->in($relatedProductIdList)->fetchPairs();
$relatedModules = $this->dao->select('id, name')->from(TABLE_MODULE)->where('id')->in($relatedModuleIdList)->fetchPairs();
$relatedModules = $this->loadModel('tree')->getOptionMenu($productID);
$relatedPlans = $this->dao->select('id, title')->from(TABLE_PRODUCTPLAN)->where('id')->in(join(',', $relatedPlanIdList))->fetchPairs();
$relatedStories = $this->dao->select('id,title')->from(TABLE_STORY) ->where('id')->in($relatedStoryIdList)->fetchPairs();
$relatedFiles = $this->dao->select('id, objectID, pathname, title')->from(TABLE_FILE)->where('objectType')->eq('story')->andWhere('objectID')->in(@array_keys($stories))->andWhere('extra')->ne('editor')->fetchGroup('objectID');
+5
View File
@@ -2320,6 +2320,11 @@ class storyModel extends model
$title = $story->planTitle;
$class .= ' text-ellipsis';
}
if($id == 'sourceNote')
{
$title = $story->sourceNote;
$class .= ' text-ellipsis';
}
echo "<td class='" . $class . "' title='$title'>";
switch($id)
+1 -1
View File
@@ -94,7 +94,7 @@
echo "</div>";
}
if($from == 'project') common::printIcon('task', 'create', "project=$param&storyID=$story->id&moduleID=$story->module", $story, 'button', 'smile', '', 'showinonlybody');
if($from == 'project') common::printIcon('task', 'create', "project=$param&storyID=$story->id&moduleID=$story->module", $story, 'button', 'plus', '', 'showinonlybody');
echo "<div class='divider'></div>";
common::printIcon('story', 'edit', "storyID=$story->id", $story);
+1 -1
View File
@@ -1394,7 +1394,7 @@ class task extends control
if(isset($users[$task->closedBy])) $task->closedBy = $users[$task->closedBy];
if(isset($users[$task->lastEditedBy])) $task->lastEditedBy = $users[$task->lastEditedBy];
if(!empty($task->parent)) $task->name = '>' . $task->name;
if($task->parent > 0) $task->name = '>' . $task->name;
if(!empty($task->team)) $task->name = '[' . $taskLang->multipleAB . '] ' . $task->name;
$task->openedDate = substr($task->openedDate, 0, 10);
+58 -29
View File
@@ -171,7 +171,7 @@ class taskModel extends model
}
else
{
dao::$errors['message'][] = sprintf($this->lang->duplicate, $this->lang->task->common);
dao::$errors['message'][] = sprintf($this->lang->duplicate, $this->lang->task->common) . ' ' . $tasks->name[$key];
return false;
}
}
@@ -270,6 +270,7 @@ class taskModel extends model
{
$this->updateParentStatus($taskID);
$this->computeBeginAndEnd($parentID);
$this->dao->update(TABLE_TASK)->set('parent')->eq(-1)->where('id')->eq($parentID)->exec();
}
return $mails;
}
@@ -363,10 +364,14 @@ class taskModel extends model
}
else
{
if(isset($childrenStatus['doing']) or isset($childrenStatus['pause']) or isset($childrenStatus['wait']))
if(isset($childrenStatus['doing']) or isset($childrenStatus['pause']))
{
$status = 'doing';
}
elseif(isset($childrenStatus['wait']))
{
$status = 'wait';
}
elseif(isset($childrenStatus['done']))
{
$status = 'done';
@@ -921,6 +926,8 @@ class taskModel extends model
$task = $this->computeHours4Multiple($oldTask, $task);
}
if($oldTask->parent > 0) $this->updateParentStatus($taskID);
$this->dao->update(TABLE_TASK)
->data($task)
@@ -1386,7 +1393,7 @@ class taskModel extends model
$task->children = $children;
/* Check parent Task. */
if(!empty($task->parent)) $task->parentName = $this->dao->findById($task->parent)->from(TABLE_TASK)->fetch('name');
if($task->parent > 0) $task->parentName = $this->dao->findById($task->parent)->from(TABLE_TASK)->fetch('name');
$task->team = $this->dao->select('*')->from(TABLE_TEAM)->where('root')->eq($taskID)->andWhere('type')->eq('task')->orderBy('order')->fetchAll('account');
foreach($children as $child) $child->team = isset($teams[$child->id]) ? $teams[$child->id] : array();
@@ -1475,7 +1482,7 @@ class taskModel extends model
->leftJoin(TABLE_TEAM)->alias('t4')->on('t4.root = t1.id')
->leftJoin(TABLE_MODULE)->alias('t5')->on('t1.module = t5.id')
->where('t1.project')->eq((int)$projectID)
->beginIF($type =='all' || is_array($type))->andWhere('t1.parent')->eq(0)->fi()
->beginIF($type == 'all' || is_array($type))->andWhere('t1.parent')->lt(1)->fi()
->beginIF($type == 'myinvolved')
->andWhere("((t4.`account` = '{$this->app->user->account}' AND t4.`type` = 'task') OR t1.`assignedTo` = '{$this->app->user->account}' OR t1.`finishedby` = '{$this->app->user->account}')")
->fi()
@@ -1503,34 +1510,53 @@ class taskModel extends model
foreach($taskTeam as $taskID => $team) $tasks[$taskID]->team = $team;
}
/* Select children task. */
$children = $this->dao->select('DISTINCT t1.*, t2.id AS storyID, t2.title AS storyTitle, t2.product, t2.branch, t2.version AS latestStoryVersion, t2.status AS storyStatus, t3.realname AS assignedToRealName')
->from(TABLE_TASK)->alias('t1')
->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id')
->leftJoin(TABLE_USER)->alias('t3')->on('t1.assignedTo = t3.account')
->leftJoin(TABLE_MODULE)->alias('t4')->on('t1.module = t4.id')
->where('t1.project')->eq((int)$projectID)
->andWhere('t1.parent')->in($taskList)
->andWhere('t1.deleted')->eq(0)
->beginIF($productID)->andWhere("((t4.root=" . (int)$productID . " and t4.type='story') OR t2.product=" . (int)$productID . ")")->fi()
->beginIF($type == 'undone')->andWhere("(t1.status = 'wait' or t1.status ='doing')")->fi()
->beginIF($type == 'needconfirm')->andWhere('t2.version > t1.storyVersion')->andWhere("t2.status = 'active'")->fi()
->beginIF($type == 'assignedtome')->andWhere('t1.assignedTo')->eq($this->app->user->account)->fi()
->beginIF($type == 'finishedbyme')->andWhere('t1.finishedby')->eq($this->app->user->account)->fi()
->beginIF($type == 'delayed')->andWhere('t1.deadline')->gt('1970-1-1')->andWhere('t1.deadline')->lt(date(DT_DATE1))->andWhere('t1.status')->in('wait,doing')->fi()
->beginIF(is_array($type) or strpos(',all,undone,needconfirm,assignedtome,delayed,finishedbyme,myinvolved,', ",$type,") === false)->andWhere('t1.status')->in($type)->fi()
->beginIF($modules)->andWhere('t1.module')->in($modules)->fi()
->orderBy("t1.$orderBy")
->fetchAll('id');
if(!empty($children))
$parents = [];
foreach($tasks as $task)
{
foreach($children as $child)
if($task->parent == -1) $parents[] = $task->id;
}
if(!empty($parents))
{
/* Select children task. */
$children = $this->dao->select('DISTINCT t1.*, t2.id AS storyID, t2.title AS storyTitle, t2.product, t2.branch, t2.version AS latestStoryVersion, t2.status AS storyStatus, t3.realname AS assignedToRealName')
->from(TABLE_TASK)->alias('t1')
->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id')
->leftJoin(TABLE_USER)->alias('t3')->on('t1.assignedTo = t3.account')
->leftJoin(TABLE_MODULE)->alias('t4')->on('t1.module = t4.id')
->where('t1.parent')->in($parents)
->andWhere('t1.deleted')->eq(0)
->beginIF($productID)->andWhere("((t4.root=" . (int)$productID . " and t4.type='story') OR t2.product=" . (int)$productID . ")")->fi()
->beginIF($type == 'undone')->andWhere("(t1.status = 'wait' or t1.status ='doing')")->fi()
->beginIF($type == 'needconfirm')->andWhere('t2.version > t1.storyVersion')->andWhere("t2.status = 'active'")->fi()
->beginIF($type == 'assignedtome')->andWhere('t1.assignedTo')->eq($this->app->user->account)->fi()
->beginIF($type == 'finishedbyme')->andWhere('t1.finishedby')->eq($this->app->user->account)->fi()
->beginIF($type == 'delayed')->andWhere('t1.deadline')->gt('1970-1-1')->andWhere('t1.deadline')->lt(date(DT_DATE1))->andWhere('t1.status')->in('wait,doing')->fi()
->beginIF(is_array($type) or strpos(',all,undone,needconfirm,assignedtome,delayed,finishedbyme,myinvolved,', ",$type,") === false)->andWhere('t1.status')->in($type)->fi()
->beginIF($modules)->andWhere('t1.module')->in($modules)->fi()
->orderBy("t1.$orderBy")
->fetchAll('id');
if(!empty($children))
{
$tasks[$child->parent]->children[] = $child;
foreach($children as $child)
{
$tasks[$child->parent]->children[$child->id] = $child;
}
}
}
foreach($tasks as $task)
{
if($task->parent > 0)
{
if(isset($tasks[$task->parent]))
{
$tasks[$task->parent]->children[$task->id] = $task;
unset($tasks[$task->id]);
}
}
}
return $this->processTasks($tasks);
}
@@ -1850,7 +1876,10 @@ class taskModel extends model
$task = $this->processTask($task);
if(!empty($task->children))
{
foreach($task->children as $child) $task = $this->processTask($child);
foreach($task->children as $child)
{
$tasks[$task->id]->children[$child->id] = $this->processTask($child);
}
}
}
return $tasks;
@@ -2407,7 +2436,7 @@ class taskModel extends model
case 'name':
if(!empty($task->product) && isset($branchGroups[$task->product][$task->branch])) echo "<span class='label label-info label-outline'>" . $branchGroups[$task->product][$task->branch] . '</span> ';
if(empty($task->children) and $task->module and isset($modulePairs[$task->module])) echo "<span class='label label-gray label-badge'>" . $modulePairs[$task->module] . '</span> ';
if($child or !empty($task->parent)) echo '<span class="label label-badge label-light">' . $this->lang->task->childrenAB . '</span> ';
if($task->parent > 0) echo '<span class="label label-badge label-light">' . $this->lang->task->childrenAB . '</span> ';
if(!empty($task->team)) echo '<span class="label label-badge label-light">' . $this->lang->task->multipleAB . '</span> ';
echo $canView ? html::a($taskLink, $task->name, null, "style='color: $task->color'") : "<span style='color: $task->color'>$task->name</span>";
if(!empty($task->children)) echo '<a class="task-toggle" data-id="' . $task->id . '"><i class="icon icon-angle-double-right"></i></a>';
+3 -3
View File
@@ -22,9 +22,9 @@
<div class="page-title">
<span class="label label-id"><?php echo $task->id?></span>
<span class="text" title='<?php echo $task->name;?>' style='color: <?php echo $task->color; ?>'>
<?php if(!empty($task->parent)) echo '<span class="label label-badge label-primary no-margin">' . $this->lang->task->childrenAB . '</span>';?>
<?php if($task->parent > 0) echo '<span class="label label-badge label-primary no-margin">' . $this->lang->task->childrenAB . '</span>';?>
<?php if(!empty($task->team)) echo '<span class="label label-badge label-primary no-margin">' . $this->lang->task->multipleAB . '</span>';?>
<?php echo isset($task->parentName) ? html::a(inlink('view', "taskID={$task->parent}"), $task->parentName) . ' / ' : '';?><?php echo $task->name;?>
<?php if($task->parent > 0) echo isset($task->parentName) ? html::a(inlink('view', "taskID={$task->parent}"), $task->parentName) . ' / ' : '';?><?php echo $task->name;?>
</span>
<?php if($task->deleted):?>
<span class='label label-danger'><?php echo $lang->task->deleted;?></span>
@@ -157,7 +157,7 @@
common::printIcon('task', 'create', "productID=0&storyID=0&moduleID=0&taskID=$task->id", $task, 'button', 'copy');
common::printIcon('task', 'delete', "projectID=$task->project&taskID=$task->id", $task, 'button', '', 'hiddenwin');
if(!empty($task->parent)) echo html::a(helper::createLink('task', 'view', "taskID=$task->parent"), "<i class='icon icon-chevron-double-up'></i>", '', "class='btn btn-link' title='{$lang->task->parent}'");
if($task->parent > 0) echo html::a(helper::createLink('task', 'view', "taskID=$task->parent"), "<i class='icon icon-chevron-double-up'></i>", '', "class='btn btn-link' title='{$lang->task->parent}'");
?>
<?php endif;?>
</div>
+1 -1
View File
@@ -1100,7 +1100,7 @@ class testcase extends control
}
/* Get related objects title or names. */
$relatedModules = $this->dao->select('id, name')->from(TABLE_MODULE)->where('id')->in($relatedModuleIdList)->fetchPairs();
$relatedModules = $this->loadModel('tree')->getOptionMenu($productID, 'case');
$relatedStories = $this->dao->select('id,title')->from(TABLE_STORY) ->where('id')->in($relatedStoryIdList)->fetchPairs();
$relatedCases = $this->dao->select('id, title')->from(TABLE_CASE)->where('id')->in($relatedCaseIdList)->fetchPairs();
$relatedSteps = $this->dao->select('id,parent,`case`,version,type,`desc`,expect')->from(TABLE_CASESTEP)->where('`case`')->in(@array_keys($cases))->orderBy('version desc,id')->fetchGroup('case', 'id');
+1 -1
View File
@@ -23,7 +23,7 @@ $(document).ready(function()
}
}
}
link = createLink('story', 'ajaxGetProductStories', 'productID=' + productID + '&branch=' + branch + '&moduleID=' + module + '&storyID='+ $(select).val() + '&onlyOption=true&status=noclosed');
link = createLink('story', 'ajaxGetProductStories', 'productID=' + productID + '&branch=' + branch + '&moduleID=' + module + '&storyID='+ $(select).val() + '&onlyOption=true');
$('#story' + index).load(link, function(){$(this).trigger("chosen:updated");});
}
if($(select).val() == 'ditto')
+2 -2
View File
@@ -76,8 +76,8 @@
echo "<th class='step-id'>$stepId</th>";
echo "<td class='text-left'><div class='input-group'>";
if($step->type == 'item') echo "<span class='step-item-id'>{$stepId}.{$childId}</span>";
echo nl2br($step->desc) . "</td>";
echo "<td class='text-left'>" . nl2br($step->expect) . "</div></td>";
echo nl2br(str_replace(' ', '&nbsp;', $step->desc)) . "</td>";
echo "<td class='text-left'>" . nl2br(str_replace(' ', '&nbsp;', $step->expect)) . "</div></td>";
echo "</tr>";
$childId ++;
}
+4 -4
View File
@@ -48,10 +48,10 @@
<?php if(!$task->deleted):?>
<div class='divider'></div>
<?php
common::printIcon('testtask', 'start', "taskID=$task->id", $task, 'button', '', '', 'iframe', true);
common::printIcon('testtask', 'close', "taskID=$task->id", $task, 'button', '', '', 'iframe', true);
common::printIcon('testtask', 'block', "taskID=$task->id", $task, 'button', 'pause', '', 'iframe', true);
common::printIcon('testtask', 'activate', "taskID=$task->id", $task, 'button', 'magic', '', 'iframe', true);
common::printIcon('testtask', 'start', "taskID=$task->id", $task, 'button', '', '', 'iframe showinonlybody', true);
common::printIcon('testtask', 'close', "taskID=$task->id", $task, 'button', '', '', 'iframe showinonlybody', true);
common::printIcon('testtask', 'block', "taskID=$task->id", $task, 'button', 'pause', '', 'iframe showinonlybody', true);
common::printIcon('testtask', 'activate', "taskID=$task->id", $task, 'button', 'magic', '', 'iframe showinonlybody', true);
common::printIcon('testtask', 'cases', "taskID=$task->id", $task, 'button', 'sitemap');
common::printIcon('testtask', 'linkCase', "taskID=$task->id", $task, 'button', 'link');
?>
+1 -1
View File
@@ -340,7 +340,7 @@ class todo extends control
$this->lang->set('menugroup.todo', $from);
}
$this->view->title = "{$this->lang->todo->common} #$todo->id $todo->name";
$this->view->title = $this->app->user->account == $todo->account ? "{$this->lang->todo->common} #$todo->id $todo->name" : $this->lang->todo->common ;
$this->view->position[] = $this->lang->todo->view;
$this->view->todo = $todo;
$this->view->times = date::buildTimeList($this->config->todo->times->begin, $this->config->todo->times->end, $this->config->todo->times->delta);
+3 -4
View File
@@ -42,18 +42,17 @@ function loadList(type, id)
{
$.get(link, function(data, status)
{
if(data != ' ')
if(data.length != 0)
{
$(divClass).html(data).find('select').chosen();
}
else
{
$("#type").val("custom");
$(divClass).html("<select id='bugs' class='form-control'></select>").find('select').chosen();
$(divClass).html("<select id="+ type +" class='form-control'></select>").find('select').chosen();
}
});
}
else if(type == 'custom')
else
{
$(divClass).html($(divID).html());
}
+2 -1
View File
@@ -17,7 +17,8 @@ $(function()
$('#switchDate').closest('.input-group-addon').addClass('hidden');
$('#type').find('option').each(function()
{
if($(this).val() != 'custom') $(this).addClass('hidden');
var type = $(this).val();
if(type == 'bug' || type == 'task' || type == 'story') $(this).addClass('hidden');
})
}
else
+1 -2
View File
@@ -383,14 +383,13 @@ class todoModel extends model
->beginIF($begin)->andWhere('date')->ge($begin)->fi()
->beginIF($end)->andWhere('date')->le($end)->fi()
->beginIF($status != 'all' and $status != 'undone')->andWhere('status')->in($status)->fi()
->beginIF($status == 'undone')->andWhere('status')->ne('done')->fi()
->beginIF($status == 'undone')->andWhere('status')->notin('done,closed')->fi()
->beginIF($date == 'cycle')->andWhere('cycle')->eq('1')->fi()
->beginIF($date != 'cycle')->andWhere('cycle')->eq('0')->fi()
->orderBy($orderBy)
->beginIF($limit > 0)->limit($limit)->fi()
->page($pager)
->query();
/* Set session. */
$sql = explode('WHERE', $this->dao->get());
$sql = explode('ORDER', $sql[1]);
+9 -2
View File
@@ -1644,7 +1644,7 @@ class treeModel extends model
*/
public function getDocStructure()
{
$stmt = $this->dbh->query($this->dao->select('*')->from(TABLE_MODULE)->where('type')->eq('doc')->andWhere('deleted')->eq(0)->get());
$stmt = $this->dbh->query($this->dao->select('*')->from(TABLE_MODULE)->where('type')->eq('doc')->andWhere('deleted')->eq(0)->orderBy('id_desc')->get());
$parent = array();
while($module = $stmt->fetch())
{
@@ -1666,11 +1666,18 @@ class treeModel extends model
{
foreach($module->children as $children)
{
if($children->parent != 0) continue;//Filter project children modules.
if($children->parent != 0 && !empty($tree[$root]))
{
foreach($tree[$root] as $firstChildren)
{
if($firstChildren->id == $children->parent) $firstChildren->children[] = $children;
}
};//Filter project children modules.
$tree[$root][] = $children;
}
}
}
return $tree;
}
}
+1 -1
View File
@@ -142,7 +142,7 @@
<?php endif;?>
<td colspan="2" class="form-actions">
<?php echo html::submitButton();?>
<?php echo $this->session->{$viewType . 'List'} ? html::linkButton($this->lang->goback, $this->session->{$viewType .'List'}, 'self', '', 'btn btn-wide') : html::backButton();?>
<?php echo html::a($backLink, $lang->goback, '', "class='btn btn-wide'");?>
<?php echo html::hidden('parentModuleID', $currentModuleID);?>
<?php echo html::hidden('maxOrder', $maxOrder);?>
</td>
+1 -1
View File
@@ -110,7 +110,7 @@
<td colspan='2' class="form-actions">
<?php
echo html::submitButton();
echo $this->session->taskList ? html::linkButton($this->lang->goback, $this->session->taskList, '', '', 'btn btn-wide') : html::backButton();
echo html::a($backLink, $lang->goback, '', "class='btn btn-wide'");
echo html::hidden('parentModuleID', $currentModuleID);
echo html::hidden('maxOrder', $maxOrder);
?>
+1 -1
View File
@@ -2,7 +2,7 @@ body {background: #1183fb linear-gradient(-90deg, #0a48d1 0%, #1183fb 100%); bac
#login {max-width: 600px!important; margin: 0 auto; margin-top: 5%;}
#loginPanel {background: #fff; overflow: hidden; box-shadow: 0 0 20px 0 rgba(0,0,0,.1); border-radius: 3px;}
#loginPanel > header {padding: 20px; border-bottom: 1px #eee solid; position: relative;}
#loginPanel > header > h2 {font-size: 16px; margin: 0; line-height: 32px;}
#loginPanel > header > h2 {font-size: 16px; margin: 0; line-height: 32px; max-width: 83%;}
#loginPanel > header > .actions {position: absolute; right: 20px; top: 20px;}
#loginPanel > .table-row {margin: 20px 0;}
#loginPanel .table-form > tbody > tr > th {width: 60px;}
+1 -1
View File
@@ -1318,7 +1318,7 @@ class userModel extends model
{
if(empty($account)) $account = $this->session->user->account;
if(empty($account)) return array();
if(empty($acls) and isset($this->session->user->rights['acls'])) $acls = $this->session->user->rights['acls'];
if(empty($acls) and !empty($this->session->user->rights['acls'])) $acls = $this->session->user->rights['acls'];
$userView = $this->dao->select('*')->from(TABLE_USERVIEW)->where('account')->eq($account)->fetch();
if(empty($userView)) $userView = $this->computeUserView($account);
+3 -2
View File
@@ -25,7 +25,7 @@
<table align='center' class="table table-form">
<tr>
<th class='w-verifyPassword'><?php echo $lang->user->dept;?></th>
<td class='w-p50'><?php echo html::select('dept', $depts, $deptID, "class='form-control chosen'");?></td>
<td class='w-p40'><?php echo html::select('dept', $depts, $deptID, "class='form-control chosen'");?></td>
</tr>
<tr>
<th><?php echo $lang->user->account;?></th>
@@ -83,7 +83,8 @@
</td>
</tr>
<tr>
<td colspan='3' class='text-center form-actions'>
<th></th>
<td colspan='2' class='text-left form-actions'>
<?php echo html::submitButton();?>
<?php echo html::backButton();?>
</td>
+31
View File
@@ -0,0 +1,31 @@
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> - v<%= pkg.version %> */\n'
},
build: {
src: 'fingerprint.js',
dest: 'build/fingerprint.min.js'
}
},
jshint: {
file: ['Gruntfile.js', 'fingerprint.js', 'specs/**/*_spec.js'],
options: {
eqnull: true,
'-W086': true //W086: Expected a 'break' statement before 'case'.
}
}
});
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
// Default task(s).
grunt.registerTask('default', ['jshint', 'uglify']);
};
+285
View File
@@ -0,0 +1,285 @@
/*
* fingerprintJS 0.5.4 - Fast browser fingerprint library
* https://github.com/Valve/fingerprintjs
* Copyright (c) 2013 Valentin Vasilyev (valentin.vasilyev@outlook.com)
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
;(function (name, context, definition) {
if (typeof module !== 'undefined' && module.exports) { module.exports = definition(); }
else if (typeof define === 'function' && define.amd) { define(definition); }
else { context[name] = definition(); }
})('Fingerprint', this, function () {
'use strict';
var Fingerprint = function (options) {
var nativeForEach, nativeMap;
nativeForEach = Array.prototype.forEach;
nativeMap = Array.prototype.map;
this.each = function (obj, iterator, context) {
if (obj === null) {
return;
}
if (nativeForEach && obj.forEach === nativeForEach) {
obj.forEach(iterator, context);
} else if (obj.length === +obj.length) {
for (var i = 0, l = obj.length; i < l; i++) {
if (iterator.call(context, obj[i], i, obj) === {}) return;
}
} else {
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
if (iterator.call(context, obj[key], key, obj) === {}) return;
}
}
}
};
this.map = function(obj, iterator, context) {
var results = [];
// Not using strict equality so that this acts as a
// shortcut to checking for `null` and `undefined`.
if (obj == null) return results;
if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context);
this.each(obj, function(value, index, list) {
results[results.length] = iterator.call(context, value, index, list);
});
return results;
};
if (typeof options == 'object'){
this.hasher = options.hasher;
this.screen_resolution = options.screen_resolution;
this.screen_orientation = options.screen_orientation;
this.canvas = options.canvas;
this.ie_activex = options.ie_activex;
} else if(typeof options == 'function'){
this.hasher = options;
}
};
Fingerprint.prototype = {
get: function(){
var keys = [];
keys.push(navigator.userAgent);
keys.push(navigator.language);
keys.push(screen.colorDepth);
if (this.screen_resolution) {
var resolution = this.getScreenResolution();
if (typeof resolution !== 'undefined'){ // headless browsers, such as phantomjs
keys.push(this.getScreenResolution().join('x'));
}
}
keys.push(new Date().getTimezoneOffset());
keys.push(this.hasSessionStorage());
keys.push(this.hasLocalStorage());
keys.push(!!window.indexedDB);
//body might not be defined at this point or removed programmatically
if(document.body){
keys.push(typeof(document.body.addBehavior));
} else {
keys.push(typeof undefined);
}
keys.push(typeof(window.openDatabase));
keys.push(navigator.cpuClass);
keys.push(navigator.platform);
keys.push(navigator.doNotTrack);
keys.push(this.getPluginsString());
if(this.canvas && this.isCanvasSupported()){
keys.push(this.getCanvasFingerprint());
}
if(this.hasher){
return this.hasher(keys.join('###'), 31);
} else {
return this.murmurhash3_32_gc(keys.join('###'), 31);
}
},
/**
* JS Implementation of MurmurHash3 (r136) (as of May 20, 2011)
*
* @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
* @see http://github.com/garycourt/murmurhash-js
* @author <a href="mailto:aappleby@gmail.com">Austin Appleby</a>
* @see http://sites.google.com/site/murmurhash/
*
* @param {string} key ASCII only
* @param {number} seed Positive integer only
* @return {number} 32-bit positive integer hash
*/
murmurhash3_32_gc: function(key, seed) {
var remainder, bytes, h1, h1b, c1, c2, k1, i;
remainder = key.length & 3; // key.length % 4
bytes = key.length - remainder;
h1 = seed;
c1 = 0xcc9e2d51;
c2 = 0x1b873593;
i = 0;
while (i < bytes) {
k1 =
((key.charCodeAt(i) & 0xff)) |
((key.charCodeAt(++i) & 0xff) << 8) |
((key.charCodeAt(++i) & 0xff) << 16) |
((key.charCodeAt(++i) & 0xff) << 24);
++i;
k1 = ((((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16))) & 0xffffffff;
k1 = (k1 << 15) | (k1 >>> 17);
k1 = ((((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16))) & 0xffffffff;
h1 ^= k1;
h1 = (h1 << 13) | (h1 >>> 19);
h1b = ((((h1 & 0xffff) * 5) + ((((h1 >>> 16) * 5) & 0xffff) << 16))) & 0xffffffff;
h1 = (((h1b & 0xffff) + 0x6b64) + ((((h1b >>> 16) + 0xe654) & 0xffff) << 16));
}
k1 = 0;
switch (remainder) {
case 3: k1 ^= (key.charCodeAt(i + 2) & 0xff) << 16;
case 2: k1 ^= (key.charCodeAt(i + 1) & 0xff) << 8;
case 1: k1 ^= (key.charCodeAt(i) & 0xff);
k1 = (((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16)) & 0xffffffff;
k1 = (k1 << 15) | (k1 >>> 17);
k1 = (((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16)) & 0xffffffff;
h1 ^= k1;
}
h1 ^= key.length;
h1 ^= h1 >>> 16;
h1 = (((h1 & 0xffff) * 0x85ebca6b) + ((((h1 >>> 16) * 0x85ebca6b) & 0xffff) << 16)) & 0xffffffff;
h1 ^= h1 >>> 13;
h1 = ((((h1 & 0xffff) * 0xc2b2ae35) + ((((h1 >>> 16) * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff;
h1 ^= h1 >>> 16;
return h1 >>> 0;
},
// https://bugzilla.mozilla.org/show_bug.cgi?id=781447
hasLocalStorage: function () {
try{
return !!window.localStorage;
} catch(e) {
return true; // SecurityError when referencing it means it exists
}
},
hasSessionStorage: function () {
try{
return !!window.sessionStorage;
} catch(e) {
return true; // SecurityError when referencing it means it exists
}
},
isCanvasSupported: function () {
var elem = document.createElement('canvas');
return !!(elem.getContext && elem.getContext('2d'));
},
isIE: function () {
if(navigator.appName === 'Microsoft Internet Explorer') {
return true;
} else if(navigator.appName === 'Netscape' && /Trident/.test(navigator.userAgent)){// IE 11
return true;
}
return false;
},
getPluginsString: function () {
if(this.isIE() && this.ie_activex){
return this.getIEPluginsString();
} else {
return this.getRegularPluginsString();
}
},
getRegularPluginsString: function () {
return this.map(navigator.plugins, function (p) {
var mimeTypes = this.map(p, function(mt){
return [mt.type, mt.suffixes].join('~');
}).join(',');
return [p.name, p.description, mimeTypes].join('::');
}, this).join(';');
},
getIEPluginsString: function () {
if(window.ActiveXObject){
var names = ['ShockwaveFlash.ShockwaveFlash',//flash plugin
'AcroPDF.PDF', // Adobe PDF reader 7+
'PDF.PdfCtrl', // Adobe PDF reader 6 and earlier, brrr
'QuickTime.QuickTime', // QuickTime
// 5 versions of real players
'rmocx.RealPlayer G2 Control',
'rmocx.RealPlayer G2 Control.1',
'RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)',
'RealVideo.RealVideo(tm) ActiveX Control (32-bit)',
'RealPlayer',
'SWCtl.SWCtl', // ShockWave player
'WMPlayer.OCX', // Windows media player
'AgControl.AgControl', // Silverlight
'Skype.Detection'];
// starting to detect plugins in IE
return this.map(names, function(name){
try{
new ActiveXObject(name);
return name;
} catch(e){
return null;
}
}).join(';');
} else {
return ""; // behavior prior version 0.5.0, not breaking backwards compat.
}
},
getScreenResolution: function () {
var resolution;
if(this.screen_orientation){
resolution = (screen.height > screen.width) ? [screen.height, screen.width] : [screen.width, screen.height];
}else{
resolution = [screen.height, screen.width];
}
return resolution;
},
getCanvasFingerprint: function () {
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
// https://www.browserleaks.com/canvas#how-does-it-work
var txt = 'http://valve.github.io';
ctx.textBaseline = "top";
ctx.font = "14px 'Arial'";
ctx.textBaseline = "alphabetic";
ctx.fillStyle = "#f60";
ctx.fillRect(125,1,62,20);
ctx.fillStyle = "#069";
ctx.fillText(txt, 2, 15);
ctx.fillStyle = "rgba(102, 204, 0, 0.7)";
ctx.fillText(txt, 4, 17);
return canvas.toDataURL();
}
};
return Fingerprint;
});
+10
View File
@@ -0,0 +1,10 @@
{
"name": "fingerprintjs",
"version": "0.5.3",
"main": "fingerprint.js",
"devDependencies": {
"grunt": "~0.4.2",
"grunt-contrib-jshint": "~0.6.3",
"grunt-contrib-uglify": "~0.2.2"
}
}
@@ -0,0 +1,124 @@
describe("Fingerprint", function(){
beforeEach(function() {
this.addMatchers({
toBeInstanceOf : function(expected) {
return this.actual instanceof expected && this.actual.length > 0;
},
toBeA: function(expected) {
return typeof this.actual === expected;
}
});
});
describe("new Fingerprint", function(){
it("Creates a new instance of Fingerprint", function(){
expect(new Fingerprint()).not.toBeNull();
});
it("Accepts a custom hashing function as argument", function(){
var hasher = function(){return 31;};
expect(new Fingerprint(hasher)).not.toBeNull();
});
it("Accepts a custom hasing function as options argument", function(){
var hasher = function(){return 31;};
expect(new Fingerprint({hasher: hasher})).not.toBeNull();
});
});
describe("#get", function(){
it("Calculates fingerprint with built-in hashing if no custom hashing is given", function(){
var fingerprint = new Fingerprint();
spyOn(fingerprint, 'murmurhash3_32_gc');
fingerprint.get();
expect(fingerprint.murmurhash3_32_gc).toHaveBeenCalled();
});
it("Calculates fingerprint with custom hashing if it is given as an argument", function(){
var hasher = function(){return 'abcdef';};
var fingerprint = new Fingerprint(hasher);
expect(fingerprint.get()).toEqual('abcdef');
});
it("Calculates fingerprint with custom hashing if it is given as an options argument", function(){
var hasher = function(){return 'abcdef';};
var fingerprint = new Fingerprint({hasher: hasher});
expect(fingerprint.get()).toEqual('abcdef');
});
it('Calculates fingerprint with canvas fingerprinting if it is said to do so', function(){
var fp = new Fingerprint({canvas: true});
spyOn(fp, 'getCanvasFingerprint');
fp.get();
expect(fp.getCanvasFingerprint).toHaveBeenCalled();
});
it('Does not try to use canvas fingerprinting when not told to(version 1)', function(){
var fp = new Fingerprint({canvas: false});
spyOn(fp, 'getCanvasFingerprint');
fp.get();
expect(fp.getCanvasFingerprint).not.toHaveBeenCalled();
});
it('Does not try to use canvas fingerprinting when not told to(version 2)', function(){
var fp = new Fingerprint();
spyOn(fp, 'getCanvasFingerprint');
fp.get();
expect(fp.getCanvasFingerprint).not.toHaveBeenCalled();
});
it('Calculates fingerprint with ActiveX fingerprinting if it is said to do so', function(){
var fp = new Fingerprint({ie_activex: true});
spyOn(fp, 'isIE').andReturn(true);
spyOn(fp, 'getIEPluginsString');
fp.get();
expect(fp.getIEPluginsString).toHaveBeenCalled();
});
it('Does not try to use ActiveX fingerprinting when not told to(version 1)', function(){
var fp = new Fingerprint({ie_activex: false});
spyOn(fp, 'getIEPluginsString');
fp.get();
expect(fp.getIEPluginsString).not.toHaveBeenCalled();
});
it('Does not try to use ActiveX fingerprinting when not told to(version 2)', function(){
var fp = new Fingerprint();
spyOn(fp, 'getIEPluginsString');
fp.get();
expect(fp.getIEPluginsString).not.toHaveBeenCalled();
});
it('Calculates fingerprint accessing screen resolution if it is said to do so', function(){
var fp = new Fingerprint({screen_resolution: true});
spyOn(fp, 'getScreenResolution');
fp.get();
expect(fp.getScreenResolution).toHaveBeenCalled();
});
it('Does not try to use screen resolution when not told to', function(){
var fp = new Fingerprint();
spyOn(fp, 'getScreenResolution');
fp.get();
expect(fp.getScreenResolution).not.toHaveBeenCalled();
});
it("Returns a number as a fingerprint value when used with a built-in hashing function", function(){
var fingerprint = new Fingerprint();
expect(fingerprint.get()).toBeA('number');
});
it('Returns a string from getCanvasFingerprint function', function(){
var fp = new Fingerprint({canvas: true});
expect(fp.getCanvasFingerprint()).toBeA('string');
});
it('Does not fail when document.body is null', function(){
var body = document.body.parentNode.removeChild(document.body);
var fingerprint = new Fingerprint();
expect(fingerprint.get()).toBeA('number');
document.body = body;
});
});
});
@@ -0,0 +1,681 @@
jasmine.HtmlReporterHelpers = {};
jasmine.HtmlReporterHelpers.createDom = function(type, attrs, childrenVarArgs) {
var el = document.createElement(type);
for (var i = 2; i < arguments.length; i++) {
var child = arguments[i];
if (typeof child === 'string') {
el.appendChild(document.createTextNode(child));
} else {
if (child) {
el.appendChild(child);
}
}
}
for (var attr in attrs) {
if (attr == "className") {
el[attr] = attrs[attr];
} else {
el.setAttribute(attr, attrs[attr]);
}
}
return el;
};
jasmine.HtmlReporterHelpers.getSpecStatus = function(child) {
var results = child.results();
var status = results.passed() ? 'passed' : 'failed';
if (results.skipped) {
status = 'skipped';
}
return status;
};
jasmine.HtmlReporterHelpers.appendToSummary = function(child, childElement) {
var parentDiv = this.dom.summary;
var parentSuite = (typeof child.parentSuite == 'undefined') ? 'suite' : 'parentSuite';
var parent = child[parentSuite];
if (parent) {
if (typeof this.views.suites[parent.id] == 'undefined') {
this.views.suites[parent.id] = new jasmine.HtmlReporter.SuiteView(parent, this.dom, this.views);
}
parentDiv = this.views.suites[parent.id].element;
}
parentDiv.appendChild(childElement);
};
jasmine.HtmlReporterHelpers.addHelpers = function(ctor) {
for(var fn in jasmine.HtmlReporterHelpers) {
ctor.prototype[fn] = jasmine.HtmlReporterHelpers[fn];
}
};
jasmine.HtmlReporter = function(_doc) {
var self = this;
var doc = _doc || window.document;
var reporterView;
var dom = {};
// Jasmine Reporter Public Interface
self.logRunningSpecs = false;
self.reportRunnerStarting = function(runner) {
var specs = runner.specs() || [];
if (specs.length == 0) {
return;
}
createReporterDom(runner.env.versionString());
doc.body.appendChild(dom.reporter);
setExceptionHandling();
reporterView = new jasmine.HtmlReporter.ReporterView(dom);
reporterView.addSpecs(specs, self.specFilter);
};
self.reportRunnerResults = function(runner) {
reporterView && reporterView.complete();
};
self.reportSuiteResults = function(suite) {
reporterView.suiteComplete(suite);
};
self.reportSpecStarting = function(spec) {
if (self.logRunningSpecs) {
self.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
}
};
self.reportSpecResults = function(spec) {
reporterView.specComplete(spec);
};
self.log = function() {
var console = jasmine.getGlobal().console;
if (console && console.log) {
if (console.log.apply) {
console.log.apply(console, arguments);
} else {
console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
}
}
};
self.specFilter = function(spec) {
if (!focusedSpecName()) {
return true;
}
return spec.getFullName().indexOf(focusedSpecName()) === 0;
};
return self;
function focusedSpecName() {
var specName;
(function memoizeFocusedSpec() {
if (specName) {
return;
}
var paramMap = [];
var params = jasmine.HtmlReporter.parameters(doc);
for (var i = 0; i < params.length; i++) {
var p = params[i].split('=');
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
}
specName = paramMap.spec;
})();
return specName;
}
function createReporterDom(version) {
dom.reporter = self.createDom('div', { id: 'HTMLReporter', className: 'jasmine_reporter' },
dom.banner = self.createDom('div', { className: 'banner' },
self.createDom('span', { className: 'title' }, "Jasmine "),
self.createDom('span', { className: 'version' }, version)),
dom.symbolSummary = self.createDom('ul', {className: 'symbolSummary'}),
dom.alert = self.createDom('div', {className: 'alert'},
self.createDom('span', { className: 'exceptions' },
self.createDom('label', { className: 'label', 'for': 'no_try_catch' }, 'No try/catch'),
self.createDom('input', { id: 'no_try_catch', type: 'checkbox' }))),
dom.results = self.createDom('div', {className: 'results'},
dom.summary = self.createDom('div', { className: 'summary' }),
dom.details = self.createDom('div', { id: 'details' }))
);
}
function noTryCatch() {
return window.location.search.match(/catch=false/);
}
function searchWithCatch() {
var params = jasmine.HtmlReporter.parameters(window.document);
var removed = false;
var i = 0;
while (!removed && i < params.length) {
if (params[i].match(/catch=/)) {
params.splice(i, 1);
removed = true;
}
i++;
}
if (jasmine.CATCH_EXCEPTIONS) {
params.push("catch=false");
}
return params.join("&");
}
function setExceptionHandling() {
var chxCatch = document.getElementById('no_try_catch');
if (noTryCatch()) {
chxCatch.setAttribute('checked', true);
jasmine.CATCH_EXCEPTIONS = false;
}
chxCatch.onclick = function() {
window.location.search = searchWithCatch();
};
}
};
jasmine.HtmlReporter.parameters = function(doc) {
var paramStr = doc.location.search.substring(1);
var params = [];
if (paramStr.length > 0) {
params = paramStr.split('&');
}
return params;
}
jasmine.HtmlReporter.sectionLink = function(sectionName) {
var link = '?';
var params = [];
if (sectionName) {
params.push('spec=' + encodeURIComponent(sectionName));
}
if (!jasmine.CATCH_EXCEPTIONS) {
params.push("catch=false");
}
if (params.length > 0) {
link += params.join("&");
}
return link;
};
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);
jasmine.HtmlReporter.ReporterView = function(dom) {
this.startedAt = new Date();
this.runningSpecCount = 0;
this.completeSpecCount = 0;
this.passedCount = 0;
this.failedCount = 0;
this.skippedCount = 0;
this.createResultsMenu = function() {
this.resultsMenu = this.createDom('span', {className: 'resultsMenu bar'},
this.summaryMenuItem = this.createDom('a', {className: 'summaryMenuItem', href: "#"}, '0 specs'),
' | ',
this.detailsMenuItem = this.createDom('a', {className: 'detailsMenuItem', href: "#"}, '0 failing'));
this.summaryMenuItem.onclick = function() {
dom.reporter.className = dom.reporter.className.replace(/ showDetails/g, '');
};
this.detailsMenuItem.onclick = function() {
showDetails();
};
};
this.addSpecs = function(specs, specFilter) {
this.totalSpecCount = specs.length;
this.views = {
specs: {},
suites: {}
};
for (var i = 0; i < specs.length; i++) {
var spec = specs[i];
this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom, this.views);
if (specFilter(spec)) {
this.runningSpecCount++;
}
}
};
this.specComplete = function(spec) {
this.completeSpecCount++;
if (isUndefined(this.views.specs[spec.id])) {
this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom);
}
var specView = this.views.specs[spec.id];
switch (specView.status()) {
case 'passed':
this.passedCount++;
break;
case 'failed':
this.failedCount++;
break;
case 'skipped':
this.skippedCount++;
break;
}
specView.refresh();
this.refresh();
};
this.suiteComplete = function(suite) {
var suiteView = this.views.suites[suite.id];
if (isUndefined(suiteView)) {
return;
}
suiteView.refresh();
};
this.refresh = function() {
if (isUndefined(this.resultsMenu)) {
this.createResultsMenu();
}
// currently running UI
if (isUndefined(this.runningAlert)) {
this.runningAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "runningAlert bar" });
dom.alert.appendChild(this.runningAlert);
}
this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + specPluralizedFor(this.totalSpecCount);
// skipped specs UI
if (isUndefined(this.skippedAlert)) {
this.skippedAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "skippedAlert bar" });
}
this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
if (this.skippedCount === 1 && isDefined(dom.alert)) {
dom.alert.appendChild(this.skippedAlert);
}
// passing specs UI
if (isUndefined(this.passedAlert)) {
this.passedAlert = this.createDom('span', { href: jasmine.HtmlReporter.sectionLink(), className: "passingAlert bar" });
}
this.passedAlert.innerHTML = "Passing " + specPluralizedFor(this.passedCount);
// failing specs UI
if (isUndefined(this.failedAlert)) {
this.failedAlert = this.createDom('span', {href: "?", className: "failingAlert bar"});
}
this.failedAlert.innerHTML = "Failing " + specPluralizedFor(this.failedCount);
if (this.failedCount === 1 && isDefined(dom.alert)) {
dom.alert.appendChild(this.failedAlert);
dom.alert.appendChild(this.resultsMenu);
}
// summary info
this.summaryMenuItem.innerHTML = "" + specPluralizedFor(this.runningSpecCount);
this.detailsMenuItem.innerHTML = "" + this.failedCount + " failing";
};
this.complete = function() {
dom.alert.removeChild(this.runningAlert);
this.skippedAlert.innerHTML = "Ran " + this.runningSpecCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
if (this.failedCount === 0) {
dom.alert.appendChild(this.createDom('span', {className: 'passingAlert bar'}, "Passing " + specPluralizedFor(this.passedCount)));
} else {
showDetails();
}
dom.banner.appendChild(this.createDom('span', {className: 'duration'}, "finished in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s"));
};
return this;
function showDetails() {
if (dom.reporter.className.search(/showDetails/) === -1) {
dom.reporter.className += " showDetails";
}
}
function isUndefined(obj) {
return typeof obj === 'undefined';
}
function isDefined(obj) {
return !isUndefined(obj);
}
function specPluralizedFor(count) {
var str = count + " spec";
if (count > 1) {
str += "s"
}
return str;
}
};
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.ReporterView);
jasmine.HtmlReporter.SpecView = function(spec, dom, views) {
this.spec = spec;
this.dom = dom;
this.views = views;
this.symbol = this.createDom('li', { className: 'pending' });
this.dom.symbolSummary.appendChild(this.symbol);
this.summary = this.createDom('div', { className: 'specSummary' },
this.createDom('a', {
className: 'description',
href: jasmine.HtmlReporter.sectionLink(this.spec.getFullName()),
title: this.spec.getFullName()
}, this.spec.description)
);
this.detail = this.createDom('div', { className: 'specDetail' },
this.createDom('a', {
className: 'description',
href: '?spec=' + encodeURIComponent(this.spec.getFullName()),
title: this.spec.getFullName()
}, this.spec.getFullName())
);
};
jasmine.HtmlReporter.SpecView.prototype.status = function() {
return this.getSpecStatus(this.spec);
};
jasmine.HtmlReporter.SpecView.prototype.refresh = function() {
this.symbol.className = this.status();
switch (this.status()) {
case 'skipped':
break;
case 'passed':
this.appendSummaryToSuiteDiv();
break;
case 'failed':
this.appendSummaryToSuiteDiv();
this.appendFailureDetail();
break;
}
};
jasmine.HtmlReporter.SpecView.prototype.appendSummaryToSuiteDiv = function() {
this.summary.className += ' ' + this.status();
this.appendToSummary(this.spec, this.summary);
};
jasmine.HtmlReporter.SpecView.prototype.appendFailureDetail = function() {
this.detail.className += ' ' + this.status();
var resultItems = this.spec.results().getItems();
var messagesDiv = this.createDom('div', { className: 'messages' });
for (var i = 0; i < resultItems.length; i++) {
var result = resultItems[i];
if (result.type == 'log') {
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
} else if (result.type == 'expect' && result.passed && !result.passed()) {
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
if (result.trace.stack) {
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
}
}
}
if (messagesDiv.childNodes.length > 0) {
this.detail.appendChild(messagesDiv);
this.dom.details.appendChild(this.detail);
}
};
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView);jasmine.HtmlReporter.SuiteView = function(suite, dom, views) {
this.suite = suite;
this.dom = dom;
this.views = views;
this.element = this.createDom('div', { className: 'suite' },
this.createDom('a', { className: 'description', href: jasmine.HtmlReporter.sectionLink(this.suite.getFullName()) }, this.suite.description)
);
this.appendToSummary(this.suite, this.element);
};
jasmine.HtmlReporter.SuiteView.prototype.status = function() {
return this.getSpecStatus(this.suite);
};
jasmine.HtmlReporter.SuiteView.prototype.refresh = function() {
this.element.className += " " + this.status();
};
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SuiteView);
/* @deprecated Use jasmine.HtmlReporter instead
*/
jasmine.TrivialReporter = function(doc) {
this.document = doc || document;
this.suiteDivs = {};
this.logRunningSpecs = false;
};
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
var el = document.createElement(type);
for (var i = 2; i < arguments.length; i++) {
var child = arguments[i];
if (typeof child === 'string') {
el.appendChild(document.createTextNode(child));
} else {
if (child) { el.appendChild(child); }
}
}
for (var attr in attrs) {
if (attr == "className") {
el[attr] = attrs[attr];
} else {
el.setAttribute(attr, attrs[attr]);
}
}
return el;
};
jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
var showPassed, showSkipped;
this.outerDiv = this.createDom('div', { id: 'TrivialReporter', className: 'jasmine_reporter' },
this.createDom('div', { className: 'banner' },
this.createDom('div', { className: 'logo' },
this.createDom('span', { className: 'title' }, "Jasmine"),
this.createDom('span', { className: 'version' }, runner.env.versionString())),
this.createDom('div', { className: 'options' },
"Show ",
showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
)
),
this.runnerDiv = this.createDom('div', { className: 'runner running' },
this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
);
this.document.body.appendChild(this.outerDiv);
var suites = runner.suites();
for (var i = 0; i < suites.length; i++) {
var suite = suites[i];
var suiteDiv = this.createDom('div', { className: 'suite' },
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
this.suiteDivs[suite.id] = suiteDiv;
var parentDiv = this.outerDiv;
if (suite.parentSuite) {
parentDiv = this.suiteDivs[suite.parentSuite.id];
}
parentDiv.appendChild(suiteDiv);
}
this.startedAt = new Date();
var self = this;
showPassed.onclick = function(evt) {
if (showPassed.checked) {
self.outerDiv.className += ' show-passed';
} else {
self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
}
};
showSkipped.onclick = function(evt) {
if (showSkipped.checked) {
self.outerDiv.className += ' show-skipped';
} else {
self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
}
};
};
jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
var results = runner.results();
var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
this.runnerDiv.setAttribute("class", className);
//do it twice for IE
this.runnerDiv.setAttribute("className", className);
var specs = runner.specs();
var specCount = 0;
for (var i = 0; i < specs.length; i++) {
if (this.specFilter(specs[i])) {
specCount++;
}
}
var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
};
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
var results = suite.results();
var status = results.passed() ? 'passed' : 'failed';
if (results.totalCount === 0) { // todo: change this to check results.skipped
status = 'skipped';
}
this.suiteDivs[suite.id].className += " " + status;
};
jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
if (this.logRunningSpecs) {
this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
}
};
jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
var results = spec.results();
var status = results.passed() ? 'passed' : 'failed';
if (results.skipped) {
status = 'skipped';
}
var specDiv = this.createDom('div', { className: 'spec ' + status },
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
this.createDom('a', {
className: 'description',
href: '?spec=' + encodeURIComponent(spec.getFullName()),
title: spec.getFullName()
}, spec.description));
var resultItems = results.getItems();
var messagesDiv = this.createDom('div', { className: 'messages' });
for (var i = 0; i < resultItems.length; i++) {
var result = resultItems[i];
if (result.type == 'log') {
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
} else if (result.type == 'expect' && result.passed && !result.passed()) {
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
if (result.trace.stack) {
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
}
}
}
if (messagesDiv.childNodes.length > 0) {
specDiv.appendChild(messagesDiv);
}
this.suiteDivs[spec.suite.id].appendChild(specDiv);
};
jasmine.TrivialReporter.prototype.log = function() {
var console = jasmine.getGlobal().console;
if (console && console.log) {
if (console.log.apply) {
console.log.apply(console, arguments);
} else {
console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
}
}
};
jasmine.TrivialReporter.prototype.getLocation = function() {
return this.document.location;
};
jasmine.TrivialReporter.prototype.specFilter = function(spec) {
var paramMap = {};
var params = this.getLocation().search.substring(1).split('&');
for (var i = 0; i < params.length; i++) {
var p = params[i].split('=');
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
}
if (!paramMap.spec) {
return true;
}
return spec.getFullName().indexOf(paramMap.spec) === 0;
};
@@ -0,0 +1,82 @@
body { background-color: #eeeeee; padding: 0; margin: 5px; overflow-y: scroll; }
#HTMLReporter { font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333333; }
#HTMLReporter a { text-decoration: none; }
#HTMLReporter a:hover { text-decoration: underline; }
#HTMLReporter p, #HTMLReporter h1, #HTMLReporter h2, #HTMLReporter h3, #HTMLReporter h4, #HTMLReporter h5, #HTMLReporter h6 { margin: 0; line-height: 14px; }
#HTMLReporter .banner, #HTMLReporter .symbolSummary, #HTMLReporter .summary, #HTMLReporter .resultMessage, #HTMLReporter .specDetail .description, #HTMLReporter .alert .bar, #HTMLReporter .stackTrace { padding-left: 9px; padding-right: 9px; }
#HTMLReporter #jasmine_content { position: fixed; right: 100%; }
#HTMLReporter .version { color: #aaaaaa; }
#HTMLReporter .banner { margin-top: 14px; }
#HTMLReporter .duration { color: #aaaaaa; float: right; }
#HTMLReporter .symbolSummary { overflow: hidden; *zoom: 1; margin: 14px 0; }
#HTMLReporter .symbolSummary li { display: block; float: left; height: 7px; width: 14px; margin-bottom: 7px; font-size: 16px; }
#HTMLReporter .symbolSummary li.passed { font-size: 14px; }
#HTMLReporter .symbolSummary li.passed:before { color: #5e7d00; content: "\02022"; }
#HTMLReporter .symbolSummary li.failed { line-height: 9px; }
#HTMLReporter .symbolSummary li.failed:before { color: #b03911; content: "x"; font-weight: bold; margin-left: -1px; }
#HTMLReporter .symbolSummary li.skipped { font-size: 14px; }
#HTMLReporter .symbolSummary li.skipped:before { color: #bababa; content: "\02022"; }
#HTMLReporter .symbolSummary li.pending { line-height: 11px; }
#HTMLReporter .symbolSummary li.pending:before { color: #aaaaaa; content: "-"; }
#HTMLReporter .exceptions { color: #fff; float: right; margin-top: 5px; margin-right: 5px; }
#HTMLReporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; }
#HTMLReporter .runningAlert { background-color: #666666; }
#HTMLReporter .skippedAlert { background-color: #aaaaaa; }
#HTMLReporter .skippedAlert:first-child { background-color: #333333; }
#HTMLReporter .skippedAlert:hover { text-decoration: none; color: white; text-decoration: underline; }
#HTMLReporter .passingAlert { background-color: #a6b779; }
#HTMLReporter .passingAlert:first-child { background-color: #5e7d00; }
#HTMLReporter .failingAlert { background-color: #cf867e; }
#HTMLReporter .failingAlert:first-child { background-color: #b03911; }
#HTMLReporter .results { margin-top: 14px; }
#HTMLReporter #details { display: none; }
#HTMLReporter .resultsMenu, #HTMLReporter .resultsMenu a { background-color: #fff; color: #333333; }
#HTMLReporter.showDetails .summaryMenuItem { font-weight: normal; text-decoration: inherit; }
#HTMLReporter.showDetails .summaryMenuItem:hover { text-decoration: underline; }
#HTMLReporter.showDetails .detailsMenuItem { font-weight: bold; text-decoration: underline; }
#HTMLReporter.showDetails .summary { display: none; }
#HTMLReporter.showDetails #details { display: block; }
#HTMLReporter .summaryMenuItem { font-weight: bold; text-decoration: underline; }
#HTMLReporter .summary { margin-top: 14px; }
#HTMLReporter .summary .suite .suite, #HTMLReporter .summary .specSummary { margin-left: 14px; }
#HTMLReporter .summary .specSummary.passed a { color: #5e7d00; }
#HTMLReporter .summary .specSummary.failed a { color: #b03911; }
#HTMLReporter .description + .suite { margin-top: 0; }
#HTMLReporter .suite { margin-top: 14px; }
#HTMLReporter .suite a { color: #333333; }
#HTMLReporter #details .specDetail { margin-bottom: 28px; }
#HTMLReporter #details .specDetail .description { display: block; color: white; background-color: #b03911; }
#HTMLReporter .resultMessage { padding-top: 14px; color: #333333; }
#HTMLReporter .resultMessage span.result { display: block; }
#HTMLReporter .stackTrace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666666; border: 1px solid #ddd; background: white; white-space: pre; }
#TrivialReporter { padding: 8px 13px; position: absolute; top: 0; bottom: 0; left: 0; right: 0; overflow-y: scroll; background-color: white; font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif; /*.resultMessage {*/ /*white-space: pre;*/ /*}*/ }
#TrivialReporter a:visited, #TrivialReporter a { color: #303; }
#TrivialReporter a:hover, #TrivialReporter a:active { color: blue; }
#TrivialReporter .run_spec { float: right; padding-right: 5px; font-size: .8em; text-decoration: none; }
#TrivialReporter .banner { color: #303; background-color: #fef; padding: 5px; }
#TrivialReporter .logo { float: left; font-size: 1.1em; padding-left: 5px; }
#TrivialReporter .logo .version { font-size: .6em; padding-left: 1em; }
#TrivialReporter .runner.running { background-color: yellow; }
#TrivialReporter .options { text-align: right; font-size: .8em; }
#TrivialReporter .suite { border: 1px outset gray; margin: 5px 0; padding-left: 1em; }
#TrivialReporter .suite .suite { margin: 5px; }
#TrivialReporter .suite.passed { background-color: #dfd; }
#TrivialReporter .suite.failed { background-color: #fdd; }
#TrivialReporter .spec { margin: 5px; padding-left: 1em; clear: both; }
#TrivialReporter .spec.failed, #TrivialReporter .spec.passed, #TrivialReporter .spec.skipped { padding-bottom: 5px; border: 1px solid gray; }
#TrivialReporter .spec.failed { background-color: #fbb; border-color: red; }
#TrivialReporter .spec.passed { background-color: #bfb; border-color: green; }
#TrivialReporter .spec.skipped { background-color: #bbb; }
#TrivialReporter .messages { border-left: 1px dashed gray; padding-left: 1em; padding-right: 1em; }
#TrivialReporter .passed { background-color: #cfc; display: none; }
#TrivialReporter .failed { background-color: #fbb; }
#TrivialReporter .skipped { color: #777; background-color: #eee; display: none; }
#TrivialReporter .resultMessage span.result { display: block; line-height: 2em; color: black; }
#TrivialReporter .resultMessage .mismatch { color: black; }
#TrivialReporter .stackTrace { white-space: pre; font-size: .8em; margin-left: 10px; max-height: 5em; overflow: auto; border: 1px inset red; padding: 1em; background: #eef; }
#TrivialReporter .finished-at { padding-left: 1em; font-size: .6em; }
#TrivialReporter.show-passed .passed, #TrivialReporter.show-skipped .skipped { display: block; }
#TrivialReporter #jasmine_content { position: fixed; right: 100%; }
#TrivialReporter .runner { border: 1px solid gray; display: block; margin: 5px 0; padding: 2px 0 2px 10px; }
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,104 @@
/**
Jasmine Reporter that outputs test results to the browser console.
Useful for running in a headless environment such as PhantomJs, ZombieJs etc.
Usage:
// From your html file that loads jasmine:
jasmine.getEnv().addReporter(new jasmine.ConsoleReporter());
jasmine.getEnv().execute();
*/
(function(jasmine, console) {
if (!jasmine) {
throw "jasmine library isn't loaded!";
}
var ANSI = {}
ANSI.color_map = {
"green" : 32,
"red" : 31
}
ANSI.colorize_text = function(text, color) {
var color_code = this.color_map[color];
return "\033[" + color_code + "m" + text + "\033[0m";
}
var ConsoleReporter = function() {
if (!console || !console.log) { throw "console isn't present!"; }
this.status = this.statuses.stopped;
};
var proto = ConsoleReporter.prototype;
proto.statuses = {
stopped : "stopped",
running : "running",
fail : "fail",
success : "success"
};
proto.reportRunnerStarting = function(runner) {
this.status = this.statuses.running;
this.start_time = (new Date()).getTime();
this.executed_specs = 0;
this.passed_specs = 0;
this.log("Starting...");
};
proto.reportRunnerResults = function(runner) {
var failed = this.executed_specs - this.passed_specs;
var spec_str = this.executed_specs + (this.executed_specs === 1 ? " spec, " : " specs, ");
var fail_str = failed + (failed === 1 ? " failure in " : " failures in ");
var color = (failed > 0)? "red" : "green";
var dur = (new Date()).getTime() - this.start_time;
this.log("");
this.log("Finished");
this.log("-----------------");
this.log(spec_str + fail_str + (dur/1000) + "s.", color);
this.status = (failed > 0)? this.statuses.fail : this.statuses.success;
/* Print something that signals that testing is over so that headless browsers
like PhantomJs know when to terminate. */
this.log("");
this.log("ConsoleReporter finished");
};
proto.reportSpecStarting = function(spec) {
this.executed_specs++;
};
proto.reportSpecResults = function(spec) {
if (spec.results().passed()) {
this.passed_specs++;
return;
}
var resultText = spec.suite.description + " : " + spec.description;
this.log(resultText, "red");
var items = spec.results().getItems()
for (var i = 0; i < items.length; i++) {
var trace = items[i].trace.stack || items[i].trace;
this.log(trace, "red");
}
};
proto.reportSuiteResults = function(suite) {
if (!suite.parentSuite) { return; }
var results = suite.results();
var failed = results.totalCount - results.passedCount;
var color = (failed > 0)? "red" : "green";
this.log(suite.getFullName() + ": " + results.passedCount + " of " + results.totalCount + " passed.", color);
};
proto.log = function(str, color) {
var text = (color != undefined)? ANSI.colorize_text(str, color) : str;
console.log(text)
};
jasmine.ConsoleReporter = ConsoleReporter;
})(jasmine, console);
@@ -0,0 +1,46 @@
#!/usr/local/bin/phantomjs
# Runs a Jasmine Suite from an html page
# @page is a PhantomJs page object
# @exit_func is the function to call in order to exit the script
class PhantomJasmineRunner
constructor: (@page, @exit_func = phantom.exit) ->
@tries = 0
@max_tries = 10
get_status: -> @page.evaluate(-> console_reporter.status)
terminate: ->
switch @get_status()
when "success" then @exit_func 0
when "fail" then @exit_func 1
else @exit_func 2
# Script Begin
if phantom.args.length == 0
console.log "Need a url as the argument"
phantom.exit 1
page = new WebPage()
runner = new PhantomJasmineRunner(page)
# Don't supress console output
page.onConsoleMessage = (msg) ->
console.log msg
# Terminate when the reporter singals that testing is over.
# We cannot use a callback function for this (because page.evaluate is sandboxed),
# so we have to *observe* the website.
if msg == "ConsoleReporter finished"
runner.terminate()
address = phantom.args[0]
page.open address, (status) ->
if status != "success"
console.log "can't load the address!"
phantom.exit 1
# Now we wait until onConsoleMessage reads the termination signal from the log.
+1
View File
@@ -0,0 +1 @@
phantomjs lib/phantom-jasmine/run_jasmine_test.coffee test_runner.html
+22
View File
@@ -0,0 +1,22 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Jasmine Test Runner</title>
<link rel="stylesheet" type="text/css" href="lib/jasmine-1.3.1/jasmine.css">
<script type="text/javascript" src="lib/jasmine-1.3.1/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-1.3.1/jasmine-html.js"></script>
<script type="text/javascript" src="lib/phantom-jasmine/console-runner.js"></script>
<script type="text/javascript" src="../fingerprint.js"></script>
<script type="text/javascript" src="fingerprint_spec.js"></script>
</head>
<body>
<script type="text/javascript">
var console_reporter = new jasmine.ConsoleReporter()
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
jasmine.getEnv().addReporter(console_reporter);
jasmine.getEnv().execute();
</script>
</body>
</html>
+18
View File
@@ -681,6 +681,24 @@ function notifyMessage(data)
}
}
/**
* Get fingerprint.
*
* @access public
* @return void
*/
function getFingerprint()
{
if(typeof(Fingerprint) == 'function') return new Fingerprint().get();
fingerprint = '';
$.each(navigator, function(key, value)
{
if(typeof(value) == 'string') fingerprint += value.length;
})
return fingerprint;
}
/* Ping the server every some minutes to keep the session. */
needPing = true;
+1
View File
@@ -1,4 +1,5 @@
body{padding-bottom:0px;}
body.has-fixed-footer{padding-bottom:20px;}
#header{padding-top:0px;}
#header #heading{display:none !important;}
#header #navbar{text-align:left !important;}