السلام عليكم ورحمة الله وبركاته
أنا ابحث عن كود (جافا سكربت) أستطيع من خلاله ترقيم الأسطر داخل الـ textarea
وفي نفس الوقت اوقف الـ word wrap .
بعد البحث وجدت هذا الكود الموجود في هذه الصفحة
http://4umi.com/web/javascript/textarea.htm
الكود يعمل بكفاءة تامة على متصفح الإكسبلورر
لكنه لا يعمل بشكل سليم على الفايرفوكس
اتمنى أن اجد من يملك حلا مناسبا لي ..
ما يهمني فعلا هو تمييز كل سطر في الـ textarea بحث يكون واضحا لمن يكتب فيها ان كل سطر يشكل وحدة مستقلة بنفسها لاسيما الأسطر الطويلة ..
سواء كان هذا التمييز باللون او بوضع خط بين كل سطر والآخر أو بوضع كل جملة في سطر مستقل أو بأي طريقة أخرى
كود:
function scrollit() {
var o = document.getElementById( 'dyna' );
o.style.top = '-' + tt.scrollTop + 'px';
o.style.clip =
'rect(' + ( tt.scrollTop + 1 ) + 'px ' + o.scrollWidth + 'px ' + ( tt.scrollTop + tt.offsetHeight - 1 ) + 'px 0)';
}
function linenumbers() {
var d = document,
o = d.createElement( 'div' ),
p = o.cloneNode( false ), q = o.cloneNode( false ),
i, max = 10 + tt.value.split(/\n/).length;
o.id = 'stat';
p.id = 'dyna';
q.appendChild( d.createTextNode( 'c' ) );
for( i = 1; i<max; i++ ) {
r = q.cloneNode( true );
r.firstChild.nodeValue = i;
p.appendChild( r );
}
o.appendChild( p );
o.style.fontFamily = getstyle( tt, 'font-family' );
o.style.lineHeight = getstyle( tt, 'line-height' );
o.style.paddingTop = getstyle( tt, 'padding-top' );
//o.style.borderRight = '2px outset white';
o.style.top = getpos( tt ).y + 'px';
tt.parentNode.insertBefore( o, tt );
w = p.scrollWidth;
if( ff.wrp.checked ) { o.className = 'hid'; }
o.style.width = w + 'px';
o.style.height = tt.offsetHeight + 'px';
o.style.left = getpos( tt ).x - w * 2 + 'px';
}
function wrapta() {
tt.wrap = ff.wrp.checked ? 'soft' : 'off';
document.getElementById( 'stat' ).className = ff.wrp.checked ? 'hid' : 'lit';
scrollit();
}
var ff = document.forms.f, tt = ff.elements.txt;
tt.onscroll = scrollit;
linenumbers();
كود HTML:
<form action="?f" id="f">
<fieldset><legend>The area</legend>
<div><label for="wrp"><input name="wrp" id="wrp" type="checkbox" class="zm" onclick="wrapta();" checked="checked" accesskey="w"/><i>W</i>rap</label></div>
<textarea id="txt" name="txt" cols="60" rows="8">
I sent thee late a rosy wreath,
Not so much honoring thee,
As giving it a hope, that there
It could not wither'd be.
But thou thereon didst only breathe,
And sent'st it back to me:
Since when it grows, and smells, I swear,
Not of itself, but thee.
</textarea></fieldset>
</form>