From c7a47a56c61b505bc3a81489c6a2a31605ea97a9 Mon Sep 17 00:00:00 2001 From: LoveEevee Date: Sun, 9 Sep 2018 07:11:05 +0300 Subject: [PATCH] Add element function --- public/index.html | 1 + public/src/js/element.js | 49 +++++++++++++++++ public/src/js/songselect.js | 101 +++++++++++++++++++++++------------- 3 files changed, 114 insertions(+), 37 deletions(-) create mode 100644 public/src/js/element.js diff --git a/public/index.html b/public/index.html index f6c9c49..44a11a4 100644 --- a/public/index.html +++ b/public/index.html @@ -49,6 +49,7 @@ + diff --git a/public/src/js/element.js b/public/src/js/element.js new file mode 100644 index 0000000..e38a7e6 --- /dev/null +++ b/public/src/js/element.js @@ -0,0 +1,49 @@ +function element(){ + var parent + var lasttag + var createdtag + var toreturn={} + for(var i=0;i
"; + var song = assets.songs[i]; + var songTitle = song.title; + var skipChars = []; + var charElements = [0] + var diffElements = [0] + for (var c=0; c -1) { continue; }; - - var ch = songTitle.charAt(c) == ' ' ? ' ' : songTitle.charAt(c); - + + var ch = songTitle.charAt(c) == " " ? "\xa0" : songTitle.charAt(c); + var isApos = false; - if (songTitle.charAt(c+1) == '\'') { - ch = ch + '\''; + if (songTitle.charAt(c+1) == "'") { + ch = ch + "'"; skipChars.push(c+1); isApos = true; }; - - var cl = ch == ' ' ? 'song-title-char song-title-space' : 'song-title-char'; - cl = isApos ? cl + ' song-title-apos' : cl; - - _code += '' + ch + ''; + + var cl = ch == "\xa0" ? "song-title-char song-title-space" : "song-title-char"; + cl = isApos ? cl + " song-title-apos" : cl; + + charElements.push( + ["span", { + class: cl, + alt: ch + }, ch] + ) }; - _code += "
"; - + songElements.push( + ["div", { + id: "song-" + song.id, + class: "song", + "data-title": songTitle, + "data-song-id": song.id, + "data-preview": song.preview + }, + ["div", { + class: /^[\x00-\xFF]*$/.test(songTitle) ? "song-title alpha-title" : "song-title" + }, charElements], + ["ul", { + class: "difficulties" + }, diffElements] + ] + ) } - $("#song-container").html(_code); + element( + document.getElementById("song-container"), + songElements + ) $('.difficulty').hide(); }