* moved reputation requirement to conditions
Misc:
 * removed temp-hack from ShowOnMap.js
 * fixed some formating in global.js
 * allow display of extra html in all generic templates
This commit is contained in:
Sarjuuk
2014-11-09 18:41:57 +01:00
parent edfb0be602
commit aeda3df39e
9 changed files with 103 additions and 102 deletions

View File

@@ -702,6 +702,7 @@ class Util
// creates an announcement; use if minor issues arise
public static function addNote($uGroupMask, $str)
{
// todo (med): log all those errors to DB
self::$notes[] = [$uGroupMask, $str];
}
@@ -893,6 +894,26 @@ class Util
return 3;
}
public static function getReputationLevelForPoints($pts)
{
if ($pts >= 41999)
return REP_EXALTED;
else if ($pts >= 20999)
return REP_REVERED;
else if ($pts >= 8999)
return REP_HONORED;
else if ($pts >= 2999)
return REP_FRIENDLY;
else if ($pts >= 0)
return REP_NEUTRAL;
else if ($pts >= -3000)
return REP_UNFRIENDLY;
else if ($pts >= -6000)
return REP_HOSTILE;
else
return REP_HATED;
}
// pageText for Books (Item or GO) and questText
public static function parseHtmlText($text)
{

View File

@@ -121,22 +121,9 @@ class Lang
public static function getReputationLevelForPoints($pts)
{
if ($pts >= 41999)
return self::$game['rep'][REP_EXALTED];
else if ($pts >= 20999)
return self::$game['rep'][REP_REVERED];
else if ($pts >= 8999)
return self::$game['rep'][REP_HONORED];
else if ($pts >= 2999)
return self::$game['rep'][REP_FRIENDLY];
else if ($pts >= 0)
return self::$game['rep'][REP_NEUTRAL];
else if ($pts >= -3000)
return self::$game['rep'][REP_UNFRIENDLY];
else if ($pts >= -6000)
return self::$game['rep'][REP_HOSTILE];
else
return self::$game['rep'][REP_HATED];
$_ = Util::getReputationLevelForPoints($pts);
return self::$game['rep'][$_];
}
public static function getRequiredItems($class, $mask, $short = true)

View File

@@ -297,7 +297,7 @@ class QuestPage extends GenericPage
$this->series[] = [$chain, null];
// todo (low): sensibly merge te following lists into 'series'
// todo (low): sensibly merge the following lists into 'series'
$listGen = function($cnd)
{
$chain = [];
@@ -522,10 +522,11 @@ class QuestPage extends GenericPage
// $startend + reqNpcOrGo[1-4]
$this->map = array(
'data' => ['zone' => $this->typeId],
$this->map = null;
// array(
// 'data' => ['zone' => $this->typeId],
// 'som' => json_encode($som, JSON_NUMERIC_CHECK)
);
// );
/****************/
/* Main Content */
@@ -550,18 +551,6 @@ class QuestPage extends GenericPage
if ($maTab)
$this->lvTabs[] = $maTab;
if ($_ = $this->subject->getField('reqMinRepFaction'))
{
$val = $this->subject->getField('reqMinRepValue');
$this->reqMinRep = sprintf(Lang::$quest['reqRepWith'], $_, FactionList::getName($_), Lang::$quest['reqRepMin'], sprintf(Util::$dfnString, $val.' '.Lang::$achievement['points'], Lang::getReputationLevelForPoints($val)));
}
if ($_ = $this->subject->getField('reqMaxRepFaction'))
{
$val = $this->subject->getField('reqMaxRepValue');
$this->reqMaxRep = sprintf(Lang::$quest['reqRepWith'], $_, FactionList::getName($_), Lang::$quest['reqRepMax'], sprintf(Util::$dfnString, $val.' '.Lang::$achievement['points'], Lang::getReputationLevelForPoints($val)));
}
// todo (low): create pendant from player_factionchange_quests
/**************/
@@ -599,12 +588,41 @@ class QuestPage extends GenericPage
}
// tab: conditions
$sc = Util::getServerConditions([CND_SRC_QUEST_ACCEPT, CND_SRC_QUEST_SHOW_MARK], null, $this->typeId);
if (!empty($sc[0]))
$cnd = [];
if ($_ = $this->subject->getField('reqMinRepFaction'))
{
$cnd[CND_SRC_QUEST_ACCEPT][$this->typeId][0][] = [CND_REPUTATION_RANK, $_, 1 << Util::getReputationLevelForPoints($this->subject->getField('reqMinRepValue'))];
$this->extendGlobalIds(TYPE_FACTION, $_);
}
if ($_ = $this->subject->getField('reqMaxRepFaction'))
{
$cnd[CND_SRC_QUEST_ACCEPT][$this->typeId][0][] = [-CND_REPUTATION_RANK, $_, 1 << Util::getReputationLevelForPoints($this->subject->getField('reqMaxRepValue'))];
$this->extendGlobalIds(TYPE_FACTION, $_);
}
$_ = Util::getServerConditions([CND_SRC_QUEST_ACCEPT, CND_SRC_QUEST_SHOW_MARK], null, $this->typeId);
if (!empty($_[0]))
{
// awkward merger
if (isset($_[0][CND_SRC_QUEST_ACCEPT][$this->typeId][0]))
{
if (isset($cnd[CND_SRC_QUEST_ACCEPT][$this->typeId][0]))
$cnd[CND_SRC_QUEST_ACCEPT][$this->typeId][0] = array_merge($cnd[CND_SRC_QUEST_ACCEPT][$this->typeId][0], $_[0][CND_SRC_QUEST_ACCEPT][$this->typeId][0]);
else
$cnd[CND_SRC_QUEST_ACCEPT] = $_[0][CND_SRC_QUEST_ACCEPT];
}
if (isset($_[0][CND_SRC_QUEST_SHOW_MARK]))
$cnd[CND_SRC_QUEST_SHOW_MARK] = $_[0][CND_SRC_QUEST_SHOW_MARK];
$this->extendGlobalData($_[1]);
}
if ($cnd)
{
$this->extendGlobalData($sc[1]);
$tab = "<script type=\"text/javascript\">\n" .
"var markup = ConditionList.createTab(".json_encode($sc[0], JSON_NUMERIC_CHECK).");\n" .
"var markup = ConditionList.createTab(".json_encode($cnd, JSON_NUMERIC_CHECK).");\n" .
"Markup.printHtml(markup, 'tab-conditions', { allow: Markup.CLASS_STAFF })" .
"</script>";

View File

@@ -787,18 +787,3 @@ ShowOnMap.buildTooltip = function(list, dailyOnly) {
return ret;
};
// // !sarjuuk: tempfix!
Markup._fixUrl = function(url) {
if(!url) {
return '';
}
// Make local URLs absolute
var firstChar = url.charAt(0);
if(firstChar == '/' || firstChar == '?')
url = '?' + url.replace(/^[\/\?]+/, '');
return url;
}

View File

@@ -90,7 +90,7 @@ function Ajax(url, opt) {
$WH.cO(this, opt);
this.method = this.method || (this.params && 'POST') || 'GET';
_.open(this.method, url, this.async == null ? true: this.async);
_.open(this.method, url, this.async == null ? true : this.async);
_.onreadystatechange = Ajax.onReadyStateChange.bind(this);
if (this.method.toUpperCase() == 'POST') {
@@ -1364,7 +1364,7 @@ function g_createAchievementBar(points, outOf, overall, bonus) {
}
var opt = {
text: points + (bonus > 0 ? '(+' + bonus + ')': '') + (outOf > 0 ? ' / ' + outOf: ''),
text: points + (bonus > 0 ? '(+' + bonus + ')' : '') + (outOf > 0 ? ' / ' + outOf : ''),
color: (overall ? 'rep7' : 'ach' + (outOf > 0 ? 0 : 1)),
width: (outOf > 0 ? parseInt(points / outOf * 100) : 100)
};
@@ -2368,7 +2368,7 @@ var ScreenshotViewer = new function() {
computeDimensions(0);
var url = (screenshot.url ? screenshot.url: g_staticUrl + '/uploads/screenshots/' + (resized ? 'resized/': 'normal/') + screenshot.id + '.jpg');
var url = (screenshot.url ? screenshot.url : g_staticUrl + '/uploads/screenshots/' + (resized ? 'resized/': 'normal/') + screenshot.id + '.jpg');
var html =
'<img src="' + url + '"'
@@ -3055,7 +3055,7 @@ var VideoViewer = new function() {
html += LANG.dash;
}
html += (video.noMarkup ? video.caption: Markup.toHtml(video.caption, {
html += (video.noMarkup ? video.caption : Markup.toHtml(video.caption, {
mode: Markup.MODE_SIGNATURE
}));
}
@@ -3458,7 +3458,7 @@ var
field.__tr = tr;
if (_data[field.id] == null) {
_data[field.id] = (field.value ? field.value: '');
_data[field.id] = (field.value ? field.value : '');
}
var options;
@@ -4208,7 +4208,7 @@ Dialog.templates.docompare = {
id: 'selecteditems',
type: 'caption',
compute: function(field, value, form, td) {
td.innerHTML = $WH.sprintf((value == 1 ? LANG.dialog_selecteditem: LANG.dialog_selecteditems), value);
td.innerHTML = $WH.sprintf((value == 1 ? LANG.dialog_selecteditem : LANG.dialog_selecteditems), value);
}
},
{
@@ -4847,7 +4847,7 @@ function Listview(opt) {
var col = this.extraCols[i];
if (col.after || col.before) {
var index = $WH.in_array(this.columns, (col.after ? col.after: col.before), function(x) {
var index = $WH.in_array(this.columns, (col.after ? col.after : col.before), function(x) {
return x.id;
});
@@ -5455,7 +5455,7 @@ Listview.prototype = {
},
refreshRows: function() {
var target = (this.mode == Listview.MODE_DIV ? this.mainContainer: this.tbody);
var target = (this.mode == Listview.MODE_DIV ? this.mainContainer : this.tbody);
$WH.ee(target);
if (this.nRowsVisible == 0) {
@@ -5642,7 +5642,7 @@ Listview.prototype = {
}
if (result == -1) {
$WH.ae(this.noData, $WH.ct(this.filtered ? LANG.lvnodata2: LANG.lvnodata));
$WH.ae(this.noData, $WH.ct(this.filtered ? LANG.lvnodata2 : LANG.lvnodata));
}
},
@@ -5875,7 +5875,7 @@ Listview.prototype = {
getRowOffset: function(rowNo) {
var rpp = this.nItemsPerPage;
return (rpp > 0 && rowNo > 0 ? Math.floor(rowNo / rpp) * rpp: 0);
return (rpp > 0 && rowNo > 0 ? Math.floor(rowNo / rpp) * rpp : 0);
},
resetRowVisibility: function() {
@@ -6957,15 +6957,15 @@ Listview.headerFilter = function(col, res) {
Listview.headerOver = function(a, col, e) {
var buffer = '';
buffer += '<b class="q1">' + (col.tooltip ? col.tooltip: col.name) + '</b>';
buffer += '<b class="q1">' + (col.tooltip ? col.tooltip : col.name) + '</b>';
if (col.__filter) {
buffer += '<br />' + $WH.sprintf((col.__filter.invert ? LANG.tooltip_colfilter2: LANG.tooltip_colfilter1), col.__filter.text);
buffer += '<br />' + $WH.sprintf((col.__filter.invert ? LANG.tooltip_colfilter2 : LANG.tooltip_colfilter1), col.__filter.text);
}
buffer += '<br /><span class="q2">' + LANG.tooltip_lvheader1 + '</span>';
if (this.filtrable && (col.filtrable == null || col.filtrable)) {
buffer += '<br /><span class="q2">' + ($WH.Browser.opera ? LANG.tooltip_lvheader3: LANG.tooltip_lvheader2) + '</span>';
buffer += '<br /><span class="q2">' + ($WH.Browser.opera ? LANG.tooltip_lvheader3 : LANG.tooltip_lvheader2) + '</span>';
}
$WH.Tooltip.show(a, buffer, 0, 0, 'q');
@@ -9842,10 +9842,10 @@ Listview.templates = {
value: 'level',
type: 'range',
getMinValue: function(item) {
return item.minlevel ? item.minlevel: item.level;
return item.minlevel ? item.minlevel : item.level;
},
getMaxValue: function(item) {
return item.maxlevel ? item.maxlevel: item.level;
return item.maxlevel ? item.maxlevel : item.level;
},
compute: function(item, td) {
if (item.minlevel && item.maxlevel) {
@@ -10100,8 +10100,8 @@ Listview.templates = {
}
var
na = (a.sourcemore && a.source.length == 1 ? a.sourcemore[0].n: null),
nb = (b.sourcemore && b.source.length == 1 ? b.sourcemore[0].n: null);
na = (a.sourcemore && a.source.length == 1 ? a.sourcemore[0].n : null),
nb = (b.sourcemore && b.source.length == 1 ? b.sourcemore[0].n : null);
return $WH.strcmp(na, nb);
}
@@ -10398,8 +10398,8 @@ Listview.templates = {
Listview.funcBox.createCenteredIcons(itemSet.pieces, td);
},
sortFunc: function(a, b) {
var lena = (a.pieces != null ? a.pieces.length: 0);
var lenb = (b.pieces != null ? b.pieces.length: 0);
var lena = (a.pieces != null ? a.pieces.length : 0);
var lenb = (b.pieces != null ? b.pieces.length : 0);
return $WH.strcmp(lena, lenb);
}
},
@@ -11577,7 +11577,7 @@ Listview.templates = {
hidden: true,
compute: function(spell, td) {
var text = '';
var schools = spell.schools ? spell.schools: spell.school;
var schools = spell.schools ? spell.schools : spell.school;
for (var i = 0; i < 32; ++i) {
if (!(schools & (1 << i))) {
@@ -11693,7 +11693,7 @@ Listview.templates = {
width: '9%',
hidden: true,
getValue: function(spell) {
return (spell.reagents ? spell.reagents.length: 0);
return (spell.reagents ? spell.reagents.length : 0);
},
compute: function(spell, td) {
var hasIcons = (spell.reagents != null);
@@ -11718,8 +11718,8 @@ Listview.templates = {
}
},
sortFunc: function(a, b) {
var lena = (a.reagents != null ? a.reagents.length: 0);
var lenb = (b.reagents != null ? b.reagents.length: 0);
var lena = (a.reagents != null ? a.reagents.length : 0);
var lenb = (b.reagents != null ? b.reagents.length : 0);
if (lena > 0 && lena == lenb) {
return $WH.strcmp(a.reagents.toString(), b.reagents.toString());
}
@@ -11901,7 +11901,7 @@ Listview.templates = {
var skill = [a.learnedat, b.learnedat];
for (var s = 0; s < 2; ++s) {
var sp = (s == 0 ? a: b);
var sp = (s == 0 ? a : b);
if (skill[s] == 9999 && sp.colors != null) {
var i = 0;
while (sp.colors[i] == 0 && i < sp.colors.length) {
@@ -13500,7 +13500,7 @@ Listview.templates = {
],
getItemLink: function(comment) {
return '?' + g_types[comment.type] + '=' + comment.typeId + (comment.id != null ? '#comments:id=' + comment.id: '')
return '?' + g_types[comment.type] + '=' + comment.typeId + (comment.id != null ? '#comments:id=' + comment.id : '')
}
},
@@ -16588,7 +16588,7 @@ function MessageBox(parent, text) {
}, 5000);
box.click(function (e) {
e.stopPropagation(); // sarjuuk - custom: without this, the comment-header would also register the click
$WH.sp(e); // sarjuuk - custom: without this, the comment-header would also register the click
$(this).fadeOut();
});
@@ -17050,7 +17050,7 @@ var RedButton = {
},
setFunc: function(button, func) {
button.onclick = (func ? func: null);
button.onclick = (func ? func : null);
}
};
@@ -17315,7 +17315,7 @@ var LiveSearch = new function() {
colorDiv(bakDiv);
}
else {
var div = dir ? lastDiv.nextSibling: lastDiv.previousSibling;
var div = dir ? lastDiv.nextSibling : lastDiv.previousSibling;
if (div) {
if (div.nodeName == "STRONG") {
div = container.lastChild;
@@ -20047,6 +20047,7 @@ var ConditionList = new function() {
var sName = srcGrp[1];
if ($WH.in_array([18, 21, 23], g) != -1)
sName = g_npcs[srcGrp[1]]['name_' + Locale.getName()];
buff += '[tab name="' + g_condition_types[g][0] + ' (' + sName + ')"]';
}
else

View File

@@ -23,7 +23,7 @@ endif;
?>
</div>
</div><!-- #wrapper .nosidebar -->
</div<!-- #layout-inner -->
</div><!-- #layout-inner -->
</div><!-- #layout .nosidebar -->
<noscript>

View File

@@ -11,10 +11,11 @@
$this->brick('pageTemplate');
if (!empty($this->name) || !empty($this->h1Links)):
if (!empty($this->name) || !empty($this->h1Links) || !empty($this->extraHTML)):
echo '<div class="text">' .
(!empty($this->h1Links) ? '<div class="h1-links">'.$this->h1Links.'</div>' : null) .
(!empty($this->name) ? '<h1>'.$this->name.'</h1>' : null) .
(!empty($this->extraHTML) ? $this->extraHTML : null) .
'</div>';
endif;

View File

@@ -22,23 +22,6 @@
<?php
endif;
if (isset($this->reqMinRep) || isset($this->reqMaxRep)):
?>
<h3><?php echo Lang::$quest['additionalReq'].Lang::$main['colon']; ?></h3>
<ul style="border-bottom:solid 1px #505050;">
<?php
if (isset($this->reqMinRep)):
echo ' <li><div>'.$this->reqMinRep."</div></li>\n";
endif;
if (isset($this->reqMaxRep)):
echo ' <li><div>'.$this->reqMaxRep."</div></li>\n";
endif;
?>
<br />
</ul>
<?php
endif;
if ($this->objectives):
echo $this->objectives."\n";
elseif ($this->requestItems):

View File

@@ -29,7 +29,7 @@ else:
?>
<div id="text-generic" class="left"></div>
<script type="text/javascript">//<![CDATA[
Markup.printHtml("<?php echo Util::jsEscape($extraText); ?>", "text-generic", {
Markup.printHtml("<?php echo Util::jsEscape($this->extraText); ?>", "text-generic", {
allow: Markup.CLASS_ADMIN,
dbpage: true
});
@@ -38,6 +38,11 @@ else:
<div class="pad2"></div>
<?php
endif;
if (isset($this->extraHTML)):
echo $this->extraHTML;
endif;
endif;
?>
</div>