Popup.js

From Wiki The-West EN
Revision as of 16:01, 11 June 2017 by Thathanka (talk | contribs) (Created page with "$('.item_container').each(function() { var url = 'https://westzzs.innogamescdn.com/images/items/' + $(this).attr('data-cdn-cat') + '/' + $(this).attr('data-cdn-img') + '.p...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation

$('.item_container').each(function() {

   var url = 'https://westzzs.innogamescdn.com/images/items/' + $(this).attr('data-cdn-cat') + '/' + $(this).attr('data-cdn-img') + '.png';
   $(this).append('<img src="' + url + '">');
   $(this).attr('onmouseover', 'showPopup(this)');
   $(this).attr('onmouseout', 'hidePopup()');

})

$('body').append('

');

var popup = {

   dmg: {

dmg: '

', dmglvl: '

'

   },
   skills: {

str: '

', mob: '

', dex: '

', cha: '

', con: '

', vig: '

', tou: '

', sta: '

', hea: '

', rid: '

', ref: '

', dod: '

', hid: '

', swi: '

', aim: '

', sho: '

', pit: '

', fin: '

', rep: '

', lea: '

', tac: '

', tra: '

', ani: '

', app: '

'

   },
   fb: {

fbdef: '

', fboff: '

', fbres: '

', fbdefs: '

', fboffs: '

', fbdmgs: '

'

   },
   txt: {

t1: '

', t2: '

', t3: '

', t4: '

'

   },
   bonus: {

b1: '

', b2: '

', b3: '

', b4: '

'

   }

}

function createPopup(data, cdn_cat, cdn_name) {

   data = JSON.parse(data);

var html = '

<img class="popup_divider"/>


';

   for (var cat in popup) {

var cnt = 0;

       for (var key in popup[cat]) {
           if (data.hasOwnProperty(key)) {

cnt++;

               var per_level = "";
               if (Math.sign(data[key]) == -1) {
                   per_level = " (per Level)";
                   data[key] = -data[key];
               }
               html += popup[cat][key].replace('#1', data[key]).replace('#2', per_level);
           }
       }
       if (cnt > 0) {
           html += '
'; } }

html += '

';

   return html;

}

function showPopup(obj) {

   var html = createPopup($(obj).attr('data-popup'), $(obj).attr('data-cdn-cat'), $(obj).attr('data-cdn-img'));
   $('.popup_contents').html(html);
   $('.popup_window').show();

}

function hidePopup() {

   $('.popup_window').hide();

}