implemented 'serverside cookies'

minor:
 - icons in summary-dropdown menu
 - improved handling of non-standard specs for weight-presets (mostly due
   to Profiler)
 - probably some things i forgott... :x
This commit is contained in:
Sarjuuk
2014-03-14 16:00:40 +01:00
parent e1ed96ec73
commit 63895e838b
10 changed files with 912 additions and 721 deletions

View File

@@ -1,7 +1,7 @@
var wt_presets = {
1: {
pve: {
// arms: {__icon:'ability_warrior_savageblow'},
arms: {__icon:'ability_rogue_eviscerate'},
fury: {__icon:'ability_warrior_innerrage',exprtng:100,str:82,critstrkrtng:66,agi:53,armorpenrtng:52,hitrtng:48,hastertng:36,atkpwr:31,armor:5},
prot: {__icon:'ability_warrior_defensivestance',sta:100,dodgertng:90,defrtng:86,block:81,agi:67,parryrtng:67,blockrtng:48,str:48,exprtng:19,hitrtng:10,armorpenrtng:10,critstrkrtng:7,armor:6,hastertng:1,atkpwr:1}
}
@@ -16,8 +16,8 @@ var wt_presets = {
3: {
pve: {
beast: {__icon:'ability_hunter_beasttaming',rgddps:213,hitrtng:100,agi:58,critstrkrtng:40,int:37,atkpwr:30,armorpenrtng:28,hastertng:21},
marks: {__icon:'ability_hunter_focusedaim',rgddps:379,hitrtng:100,agi:74,critstrkrtng:57,armorpenrtng:40,int:39,atkpwr:32,hastertng:24},
surv: {__icon:'inv_spear_02',rgddps:181,hitrtng:100,agi:76,critstrkrtng:42,int:35,hastertng:31,atkpwr:29,armorpenrtng:26}
marks: {__icon:'ability_marksmanship',rgddps:379,hitrtng:100,agi:74,critstrkrtng:57,armorpenrtng:40,int:39,atkpwr:32,hastertng:24},
surv: {__icon:'ability_hunter_swiftstrike',rgddps:181,hitrtng:100,agi:76,critstrkrtng:42,int:35,hastertng:31,atkpwr:29,armorpenrtng:26}
}
},
4: {
@@ -29,7 +29,7 @@ var wt_presets = {
},
5: {
pve: {
disc: {__icon:'spell_holy_powerwordshield',splpwr:100,manargn:67,int:65,hastertng:59,critstrkrtng:48,spi:22},
disc: {__icon:'spell_holy_wordfortitude',splpwr:100,manargn:67,int:65,hastertng:59,critstrkrtng:48,spi:22},
holy: {__icon:'spell_holy_guardianspirit',manargn:100,int:69,splpwr:60,spi:52,critstrkrtng:38,hastertng:31},
shadow: {__icon:'spell_shadow_shadowwordpain',hitrtng:100,shasplpwr:76,splpwr:76,critstrkrtng:54,hastertng:50,spi:16,int:16}
}
@@ -45,7 +45,7 @@ var wt_presets = {
7: {
pve: {
elem: {__icon:'spell_nature_lightning',hitrtng:100,splpwr:60,hastertng:56,critstrkrtng:40,int:11},
enhance: {__icon:'spell_shaman_improvedstormstrike',mledps:135,hitrtng:100,exprtng:84,agi:55,int:55,critstrkrtng:55,hastertng:42,str:35,atkpwr:32,splpwr:29,armorpenrtng:26},
enhance: {__icon:'spell_nature_lightningshield',mledps:135,hitrtng:100,exprtng:84,agi:55,int:55,critstrkrtng:55,hastertng:42,str:35,atkpwr:32,splpwr:29,armorpenrtng:26},
resto: {__icon:'spell_nature_magicimmunity',manargn:100,int:85,splpwr:77,critstrkrtng:62,hastertng:35}
}
},
@@ -66,9 +66,9 @@ var wt_presets = {
11: {
pve: {
balance: {__icon:'spell_nature_starfall',hitrtng:100,splpwr:66,hastertng:54,critstrkrtng:43,spi:22,int:22},
feraldps: {__icon:'ability_druid_catform',agi:100,armorpenrtng:90,str:80,critstrkrtng:55,exprtng:50,hitrtng:50,feratkpwr:40,atkpwr:40,hastertng:35},
feraltank: {__icon:'ability_racial_bearform',agi:100,sta:75,dodgertng:65,defrtng:60,exprtng:16,str:10,armor:10,hitrtng:8,hastertng:5,atkpwr:4,feratkpwr:4,critstrkrtng:3},
resto: {__icon:'spell_nature_healingtouch',splpwr:100,manargn:73,hastertng:57,int:51,spi:32,critstrkrtng:11}
resto: {__icon:'spell_nature_healingtouch',splpwr:100,manargn:73,hastertng:57,int:51,spi:32,critstrkrtng:11},
feraldps: {__icon:'ability_druid_catform',agi:100,armorpenrtng:90,str:80,critstrkrtng:55,exprtng:50,hitrtng:50,feratkpwr:40,atkpwr:40,hastertng:35}
}
}
};

View File

@@ -262,6 +262,7 @@ class User
'name' => self::$displayName ? self::$displayName : '',
'perms' => self::$perms ? self::$perms : 0,
'roles' => self::$groups ? self::$groups : 0,
'cookies' => []
);
if (self::$id > 0)
@@ -280,7 +281,8 @@ class User
'avatar' => self::$avatar,
'community' => self::$description,
'chars' => self::getCharacters(),
'profiles' => self::getProfiles()
'profiles' => self::getProfiles(),
'cookies' => self::getCookies(),
);
if ($_ = self::getWeightScales())
@@ -328,10 +330,10 @@ class User
// todo: do after profiler
// existing chars on realm(s)
if ($asJSON)
$chars = '[{"name":"ExampleChar", "realmname":"Example Realm", "region":"eu", "realm":"exrealm", icon:"inv_axe_04", "race":4, "gender":0, "classs":11, "level":80}]';
$chars = '[{"name":"ExampleChar", "realmname":"Example Realm", "region":"eu", "realm":"exrealm", icon:"inv_axe_04", "race":4, "gender":0, "classs":11, "level":80, "pinned":1}]';
else
$chars = array(
array("name" => "ExampleChar", "realmname" => "Example Realm", "region" => "eu", "realm" => "exrealm", "icon" => "inv_axe_04", "race" => 4, "gender" => 0, "classs" => 11, "level" => 80)
array("name" => "ExampleChar", "realmname" => "Example Realm", "region" => "eu", "realm" => "exrealm", "icon" => "inv_axe_04", "race" => 4, "gender" => 0, "classs" => 11, "level" => 80, "pinned" => 1)
);
self::$characters = $chars;
@@ -358,6 +360,16 @@ class User
return self::$profiles;
}
public static function getCookies()
{
$data = [];
if (self::$id)
$data = DB::Aowow()->selectCol('SELECT name AS ARRAY_KEY, data FROM ?_account_cookies WHERE userId = ?d', self::$id);
return json_encode($data);
}
public static function writeCookie()
{
$cookie = self::$localeId.count(dechex(self::$id)).dechex(self::$id).base64_encode(self::$passHash);

View File

@@ -55,6 +55,8 @@ switch ($pageCall)
case 'races':
case 'skill':
case 'skills':
// case 'sound': // db: sounds for zone, creature, spell, ...
// case 'sounds':
case 'spell':
case 'spells':
case 'title':
@@ -73,23 +75,26 @@ switch ($pageCall)
require 'pages/talent.php';
break;
/* called by script */
case 'contactus':
if ($pageCall == 'contactus')
case 'cookie': // lossless cookies and user settings
if (User::$id && $pageParam && !empty($_GET[$pageParam]))
{
// 0:ok; 1:captchaInvalid; 2:tooLong; 3:noReasonGiven; 7:alreadyReported; other:prints String
die("not yet implemented:\n".print_r($_POST));
// don't panic .. again .... it get's escaped
if (DB::Aowow()->query('REPLACE INTO ?_account_cookies VALUES (?d, ?, ?)', User::$id, $pageParam, urldecode($_GET[$pageParam])))
die('0'); // 0: success
else
die();
}
break;
case 'contactus':
die("not yet implemented:\n".print_r($_POST)); // 0:ok; 1:captchaInvalid; 2:tooLong; 3:noReasonGiven; 7:alreadyReported; other:prints String
case 'comment':
if ($pageParam == 'rating')
{
// why is this called via index...?
die('{"success":true,"error":"","up":7,"down":9}');
}
else if ($pageParam == 'rate')
{
// 0:success, 1:ratingban, 3:rated too often
die('3');
}
die('3'); // 0:success, 1:ratingban, 3:rated too often
break;
case 'locale': // subdomain-workaround, change the language
User::setLocale($pageParam);
User::writeCookie();
@@ -117,13 +122,13 @@ switch ($pageCall)
case 'build':
if (User::isInGroup(U_GROUP_EMPLOYEE))
{
require 'setup/tools/dataset-assembler/'.$pageParam.'.php';
require 'setup/tools/dataset/'.$pageParam.'.php';
break;
}
case 'sql':
if (User::isInGroup(U_GROUP_EMPLOYEE))
{
require 'setup/tools/sql/_'.$pageParam.'.php';
require 'setup/tools/database/_'.$pageParam.'.php';
break;
}
case 'setup':

View File

@@ -16,6 +16,7 @@ $pageData = array(
['path' => 'template/css/Summary_ie6.css', 'ieCond' => 'lte IE 6'],
),
'reqJS' => array(
'template/js/profile.js',
'template/js/Draggable.js',
'template/js/filters.js',
'template/js/Summary.js',

View File

@@ -36,7 +36,8 @@
id:{$user.id},
name:'{$user.name|escape:"quotes"}',
roles:{$user.roles},
permissions:{$user.perms}
permissions:{$user.perms},
cookies: {$user.cookies}
{if isset($user.chars)}, characters: {$user.chars} {/if}
{if isset($user.profiles)}, profiles: {$user.profiles}{/if}
{if isset($user.weights)}, weightscales: {$user.weights}{/if}

View File

@@ -713,8 +713,10 @@ Mapper.prototype = {
this.sZoom.style.display = 'none';
}
/* sarjuuk: thats one feature i never understood. the inflatable map is superior to the popup in every way possible
if(this.zoom)
MapViewer.show({ mapper: this });
*/
},
getShow: function() { return this.show; },

View File

@@ -105,7 +105,7 @@ function Summary(opt) {
this.level = parseInt(GET.l);
}
else {
var l = $WH.gc('compare_level');
var l = g_getWowheadCookie('compare_level');
if (l) {
this.level = l;
}
@@ -118,7 +118,7 @@ function Summary(opt) {
this.readGroups(GET.compare);
}
else {
this.readGroups($WH.gc('compare_groups'));
this.readGroups(g_getWowheadCookie('compare_groups'));
}
}
@@ -130,7 +130,7 @@ function Summary(opt) {
this.readWeights(GET.weights);
}
else {
this.readWeights($WH.gc('compare_weights'));
this.readWeights(g_getWowheadCookie('compare_weights'));
}
}
}
@@ -1298,10 +1298,10 @@ Summary.prototype = {
// Enchant
if (this.canBeEnchanted(g_items[itemId].jsonequip.slotbak, g_items[itemId].jsonequip.subclass)) {
var _ = [0, (item[2] ? LANG.pr_menu_repenchant : LANG.pr_menu_addenchant), this.openEnchantPicker.bind(this, col, i)];
var _ = [0, (item[2] ? LANG.pr_menu_repenchant : LANG.pr_menu_addenchant), this.openEnchantPicker.bind(this, col, i), null, {}];
if (item[2] && g_enchants[item[2]]) {
_.tinyIcon = g_enchants[item[2]].icon;
_[4].tinyIcon = g_enchants[item[2]].icon;
}
menu.push(_);
@@ -1313,13 +1313,13 @@ Summary.prototype = {
var
gemId = (item[k + 4] > 0 ? item[k + 4] : 0),
c = (extraSocket && k == len3 - 1 ? 14 : g_items[itemId].jsonequip['socket' + (k + 1)]),
_ = [0, (gemId ? LANG.pr_menu_repgem : LANG.pr_menu_addgem), this.openGemPicker.bind(this, col, i, 4 + k, c)];
_ = [0, (gemId ? LANG.pr_menu_repgem : LANG.pr_menu_addgem), this.openGemPicker.bind(this, col, i, 4 + k, c), null, {}];
if (gemId) {
_.tinyIcon = g_gems[gemId].icon;
_[4].tinyIcon = g_gems[gemId].icon;
}
else {
_.socketColor = c;
_[4].socketColor = c;
}
menu.push(_);
@@ -1648,12 +1648,9 @@ Summary.prototype = {
saveComparison: function(refresh) {
window.onbeforeunload = null;
// g_setWowheadCookie('compare_groups', this.getGroupData(), true);
$WH.sc('compare_groups', 20, this.getGroupData(), '/', location.hostname);
// g_setWowheadCookie('compare_weights', $WH.rtrim(this.getWeightData(1).join(';'), ';'), true);
$WH.sc('compare_weights', 20, $WH.rtrim(this.getWeightData(1).join(';'), ';'), '/', location.hostname);
// g_setWowheadCookie('compare_level', this.level, true);
$WH.sc('compare_level', 20, this.level, '/', location.hostname);
g_setWowheadCookie('compare_groups', this.getGroupData(), true);
g_setWowheadCookie('compare_weights', $WH.rtrim(this.getWeightData(1).join(';'), ';'), true);
g_setWowheadCookie('compare_level', this.level, true);
if (refresh) {
document.location.href = '?compare'
@@ -2046,7 +2043,7 @@ Summary.prototype = {
a = this.createControl(LANG.su_autosaving, null, 'autosave-icon selected');
}
else {
if ($WH.gc('compare_groups')) {
if (g_getWowheadCookie('compare_groups')) {
a = this.createControl(LANG.su_viewsaved, 'su_viewsaved', 'save-icon', this.viewSavedComparison.bind(this, 1));
$WH.ae(div, a);
}
@@ -2464,11 +2461,12 @@ Summary.prototype = {
$WH.aE(this.searchName, 'keyup', this.onSearchKeyUp.bind(this, 333));
$WH.aE(this.searchName, 'keydown', this.onSearchKeyDown.bind(this));
$WH.ae(sm, this.searchName);
this.searchMsg = sp;
this.searchMsg.style.fontWeight = 'bold';
$WH.ae(sm, this.searchMsg);
$WH.ae(div, sm);
},
@@ -3236,7 +3234,7 @@ Summary.prototype = {
new Ajax('?search=' + $WH.urlencode(search) + '&json&type=' + type + pr_getScaleFilter(this.currentScale, 1), {
method: 'POST',
search: search,
onSuccess: function(xhr, opt) {
onSuccess: function (xhr, opt) {
var text = xhr.responseText;
if (text.charAt(0) != '[' || text.charAt(text.length - 1) != ']') {
return;
@@ -5076,35 +5074,3 @@ Listview.templates.gempicker = {
}
]
};
/* sarjuuk: bandaid .. belongs to profile.js */
function pr_getScaleFilter(scale, noFilter) {
var temp = [];
if (scale) {
for (var i = 0, len = fi_filters.items.length; i < len; ++i) {
var f = fi_filters.items[i];
if (LANG.traits[f.name] && scale[f.name]) {
temp.push([f.id, scale[f.name]]);
}
}
}
temp.sort(function(a, b) {
return -$WH.strcmp(a[1], b[1]);
});
var wt = [], wtv = [];
for (var i = 0, len = temp.length; i < len; ++i) {
wt.push(temp[i][0]);
wtv.push(temp[i][1]);
}
if (wt.length && wtv.length) {
return (noFilter ? '&' : ';gm=3;rf=1;') + 'wt=' + wt.join(':') + (noFilter ? '&' : ';') + 'wtv=' + wtv.join(':');
}
return '';
}

View File

@@ -342,7 +342,7 @@ $WH.array_unique = function(a) {
// Get element
$WH.ge = function(z) {
if(typeof z != 'string') {
if (typeof z != 'string') {
return z;
}
@@ -545,7 +545,7 @@ $WH.gc = function(z) {
// Prevent element from being selected/dragged (IE only)
$WH.ns = function(a) {
if ($WH.Browser.ie6789) {
a.onfocus = tb;
a.onfocus = $WH.tb;
a.onmousedown = a.onselectstart = a.ondragstart = $WH.rf;
}
}
@@ -1206,7 +1206,7 @@ $WH.g_convertScalingFactor = function(level, factor, dist, stat, json) {
var scalingValues = $WH.g_convertScalingFactor.SV;
var scalingDistributions = $WH.g_convertScalingFactor.SD;
if(!scalingValues[level]) {
if (!scalingValues[level]) {
if (g_user.roles & U_GROUP_ADMIN) {
alert('There are no item scaling values for level ' + level);
}
@@ -1765,7 +1765,7 @@ $WH.Tooltip = {
c[0].style.whiteSpace = 'nowrap';
var m = parseInt(tooltip.style.width);
if(!tooltip.slider || !m) {
if (!tooltip.slider || !m) {
if (c[1].offsetWidth > 300) {
m = Math.max(300, c[0].offsetWidth) + 20;
}
@@ -1780,7 +1780,7 @@ $WH.Tooltip = {
tooltip.style.width = m + 'px';
c[0].style.width = c[1].style.width = '100%';
if(tooltip.slider) {
if (tooltip.slider) {
Slider.setSize(tooltip.slider, m - 6);
tooltip.className += ' tooltip-slider';
}

View File

@@ -1190,6 +1190,10 @@ function fi_presetMatch(weights, stealth) {
for (var l in wt_presets) {
for (var k in wt_presets[l]) {
for (var v in wt_presets[l][k]) {
if (Object.keys(wt_presets[l][k][v]).length == 1) {
continue;
}
p = fi_convertWeights(wt_presets[l][k][v]);
var match = true;

File diff suppressed because it is too large Load Diff