1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-16 02:19:55 +00:00

Fix another IE11 problem

IE11 doesn’t support String.prototype.repeat
This commit is contained in:
Jermolene 2016-05-01 18:17:47 +01:00
parent 01eb45946c
commit cdeca55d45
2 changed files with 13 additions and 2 deletions

View File

@ -21,7 +21,7 @@ exports["prefix-lines"] = function(event,operation) {
var lines = operation.text.substring(operation.cutStart,operation.cutEnd).split(/\r?\n/mg);
$tw.utils.each(lines,function(line,index) {
// Compose the required prefix
var prefix = event.paramObject.character.repeat(event.paramObject.count);
var prefix = $tw.utils.repeat(event.paramObject.character,event.paramObject.count);
// Check if we already have the required prefix
if(line.substring(0,prefix.length) === prefix) {
// If so, remove the prefix

View File

@ -17,7 +17,18 @@ Display a warning, in colour if we're on a terminal
*/
exports.warning = function(text) {
console.log($tw.node ? "\x1b[1;33m" + text + "\x1b[0m" : text);
}
};
/*
Repeats a string
*/
exports.repeat = function(str,count) {
var result = "";
for(var t=0;t<count;t++) {
result += str;
}
return result;
};
/*
Trim whitespace from the start and end of a string