X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?a=blobdiff_plain;f=jsMath%2Fextensions%2Feqn-number.js;fp=jsMath%2Fextensions%2Feqn-number.js;h=0000000000000000000000000000000000000000;hb=cb3848eeb2c1340d5a5090b46b51c6e53b21ad39;hp=be98db73af19c28acab359e7854fa20abd36a890;hpb=10b8a88ca57bb59dc6d5866d943a193f2ecf11d4;p=lambda.git diff --git a/jsMath/extensions/eqn-number.js b/jsMath/extensions/eqn-number.js deleted file mode 100644 index be98db73..00000000 --- a/jsMath/extensions/eqn-number.js +++ /dev/null @@ -1,234 +0,0 @@ -/* - * extensions/eqn-number.js - * - * Part of the jsMath package for mathematics on the web. - * - * This file causes jsMath to add equation numbers to displayed - * equations. These are displayed at the right, but the styles can - * be controlled through the jsMath.EqnNumber object. Equations - * are numbered if they include a \label{xxx} call, and the macro - * \ref{xxx} can be used to refer to the equation number elsewhere - * in the document (it must appear by itself in a math formula, - * e.g., $\ref{xxx}$). The "label-ref" CSS style can be used to - * style the references. - * - * If jsMath.EqnNumber.autonumber is set to 1, then ALL displayed - * equations will be numberd. Use the \nolabel macro to prevent - * equation numbering on an equation. - * - * You can activate eqn-numbering by calling - * - * jsMath.Extension.Require('eqn-number'); - * - * once jsMath.js has been loaded, or by adding "extensions/eqn-number.js" - * to the loadFiles array in jsMath/easy/load.js. - * - * --------------------------------------------------------------------- - * - * Copyright 2008 by Davide P. Cervone - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/********************************************************************/ - -if (jsMath.EqnNumber) {jsMath.EqnNumber_old = jsMath.EqnNumber} - -jsMath.EqnNumber = { - - styles: { - '.jsMath_displayBox, .tex2math_div': {position: 'relative'}, - '.jsMath_number': { - position: 'absolute', - right: '2em', top: '50%', 'margin-top': '-.5em', - height: 'auto', width: 'auto' - }, - '.jsMath_ref': {'text-decoration': 'none'} - }, - - autonumber: 0, // set to 1 to have ALL equations numbered - - number: 0, - format: function (n) {return n}, - formatLabel: function (n) {return '('+n+')'}, - formatRef: function (n) {return '('+n+')'}, - - _label: null, // flag set when \label{x} is used - _labels: {}, // stores label-name => label-value pairs - _refs: {}, // stores elements referring to undefined labels - _nolabel: 0, // set by \nolabel - - nextNumber: function () { - var ref = this.format(++this.number); - if (this._label) { - this._labels[this._label] = ref; - if (this._refs[this._label]) this.fixRefs(this._label); - } - return this.formatLabel(ref); - }, - - isRef: function (element) { - var tex = element.innerHTML; - var result = tex.match(/^\s*\\ref\s*\{([^\}]+)\}\s*$/); - if (!result) {return 0} - var ref = result[1]; - if (this._labels[ref]) { - this.setRef(element,ref); - } else { - if (!this._refs[ref]) {this._refs[ref] = []} - this._refs[ref][this._refs[ref].length] = element; - } - return 1; - }, - - setRef: function (element,ref) { - element.innerHTML = this.formatRef(this._labels[ref]); - element.className = "label-ref"; - }, - - fixRefs: function (label) { - for (var i = 0; i < this._refs[label].length; i++) - {this.setRef(this._refs[label][i],label)} - delete this._refs[label]; - }, - - badRefs: function () { - for (var label in this._refs) { - for (var i = 0; i < this._refs[label].length; i++) { - var element = this._refs[label][i]; - element.className = "typeset"; - element.innerHTML = "Reference '"+label+"' is undefined"; - } - } - }, - - makeDIV: function (element) { - var div = document.createElement('div'); - div.className = 'jsMath_displayBox'; - div.innerHTML = '