User:Hoof Hearted/monobook.js: Difference between revisions

Jump to navigation Jump to search
m
no edit summary
(fix red links to EnWp)
mNo edit summary
Line 135: Line 135:
};
};
   
   
// === Helpers a la functional programming ===
// ===Helpers a la functional programming===
// A higher-order function---produces a cached version of a one-arg function.
// A higher-order function---produces a cached version of a one-arg function.
ct.makeCached = function (f) {
ct.makeCached = function (f) {
Line 144: Line 144:
};
};
   
   
// === Regular expressions ===
// ===Regular expressions===
// Regular expressions can sometimes become inconveniently large.
// Regular expressions can sometimes become inconveniently large.
// In order to make complex ones easier to read, we introduce
// In order to make complex ones easier to read, we introduce
Line 224: Line 224:
};
};
   
   
// == Advisor core ==
// ==Advisor core==
// This is the basic functionality of showing and fixing suggestions.
// This is the basic functionality of showing and fixing suggestions.
   
   
// === Global constants and variables ===
// ===Global constants and variables===
ct.DEFAULT_MAX_SUGGESTIONS = 8;
ct.DEFAULT_MAX_SUGGESTIONS = 8;
ct.maxSuggestions = ct.DEFAULT_MAX_SUGGESTIONS;
ct.maxSuggestions = ct.DEFAULT_MAX_SUGGESTIONS;
Line 246: Line 246:
                         // a scan, this variable tracks its id
                         // a scan, this variable tracks its id
   
   
// === int main() ===
// ===int main()===
// This is the entry point
// This is the entry point
ct.observe(window, 'load', function () {
ct.observe(window, 'load', function () {
Line 276: Line 276:
});
});
   
   
// === Internationalisation ===
// ===Internationalisation===
// ct._() is a gettext-style internationalisation helper
// ct._() is a gettext-style internationalisation helper
// (http://en.wikipedia.org/wiki/gettext)
// (https://en.Wikipedia.org/wiki/gettext)
// If no translation is found for the parameter, it is returned as is.
// If no translation is found for the parameter, it is returned as is.
// Additionally, subsequent parameters are substituted for $1, $2, and so on.
// Additionally, subsequent parameters are substituted for $1, $2, and so on.
Line 293: Line 293:
};
};
   
   
// === Editor compatibility layer ===
// ===Editor compatibility layer===
// Controlling access to wpTextbox1 helps abstract out compatibility
// Controlling access to wpTextbox1 helps abstract out compatibility
// with editors like wikEd (https://en.Wikipedia.org/wiki/User:Cacycle/wikEd)
// with editors like wikEd (https://en.Wikipedia.org/wiki/User:Cacycle/wikEd)
Line 350: Line 350:
};
};
   
   
// === Interaction with the user ===
// ===Interaction with the user===
// ct.scan() analyses the text and handles how the proposals are reflected in the UI.
// ct.scan() analyses the text and handles how the proposals are reflected in the UI.
ct.scan = function (force) {
ct.scan = function (force) {
Line 600: Line 600:
};
};
   
   
// == Rules ==
// ==Rules==
   
   
// This chapter contains the ``rules'' that produce suggestions---this is where
// This chapter contains the ``rules'' that produce suggestions---this is where
Line 625: Line 625:
// and are grouped into categories.
// and are grouped into categories.
   
   
// === Linking rules ===
// ===Linking rules===
   
   
ct.rules.push(function (s) {
ct.rules.push(function (s) {
Line 787: Line 787:
});
});
   
   
// === Character formatting rules ===
// ===Character formatting rules===
   
   
ct.rules.push(function (s) {
ct.rules.push(function (s) {
Line 1,026: Line 1,026:
});
});
   
   
// === Template usage rules ===
// ===Template usage rules===
   
   
ct.rules.push(function (s) {
ct.rules.push(function (s) {
Line 1,069: Line 1,069:
   
   
   
   
// === Other rules ===
// ===Other rules===
   
   
ct.rules.push(function (s) {
ct.rules.push(function (s) {

Navigation menu