Browse Source

improvemnts on split functionality

master
erqan 11 years ago
parent
commit
36fbe9a6b8
  1. 27
      js/interface_common.js

27
js/interface_common.js

@ -467,31 +467,45 @@ function replyTextKeypress(e) {
splitedPosts = [""]; splitedPosts = [""];
var $tas = tweetForm.find("textarea"); var $tas = tweetForm.find("textarea");
if ($tas.length > 1 && $tas[$tas.length - 1].value.length === 0) {
$tas[$tas.length - 1].value = $tas[$tas.length - 2].value;
$($tas[$tas.length - 2]).remove();
splitedPosts.splice(0, 1);
}
splitedPosts[splitedPosts.length - 1] = $tas[$tas.length - 1].value; splitedPosts[splitedPosts.length - 1] = $tas[$tas.length - 1].value;
for (var i = 0; i < $tas.length - 1; i++) { for (var i = 0; i < $tas.length - 1; i++) {
if ($tas[i].value.length > 131) { var pml = 140 - i.toString().length - $tas.length.toLocaleString().length - 6;
var ci = $tas[i].value.lastIndexOf(" ", 131); if ($tas[i].value.length > pml) {
ci = (ci == -1 ? 131 : ci); var ci = $tas[i].value.lastIndexOf(" ", pml);
ci = (ci == -1 ? pml : ci);
$tas[i + 1].value = $tas[i].value.substr(ci) + $tas[i + 1].value; $tas[i + 1].value = $tas[i].value.substr(ci) + $tas[i + 1].value;
$tas[i].value = $tas[i].value.substr(0, ci); $tas[i].value = $tas[i].value.substr(0, ci);
splitedPosts[i+1] = $tas[i + 1].value; splitedPosts[i+1] = $tas[i + 1].value;
} else if ($tas[i].value.length === 0) { } else if ($tas[i].value.length === 0) {
$($tas[i]).remove(); $($tas[i]).remove();
splitedPosts.splice(i, 1); splitedPosts[i] = '';
continue;
} }
splitedPosts[i] = $tas[i].value; splitedPosts[i] = $tas[i].value;
} }
for (var i = splitedPosts.length-1; i >= 0; i--) {
if (splitedPosts[i].length == 0)
splitedPosts.splice(i, 1);
}
splitedPostsCount = splitedPosts.length;
c = 140 - splitedPosts[splitedPosts.length - 1].length; c = 140 - splitedPosts[splitedPosts.length - 1].length;
} }
var remainingCount = tweetForm.find(".post-area-remaining"); var remainingCount = tweetForm.find(".post-area-remaining");
if( c < 0 ) { if( c < 0 ) {
if (usePostSpliting){ if (usePostSpliting){
var pml = 140 - (2*splitedPosts.length.toLocaleString().length) - 6;
var cp = splitedPosts[splitedPosts.length-1]; var cp = splitedPosts[splitedPosts.length-1];
var ci = cp.lastIndexOf(" ", 131); var ci = cp.lastIndexOf(" ", pml);
ci = (ci == -1 ? 131 : ci); ci = (ci == -1 ? pml : ci);
splitedPosts[splitedPosts.length-1] = cp.substr(0, ci); splitedPosts[splitedPosts.length-1] = cp.substr(0, ci);
splitedPosts.push(cp.substr(ci)); splitedPosts.push(cp.substr(ci));
splitedPostsCount = splitedPosts.length; splitedPostsCount = splitedPosts.length;
@ -502,7 +516,6 @@ function replyTextKeypress(e) {
remainingCount.removeClass("warn"); remainingCount.removeClass("warn");
if (usePostSpliting) { if (usePostSpliting) {
//var np = "";
var $tas = tweetForm.find("textarea"); var $tas = tweetForm.find("textarea");
if ($tas.length < splitedPosts.length){ if ($tas.length < splitedPosts.length){

Loading…
Cancel
Save