/********************************** - Draw text box in correct position @done - With word wrap @done - Detect device - Download a wallpaper/lockscreen **********************************/ // CARDS TO LOAD var CARDNAMES = [ "intro_a", "intro_b", "intro_c", "sci_a", "sci_b", "sci_c", "leit_a", "leit_b", "leit_c", "leit_d", "you_what", "you_why", "you_how", "you_when" ]; var download_btn = $("#download"); download_btn.innerHTML = _getLabel("download_all"); download_btn.onclick = function(){ // disable while we wait... download_btn.disabled = true; // Loads var CARD_HTMLS = []; for(var i=0; i word.trim()); var line = ''; for(var n=0; nmaxWidth && n>0){ context.fillText(line, x, y); line = words[n]; y += lineHeight; }else{ line = testLine; } } context.fillText(line, x, y); } function testHowManyLines(context, text, maxWidth){ var numLines = 1; var words = text.replace(/\n/g," ").split(' '); words = words.map(word => word.trim()); var line = ''; for(var n=0; nmaxWidth && n>0){ //context.fillText(line, x, y); line = words[n]; numLines++; }else{ line = testLine; } } //context.fillText(line, x, y); return numLines; }