From 065d3207b54c2802c95f7f18a905e698be777ea7 Mon Sep 17 00:00:00 2001 From: lduboeuf Date: Wed, 22 Mar 2017 09:40:05 +0100 Subject: [PATCH] publish to gh-pages site --- dist/dev/app.js | 2 + dist/dev/archives/archive-details.html | 12 +- dist/dev/archives/archive-save.html | 2 +- dist/dev/commons/app-components.js | 129 ++++++++++++ dist/dev/commons/app.css | 50 ++++- dist/dev/index.html | 88 +++++--- .../remotestorage-ttb-archives.js | 2 +- dist/dev/teams/team-list-details.html | 5 +- dist/dev/teams/team-member-details.html | 4 +- dist/dev/tools/tool-build-teams.html | 109 +++------- dist/dev/tools/tool-find-members.html | 97 +++------ dist/dev/tools/tool-match.html | 191 ++---------------- dist/dev/tools/tool-match2.html | 90 +++++++++ dist/dev/tools/tool-match3.html | 82 ++++++++ dist/dev/tools/tool-next-member.html | 117 ++--------- dist/dev/vendors/spapp.js | 15 +- 16 files changed, 531 insertions(+), 464 deletions(-) create mode 100644 dist/dev/commons/app-components.js create mode 100644 dist/dev/tools/tool-match2.html create mode 100644 dist/dev/tools/tool-match3.html diff --git a/dist/dev/app.js b/dist/dev/app.js index cb344f6..bd7de5f 100644 --- a/dist/dev/app.js +++ b/dist/dev/app.js @@ -9,6 +9,7 @@ app.alert = function(type, message){ } + app.cleanUI = function(evt){ //toggle menu when a menu item is clicked if (evt.target.parentNode.className!=='icon'){ @@ -39,6 +40,7 @@ app.init = function(event) { $menu_icon.onclick = toggleMenu; + //remotestorage remoteStorage.access.claim('teams', 'rw'); remoteStorage.access.claim('archives', 'rw'); diff --git a/dist/dev/archives/archive-details.html b/dist/dev/archives/archive-details.html index d730db4..6e4dae2 100644 --- a/dist/dev/archives/archive-details.html +++ b/dist/dev/archives/archive-details.html @@ -18,11 +18,15 @@

{{=team.name}}


- - + +
- +
+ +
+ + diff --git a/dist/dev/archives/archive-save.html b/dist/dev/archives/archive-save.html index 363e662..d72342f 100644 --- a/dist/dev/archives/archive-save.html +++ b/dist/dev/archives/archive-save.html @@ -52,6 +52,6 @@

Save result

$desc.value=""; } }); - + //# sourceURL=archive-save.js diff --git a/dist/dev/commons/app-components.js b/dist/dev/commons/app-components.js new file mode 100644 index 0000000..b5eb0a3 --- /dev/null +++ b/dist/dev/commons/app-components.js @@ -0,0 +1,129 @@ +//reusable components +app.checkList = (function(){ + + var $cl = document.getElementById('check-list'); + var tplCheckList = doT.template($cl.innerHTML); + //empty component + $cl.innerHTML =null; + + //provide a memberId->member object key-value + function mapMembers(teams){ + var currentSelection = {}; + for (var t_id in teams){ + var members = teams[t_id].members; + for (var i=0; i < members.length; i++){ + var m = members[i]; + currentSelection[m.id] = m; + } + } + return currentSelection; + } + + function applyTo($target){ + var $this = $target; + var members= null; + + $this.render = function(teams){ + members = mapMembers(teams); + $this.innerHTML = tplCheckList(teams); + $this.querySelector('input[name="tick_all"]').onclick = $this.selectAll; + } + + $this.selectAll =function(){ + var $checkbox_members = $this.querySelectorAll('input[name="member_id"]'); + var checked = this.checked; + for (var i=0; i < $checkbox_members.length; i++){ + $checkbox_members[i].checked = checked; + } + } + + $this.getSelectedItems = function(){ + var $checkboxes = $this.querySelectorAll('input[name="member_id"]'); + var items = []; + for (var i=0; i < $checkboxes.length; i++){ + if ($checkboxes[i].checked){ + items.push(members[$checkboxes[i].value]); + } + } + return items; + } + + + + } + + return { + applyTo: applyTo + } + +})(); + + +app.selectList = (function(){ + + var $select = document.getElementById('select-list'); + var tplList = doT.template($select.innerHTML); + //empty component + $select.innerHTML =null; + + function applyTo($target){ + var $this = $target; + var _teams = null; + + $this.populate = function(){ + remoteStorage.teams.findAll().then( + function(teams){ + + if (Object.keys(teams).length === 0){ + app.alert('alert-info','humm, no members found, you can add members by clicking on the "My Groups" menu'); + } + $this.render(teams); + } + ); + } + + $this.render = function(teams){ + _teams = teams; + $this.innerHTML = tplList(teams); + } + + $this.getSelectedItems = function(){ + if ($this.value==-1){ + return _teams; + }else{ + var t = {}; + t[$this.value] = _teams[$this.value]; + return t; + } + } + + } + + return { + applyTo: applyTo + } + +})(); + +app.list = (function(){ + + var $list = document.getElementById('list'); + var tplList = doT.template($list.innerHTML); + //empty component + $list.innerHTML =null; + + + function applyTo($target){ + var $this = $target; + + $this.render = function(teams){ + $this.innerHTML = tplList(teams); + } + + } + + return { + applyTo: applyTo + } + +})(); diff --git a/dist/dev/commons/app.css b/dist/dev/commons/app.css index b32c559..705223b 100644 --- a/dist/dev/commons/app.css +++ b/dist/dev/commons/app.css @@ -41,6 +41,8 @@ body.tool-next-member > section#tool-next-member , body.sync > section#sync, body.settings > section#settings, body.tool-match > section#tool-match, +body.tool-match2 > section#tool-match2, +body.tool-match3 > section#tool-match3, /*@spapp_generator css*/ body.team-member-details > section#team-member-details { display:block;} @@ -57,6 +59,10 @@ body.archive-details #menu a[href="#archive-list "], body.settings #menu a[href="#settings"], body.home #menu a[href="#home"] { background-color: #555; } +/*components*/ +#components { + display: none; +} /*header*/ body> header { @@ -323,18 +329,27 @@ ul.topnav li.icon { padding:8px; /*padding-top:12px;*/ } -#tool-next-member li, #tool-match li{ + +.checklist li{ padding:0; } -#tool-next-member li label, #tool-match li label{ + +.checklist li label{ display:block; padding:10px 16px; } -#tool-next-member li input, #tool-match li input{ + +.checklist li input{ float:right; } +.danger-zone{ + padding:1em; + margin:1em 0; + border: 1px dashed grey; + text-align: center; +} .list { @@ -365,6 +380,33 @@ ul.topnav li.icon { border-bottom: none } + + + + +ol { + counter-reset: nbres; +} +ol li{ + list-style-type: none; + counter-increment: nbres; /* on incrémente le compteur à chaque nouveau li */ + margin-bottom: 10px; + border-bottom: : 1px solid #ddd; +} +ol li::before{ + content: counter(nbres); + padding: 0 20px 6px; + margin-right: 8px; + vertical-align: top; + background: #678; + -moz-border-radius: 60px; + border-radius: 60px; + font-weight: bold; + font-size: 0.8em; + color: white; +} + + div.team h3, .header-tbl{ margin:0; padding:12px 0px; @@ -463,7 +505,7 @@ button, input[type=submit], input[type=button]:hover { textarea{ color: #5f5f5f; box-sizing: border-box; - width: 50%; + width: 100%; height: 80px; box-shadow: 1px 2px 4px 0 rgba(0, 0, 0, 0.08); font: normal 13px sans-serif; diff --git a/dist/dev/index.html b/dist/dev/index.html index 0fc46fa..e0f99af 100644 --- a/dist/dev/index.html +++ b/dist/dev/index.html @@ -2,41 +2,21 @@ - Team ToolBox + Team Toolbox - - - - - - - - - - - - - - - - - - - -
- Team ToolBox + Team ToolBox Build your teams randomly!
@@ -63,7 +43,7 @@

title

  • build teams
  • find members
  • who's next
  • -
  • match
  • +
  • find pairs
  • @@ -80,12 +60,70 @@

    title

    -
    - +
    +
    +
    ×

    +
    +
    + {{ for(var prop in it) { }} +
    +

    {{=it[prop].name}}

    +
      + {{~it[prop].members :member:idxm}} +
    • + {{~}} +
    +
    + {{ } }} +
    +
    + + {{ for(var prop in it) { }} + + {{ } }} + +
    +
    + {{~it.teams :team:idx}} +
    +

    {{=team.name}}

    +
      + {{~team.members :member:idxm}} +
    • {{=member.name}}
    • + {{~}} +
    +
    + {{~}} + {{? it.orphans }} +
    +

    Team Orphan(s)

    +
      + {{~it.orphans :orphan:idx}} +
    • {{=orphan.name}}
    • + {{~}} +
    +
    + {{?}} +
    + +
    + + + + + + + + + + + + + diff --git a/dist/dev/remotestorage/remotestorage-ttb-archives.js b/dist/dev/remotestorage/remotestorage-ttb-archives.js index 6edc13a..6f41381 100644 --- a/dist/dev/remotestorage/remotestorage-ttb-archives.js +++ b/dist/dev/remotestorage/remotestorage-ttb-archives.js @@ -52,7 +52,7 @@ RemoteStorage.defineModule("archives", function (privateClient, publicClient) { }, remove: function(archiveId){ - return privateClient.remove('archiveId'); + return privateClient.remove(archiveId); }, find: function(id) { return privateClient.getObject(id); diff --git a/dist/dev/teams/team-list-details.html b/dist/dev/teams/team-list-details.html index 6378515..49528b8 100644 --- a/dist/dev/teams/team-list-details.html +++ b/dist/dev/teams/team-list-details.html @@ -18,7 +18,10 @@

    members:

    {{~}} - +
    + + +
    diff --git a/dist/dev/tools/tool-find-members.html b/dist/dev/tools/tool-find-members.html index e11deea..1b663c1 100644 --- a/dist/dev/tools/tool-find-members.html +++ b/dist/dev/tools/tool-find-members.html @@ -14,29 +14,14 @@ -
    - {{~it :team:idx}} -
    -

    {{=team.name}}

    -
      - {{~team.members :member:idxm}} -
    • {{=member.name}}
    • - {{~}} -
    -
    - {{~}} -
    - -
    +
    +
    +
    @@ -49,39 +34,19 @@

    {{=team.name}}

    var $teamList = $section.querySelector('.team-list'); var $resultList = $section.querySelector('.teams-result'); var $okBtn = $section.querySelector('input[type="submit"]'); + var $btnSave = $section.querySelector('button'); - //store template definition - var tplTeamList = doT.template($teamList.innerHTML); - var tplResultList = doT.template($resultList.innerHTML); - var currentOutput = null; + //btn save is invisible by default + $btnSave.style.display='none'; - var exec = function(){ - var teamId = $teamList.value; - //special case for all teams - if (teamId==-1){ - - remoteStorage.teams.findAll().then( - function(teams){ - var team = {members:[]}; - for (var t_id in teams){ - team.members.push.apply(team.members, teams[t_id].members); - } - - generate(team); - } - ); - - }else{ - //team = TeamRepository.findById(teamId); - remoteStorage.teams.find(teamId).then(generate); - } - } + app.selectList.applyTo($teamList); + app.list.applyTo($resultList); - var generate = function(team){ + var currentOutput = null; + var generate = function(members){ - var members = team.members; if (members.length==0){ $resultList.innerHTML = null; app.alert('alert-info','humm, no members found, you can add members by clicking on the "My Groups" menu'); @@ -116,43 +81,33 @@

    {{=team.name}}

    var displayTeams = function(teams) { currentOutput = teams; - $resultList.innerHTML = tplResultList(teams); - var $btnSave = $resultList.querySelector('button'); - $btnSave.onclick = function(){ - if (currentOutput){ - app("archive-save", currentOutput); - } - } - } + $resultList.render({teams: teams}); - //empty tpl by default - $teamList.innerHTML = ''; - //$teamList.classList.add('spinner'); - $resultList.innerHTML = null; + $btnSave.style.display='block'; + } + $btnSave.onclick = function(){ + if (currentOutput){ + app("archive-save", currentOutput); + } + } $okBtn.onclick = function(e){ e.preventDefault(); - exec(); - } - - - //save output + var selectedTeams = $teamList.getSelectedItems(); + var members = []; + for (var t_id in selectedTeams){ + members.push.apply(members, selectedTeams[t_id].members); + } + generate(members); + } return function(params) { - remoteStorage.teams.findAll().then( - function(teams){ - - if (Object.keys(teams).length === 0){ - app.alert('alert-info','humm, no members found, you can add members by clicking on the "My Groups" menu'); - } - $teamList.innerHTML = tplTeamList(teams); - } - ); + $teamList.populate(); //list already saved ? if (params && params.event =='onSavedOutput'){ diff --git a/dist/dev/tools/tool-match.html b/dist/dev/tools/tool-match.html index f9e738e..9fcc90f 100644 --- a/dist/dev/tools/tool-match.html +++ b/dist/dev/tools/tool-match.html @@ -1,66 +1,13 @@
    -
    - {{ for(var prop in it) { }} -
    -

    {{=it[prop].name}}

    -
      - {{~it[prop].members :member:idxm}} -
    • - {{~}} -
    -
    - {{ } }}
    -
    -
    -
    - - - -
    -
    - {{ for(var prop in it) { }} -
    -

    {{=it[prop].name}}

    -
      - {{~it[prop].members :member:idxm}} -
    • - {{~}} -
    -
    - {{ } }} -
    -
    -
    - -
    -
    -

    Matches

    -
      - {{~it.left :lname:idx}} -
    • {{=lname}} -- {{=it.right[idx]}}
    • - {{~}} -
    -
    -
    +
    diff --git a/dist/dev/tools/tool-match2.html b/dist/dev/tools/tool-match2.html new file mode 100644 index 0000000..670e092 --- /dev/null +++ b/dist/dev/tools/tool-match2.html @@ -0,0 +1,90 @@ +
    +
    + + +
    +
    +
    + +
    + + +
    diff --git a/dist/dev/tools/tool-match3.html b/dist/dev/tools/tool-match3.html new file mode 100644 index 0000000..66b11a4 --- /dev/null +++ b/dist/dev/tools/tool-match3.html @@ -0,0 +1,82 @@ +
    +

    Result:

    +
    +
    + +
    + + +
    diff --git a/dist/dev/tools/tool-next-member.html b/dist/dev/tools/tool-next-member.html index 2286ee6..c8ad14e 100644 --- a/dist/dev/tools/tool-next-member.html +++ b/dist/dev/tools/tool-next-member.html @@ -2,31 +2,17 @@
    - {{ for(var prop in it) { }} -
    -

    {{=it[prop].name}}

    -
      - {{~it[prop].members :member:idxm}} -
    • - {{~}} -
    -
    - {{ } }} -
    - -
    + +
    +
    +
    -

    Random ordered list

    +

    Random ordered list:

      {{~it :member:idx}}
    1. {{=member.name}}
    2. @@ -41,20 +27,22 @@

      Random ordered list

      var $teamList = $section.querySelector('.team-list'); var $resultList = $section.querySelector('.teams-result'); var $shuffleResult = $section.querySelector('#shuffle-result'); - + var $btnSort = $section.querySelector('button'); //store template definition - var tplTeamList = doT.template($teamList.innerHTML); - var tplResultList = doT.template($resultList.innerHTML); var tplShuffleResult = doT.template($shuffleResult.innerHTML); - var currentSelection = null; - //empty tpl by default - $teamList.innerHTML = ''; - $resultList.innerHTML = null; $shuffleResult.innerHTML = null; + //btn is invisible by default + $btnSort.style.display='none'; + + //bind to checklist and selectList components + app.checkList.applyTo($resultList); + app.selectList.applyTo($teamList); + + var shuffle = function(members){ var j, x, i; for (i = members.length; i; i--) { @@ -66,94 +54,29 @@

      Random ordered list

      } - var toggleChilds = function(e){ - var $team = e.currentTarget; - var checked = $team.checked; - $checkbox_members = $team.parentNode.parentNode.querySelectorAll('input[name="member_id"]'); - - for (var i=0; i < $checkbox_members.length; i++){ - $checkbox_members[i].checked = checked; - } - } var doResult = function(e){ e.preventDefault(); - var members = []; - $checkbox_members = $section.querySelectorAll('input[name="member_id"]'); - for (var i=0; i < $checkbox_members.length; i++){ - if ($checkbox_members[i].checked){ - members.push(currentSelection[$checkbox_members[i].value]); - } - } + var members = $resultList.getSelectedItems(); shuffle(members); + $shuffleResult.innerHTML = tplShuffleResult(members); window.scrollTo(0,document.body.scrollHeight); } - var displayTeams =function(teams){ - //store current selected teams for later use - currentSelection = {}; - for (var t_id in teams){ - var members = teams[t_id].members; - for (var i=0; i < members.length; i++){ - var m = members[i]; - currentSelection[m.id] = m; - } - } - - - $resultList.innerHTML = tplResultList(teams); - $shuffleResult.innerHTML = null; - - //handle toggle all - var $ticks = $section.querySelectorAll('input[name="tick_all"]'); - for (var i=0; i < $ticks.length; i++){ - $ticks[i].onclick = toggleChilds; - } - - $section.querySelector('input[type="submit"]').onclick = doResult; - - } + $btnSort.onclick = doResult; $teamList.onchange = function(e){ - var teamId = $teamList.value; - if (teamId==-1){ - - remoteStorage.teams.findAll().then(function(teams){ - displayTeams(teams); - }); - - - }else{ - remoteStorage.teams.find(teamId).then( - function(team){ - var teams = {}; - teams[teamId] = team; - displayTeams(teams); - } - ); - } + $resultList.render($teamList.getSelectedItems()); + $btnSort.style.display='block'; } - //save output - - - return function(params) { - remoteStorage.teams.findAll().then( - function(teams){ - - if (Object.keys(teams).length === 0){ - app.alert('alert-info','humm, no members found, you can add members by clicking on the "My Groups" menu'); - } - $teamList.innerHTML = tplTeamList(teams); - } - ); - + $teamList.populate(); } }); diff --git a/dist/dev/vendors/spapp.js b/dist/dev/vendors/spapp.js index 4482bca..b0872a2 100644 --- a/dist/dev/vendors/spapp.js +++ b/dist/dev/vendors/spapp.js @@ -63,16 +63,27 @@ if($currentPage = $page){ document.dispatchEvent(new CustomEvent('page.shown', {'detail' : {'currentPage' : currentPageName, 'title': $page.getAttribute('title')}})); - //update url location if not + //update url location when access pages via code + if (!$page.hasAttribute('default') && !modal){ + var url = '#' + currentPageName; + if (param && typeof(param)!=='object') //don't display object in url + url += ':' + param; + + if (location.hash!==url){ + history.pushState(null, null, url); + } + } + /* if ($page.hasAttribute('default')){ var url = '#' + currentPageName; if (param && typeof(param)!=='object') //don't display object in url url += ':' + param; - if (location.hash=="" || location.hash!==url){ + if (location.hash!==url){ history.pushState(null, null, url); } } + */ } }