gwangyi / UCraft Helper

(function(objs) {
  objs.each(function(idx, obj) {
    var rows = $('tr td', obj).parent().map(function(idx, obj) {
      return {
        i: idx,
        o: obj
      };
    });
    rows.sort(function(a, b) {
      var aa = $('.button_list_espionage', a.o).attr('onmouseover').match(/ : ([0-9,]*)/)[1].replace(
        /,/g, '') - 0;
      var bb = $('.button_list_espionage', b.o).attr('onmouseover').match(/ : ([0-9,]*)/)[1].replace(
        /,/g, '') - 0;
      var cmp = aa - bb;
      return cmp === 0 ? a.i - b.i : cmp;
    });
    $(obj).append(rows.map(function(idx, obj) {
      return obj.o;
    }));
  });
})($('#galaxy_content_panel table'));

$('.occupy_image').each(function(idx, obj) {
    var incr = $(obj).data('planet_armor_rate_increasement') * 10000000;
    var s = $('<span/>');
    var init = $(obj).data('planet_armor_rate_init') * 10000000;
    var start = $(obj).data('start');
    var fin = '';
    if(incr < 0) {
        if($('#occupied_emblem_img').attr('src').match(/Alien/) || $('#galaxy_name').text().match(/WormHole/)) {
            if(init > 900000000) {
                s.append($('<span/>').text("90%: " + new Date(start - (init - 900000000) / incr * 1000).toLocaleString()));
                s.append($('<br/>'));
            }
            if(init > 700000000) {
                s.append($('<span/>').text("70%: " + new Date(start - (init - 700000000) / incr * 1000).toLocaleString()));
                s.append($('<br/>'));
            }
            if(init > 400000000) {
                s.append($('<span/>').text("40%: " + new Date(start - (init - 400000000) / incr * 1000).toLocaleString()));
                s.append($('<br/>'));
            }
        }
        fin = new Date($(obj).data('start') - $(obj).data('planet_armor_rate_init') / incr * 1000).toLocaleString();
        s.append($('<span/>').text("0%: " + fin));
    } else {
        fin = new Date($(obj).data('start') + (1000000000 - $(obj).data('planet_armor_rate_init')) / incr * 1000).toLocaleString();
        s.append($('<span/>').text("100%: " + fin));
    }
        $(obj).attr('title', fin);
        $(obj).parent('td').next('td').append($('<br/>')).append(s);
});

Re: @vehumet:

@vehumet,

I'd like you to reread this section of the Terms of Service. Please do not post just code snippets and especially the missing the code fence... this is your only warning and your only comment fix. Thanks.