Skip to content

Commit cc3fe82

Browse files
committed
Updated jQuery
1 parent be7641f commit cc3fe82

File tree

3 files changed

+6
-335
lines changed

3 files changed

+6
-335
lines changed

js/common.js

Lines changed: 1 addition & 334 deletions
Original file line numberDiff line numberDiff line change
@@ -203,337 +203,4 @@ return year - bornYear;
203203
return year - bornYear;
204204
else
205205
return year - bornYear - 1;
206-
}
207-
208-
209-
210-
211-
// Debugging stuff
212-
function var_dump () {
213-
// Dumps a string representation of variable to output
214-
//
215-
// version: 1109.2015
216-
// discuss at: http://phpjs.org/functions/var_dump
217-
// + original by: Brett Zamir (http://brett-zamir.me)
218-
// + improved by: Zahlii
219-
// + improved by: Brett Zamir (http://brett-zamir.me)
220-
// - depends on: echo
221-
// % note 1: For returning a string, use var_export() with the second argument set to true
222-
// * example 1: var_dump(1);
223-
// * returns 1: 'int(1)'
224-
var output = '',
225-
pad_char = ' ',
226-
pad_val = 4,
227-
lgth = 0,
228-
i = 0,
229-
d = this.window.document;
230-
var _getFuncName = function (fn) {
231-
var name = (/\W*function\s+([\w\$]+)\s*\(/).exec(fn);
232-
if (!name) {
233-
return '(Anonymous)';
234-
}
235-
return name[1];
236-
};
237-
238-
var _repeat_char = function (len, pad_char) {
239-
var str = '';
240-
for (var i = 0; i < len; i++) {
241-
str += pad_char;
242-
}
243-
return str;
244-
};
245-
var _getInnerVal = function (val, thick_pad) {
246-
var ret = '';
247-
if (val === null) {
248-
ret = 'NULL';
249-
} else if (typeof val === 'boolean') {
250-
ret = 'bool(' + val + ')';
251-
} else if (typeof val === 'string') {
252-
ret = 'string(' + val.length + ') "' + val + '"';
253-
} else if (typeof val === 'number') {
254-
if (parseFloat(val) == parseInt(val, 10)) {
255-
ret = 'int(' + val + ')';
256-
} else {
257-
ret = 'float(' + val + ')';
258-
}
259-
}
260-
// The remaining are not PHP behavior because these values only exist in this exact form in JavaScript
261-
else if (typeof val === 'undefined') {
262-
ret = 'undefined';
263-
} else if (typeof val === 'function') {
264-
var funcLines = val.toString().split('\n');
265-
ret = '';
266-
for (var i = 0, fll = funcLines.length; i < fll; i++) {
267-
ret += (i !== 0 ? '\n' + thick_pad : '') + funcLines[i];
268-
}
269-
} else if (val instanceof Date) {
270-
ret = 'Date(' + val + ')';
271-
} else if (val instanceof RegExp) {
272-
ret = 'RegExp(' + val + ')';
273-
} else if (val.nodeName) { // Different than PHP's DOMElement
274-
switch (val.nodeType) {
275-
case 1:
276-
if (typeof val.namespaceURI === 'undefined' || val.namespaceURI === 'http://www.w3.org/1999/xhtml') { // Undefined namespace could be plain XML, but namespaceURI not widely supported
277-
ret = 'HTMLElement("' + val.nodeName + '")';
278-
} else {
279-
ret = 'XML Element("' + val.nodeName + '")';
280-
}
281-
break;
282-
case 2:
283-
ret = 'ATTRIBUTE_NODE(' + val.nodeName + ')';
284-
break;
285-
case 3:
286-
ret = 'TEXT_NODE(' + val.nodeValue + ')';
287-
break;
288-
case 4:
289-
ret = 'CDATA_SECTION_NODE(' + val.nodeValue + ')';
290-
break;
291-
case 5:
292-
ret = 'ENTITY_REFERENCE_NODE';
293-
break;
294-
case 6:
295-
ret = 'ENTITY_NODE';
296-
break;
297-
case 7:
298-
ret = 'PROCESSING_INSTRUCTION_NODE(' + val.nodeName + ':' + val.nodeValue + ')';
299-
break;
300-
case 8:
301-
ret = 'COMMENT_NODE(' + val.nodeValue + ')';
302-
break;
303-
case 9:
304-
ret = 'DOCUMENT_NODE';
305-
break;
306-
case 10:
307-
ret = 'DOCUMENT_TYPE_NODE';
308-
break;
309-
case 11:
310-
ret = 'DOCUMENT_FRAGMENT_NODE';
311-
break;
312-
case 12:
313-
ret = 'NOTATION_NODE';
314-
break;
315-
}
316-
}
317-
return ret;
318-
};
319-
320-
var _formatArray = function (obj, cur_depth, pad_val, pad_char) {
321-
var someProp = '';
322-
if (cur_depth > 0) {
323-
cur_depth++;
324-
}
325-
326-
var base_pad = _repeat_char(pad_val * (cur_depth - 1), pad_char);
327-
var thick_pad = _repeat_char(pad_val * (cur_depth + 1), pad_char);
328-
var str = '';
329-
var val = '';
330-
331-
if (typeof obj === 'object' && obj !== null) {
332-
if (obj.constructor && _getFuncName(obj.constructor) === 'PHPJS_Resource') {
333-
return obj.var_dump();
334-
}
335-
lgth = 0;
336-
for (someProp in obj) {
337-
lgth++;
338-
}
339-
str += 'array(' + lgth + ') {\n';
340-
for (var key in obj) {
341-
var objVal = obj[key];
342-
if (typeof objVal === 'object' && objVal !== null && !(objVal instanceof Date) && !(objVal instanceof RegExp) && !objVal.nodeName) {
343-
str += thick_pad + '[' + key + '] =>\n' + thick_pad + _formatArray(objVal, cur_depth + 1, pad_val, pad_char);
344-
} else {
345-
val = _getInnerVal(objVal, thick_pad);
346-
str += thick_pad + '[' + key + '] =>\n' + thick_pad + val + '\n';
347-
}
348-
}
349-
str += base_pad + '}\n';
350-
} else {
351-
str = _getInnerVal(obj, thick_pad);
352-
}
353-
return str;
354-
};
355-
356-
output = _formatArray(arguments[0], 0, pad_val, pad_char);
357-
for (i = 1; i < arguments.length; i++) {
358-
output += '\n' + _formatArray(arguments[i], 0, pad_val, pad_char);
359-
}
360-
361-
if (d.body) {
362-
this.echo(output);
363-
} else {
364-
try {
365-
d = XULDocument; // We're in XUL, so appending as plain text won't work
366-
this.echo('<pre xmlns="http://www.w3.org/1999/xhtml" style="white-space:pre;">' + output + '</pre>');
367-
} catch (e) {
368-
this.echo(output); // Outputting as plain text may work in some plain XML
369-
}
370-
}
371-
}
372-
function echo () {
373-
// !No description available for echo. @php.js developers: Please update the function summary text file.
374-
//
375-
// version: 1109.2015
376-
// discuss at: http://phpjs.org/functions/echo
377-
// + original by: Philip Peterson
378-
// + improved by: echo is bad
379-
// + improved by: Nate
380-
// + revised by: Der Simon (http://innerdom.sourceforge.net/)
381-
// + improved by: Brett Zamir (http://brett-zamir.me)
382-
// + bugfixed by: Eugene Bulkin (http://doubleaw.com/)
383-
// + input by: JB
384-
// + improved by: Brett Zamir (http://brett-zamir.me)
385-
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
386-
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
387-
// + bugfixed by: EdorFaus
388-
// + improved by: Brett Zamir (http://brett-zamir.me)
389-
// % note 1: If browsers start to support DOM Level 3 Load and Save (parsing/serializing),
390-
// % note 1: we wouldn't need any such long code (even most of the code below). See
391-
// % note 1: link below for a cross-browser implementation in JavaScript. HTML5 might
392-
// % note 1: possibly support DOMParser, but that is not presently a standard.
393-
// % note 2: Although innerHTML is widely used and may become standard as of HTML5, it is also not ideal for
394-
// % note 2: use with a temporary holder before appending to the DOM (as is our last resort below),
395-
// % note 2: since it may not work in an XML context
396-
// % note 3: Using innerHTML to directly add to the BODY is very dangerous because it will
397-
// % note 3: break all pre-existing references to HTMLElements.
398-
// * example 1: echo('<div><p>abc</p><p>abc</p></div>');
399-
// * returns 1: undefined
400-
// Fix: This function really needs to allow non-XHTML input (unless in true XHTML mode) as in jQuery
401-
var arg = '',
402-
argc = arguments.length,
403-
argv = arguments,
404-
i = 0,
405-
holder, win = this.window,
406-
d = win.document,
407-
ns_xhtml = 'http://www.w3.org/1999/xhtml',
408-
ns_xul = 'http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'; // If we're in a XUL context
409-
var stringToDOM = function (str, parent, ns, container) {
410-
var extraNSs = '';
411-
if (ns === ns_xul) {
412-
extraNSs = ' xmlns:html="' + ns_xhtml + '"';
413-
}
414-
var stringContainer = '<' + container + ' xmlns="' + ns + '"' + extraNSs + '>' + str + '</' + container + '>';
415-
var dils = win.DOMImplementationLS,
416-
dp = win.DOMParser,
417-
ax = win.ActiveXObject;
418-
if (dils && dils.createLSInput && dils.createLSParser) {
419-
// Follows the DOM 3 Load and Save standard, but not
420-
// implemented in browsers at present; HTML5 is to standardize on innerHTML, but not for XML (though
421-
// possibly will also standardize with DOMParser); in the meantime, to ensure fullest browser support, could
422-
// attach http://svn2.assembla.com/svn/brettz9/DOMToString/DOM3.js (see http://svn2.assembla.com/svn/brettz9/DOMToString/DOM3.xhtml for a simple test file)
423-
var lsInput = dils.createLSInput();
424-
// If we're in XHTML, we'll try to allow the XHTML namespace to be available by default
425-
lsInput.stringData = stringContainer;
426-
var lsParser = dils.createLSParser(1, null); // synchronous, no schema type
427-
return lsParser.parse(lsInput).firstChild;
428-
} else if (dp) {
429-
// If we're in XHTML, we'll try to allow the XHTML namespace to be available by default
430-
try {
431-
var fc = new dp().parseFromString(stringContainer, 'text/xml');
432-
if (fc && fc.documentElement && fc.documentElement.localName !== 'parsererror' && fc.documentElement.namespaceURI !== 'http://www.mozilla.org/newlayout/xml/parsererror.xml') {
433-
return fc.documentElement.firstChild;
434-
}
435-
// If there's a parsing error, we just continue on
436-
} catch (e) {
437-
// If there's a parsing error, we just continue on
438-
}
439-
} else if (ax) { // We don't bother with a holder in Explorer as it doesn't support namespaces
440-
var axo = new ax('MSXML2.DOMDocument');
441-
axo.loadXML(str);
442-
return axo.documentElement;
443-
}
444-
/*else if (win.XMLHttpRequest) { // Supposed to work in older Safari
445-
var req = new win.XMLHttpRequest;
446-
req.open('GET', 'data:application/xml;charset=utf-8,'+encodeURIComponent(str), false);
447-
if (req.overrideMimeType) {
448-
req.overrideMimeType('application/xml');
449-
}
450-
req.send(null);
451-
return req.responseXML;
452-
}*/
453-
// Document fragment did not work with innerHTML, so we create a temporary element holder
454-
// If we're in XHTML, we'll try to allow the XHTML namespace to be available by default
455-
//if (d.createElementNS && (d.contentType && d.contentType !== 'text/html')) { // Don't create namespaced elements if we're being served as HTML (currently only Mozilla supports this detection in true XHTML-supporting browsers, but Safari and Opera should work with the above DOMParser anyways, and IE doesn't support createElementNS anyways)
456-
if (d.createElementNS && // Browser supports the method
457-
(d.documentElement.namespaceURI || // We can use if the document is using a namespace
458-
d.documentElement.nodeName.toLowerCase() !== 'html' || // We know it's not HTML4 or less, if the tag is not HTML (even if the root namespace is null)
459-
(d.contentType && d.contentType !== 'text/html') // We know it's not regular HTML4 or less if this is Mozilla (only browser supporting the attribute) and the content type is something other than text/html; other HTML5 roots (like svg) still have a namespace
460-
)) { // Don't create namespaced elements if we're being served as HTML (currently only Mozilla supports this detection in true XHTML-supporting browsers, but Safari and Opera should work with the above DOMParser anyways, and IE doesn't support createElementNS anyways); last test is for the sake of being in a pure XML document
461-
holder = d.createElementNS(ns, container);
462-
} else {
463-
holder = d.createElement(container); // Document fragment did not work with innerHTML
464-
}
465-
holder.innerHTML = str;
466-
while (holder.firstChild) {
467-
parent.appendChild(holder.firstChild);
468-
}
469-
return false;
470-
// throw 'Your browser does not support DOM parsing as required by echo()';
471-
};
472-
473-
474-
var ieFix = function (node) {
475-
if (node.nodeType === 1) {
476-
var newNode = d.createElement(node.nodeName);
477-
var i, len;
478-
if (node.attributes && node.attributes.length > 0) {
479-
for (i = 0, len = node.attributes.length; i < len; i++) {
480-
newNode.setAttribute(node.attributes[i].nodeName, node.getAttribute(node.attributes[i].nodeName));
481-
}
482-
}
483-
if (node.childNodes && node.childNodes.length > 0) {
484-
for (i = 0, len = node.childNodes.length; i < len; i++) {
485-
newNode.appendChild(ieFix(node.childNodes[i]));
486-
}
487-
}
488-
return newNode;
489-
} else {
490-
return d.createTextNode(node.nodeValue);
491-
}
492-
};
493-
494-
var replacer = function (s, m1, m2) {
495-
// We assume for now that embedded variables do not have dollar sign; to add a dollar sign, you currently must use {$$var} (We might change this, however.)
496-
// Doesn't cover all cases yet: see http://php.net/manual/en/language.types.string.php#language.types.string.syntax.double
497-
if (m1 !== '\\') {
498-
return m1 + eval(m2);
499-
} else {
500-
return s;
501-
}
502-
};
503-
504-
this.php_js = this.php_js || {};
505-
var phpjs = this.php_js,
506-
ini = phpjs.ini,
507-
obs = phpjs.obs;
508-
for (i = 0; i < argc; i++) {
509-
arg = argv[i];
510-
if (ini && ini['phpjs.echo_embedded_vars']) {
511-
arg = arg.replace(/(.?)\{?\$(\w*?\}|\w*)/g, replacer);
512-
}
513-
514-
if (!phpjs.flushing && obs && obs.length) { // If flushing we output, but otherwise presence of a buffer means caching output
515-
obs[obs.length - 1].buffer += arg;
516-
continue;
517-
}
518-
519-
if (d.appendChild) {
520-
if (d.body) {
521-
if (win.navigator.appName === 'Microsoft Internet Explorer') { // We unfortunately cannot use feature detection, since this is an IE bug with cloneNode nodes being appended
522-
d.body.appendChild(stringToDOM(ieFix(arg)));
523-
} else {
524-
var unappendedLeft = stringToDOM(arg, d.body, ns_xhtml, 'div').cloneNode(true); // We will not actually append the div tag (just using for providing XHTML namespace by default)
525-
if (unappendedLeft) {
526-
d.body.appendChild(unappendedLeft);
527-
}
528-
}
529-
} else {
530-
d.documentElement.appendChild(stringToDOM(arg, d.documentElement, ns_xul, 'description')); // We will not actually append the description tag (just using for providing XUL namespace by default)
531-
}
532-
} else if (d.write) {
533-
d.write(arg);
534-
}
535-
/* else { // This could recurse if we ever add print!
536-
print(arg);
537-
}*/
538-
}
539-
}
206+
}

0 commit comments

Comments
 (0)