Ответы пользователя по тегу Фронтенд
  • Как перебрать json данные для асинхронного вывода с таймингом?

    shmatuan
    @shmatuan
    8 year of Web, 5 years of Vue
    https://codepen.io/andreysh/pen/mvwpwo?editors=1010

    var dataBattle = JSON.parse('[{"stages_of_the_battle":{"my_heroes":[[{"life_of_hero":100,"faith_of_hero":100},{"life_of_hero":98,"faith_of_hero":25}],[{"life_of_hero":100,"faith_of_hero":100},{"life_of_hero":97.5,"faith_of_hero":25}],[{"life_of_hero":100,"faith_of_hero":100},{"life_of_hero":96.8,"faith_of_hero":25}]],"rival_heroes":[[{"life_of_hero":100,"faith_of_hero":100},{"life_of_hero":99,"faith_of_hero":25}],[{"life_of_hero":100,"faith_of_hero":100},{"life_of_hero":95.5,"faith_of_hero":25}],[{"life_of_hero":100,"faith_of_hero":100},{"life_of_hero":99.8,"faith_of_hero":25}]],"visual_log_of_the_battle":[{"my_hero_login":"vovkka","img":"ico_1","name_of_the_type_impact":"\u0443\u0434 1","rival_hero_login":"groza","cause_damage":-30,"part_life_hero":370,"total_life_hero":400,"counter_attack":{"rival_hero_login":"groza","img":"ico_3","my_hero_login":"vovkka","cause_damage":-45,"part_life_hero":455,"total_life_hero":500}},{"rival_hero_login":"groza","img":"ico_3","name_of_the_type_impact":"\u0443\u0434 2","my_hero_login":"vovkka","cause_damage":-45,"part_life_hero":455,"total_life_hero":500},{"rival_hero_login":"groza","img":"ico_5","name_of_the_type_impact":"\u0443\u0434 3","my_hero_login":"vovkka","cause_damage":-25,"part_life_hero":435,"total_life_hero":500}],"result_of_fight":"\u041f\u043e\u0431\u0435\u0434\u0430!"}},{"stages_of_the_battle":{"my_heroes":[[{"life_of_hero":100,"faith_of_hero":100},{"life_of_hero":98,"faith_of_hero":25}],[{"life_of_hero":100,"faith_of_hero":100},{"life_of_hero":97.5,"faith_of_hero":25}],[{"life_of_hero":100,"faith_of_hero":100},{"life_of_hero":96.8,"faith_of_hero":25}]],"rival_heroes":[[{"life_of_hero":100,"faith_of_hero":100},{"life_of_hero":99,"faith_of_hero":25}],[{"life_of_hero":100,"faith_of_hero":100},{"life_of_hero":95.5,"faith_of_hero":25}],[{"life_of_hero":100,"faith_of_hero":100},{"life_of_hero":99.8,"faith_of_hero":25}]],"visual_log_of_the_battle":[{"my_hero_login":"vovkka","img":"ico_3","name_of_the_type_impact":"\u0443\u0434 1","rival_hero_login":"zmei","cause_damage":-60,"part_life_hero":360,"total_life_hero":400,"counter_attack":{"rival_hero_login":"zmei","img":"ico_3","my_hero_login":"vovkka","cause_damage":-45,"part_life_hero":455,"total_life_hero":500}},{"rival_hero_login":"zmei","img":"ico_7","name_of_the_type_impact":"\u0443\u0434 2","my_hero_login":"vovkka","cause_damage":-45,"part_life_hero":415,"total_life_hero":500},{"rival_hero_login":"zmei","img":"ico_2","name_of_the_type_impact":"\u0443\u0434 3","my_hero_login":"vovkka","cause_damage":-55,"part_life_hero":375,"total_life_hero":500}],"result_of_fight":"\u041f\u043e\u0431\u0435\u0434\u0430!"}}]');
    
    var data = []
    
    for (var i = 0; i < dataBattle.length; i++) {
      for (var k = 0; k < dataBattle[i].stages_of_the_battle.visual_log_of_the_battle.length; k++) {
        let str = '<div class="battle-plan-plash-step">';
        str += '<div class="step-user-one">' + dataBattle[i].stages_of_the_battle.visual_log_of_the_battle[k].my_hero_login + '</div>';
        str += '<span class="step-ico jtooltip" title="' + dataBattle[i].stages_of_the_battle.visual_log_of_the_battle[k].name_of_the_type_impact + '"><i class="ico-step-one"></i></span>';
        str += '<div class="step-user-two step-user-enemy">' + dataBattle[i].stages_of_the_battle.visual_log_of_the_battle[k].rival_hero_login + '</div>';
        str += '<div class="step-user-return">' + dataBattle[i].stages_of_the_battle.visual_log_of_the_battle[k].cause_damage + '</div>';
        str += '<div class="step-user-summary">[' + dataBattle[i].stages_of_the_battle.visual_log_of_the_battle[k].part_life_hero + ' / ' + dataBattle[i].stages_of_the_battle.visual_log_of_the_battle[k].total_life_hero + ']</div>';
        str += '</div>';
    
        data.push({k, str})
      }
    }
    
    var update = function(k) {
      setTimeout(function() {
        //$('.battle-plan-plash-holder').prepend(str);
        console.log( "time " + (1000 * (k + 1)) ,data[k].str);
        update(k + 1)
      }, 1000 * (k + 1));
    }
    
    update(0)
    Ответ написан
    3 комментария
  • Как сделать ручную сортировку списка на фронте в Angularjs?

    shmatuan
    @shmatuan
    8 year of Web, 5 years of Vue
    Добавить drag and drop - он будет изменять очерёдность (+ можно добавить корзину для перетягивания в удаление) marceljuenemann.github.io/angular-drag-and-drop-li...
    Ответ написан
    Комментировать
  • Ссылка на страницу с заполненными полями формы?

    shmatuan
    @shmatuan
    8 year of Web, 5 years of Vue
    Ссылка вида ?param1=test1&param2=test2&param3=test3

    https://stackoverflow.com/questions/5448545/how-to...
    function getSearchParameters() {
          var prmstr = window.location.search.substr(1);
          return prmstr != null && prmstr != "" ? transformToAssocArray(prmstr) : {};
    }
    
    function transformToAssocArray( prmstr ) {
        var params = {};
        var prmarr = prmstr.split("&");
        for ( var i = 0; i < prmarr.length; i++) {
            var tmparr = prmarr[i].split("=");
            params[tmparr[0]] = tmparr[1];
        }
        return params;
    }
    
    var params = getSearchParameters();
    Ответ написан
  • Откуда черпать свежую информацию в мире Front-end?

    shmatuan
    @shmatuan
    8 year of Web, 5 years of Vue
    Самое информативное и свежее с того же хабра - подборки всех статей по фронтенду за неделю)

    последний: https://habr.com/post/431040/
    Ответ написан
    1 комментарий
  • Как исправить галерею?

    shmatuan
    @shmatuan
    8 year of Web, 5 years of Vue
    float: left; - это очень плохой костыль, делайте через flex/grid

    https://codepen.io/andreysh/pen/EOXzPB
    .grid{
      display: flex;
      flex-wrap :wrap;
    Ответ написан
    Комментировать