„Benutzer:Revvar/wikibits.js“ – Versionsunterschied
Erscheinungsbild
Inhalt gelöscht Inhalt hinzugefügt
Revvar (Diskussion | Beiträge) K Leerzeichen |
Revvar (Diskussion | Beiträge) K setze die Endungen ".js" und ".css" fest ein, um unsicheren Gebrauch zu verhindern |
||
Zeile 5: | Zeile 5: | ||
@date 2007/03/22 |
@date 2007/03/22 |
||
@author: based on function importPage from [[de:User:PDD]]s monobook.js, extended by [[de:User:Revvar]] |
@author: based on function importPage from [[de:User:PDD]]s monobook.js, extended by [[de:User:Revvar]] |
||
@param page Name of the user page without the "user:" prefix |
@param page Name of the user page without the "user:" prefix and the ".js" appendix |
||
@param lang (optional) Language code of the corresponding wikipedia project. Default is the callers project. |
@param lang (optional) Language code of the corresponding wikipedia project. Default is the callers project. |
||
@return "true" on success, "false" otherwise |
@return "true" on success, "false" otherwise |
||
Zeile 19: | Zeile 19: | ||
/* create import url */ |
/* create import url */ |
||
var import_url = 'http://' + lang + '.wikipedia.org' + wgScriptPath + '/index.php?title=User:' + page + |
var import_url = 'http://' + lang + '.wikipedia.org' + wgScriptPath + '/index.php?title=User:' + page + |
||
'&action=raw&ctype=text/javascript&smaxage=2678400&dontcountme=s'; |
'.js&action=raw&ctype=text/javascript&smaxage=2678400&dontcountme=s'; |
||
/* import page */ |
/* import page */ |
||
Zeile 42: | Zeile 42: | ||
@date 2007/03/22 |
@date 2007/03/22 |
||
@author: based on function importPage from [[de:User:PDD]]s monobook.js, rewritten by [[de:User:Revvar]] |
@author: based on function importPage from [[de:User:PDD]]s monobook.js, rewritten by [[de:User:Revvar]] |
||
@param page Name of the user page without the "user:" prefix |
@param page Name of the user page without the "user:" prefix and the ".css" appendix |
||
@param lang (optional) Language code of the corresponding wikipedia project. Default is the callers project. |
@param lang (optional) Language code of the corresponding wikipedia project. Default is the callers project. |
||
@return "true" on success, "false" otherwise |
@return "true" on success, "false" otherwise |
||
Zeile 56: | Zeile 56: | ||
/* create import url */ |
/* create import url */ |
||
var import_url = 'http://' + lang + '.wikipedia.org' + wgScriptPath + '/index.php?title=User:' + page + |
var import_url = 'http://' + lang + '.wikipedia.org' + wgScriptPath + '/index.php?title=User:' + page + |
||
'&action=raw&ctype=text/css&smaxage=2678400&dontcountme=s'; |
'.css&action=raw&ctype=text/css&smaxage=2678400&dontcountme=s'; |
||
/* import page */ |
/* import page */ |
Version vom 23. März 2007, 12:27 Uhr
/**
Imports a user javascript page from any wikipedia project into the actual document.
@version 0.1
@date 2007/03/22
@author: based on function importPage from [[de:User:PDD]]s monobook.js, extended by [[de:User:Revvar]]
@param page Name of the user page without the "user:" prefix and the ".js" appendix
@param lang (optional) Language code of the corresponding wikipedia project. Default is the callers project.
@return "true" on success, "false" otherwise
*/
function importJavascript(page, lang)
{
try {
/* check the parameters and set defaults */
if(!page) throw("importJavascript: Missing parameter page.");
if(!lang) lang = wgContentLanguage;
/* create import url */
var import_url = 'http://' + lang + '.wikipedia.org' + wgScriptPath + '/index.php?title=User:' + page +
'.js&action=raw&ctype=text/javascript&smaxage=2678400&dontcountme=s';
/* import page */
var Head = document.getElementsByTagName('head').item(0);
var Script = document.createElement('script');
Script.setAttribute('type', 'text/javascript');
Script.setAttribute('src', import_url);
Script.setAttribute('charset', 'utf-8');
Head.appendChild(Script);
return true;
} catch(e) {
alert(e.message);
return false;
}
}
/**
Imports a user css page from any wikipedia project into the actual document.
@version 0.1
@date 2007/03/22
@author: based on function importPage from [[de:User:PDD]]s monobook.js, rewritten by [[de:User:Revvar]]
@param page Name of the user page without the "user:" prefix and the ".css" appendix
@param lang (optional) Language code of the corresponding wikipedia project. Default is the callers project.
@return "true" on success, "false" otherwise
*/
function importCSS(page, lang)
{
try {
/* check the parameters and set defaults */
if(!page) throw("importCSS: Missing parameter page.");
if(!lang) lang = wgContentLanguage;
/* create import url */
var import_url = 'http://' + lang + '.wikipedia.org' + wgScriptPath + '/index.php?title=User:' + page +
'.css&action=raw&ctype=text/css&smaxage=2678400&dontcountme=s';
/* import page */
var Head = document.getElementsByTagName('head').item(0);
var CSS = document.createElement('style');
CSS.setAttribute('type', 'text/javascript');
CSS.setAttribute('charset', 'utf-8');
CSS.appendChild(document.createTextNode("@import url(" + import_url + ");"));
Head.appendChild(CSS);
return true;
} catch(e) {
alert(e.message);
return false;
}
}