X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/d04a06a9b7966b84258a9a8d2ae06148eedb8264..3314477c16f2492b2a6b95b17922e5b6f2b087ca:/redakcja/static/js/button_scripts.js?ds=inline diff --git a/redakcja/static/js/button_scripts.js b/redakcja/static/js/button_scripts.js index 06bc7c5b..c3275938 100644 --- a/redakcja/static/js/button_scripts.js +++ b/redakcja/static/js/button_scripts.js @@ -95,7 +95,7 @@ function ScriptletCenter() } if (move_cursor) { - move_forward += params.tag.length+2; + move_forward -= params.tag.length+3; } done(output, move_forward); @@ -114,7 +114,6 @@ function ScriptletCenter() }; }); - var partial = true; if(!text) done(text, move_forward); var changed = 0; @@ -155,7 +154,6 @@ function ScriptletCenter() }); if(!text) done(text, move_forward); - var original = text;$ nblck_each(exprs, function(expr, index) { $progress.html(600 + index); @@ -186,24 +184,7 @@ function ScriptletCenter() this.scriptlets['lowercase'] = function(context, params, text, move_forward, done) { if(!text) done(text, move_forward); - - var lcase = text.toLowerCase(); - var ucase = text.toUpperCase(); - - if(lcase == text) repl = ucase; /* was lowercase */ - else if(ucase != text) repl = lcase; /* neither lower- or upper-case */ - else { /* upper case -> camel-case */ - var words = $.map(lcase.split(/\s/), function(word) { - if(word.length > 0) { - return word[0].toUpperCase() + word.slice(1); - } else { - return ''; - } - }); - text = words.join(' '); - } - - done(text, move_forward); + done(text.toLowerCase(), move_forward); }.bind(this); @@ -227,7 +208,47 @@ function ScriptletCenter() text = text + buf + '\n' + ebuf; } else { - move_forward += params.tag.length + 2; + text = "" + move_forward -= "".length; + } + + done(text, move_forward); + }.bind(this); + + + this.scriptlets['autotag'] = function(context, params, text, move_forward, done) + { + if(!text.match(/^\n+$/)) done(text, move_forward); + + function insert_done(output, mf) { + text += output; + } + + if (!params.split) params.split = 2; + if (!params.padding) params.padding = 3; + + chunks = text.replace(/^\n+|\n+$/, '').split(new RegExp("\\n{"+params.split+",}")); + text = text.match(/^\n+/); + if (!text) + text = ''; + padding = ''; + for(; params.padding; params.padding--) { + padding += "\n"; + } + + if (params.tag == 'strofa') + tagger = this.scriptlets['insert_stanza']; + else + tagger = this.scriptlets['insert_tag']; + + for (i in chunks) { + if (chunks[i]) { + if (params.tag == 'akap' && chunks[i].match(/^---/)) + tag = 'akap_dialog'; + else tag = params.tag; + tagger(context, {tag: tag}, chunks[i], 0, insert_done); + text += padding; + } } done(text, move_forward);