អ្នកប្រើប្រាស់:Nums/monobook.js
Appearance
សម្គាល់: បន្ទាប់ពីបានរក្សាទុករួចហើយ លោកអ្នកគួរតែសំអាត browser's cache របស់លោកអ្នកដើម្បីមើលការផ្លាស់ប្តូរ។ ខាងក្រោមនេះជាវិធីសំអាត browser's cache ចំពោះកម្មវិធីរុករក(Browser)មួយចំនួន។
- Firefox / Safari: សង្កត់ [Shift] ឱ្យជាប់រួចចុចប៊ូតុង Reload ឬក៏ចុច Ctrl-F5 ឬ Ctrl-R ( ⌘-R សំរាប់ Mac)
- Google Chrome: ចុច Ctrl-Shift-R (⌘-Shift-R សំរាប់ Mac)
- IE(Internet Explorer): សង្កត់ [Ctrl] ឱ្យជាប់ រួចចុច Refreshប៊ូតុង ឬក៏ចុច Ctrl-F5។
- Konqueror: ចុចប៊ូតុង Reload ឬក៏ចុច F5
- Opera: សូមសំអាតcacheនៅក្នុង [Tools]→[Preferences]
/* <pre><nowiki> */
// Simplified edit section 0 ([[User:ais523/editsection0tab.js]])
// Loosely based on [[Wikipedia:WikiProject User scripts/Scripts/Add edit section 0]]
addOnloadHook(function()
{
var x=document.getElementById('ca-history');
if(x!=null)
addPortletLink('p-cactions', wgServer+wgScript+"?title="+encodeURIComponent(wgPageName)+
"&action=edit§ion=0", '0', 'ca-edit-0',
'កែប្រែផ្នែកនៅមុខគេនៃទំព័រនេះ', '0', x);
});
//HotCat
addOnloadHook ( hotcat ) ;
var hotcat_running = 0 ;
var hotcat_last_v = "" ;
var hotcat_exists_yes = "/media/wikipedia/commons/thumb/b/be/P_yes.svg/20px-P_yes.svg.png" ;
var hotcat_exists_no = "/media/wikipedia/commons/thumb/4/42/P_no.svg/20px-P_no.svg.png" ;
function hotcat () {
if ( hotcat_check_action() ) return ;
var catlinks = document.getElementById("catlinks");
if (! catlinks && wgNamespaceNumber %2 == 0) {
var bodyC = document.getElementById("bodyContent");
catlinks = document.createElement("div");
catlinks.id = "catlinks";
catlinks.appendChild(document.createElement("p"));
catlinks.firstChild.className = "catlinks";
bodyC.appendChild(catlinks);
}
var catline = getElementsByClassName ( document , "p" , "catlinks" ) [0] ;
if ( catline == null || typeof catline == 'undefined' ) return ;
hotcat_modify_existing ( catline ) ;
hotcat_append_add_span ( catline ) ;
}
function hotcat_append_add_span ( catline ) {
var span_add = document.createElement ( "span" ) ;
var span_sep = document.createTextNode ( " | " ) ;
if ( catline.firstChild ) catline.appendChild ( span_sep ) ;
catline.appendChild ( span_add ) ;
hotcat_create_span ( span_add ) ;
}
String.prototype.ucFirst = function () {
return this.substr(0,1).toUpperCase() + this.substr(1,this.length);
}
function hotcat_modify_span ( span , i ) {
var cat_title = span.firstChild.getAttribute ( "title" ) ;
cat_title = cat_title.substr(cat_title.indexOf(":") + 1);
var sep1 = document.createTextNode ( " " ) ;
var a1 = document.createTextNode ( "(-)" ) ;
var remove_link = document.createElement ( "a" ) ;
remove_link.href = "javascript:hotcat_remove(\"" + cat_title + "\");" ;
remove_link.appendChild ( a1 ) ;
span.appendChild ( sep1 ) ;
span.appendChild ( remove_link ) ;
var mod_id = "hotcat_modify_" + i ;
var sep2 = document.createTextNode ( " " ) ;
var a2 = document.createTextNode ( "(±)" ) ;
var modify_link = document.createElement ( "a" ) ;
modify_link.id = mod_id ;
modify_link.href = "javascript:hotcat_modify(\"" + mod_id + "\");" ;
modify_link.appendChild ( a2 ) ;
span.appendChild ( sep2 ) ;
span.appendChild ( modify_link ) ;
}
function hotcat_modify_existing ( catline ) {
var spans = catline.getElementsByTagName ( "span" ) ;
for ( var i = 0 ; i < spans.length ; i++ ) {
hotcat_modify_span ( spans[i] , i ) ;
}
}
function hotcat_remove ( cat_title ) {
var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
if (window.confirm("តើអ្នកប្រាកដថានឹងដក Category:'" + cat_title + "' ចេញពីទំព័រនេះរឺ?")) {
document.location = editlk + '&hotcat_removecat=' + encodeURIComponent(cat_title) ;
}
}
function hotcatGetParamValue(paramName, h) {
if (typeof h == 'undefined' ) { h = document.location.href; }
var cmdRe=RegExp('[&?]'+paramName+'=([^&]*)');
var m=cmdRe.exec(h);
if (m) {
try {
return decodeURIComponent(m[1]);
} catch (someError) {}
}
return null;
}
function hotcat_check_action () {
var ret = 0 ;
if ( wgAction != "edit" ) return ret ;
var summary = new Array () ;
var t = document.editform.wpTextbox1.value ;
var prevent_autocommit = 0 ;
if ( typeof hotcat_no_autocommit != 'undefined' && hotcat_no_autocommit ) prevent_autocommit = 1 ;
var hrc = hotcatGetParamValue('hotcat_removecat') ;
var hnc = hotcatGetParamValue('hotcat_newcat') ;
if ( typeof hrc != "undefined" && hrc != null && hrc != "" ) {
var hcre = new RegExp("(\\s*)\\[\\[ *Category *: *" + hrc.replace(/([\\\^\$\*\+\?\.\|\{\}\[\]\(\)])/g, "\\$1") + " *(\\|[^\\]]*)?\\]\\]", "gi");
var matches = t.match(hcre);
if (matches != null && matches.length == 1) {
if ( typeof hnc != "undefined" && hnc != null && hnc != "" ) {
t = t.replace(hcre, "$1[[Category:" + hnc + "$2]]");
summary.push ( "កែប្រែ [[Category:" + hrc + "]] → [[Category:" + hnc + "]]" ) ;
} else {
t = t.replace(hcre, "");
summary.push ( "លុប [[Category:" + hrc + "]]" ) ;
}
ret = 1 ;
} else {
alert ( " មិនអាចកែ ឬលុបចំណាត់ថ្នាក់ក្រុមនេះបានទេ ពីព្រោះ វាមាននៅក្នុងទំព័រគំរូ \"" + hrc + "\" រួចហើយ" ) ;
prevent_autocommit = 1 ;
}
} else {
if ( typeof hnc != "undefined" && hnc != null && hnc != "" ) {
var re = /\[\[Category:[^\]]+\]\]/ig
var index = -1;
while (re.exec(t) != null) index = re.lastIndex;
var txt = "[[Category:" + hnc + "]]" ;
if (index < 0) {
t = t + '\n' + txt ;
} else {
t = t.substring(0, index) + '\n' + txt + t.substring(index);
}
summary.push ( "បន្ថែម [[Category:" + hnc + "]]" ) ;
ret = 1 ;
}
}
if ( ret ) {
document.editform.wpTextbox1.value = t ;
document.editform.wpSummary.value = summary.join( " ; " ) + " បំរើបំរាស់ [[User:Nums/monobook.js|HotCats]]" ;
if ( !prevent_autocommit ) {
document.getElementById("bodyContent").style.display = "none" ;
document.editform.wpMinoredit.checked = true ;
document.editform.wpSave.click();
}
}
return ret ;
}
function hotcat_clear_span ( span_add ) {
while ( span_add.firstChild ) span_add.removeChild ( span_add.firstChild ) ;
}
function hotcat_create_span ( span_add ) {
hotcat_clear_span ( span_add ) ;
var a_add = document.createElement ( "a" ) ;
var a_text = document.createTextNode ( "(+)" ) ;
span_add.id = "hotcat_add" ;
a_add.href = "javascript:hotcat_add_new()" ;
a_add.appendChild ( a_text ) ;
span_add.appendChild ( a_add ) ;
}
function hotcat_modify ( link_id ) {
var link = document.getElementById ( link_id ) ;
var span = link.parentNode ;
var catname = span.firstChild.firstChild.data ;
while ( span.firstChild.nextSibling ) span.removeChild ( span.firstChild.nextSibling ) ;
span.firstChild.style.display = "none" ;
hotcat_create_new_span ( span , catname ) ;
hotcat_last_v = "" ;
hotcat_text_changed () ;
}
function hotcat_add_new () {
var span_add = document.getElementById ( "hotcat_add" ) ;
hotcat_clear_span ( span_add ) ;
hotcat_last_v = "" ;
hotcat_create_new_span ( span_add , "" ) ;
}
function hotcat_create_new_span ( thespan , init_text ) {
var form = document.createElement ( "form" ) ;
form.method = "post" ;
form.onsubmit = function () { hotcat_ok(); return false; } ;
form.id = "hotcat_form" ;
form.style.display = "inline" ;
var list = document.createElement ( "select" ) ;
list.id = "hotcat_list" ;
list.onclick = function () { document.getElementById("hotcat_text").value = document.getElementById("hotcat_list").value ; hotcat_text_changed() ; } ;
list.ondblclick = function () { document.getElementById("hotcat_text").value = document.getElementById("hotcat_list").value ; hotcat_text_changed() ; hotcat_ok(); } ;
list.style.display = "none" ;
var text = document.createElement ( "input" ) ;
text.size = 40 ;
text.id = "hotcat_text" ;
text.type = "text" ;
text.value = init_text ;
text.onkeyup = function () { window.setTimeout("hotcat_text_changed();", 100 ); } ;
var exists = document.createElement ( "img" ) ;
exists.id = "hotcat_exists" ;
exists.src = hotcat_exists_no ;
var OK = document.createElement ( "input" ) ;
OK.type = "button" ;
OK.value = "ដាក់ស្នើ" ;
OK.onclick = hotcat_ok ;
var cancel = document.createElement ( "input" ) ;
cancel.type = "button" ;
cancel.value = "លុបចោល" ;
cancel.onclick = hotcat_cancel ;
form.appendChild ( list ) ;
form.appendChild ( text ) ;
form.appendChild ( exists ) ;
form.appendChild ( OK ) ;
form.appendChild ( cancel ) ;
thespan.appendChild ( form ) ;
text.focus () ;
}
function hotcat_ok () {
var text = document.getElementById ( "hotcat_text" ) ;
var v = text.value ;
if ( v == "" ) {
hotcat_cancel() ;
return ;
}
var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
var url = editlk + '&hotcat_newcat=' + encodeURIComponent( v ) ;
var span = text.parentNode.parentNode ;
if ( span.id != "hotcat_add" ) {
var cat_title = span.firstChild.getAttribute ( "title" ) ;
cat_title = cat_title.substr(cat_title.indexOf(":") + 1);
url += '&hotcat_removecat=' + encodeURIComponent( cat_title ) ;
}
document.location = url ;
}
function hotcat_cancel () {
var span = document.getElementById("hotcat_form").parentNode ;
if ( span.id == "hotcat_add" ) {
hotcat_create_span ( span ) ;
} else {
while ( span.firstChild.nextSibling ) span.removeChild ( span.firstChild.nextSibling ) ;
span.firstChild.style.display = "" ;
for ( var i = 0 ; i < span.parentNode.childNodes.length ; i++ ) {
if ( span.parentNode.childNodes[i] != span ) continue ;
hotcat_modify_span ( span , i ) ;
break ;
}
}
}
function hotcat_text_changed () {
if ( hotcat_running ) return ;
var text = document.getElementById ( "hotcat_text" ) ;
var v = text.value.ucFirst() ;
if ( hotcat_last_v == v ) return ;
hotcat_running = 1 ;
hotcat_last_v = v ;
if ( v != "" ) {
var url = wgServer + "/" + wgScriptPath + "/api.php?format=xml&action=query&list=allpages&apnamespace=14&apfrom=" + encodeURIComponent( v ) ;
if ( typeof ( hotcat_xmlhttp ) != "undefined" ) hotcat_xmlhttp.abort() ; // Just to make sure...
hotcat_xmlhttp = new sajax_init_object() ;
hotcat_xmlhttp.open('GET', url, true);
hotcat_xmlhttp.onreadystatechange = function () {
if ( typeof hotcat_xmlhttp == "undefined" ) return ;
if (hotcat_xmlhttp.readyState == 4) {
var xml = hotcat_xmlhttp.responseXML ;
if ( xml == null ) return ;
var pages = xml.getElementsByTagName( "p" ) ;
var titles = new Array () ;
for ( var i = 0 ; i < pages.length ; i++ ) {
var s = pages[i].getAttribute("title");
s = s.substr(s.indexOf(":") + 1);
if ( s.substr ( 0 , hotcat_last_v.length ) != hotcat_last_v ) break ;
titles.push ( s ) ;
}
hotcat_show_suggestions ( titles ) ;
}
};
hotcat_xmlhttp.send(null);
} else {
var titles = new Array () ;
hotcat_show_suggestions ( titles ) ;
}
hotcat_running = 0 ;
}
function hotcat_show_suggestions ( titles ) {
var text = document.getElementById ( "hotcat_text" ) ;
var list = document.getElementById ( "hotcat_list" ) ;
var icon = document.getElementById ( "hotcat_exists" ) ;
if ( titles.length == 0 ) {
list.style.display = "none" ;
icon.src = hotcat_exists_no ;
return ;
}
var listh = titles.length * 20 ;
var nl = parseInt ( text.parentNode.offsetLeft ) - 1 ;
var nt = parseInt(text.offsetTop) - listh ;
if (typeof hotcat_list_down != "undefined" && hotcat_list_down) {
nt = text.offsetTop + text.offsetHeight;
}
list.size = 5 ;
list.style.align = "left" ;
list.style.zIndex = 5 ;
list.style.position = "absolute" ;
list.style.top = nt + "px" ;
list.style.width = text.offsetWidth + "px" ;
list.style.height = listh + "px" ;
list.style.left = nl + "px" ;
while ( list.firstChild ) list.removeChild ( list.firstChild ) ;
for ( var i = 0 ; i < titles.length ; i++ ) {
var opt = document.createElement ( "option" ) ;
var ot = document.createTextNode ( titles[i] ) ;
opt.appendChild ( ot ) ;
opt.setAttribute( "value", titles[i] );
list.appendChild ( opt ) ;
}
list.style.display = "block" ;
icon.src = hotcat_exists_yes ;
var first_title = titles.shift () ;
if ( first_title == hotcat_last_v ) return ;
var nosel = hotcat_last_v.length ;
text.value = first_title ;
if( is_khtml )
text.setSelectionRange( nosel, first_title.length );
else
{
text.selectionStart = nosel ;
text.selectionEnd = first_title.length ;
}
}
/* </nowiki></pre> */