Difference between revisions of "MediaWiki:Common.js"
Jump to navigation
Jump to search
(Testing) |
(Testing) |
||
Line 24: | Line 24: | ||
return isObject(obj) && obj.constructor.toString().indexOf("Array") != -1; |
return isObject(obj) && obj.constructor.toString().indexOf("Array") != -1; |
||
} |
} |
||
+ | |||
− | |||
+ | Array.prototype.Contains = function(element,strict) { |
||
+ | for (i in this) { |
||
+ | if (this[i] == element && !strict || this[i] === element) return true; |
||
+ | } |
||
+ | return false; |
||
+ | } |
||
+ | |||
if (!isArray(wgUserGroups)) { |
if (!isArray(wgUserGroups)) { |
||
addOnloadHook(customizeSidebarForAnon); |
addOnloadHook(customizeSidebarForAnon); |
Revision as of 00:17, 19 January 2012
/* sidebar modifications for anonymous users */
function removeSidebarSection(section) {
try {
var target = "p-" + section;
var sidebar = document.getElementById("mw-panel");
var element = document.getElementById(target);
sidebar.removeChild(element);
} catch (e) {
return;
}
}
function customizeSidebarForAnon() {
removeSidebarSection("Internal");
removeSidebarSection("tb");
}
function isObject(obj) {
return typeof obj == "object" && obj != null;
}
function isArray(obj) {
return isObject(obj) && obj.constructor.toString().indexOf("Array") != -1;
}
Array.prototype.Contains = function(element,strict) {
for (i in this) {
if (this[i] == element && !strict || this[i] === element) return true;
}
return false;
}
if (!isArray(wgUserGroups)) {
addOnloadHook(customizeSidebarForAnon);
}
/* add membership payment button */
if ( ( mw.config.get('wgPageName') == 'Membership' ) && ( wgNamespaceNumber == 0 ) ) {
$('#membershipbutton').html('<form action="https://www.paypal.com/cgi-bin/webscr" method="post"><input type="hidden" name="cmd" value="_s-xclick"><input type="hidden" name="hosted_button_id" value="QTRS8N8RD8WNL"><input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"><img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"></form>');
}
/* add calendar */
if ( ( mw.config.get('wgPageName') == 'Calendar' ) && ( wgNamespaceNumber == 0 ) ) {
$('#calendarwidget').html('<iframe src="http://www.google.com/calendar/embed?src=wikidc.org_svr4b3s6n6rs8mt189kbc4uegg%40group.calendar.google.com&ctz=America/New_York" style="border: 0" width="800" height="600" frameborder="0" scrolling="no"></iframe>');
}
/* add donate button */
if ( ( mw.config.get('wgPageName') == 'Donate' ) && ( wgNamespaceNumber == 0 ) ) {
$('#donatebutton').html('<form action="https://www.paypal.com/cgi-bin/webscr" method="post"><input type="hidden" name="cmd" value="_s-xclick"><input type="hidden" name="hosted_button_id" value="PSCZL9L3NKNRQ"><input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"><img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"></form>');
}