|
|
(38 intermediate revisions not shown) |
Line 1: |
Line 1: |
| <html> | | <html> |
| | | |
- | <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script> | + | <!-- MathJax (LaTeX for the web) --> |
| + | <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> |
| + | |
| | | |
| <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script> | | <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script> |
- |
| |
- |
| |
- | <script>
| |
- | (function() {
| |
- | var supports = (function() {
| |
- | var supports = {};
| |
- |
| |
- | var html;
| |
- | var work = this.document.createElement('div');
| |
- |
| |
- | html = "<P><I></P></I>";
| |
- | work.innerHTML = html;
| |
- | supports.tagSoup = work.innerHTML !== html;
| |
- |
| |
- | work.innerHTML = "<P><i><P></P></i></P>";
| |
- | supports.selfClose = work.childNodes.length === 2;
| |
- |
| |
- | return supports;
| |
- | })();
| |
- |
| |
- |
| |
- |
| |
- | // Regular Expressions for parsing tags and attributes
| |
- | var startTag = /^<([\-A-Za-z0-9_]+)((?:\s+[\w\-]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/;
| |
- | var endTag = /^<\/([\-A-Za-z0-9_]+)[^>]*>/;
| |
- | var attr = /([\-A-Za-z0-9_]+)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g;
| |
- | var fillAttr = /^(checked|compact|declare|defer|disabled|ismap|multiple|nohref|noresize|noshade|nowrap|readonly|selected)$/i;
| |
- |
| |
- | var DEBUG = false;
| |
- |
| |
- | function htmlParser(stream, options) {
| |
- | stream = stream || '';
| |
- |
| |
- | // Options
| |
- | options = options || {};
| |
- |
| |
- | for(var key in supports) {
| |
- | if(supports.hasOwnProperty(key)) {
| |
- | if(options.autoFix) {
| |
- | options['fix_'+key] = true;//!supports[key];
| |
- | }
| |
- | options.fix = options.fix || options['fix_'+key];
| |
- | }
| |
- | }
| |
- |
| |
- | var stack = [];
| |
- |
| |
- | var append = function(str) {
| |
- | stream += str;
| |
- | };
| |
- |
| |
- | var prepend = function(str) {
| |
- | stream = str + stream;
| |
- | };
| |
- |
| |
- | // Order of detection matters: detection of one can only
| |
- | // succeed if detection of previous didn't
| |
- | var detect = {
| |
- | comment: /^<!--/,
| |
- | endTag: /^<\//,
| |
- | atomicTag: /^<\s*(script|style|noscript|iframe|textarea)[\s>]/i,
| |
- | startTag: /^</,
| |
- | chars: /^[^<]/
| |
- | };
| |
- |
| |
- | // Detection has already happened when a reader is called.
| |
- | var reader = {
| |
- |
| |
- | comment: function() {
| |
- | var index = stream.indexOf("-->");
| |
- | if ( index >= 0 ) {
| |
- | return {
| |
- | content: stream.substr(4, index),
| |
- | length: index + 3
| |
- | };
| |
- | }
| |
- | },
| |
- |
| |
- | endTag: function() {
| |
- | var match = stream.match( endTag );
| |
- |
| |
- | if ( match ) {
| |
- | return {
| |
- | tagName: match[1],
| |
- | length: match[0].length
| |
- | };
| |
- | }
| |
- | },
| |
- |
| |
- | atomicTag: function() {
| |
- | var start = reader.startTag();
| |
- | if(start) {
| |
- | var rest = stream.slice(start.length);
| |
- | // for optimization, we check first just for the end tag
| |
- | if(rest.match(new RegExp("<\/\\s*" + start.tagName + "\\s*>", "i"))) {
| |
- | // capturing the content is inefficient, so we do it inside the if
| |
- | var match = rest.match(new RegExp("([\\s\\S]*?)<\/\\s*" + start.tagName + "\\s*>", "i"));
| |
- | if(match) {
| |
- | // good to go
| |
- | return {
| |
- | tagName: start.tagName,
| |
- | attrs: start.attrs,
| |
- | content: match[1],
| |
- | length: match[0].length + start.length
| |
- | };
| |
- | }
| |
- | }
| |
- | }
| |
- | },
| |
- |
| |
- | startTag: function() {
| |
- | var match = stream.match( startTag );
| |
- |
| |
- | if ( match ) {
| |
- | var attrs = {};
| |
- |
| |
- | match[2].replace(attr, function(match, name) {
| |
- | var value = arguments[2] || arguments[3] || arguments[4] ||
| |
- | fillAttr.test(name) && name || null;
| |
- |
| |
- | attrs[name] = value;
| |
- | });
| |
- |
| |
- | return {
| |
- | tagName: match[1],
| |
- | attrs: attrs,
| |
- | unary: !!match[3],
| |
- | length: match[0].length
| |
- | };
| |
- | }
| |
- | },
| |
- |
| |
- | chars: function() {
| |
- | var index = stream.indexOf("<");
| |
- | return {
| |
- | length: index >= 0 ? index : stream.length
| |
- | };
| |
- | }
| |
- | };
| |
- |
| |
- | var readToken = function() {
| |
- |
| |
- | // Enumerate detects in order
| |
- | for (var type in detect) {
| |
- |
| |
- | if(detect[type].test(stream)) {
| |
- | if(DEBUG) { console.log('suspected ' + type); }
| |
- |
| |
- | var token = reader[type]();
| |
- | if(token) {
| |
- | if(DEBUG) { console.log('parsed ' + type, token); }
| |
- | // Type
| |
- | token.type = token.type || type;
| |
- | // Entire text
| |
- | token.text = stream.substr(0, token.length);
| |
- | // Update the stream
| |
- | stream = stream.slice(token.length);
| |
- |
| |
- | return token;
| |
- | }
| |
- | return null;
| |
- | }
| |
- | }
| |
- | };
| |
- |
| |
- | var readTokens = function(handlers) {
| |
- | var tok;
| |
- | while(tok = readToken()) {
| |
- | // continue until we get an explicit "false" return
| |
- | if(handlers[tok.type] && handlers[tok.type](tok) === false) {
| |
- | return;
| |
- | }
| |
- | }
| |
- | };
| |
- |
| |
- | var clear = function() {
| |
- | var rest = stream;
| |
- | stream = '';
| |
- | return rest;
| |
- | };
| |
- |
| |
- | var rest = function() {
| |
- | return stream;
| |
- | };
| |
- |
| |
- | if(options.fix) {
| |
- | (function() {
| |
- | // Empty Elements - HTML 4.01
| |
- | var EMPTY = /^(AREA|BASE|BASEFONT|BR|COL|FRAME|HR|IMG|INPUT|ISINDEX|LINK|META|PARAM|EMBED)$/i;
| |
- |
| |
- | // Elements that you can| intentionally| leave open
| |
- | // (and which close themselves)
| |
- | var CLOSESELF = /^(COLGROUP|DD|DT|LI|OPTIONS|P|TD|TFOOT|TH|THEAD|TR)$/i;
| |
- |
| |
- |
| |
- | var stack = [];
| |
- | stack.last = function() {
| |
- | return this[this.length - 1];
| |
- | };
| |
- | stack.lastTagNameEq = function(tagName) {
| |
- | var last = this.last();
| |
- | return last && last.tagName &&
| |
- | last.tagName.toUpperCase() === tagName.toUpperCase();
| |
- | };
| |
- |
| |
- | stack.containsTagName = function(tagName) {
| |
- | for(var i = 0, tok; tok = this[i]; i++) {
| |
- | if(tok.tagName === tagName) {
| |
- | return true;
| |
- | }
| |
- | }
| |
- | return false;
| |
- | };
| |
- |
| |
- | var correct = function(tok) {
| |
- | if(tok && tok.type === 'startTag') {
| |
- | // unary
| |
- | tok.unary = EMPTY.test(tok.tagName) || tok.unary;
| |
- | }
| |
- | return tok;
| |
- | };
| |
- |
| |
- | var readTokenImpl = readToken;
| |
- |
| |
- | var peekToken = function() {
| |
- | var tmp = stream;
| |
- | var tok = correct(readTokenImpl());
| |
- | stream = tmp;
| |
- | return tok;
| |
- | };
| |
- |
| |
- | var closeLast = function() {
| |
- | var tok = stack.pop();
| |
- |
| |
- | // prepend close tag to stream.
| |
- | prepend('</'+tok.tagName+'>');
| |
- | };
| |
- |
| |
- | var handlers = {
| |
- | startTag: function(tok) {
| |
- | var tagName = tok.tagName;
| |
- | // Fix tbody
| |
- | if(tagName.toUpperCase() === 'TR' && stack.lastTagNameEq('TABLE')) {
| |
- | prepend('<TBODY>');
| |
- | prepareNextToken();
| |
- | } else if(options.fix_selfClose &&
| |
- | CLOSESELF.test(tagName) &&
| |
- | stack.containsTagName(tagName)) {
| |
- | if(stack.lastTagNameEq(tagName)) {
| |
- | closeLast();
| |
- | } else {
| |
- | prepend('</'+tok.tagName+'>');
| |
- | prepareNextToken();
| |
- | }
| |
- | } else if (!tok.unary) {
| |
- | stack.push(tok);
| |
- | }
| |
- | },
| |
- |
| |
- | endTag: function(tok) {
| |
- | var last = stack.last();
| |
- | if(last) {
| |
- | if(options.fix_tagSoup && !stack.lastTagNameEq(tok.tagName)) {
| |
- | // cleanup tag soup
| |
- | closeLast();
| |
- | } else {
| |
- | stack.pop();
| |
- | }
| |
- | } else if (options.fix_tagSoup) {
| |
- | // cleanup tag soup part 2: skip this token
| |
- | skipToken();
| |
- | }
| |
- | }
| |
- | };
| |
- |
| |
- | var skipToken = function() {
| |
- | // shift the next token
| |
- | readTokenImpl();
| |
- |
| |
- | prepareNextToken();
| |
- | };
| |
- |
| |
- | var prepareNextToken = function() {
| |
- | var tok = peekToken();
| |
- | if(tok && handlers[tok.type]) {
| |
- | handlers[tok.type](tok);
| |
- | }
| |
- | };
| |
- |
| |
- | // redefine readToken
| |
- | readToken = function() {
| |
- | prepareNextToken();
| |
- | return correct(readTokenImpl());
| |
- | };
| |
- | })();
| |
- | }
| |
- |
| |
- | return {
| |
- | append: append,
| |
- | readToken: readToken,
| |
- | readTokens: readTokens,
| |
- | clear: clear,
| |
- | rest: rest,
| |
- | stack: stack
| |
- | };
| |
- |
| |
- | }
| |
- |
| |
- | htmlParser.supports = supports;
| |
- |
| |
- | htmlParser.tokenToString = function(tok) {
| |
- | var handler = {
| |
- | comment: function(tok) {
| |
- | return '<--' + tok.content + '-->';
| |
- | },
| |
- | endTag: function(tok) {
| |
- | return '</'+tok.tagName+'>';
| |
- | },
| |
- | atomicTag: function(tok) {
| |
- | console.log(tok);
| |
- | return handler.startTag(tok) +
| |
- | tok.content +
| |
- | handler.endTag(tok);
| |
- | },
| |
- | startTag: function(tok) {
| |
- | var str = '<'+tok.tagName;
| |
- | for (var key in tok.attrs) {
| |
- | var val = tok.attrs[key];
| |
- | // escape quotes
| |
- | str += ' '+key+'="'+(val ? val.replace(/(^|[^\\])"/g, '$1\\\"') : '')+'"';
| |
- | }
| |
- | return str + (tok.unary ? '/>' : '>');
| |
- | },
| |
- | chars: function(tok) {
| |
- | return tok.text;
| |
- | }
| |
- | };
| |
- | return handler[tok.type](tok);
| |
- | };
| |
- |
| |
- | htmlParser.escapeAttributes = function(attrs) {
| |
- | var escapedAttrs = {};
| |
- | // escape double-quotes for writing html as a string
| |
- |
| |
- | for(var name in attrs) {
| |
- | var value = attrs[name];
| |
- | escapedAttrs[name] = value && value.replace(/(^|[^\\])"/g, '$1\\\"');
| |
- | }
| |
- | return escapedAttrs;
| |
- | };
| |
- |
| |
- | for(var key in supports) {
| |
- | htmlParser.browserHasFlaw = htmlParser.browserHasFlaw || (!supports[key]) && key;
| |
- | }
| |
- |
| |
- | this.htmlParser = htmlParser;
| |
- | })();
| |
| </script> | | </script> |
| | | |
- | | + | <script src="http://lokeshdhakar.com/projects/lightbox2/js/jquery-1.11.0.min.js"></script> |
- | | + | <script src="http://lokeshdhakar.com/projects/lightbox2/js/lightbox.js"></script> |
- | <script> | + | |
- | | + | |
- | // postscribe.js 1.1.2
| + | |
- | // (c) Copyright 2012 to the present, Krux
| + | |
- | // postscribe is freely distributable under the MIT license.
| + | |
- | // For all details and documentation:
| + | |
- | // http://krux.github.com/postscribe
| + | |
- | | + | |
- | | + | |
- | (function() {
| + | |
- | | + | |
- | var global = this;
| + | |
- | | + | |
- | if(global.postscribe) {
| + | |
- | return;
| + | |
- | }
| + | |
- | | + | |
- | // Debug write tasks.
| + | |
- | var DEBUG = true;
| + | |
- | | + | |
- | // Turn on to debug how each chunk affected the DOM.
| + | |
- | var DEBUG_CHUNK = false;
| + | |
- | | + | |
- | // # Helper Functions
| + | |
- | | + | |
- | var slice = Array.prototype.slice;
| + | |
- | | + | |
- | // A function that intentionally does nothing.
| + | |
- | function doNothing() {}
| + | |
- | | + | |
- | | + | |
- | // Is this a function?
| + | |
- | function isFunction(x) {
| + | |
- | return "function" === typeof x;
| + | |
- | }
| + | |
- | | + | |
- | // Loop over each item in an array-like value.
| + | |
- | function each(arr, fn, _this) {
| + | |
- | var i, len = (arr && arr.length) || 0;
| + | |
- | for(i = 0; i < len; i++) {
| + | |
- | fn.call(_this, arr[i], i);
| + | |
- | }
| + | |
- | }
| + | |
- | | + | |
- | // Loop over each key/value pair in a hash.
| + | |
- | function eachKey(obj, fn, _this) {
| + | |
- | var key;
| + | |
- | for(key in obj) {
| + | |
- | if(obj.hasOwnProperty(key)) {
| + | |
- | fn.call(_this, key, obj[key]);
| + | |
- | }
| + | |
- | }
| + | |
- | }
| + | |
- | | + | |
- | // Set properties on an object.
| + | |
- | function set(obj, props) {
| + | |
- | eachKey(props, function(key, value) {
| + | |
- | obj[key] = value;
| + | |
- | });
| + | |
- | return obj;
| + | |
- | }
| + | |
- | | + | |
- | // Set default options where some option was not specified.
| + | |
- | function defaults(options, _defaults) {
| + | |
- | options = options || {};
| + | |
- | eachKey(_defaults, function(key, val) {
| + | |
- | if(options[key] == null) {
| + | |
- | options[key] = val;
| + | |
- | }
| + | |
- | });
| + | |
- | return options;
| + | |
- | }
| + | |
- | | + | |
- | // Convert value (e.g., a NodeList) to an array.
| + | |
- | function toArray(obj) {
| + | |
- | try {
| + | |
- | return slice.call(obj);
| + | |
- | } catch(e) {
| + | |
- | var ret = [];
| + | |
- | each(obj, function(val) {
| + | |
- | ret.push(val);
| + | |
- | });
| + | |
- | return ret;
| + | |
- | }
| + | |
- | }
| + | |
- | | + | |
- | // Test if token is a script tag.
| + | |
- | function isScript(tok) {
| + | |
- | return (/^script$/i).test(tok.tagName);
| + | |
- | }
| + | |
- | | + | |
- | // # Class WriteStream
| + | |
- | | + | |
- | // Stream static html to an element, where "static html" denotes "html without scripts".
| + | |
- | | + | |
- | // This class maintains a *history of writes devoid of any attributes* or "proxy history".
| + | |
- | // Injecting the proxy history into a temporary div has no side-effects,
| + | |
- | // other than to create proxy elements for previously written elements.
| + | |
- | | + | |
- | // Given the `staticHtml` of a new write, a `tempDiv`'s innerHTML is set to `proxy_history + staticHtml`.
| + | |
- | // The *structure* of `tempDiv`'s contents, (i.e., the placement of new nodes beside or inside of proxy elements),
| + | |
- | // reflects the DOM structure that would have resulted if all writes had been squashed into a single write.
| + | |
- | | + | |
- | // For each descendent `node` of `tempDiv` whose parentNode is a *proxy*, `node` is appended to the corresponding *real* element within the DOM.
| + | |
- | | + | |
- | // Proxy elements are mapped to *actual* elements in the DOM by injecting a data-id attribute into each start tag in `staticHtml`.
| + | |
- | var WriteStream = (function(){
| + | |
- | | + | |
- | // Prefix for data attributes on DOM elements.
| + | |
- | var BASEATTR = 'data-ps-';
| + | |
- | | + | |
- | // get / set data attributes
| + | |
- | function data(el, name, value) {
| + | |
- | var attr = BASEATTR + name;
| + | |
- | | + | |
- | if(arguments.length === 2) {
| + | |
- | // Get
| + | |
- | var val = el.getAttribute(attr);
| + | |
- | | + | |
- | // IE 8 returns a number if it's a number
| + | |
- | return val == null ? val : String(val);
| + | |
- | | + | |
- | } else if( value != null && value !== '') {
| + | |
- | // Set
| + | |
- | el.setAttribute(attr, value);
| + | |
- | | + | |
- | } else {
| + | |
- | // Remove
| + | |
- | el.removeAttribute(attr);
| + | |
- | }
| + | |
- | }
| + | |
- | | + | |
- | function WriteStream(root, options) {
| + | |
- | var doc = root.ownerDocument;
| + | |
- | | + | |
- | set(this, {
| + | |
- | root: root,
| + | |
- | | + | |
- | options: options,
| + | |
- | | + | |
- | win: doc.defaultView || doc.parentWindow,
| + | |
- | | + | |
- | doc: doc,
| + | |
- | | + | |
- | parser: global.htmlParser('', { autoFix: true }),
| + | |
- | | + | |
- | // Actual elements by id.
| + | |
- | actuals: [root],
| + | |
- | | + | |
- | // Embodies the "structure" of what's been written so far, devoid of attributes.
| + | |
- | proxyHistory: '',
| + | |
- | | + | |
- | // Create a proxy of the root element.
| + | |
- | proxyRoot: doc.createElement(root.nodeName),
| + | |
- | | + | |
- | scriptStack: [],
| + | |
- | | + | |
- | writeQueue: []
| + | |
- | });
| + | |
- | | + | |
- | data(this.proxyRoot, 'proxyof', 0);
| + | |
- | | + | |
- | }
| + | |
- | | + | |
- | | + | |
- | WriteStream.prototype.write = function() {
| + | |
- | [].push.apply(this.writeQueue, arguments);
| + | |
- | // Process writes
| + | |
- | // When new script gets pushed or pending this will stop
| + | |
- | // because new writeQueue gets pushed
| + | |
- | var arg;
| + | |
- | while(!this.deferredRemote &&
| + | |
- | this.writeQueue.length) {
| + | |
- | arg = this.writeQueue.shift();
| + | |
- | | + | |
- | if(isFunction(arg)) {
| + | |
- | this.callFunction(arg);
| + | |
- | } else {
| + | |
- | this.writeImpl(arg);
| + | |
- | }
| + | |
- | }
| + | |
- | };
| + | |
- | | + | |
- | WriteStream.prototype.callFunction = function(fn) {
| + | |
- | var tok = { type: "function", value: fn.name || fn.toString() };
| + | |
- | this.onScriptStart(tok);
| + | |
- | fn.call(this.win, this.doc);
| + | |
- | this.onScriptDone(tok);
| + | |
- | };
| + | |
- | | + | |
- | WriteStream.prototype.writeImpl = function(html) {
| + | |
- | this.parser.append(html);
| + | |
- | | + | |
- | var tok, tokens = [];
| + | |
- | | + | |
- | // stop if we see a script token
| + | |
- | while((tok = this.parser.readToken()) && !isScript(tok)) {
| + | |
- | tokens.push(tok);
| + | |
- | }
| + | |
- | | + | |
- | this.writeStaticTokens(tokens);
| + | |
- | | + | |
- | if(tok) {
| + | |
- | this.handleScriptToken(tok);
| + | |
- | }
| + | |
- | };
| + | |
- | | + | |
- | | + | |
- | // ## Contiguous non-script tokens (a chunk)
| + | |
- | WriteStream.prototype.writeStaticTokens = function(tokens) {
| + | |
- | | + | |
- | var chunk = this.buildChunk(tokens);
| + | |
- | | + | |
- | if(!chunk.actual) {
| + | |
- | // e.g., no tokens, or a noscript that got ignored
| + | |
- | return;
| + | |
- | }
| + | |
- | chunk.html = this.proxyHistory + chunk.actual;
| + | |
- | this.proxyHistory += chunk.proxy;
| + | |
- | | + | |
- | this.proxyRoot.innerHTML = chunk.html;
| + | |
- | | + | |
- | if(DEBUG_CHUNK) {
| + | |
- | chunk.proxyInnerHTML = this.proxyRoot.innerHTML;
| + | |
- | }
| + | |
- | | + | |
- | this.walkChunk();
| + | |
- | | + | |
- | if(DEBUG_CHUNK) {
| + | |
- | chunk.actualInnerHTML = this.root.innerHTML; //root
| + | |
- | }
| + | |
- | | + | |
- | return chunk;
| + | |
- | };
| + | |
- | | + | |
- | | + | |
- | WriteStream.prototype.buildChunk = function (tokens) {
| + | |
- | var nextId = this.actuals.length,
| + | |
- | | + | |
- | // The raw html of this chunk.
| + | |
- | raw = [],
| + | |
- | | + | |
- | // The html to create the nodes in the tokens (with id's injected).
| + | |
- | actual = [],
| + | |
- | | + | |
- | // Html that can later be used to proxy the nodes in the tokens.
| + | |
- | proxy = [];
| + | |
- | | + | |
- | each(tokens, function(tok) {
| + | |
- | | + | |
- | raw.push(tok.text);
| + | |
- | | + | |
- | if(tok.attrs) { // tok.attrs <==> startTag or atomicTag or cursor
| + | |
- | // Ignore noscript tags. They are atomic, so we don't have to worry about children.
| + | |
- | if(!(/^noscript$/i).test(tok.tagName)) {
| + | |
- | var id = nextId++;
| + | |
- | | + | |
- | // Actual: inject id attribute: replace '>' at end of start tag with id attribute + '>'
| + | |
- | actual.push(
| + | |
- | tok.text.replace(/(\/?>)/, ' '+BASEATTR+'id='+id+' $1')
| + | |
- | );
| + | |
- | | + | |
- | // Don't proxy scripts: they have no bearing on DOM structure.
| + | |
- | if(tok.attrs.id !== "ps-script") {
| + | |
- | // Proxy: strip all attributes and inject proxyof attribute
| + | |
- | proxy.push(
| + | |
- | // ignore atomic tags (e.g., style): they have no "structural" effect
| + | |
- | tok.type === 'atomicTag' ? '' :
| + | |
- | '<'+tok.tagName+' '+BASEATTR+'proxyof='+id+(tok.unary ? '/>' : '>')
| + | |
- | );
| + | |
- | }
| + | |
- | }
| + | |
- | | + | |
- | } else {
| + | |
- | // Visit any other type of token
| + | |
- | // Actual: append.
| + | |
- | actual.push(tok.text);
| + | |
- | // Proxy: append endTags. Ignore everything else.
| + | |
- | proxy.push(tok.type === 'endTag' ? tok.text : '');
| + | |
- | }
| + | |
- | });
| + | |
- | | + | |
- | return {
| + | |
- | tokens: tokens,
| + | |
- | raw: raw.join(''),
| + | |
- | actual: actual.join(''),
| + | |
- | proxy: proxy.join('')
| + | |
- | };
| + | |
- | };
| + | |
- | | + | |
- | WriteStream.prototype.walkChunk = function() {
| + | |
- | var node, stack = [this.proxyRoot];
| + | |
- | | + | |
- | // use shift/unshift so that children are walked in document order
| + | |
- | | + | |
- | while((node = stack.shift()) != null) {
| + | |
- | | + | |
- | var isElement = node.nodeType === 1;
| + | |
- | var isProxy = isElement && data(node, 'proxyof');
| + | |
- | | + | |
- | // Ignore proxies
| + | |
- | if(!isProxy) {
| + | |
- | | + | |
- | if(isElement) {
| + | |
- | // New actual element: register it and remove the the id attr.
| + | |
- | this.actuals[data(node, 'id')] = node;
| + | |
- | data(node, 'id', null);
| + | |
- | }
| + | |
- | | + | |
- | // Is node's parent a proxy?
| + | |
- | var parentIsProxyOf = node.parentNode && data(node.parentNode, 'proxyof');
| + | |
- | if(parentIsProxyOf) {
| + | |
- | // Move node under actual parent.
| + | |
- | this.actuals[parentIsProxyOf].appendChild(node);
| + | |
- | }
| + | |
- | }
| + | |
- | // prepend childNodes to stack
| + | |
- | stack.unshift.apply(stack, toArray(node.childNodes));
| + | |
- | }
| + | |
- | };
| + | |
- | | + | |
- | // ### Script tokens
| + | |
- | | + | |
- | WriteStream.prototype.handleScriptToken = function(tok) {
| + | |
- | var remainder = this.parser.clear();
| + | |
- | | + | |
- | if(remainder) {
| + | |
- | // Write remainder immediately behind this script.
| + | |
- | this.writeQueue.unshift(remainder);
| + | |
- | }
| + | |
- | | + | |
- | tok.src = tok.attrs.src || tok.attrs.SRC;
| + | |
- | | + | |
- | if(tok.src && this.scriptStack.length) {
| + | |
- | // Defer this script until scriptStack is empty.
| + | |
- | // Assumption 1: This script will not start executing until
| + | |
- | // scriptStack is empty.
| + | |
- | this.deferredRemote = tok;
| + | |
- | } else {
| + | |
- | this.onScriptStart(tok);
| + | |
- | }
| + | |
- | | + | |
- | // Put the script node in the DOM.
| + | |
- | var _this = this;
| + | |
- | this.writeScriptToken(tok, function() {
| + | |
- | _this.onScriptDone(tok);
| + | |
- | });
| + | |
- | | + | |
- | };
| + | |
- | | + | |
- | WriteStream.prototype.onScriptStart = function(tok) {
| + | |
- | tok.outerWrites = this.writeQueue;
| + | |
- | this.writeQueue = [];
| + | |
- | this.scriptStack.unshift(tok);
| + | |
- | };
| + | |
- | | + | |
- | WriteStream.prototype.onScriptDone = function(tok) {
| + | |
- | // Pop script and check nesting.
| + | |
- | if(tok !== this.scriptStack[0]) {
| + | |
- | this.options.error({ message: "Bad script nesting or script finished twice" });
| + | |
- | return;
| + | |
- | }
| + | |
- | this.scriptStack.shift();
| + | |
- | | + | |
- | // Append outer writes to queue and process them.
| + | |
- | this.write.apply(this, tok.outerWrites);
| + | |
- | | + | |
- | // Check for pending remote
| + | |
- | | + | |
- | // Assumption 2: if remote_script1 writes remote_script2 then
| + | |
- | // the we notice remote_script1 finishes before remote_script2 starts.
| + | |
- | // I think this is equivalent to assumption 1
| + | |
- | if(!this.scriptStack.length && this.deferredRemote) {
| + | |
- | this.onScriptStart(this.deferredRemote);
| + | |
- | this.deferredRemote = null;
| + | |
- | }
| + | |
- | };
| + | |
- | | + | |
- | // Build a script and insert it into the DOM.
| + | |
- | // Done is called once script has executed.
| + | |
- | WriteStream.prototype.writeScriptToken = function(tok, done) {
| + | |
- | var el = this.buildScript(tok);
| + | |
- | | + | |
- | if(tok.src) {
| + | |
- | // Fix for attribute "SRC" (capitalized). IE does not recognize it.
| + | |
- | el.src = tok.src;
| + | |
- | this.scriptLoadHandler(el, done);
| + | |
- | }
| + | |
- | | + | |
- | try {
| + | |
- | this.insertScript(el);
| + | |
- | if(!tok.src) {
| + | |
- | done();
| + | |
- | }
| + | |
- | } catch(e) {
| + | |
- | this.options.error(e);
| + | |
- | done();
| + | |
- | }
| + | |
- | };
| + | |
- | | + | |
- | // Build a script element from an atomic script token.
| + | |
- | WriteStream.prototype.buildScript = function(tok) {
| + | |
- | var el = this.doc.createElement(tok.tagName);
| + | |
- | | + | |
- | // Set attributes
| + | |
- | eachKey(tok.attrs, function(name, value) {
| + | |
- | el.setAttribute(name, value);
| + | |
- | });
| + | |
- | | + | |
- | // Set content
| + | |
- | if(tok.content) {
| + | |
- | el.text = tok.content;
| + | |
- | }
| + | |
- | | + | |
- | return el;
| + | |
- | };
| + | |
- | | + | |
- | | + | |
- | // Insert script into DOM where it would naturally be written.
| + | |
- | WriteStream.prototype.insertScript = function(el) {
| + | |
- | // Append a span to the stream. That span will act as a cursor
| + | |
- | // (i.e. insertion point) for the script.
| + | |
- | this.writeImpl('<span id="ps-script"/>');
| + | |
- | | + | |
- | // Grab that span from the DOM.
| + | |
- | var cursor = this.doc.getElementById("ps-script");
| + | |
- | | + | |
- | // Replace cursor with script.
| + | |
- | cursor.parentNode.replaceChild(el, cursor);
| + | |
- | };
| + | |
- | | + | |
- | | + | |
- | WriteStream.prototype.scriptLoadHandler = function(el, done) {
| + | |
- | function cleanup() {
| + | |
- | el = el.onload = el.onreadystatechange = el.onerror = null;
| + | |
- | done();
| + | |
- | }
| + | |
- | | + | |
- | // Error handler
| + | |
- | var error = this.options.error;
| + | |
- | | + | |
- | // Set handlers
| + | |
- | set(el, {
| + | |
- | onload: function() { cleanup(); },
| + | |
- | | + | |
- | onreadystatechange: function() {
| + | |
- | if(/^(loaded|complete)$/.test( el.readyState )) {
| + | |
- | cleanup();
| + | |
- | }
| + | |
- | },
| + | |
- | | + | |
- | onerror: function() {
| + | |
- | error({ message: 'remote script failed ' + el.src });
| + | |
- | cleanup();
| + | |
- | }
| + | |
- | });
| + | |
- | };
| + | |
- | | + | |
- | return WriteStream;
| + | |
- | | + | |
- | }());
| + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | // Public-facing interface and queuing
| + | |
- | var postscribe = (function() {
| + | |
- | var nextId = 0;
| + | |
- | | + | |
- | var queue = [];
| + | |
- | | + | |
- | var active = null;
| + | |
- | | + | |
- | function nextStream() {
| + | |
- | var args = queue.shift();
| + | |
- | if(args) {
| + | |
- | args.stream = runStream.apply(null, args);
| + | |
- | }
| + | |
- | }
| + | |
- | | + | |
- | | + | |
- | function runStream(el, html, options) {
| + | |
- | active = new WriteStream(el, options);
| + | |
- | | + | |
- | // Identify this stream.
| + | |
- | active.id = nextId++;
| + | |
- | active.name = options.name || active.id;
| + | |
- | postscribe.streams[active.name] = active;
| + | |
- | | + | |
- | // Override document.write.
| + | |
- | var doc = el.ownerDocument;
| + | |
- | | + | |
- | var stash = { write: doc.write, writeln: doc.writeln };
| + | |
- | | + | |
- | function write(str) {
| + | |
- | str = options.beforeWrite(str);
| + | |
- | active.write(str);
| + | |
- | options.afterWrite(str);
| + | |
- | }
| + | |
- | | + | |
- | set(doc, { write: write, writeln: function(str) { write(str + '\n'); } });
| + | |
- | | + | |
- | // Override window.onerror
| + | |
- | var oldOnError = active.win.onerror || doNothing;
| + | |
- | | + | |
- | // This works together with the try/catch around WriteStream::insertScript
| + | |
- | // In modern browsers, exceptions in tag scripts go directly to top level
| + | |
- | active.win.onerror = function(msg, url, line) {
| + | |
- | options.error({ msg: msg + ' - ' + url + ':' + line });
| + | |
- | oldOnError.apply(active.win, arguments);
| + | |
- | };
| + | |
- | | + | |
- | // Write to the stream
| + | |
- | active.write(html, function streamDone() {
| + | |
- | // restore document.write
| + | |
- | set(doc, stash);
| + | |
- | | + | |
- | // restore window.onerror
| + | |
- | active.win.onerror = oldOnError;
| + | |
- | | + | |
- | options.done();
| + | |
- | active = null;
| + | |
- | nextStream();
| + | |
- | });
| + | |
- | | + | |
- | return active;
| + | |
- | }
| + | |
- | | + | |
- | | + | |
- | function postscribe(el, html, options) {
| + | |
- | if(isFunction(options)) {
| + | |
- | options = { done: options };
| + | |
- | }
| + | |
- | options = defaults(options, {
| + | |
- | done: doNothing,
| + | |
- | error: function(e) { throw e; },
| + | |
- | beforeWrite: function(str) { return str; },
| + | |
- | afterWrite: doNothing
| + | |
- | });
| + | |
- | | + | |
- | el =
| + | |
- | // id selector
| + | |
- | (/^#/).test(el) ? global.document.getElementById(el.substr(1)) :
| + | |
- | // jquery object. TODO: loop over all elements.
| + | |
- | el.jquery ? el[0] : el;
| + | |
- | | + | |
- | | + | |
- | var args = [el, html, options];
| + | |
- | | + | |
- | el.postscribe = {
| + | |
- | cancel: function() {
| + | |
- | if(args.stream) {
| + | |
- | // TODO: implement this
| + | |
- | args.stream.abort();
| + | |
- | } else {
| + | |
- | args[1] = doNothing;
| + | |
- | }
| + | |
- | }
| + | |
- | };
| + | |
- | | + | |
- | queue.push(args);
| + | |
- | if(!active) {
| + | |
- | nextStream();
| + | |
- | }
| + | |
- | | + | |
- | return el.postscribe;
| + | |
- | }
| + | |
- | | + | |
- | return set(postscribe, {
| + | |
- | // Streams by name.
| + | |
- | streams: {},
| + | |
- | // Queue of streams.
| + | |
- | queue: queue,
| + | |
- | // Expose internal classes.
| + | |
- | WriteStream: WriteStream
| + | |
- | });
| + | |
- | | + | |
- | }());
| + | |
- | | + | |
- | // export postscribe
| + | |
- | global.postscribe = postscribe;
| + | |
- | | + | |
- | }());
| + | |
- | | + | |
- | </script>
| + | |
- | | + | |
- | <script>
| + | |
- | | + | |
- | /**
| + | |
- | * AJAX Banner placement
| + | |
- | *
| + | |
- | * @param {int} uid
| + | |
- | * @param {int} lang
| + | |
- | * @param {int} typeNum
| + | |
- | * @param {string} startingPoint
| + | |
- | * @param {string} categories
| + | |
- | * @param {string} displayMode
| + | |
- | * @param {string} position
| + | |
- | * @param {string} hmac
| + | |
- | * @constructor
| + | |
- | */
| + | |
- | var BannerPlacement = function (uid, lang, typeNum, startingPoint, categories, displayMode, position, hmac) {
| + | |
- | var url = 'index.php?id=' + uid;
| + | |
- | url += '&L=' + lang;
| + | |
- | url += '&type=' + typeNum;
| + | |
- | url += '&tx_sfbanners_pi1[action]=getBanners';
| + | |
- | url += '&tx_sfbanners_pi1[currentPageUid]=' + uid;
| + | |
- | url += '&tx_sfbanners_pi1[hmac]=' + hmac;
| + | |
- | | + | |
- | if (typeof startingPoint !== 'undefined' && startingPoint !== '') {
| + | |
- | url += '&tx_sfbanners_pi1[startingPoint]=' + startingPoint;
| + | |
- | }
| + | |
- | | + | |
- | if (typeof categories !== 'undefined' && categories !== '') {
| + | |
- | url += '&tx_sfbanners_pi1[categories]=' + categories;
| + | |
- | }
| + | |
- | | + | |
- | if (typeof displayMode !== 'undefined' && displayMode !== '') {
| + | |
- | url += '&tx_sfbanners_pi1[displayMode]=' + displayMode;
| + | |
- | }
| + | |
- | | + | |
- | $.get(url, function(data) {
| + | |
- | postscribe('#' + position, data);
| + | |
- | });
| + | |
- | }
| + | |
- | | + | |
- | </script>
| + | |
- | | + | |
- | <script>
| + | |
- | /*
| + | |
- | * jQuery FlexSlider v2.1
| + | |
- | * Copyright 2012 WooThemes
| + | |
- | * Contributing Author: Tyler Smith
| + | |
- | */
| + | |
- | ; (function(d){d.flexslider=function(i,k){var a=d(i),c=d.extend({},d.flexslider.defaults,k),e=c.namespace,r="ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch,s=r?"touchend":"click",l="vertical"===c.direction,m=c.reverse,h=0<c.itemWidth,q="fade"===c.animation,p=""!==c.asNavFor,f={};d.data(i,"flexslider",a);f={init:function(){a.animating=!1;a.currentSlide=c.startAt;a.animatingTo=a.currentSlide;a.atEnd=0===a.currentSlide||a.currentSlide===a.last;a.containerSelector=c.selector.substr(0,
| + | |
- | c.selector.search(" "));a.slides=d(c.selector,a);a.container=d(a.containerSelector,a);a.count=a.slides.length;a.syncExists=0<d(c.sync).length;"slide"===c.animation&&(c.animation="swing");a.prop=l?"top":"marginLeft";a.args={};a.manualPause=!1;var b=a,g;if(g=!c.video)if(g=!q)if(g=c.useCSS)a:{g=document.createElement("div");var n=["perspectiveProperty","WebkitPerspective","MozPerspective","OPerspective","msPerspective"],e;for(e in n)if(void 0!==g.style[n[e]]){a.pfx=n[e].replace("Perspective","").toLowerCase();
| + | |
- | a.prop="-"+a.pfx+"-transform";g=!0;break a}g=!1}b.transitions=g;""!==c.controlsContainer&&(a.controlsContainer=0<d(c.controlsContainer).length&&d(c.controlsContainer));""!==c.manualControls&&(a.manualControls=0<d(c.manualControls).length&&d(c.manualControls));c.randomize&&(a.slides.sort(function(){return Math.round(Math.random())-0.5}),a.container.empty().append(a.slides));a.doMath();p&&f.asNav.setup();a.setup("init");c.controlNav&&f.controlNav.setup();c.directionNav&&f.directionNav.setup();c.keyboard&&
| + | |
- | (1===d(a.containerSelector).length||c.multipleKeyboard)&&d(document).bind("keyup",function(b){b=b.keyCode;if(!a.animating&&(b===39||b===37)){b=b===39?a.getTarget("next"):b===37?a.getTarget("prev"):false;a.flexAnimate(b,c.pauseOnAction)}});c.mousewheel&&a.bind("mousewheel",function(b,g){b.preventDefault();var d=g<0?a.getTarget("next"):a.getTarget("prev");a.flexAnimate(d,c.pauseOnAction)});c.pausePlay&&f.pausePlay.setup();c.slideshow&&(c.pauseOnHover&&a.hover(function(){!a.manualPlay&&!a.manualPause&&
| + | |
- | a.pause()},function(){!a.manualPause&&!a.manualPlay&&a.play()}),0<c.initDelay?setTimeout(a.play,c.initDelay):a.play());r&&c.touch&&f.touch();(!q||q&&c.smoothHeight)&&d(window).bind("resize focus",f.resize);setTimeout(function(){c.start(a)},200)},asNav:{setup:function(){a.asNav=!0;a.animatingTo=Math.floor(a.currentSlide/a.move);a.currentItem=a.currentSlide;a.slides.removeClass(e+"active-slide").eq(a.currentItem).addClass(e+"active-slide");a.slides.click(function(b){b.preventDefault();var b=d(this),
| + | |
- | g=b.index();!d(c.asNavFor).data("flexslider").animating&&!b.hasClass("active")&&(a.direction=a.currentItem<g?"next":"prev",a.flexAnimate(g,c.pauseOnAction,!1,!0,!0))})}},controlNav:{setup:function(){a.manualControls?f.controlNav.setupManual():f.controlNav.setupPaging()},setupPaging:function(){var b=1,g;a.controlNavScaffold=d('<ol class="'+e+"control-nav "+e+("thumbnails"===c.controlNav?"control-thumbs":"control-paging")+'"></ol>');if(1<a.pagingCount)for(var n=0;n<a.pagingCount;n++)g="thumbnails"===
| + | |
- | c.controlNav?'<img src="'+a.slides.eq(n).attr("data-thumb")+'"/>':"<a>"+b+"</a>",a.controlNavScaffold.append("<li>"+g+"</li>"),b++;a.controlsContainer?d(a.controlsContainer).append(a.controlNavScaffold):a.append(a.controlNavScaffold);f.controlNav.set();f.controlNav.active();a.controlNavScaffold.delegate("a, img",s,function(b){b.preventDefault();var b=d(this),g=a.controlNav.index(b);b.hasClass(e+"active")||(a.direction=g>a.currentSlide?"next":"prev",a.flexAnimate(g,c.pauseOnAction))});r&&a.controlNavScaffold.delegate("a",
| + | |
- | "click touchstart",function(a){a.preventDefault()})},setupManual:function(){a.controlNav=a.manualControls;f.controlNav.active();a.controlNav.live(s,function(b){b.preventDefault();var b=d(this),g=a.controlNav.index(b);b.hasClass(e+"active")||(g>a.currentSlide?a.direction="next":a.direction="prev",a.flexAnimate(g,c.pauseOnAction))});r&&a.controlNav.live("click touchstart",function(a){a.preventDefault()})},set:function(){a.controlNav=d("."+e+"control-nav li "+("thumbnails"===c.controlNav?"img":"a"),
| + | |
- | a.controlsContainer?a.controlsContainer:a)},active:function(){a.controlNav.removeClass(e+"active").eq(a.animatingTo).addClass(e+"active")},update:function(b,c){1<a.pagingCount&&"add"===b?a.controlNavScaffold.append(d("<li><a>"+a.count+"</a></li>")):1===a.pagingCount?a.controlNavScaffold.find("li").remove():a.controlNav.eq(c).closest("li").remove();f.controlNav.set();1<a.pagingCount&&a.pagingCount!==a.controlNav.length?a.update(c,b):f.controlNav.active()}},directionNav:{setup:function(){var b=d('<ul class="'+
| + | |
- | e+'direction-nav"><li><a class="'+e+'prev" href="#">'+c.prevText+'</a></li><li><a class="'+e+'next" href="#">'+c.nextText+"</a></li></ul>");a.controlsContainer?(d(a.controlsContainer).append(b),a.directionNav=d("."+e+"direction-nav li a",a.controlsContainer)):(a.append(b),a.directionNav=d("."+e+"direction-nav li a",a));f.directionNav.update();a.directionNav.bind(s,function(b){b.preventDefault();b=d(this).hasClass(e+"next")?a.getTarget("next"):a.getTarget("prev");a.flexAnimate(b,c.pauseOnAction)});
| + | |
- | r&&a.directionNav.bind("click touchstart",function(a){a.preventDefault()})},update:function(){var b=e+"disabled";1===a.pagingCount?a.directionNav.addClass(b):c.animationLoop?a.directionNav.removeClass(b):0===a.animatingTo?a.directionNav.removeClass(b).filter("."+e+"prev").addClass(b):a.animatingTo===a.last?a.directionNav.removeClass(b).filter("."+e+"next").addClass(b):a.directionNav.removeClass(b)}},pausePlay:{setup:function(){var b=d('<div class="'+e+'pauseplay"><a></a></div>');a.controlsContainer?
| + | |
- | (a.controlsContainer.append(b),a.pausePlay=d("."+e+"pauseplay a",a.controlsContainer)):(a.append(b),a.pausePlay=d("."+e+"pauseplay a",a));f.pausePlay.update(c.slideshow?e+"pause":e+"play");a.pausePlay.bind(s,function(b){b.preventDefault();if(d(this).hasClass(e+"pause")){a.manualPause=true;a.manualPlay=false;a.pause()}else{a.manualPause=false;a.manualPlay=true;a.play()}});r&&a.pausePlay.bind("click touchstart",function(a){a.preventDefault()})},update:function(b){"play"===b?a.pausePlay.removeClass(e+
| + | |
- | "pause").addClass(e+"play").text(c.playText):a.pausePlay.removeClass(e+"play").addClass(e+"pause").text(c.pauseText)}},touch:function(){function b(b){j=l?d-b.touches[0].pageY:d-b.touches[0].pageX;p=l?Math.abs(j)<Math.abs(b.touches[0].pageX-e):Math.abs(j)<Math.abs(b.touches[0].pageY-e);if(!p||500<Number(new Date)-k)b.preventDefault(),!q&&a.transitions&&(c.animationLoop||(j/=0===a.currentSlide&&0>j||a.currentSlide===a.last&&0<j?Math.abs(j)/o+2:1),a.setProps(f+j,"setTouch"))}function g(){if(a.animatingTo===
| + | |
- | a.currentSlide&&!p&&null!==j){var h=m?-j:j,l=0<h?a.getTarget("next"):a.getTarget("prev");a.canAdvance(l)&&(550>Number(new Date)-k&&50<Math.abs(h)||Math.abs(h)>o/2)?a.flexAnimate(l,c.pauseOnAction):a.flexAnimate(a.currentSlide,c.pauseOnAction,!0)}i.removeEventListener("touchmove",b,!1);i.removeEventListener("touchend",g,!1);f=j=e=d=null}var d,e,f,o,j,k,p=!1;i.addEventListener("touchstart",function(j){a.animating?j.preventDefault():1===j.touches.length&&(a.pause(),o=l?a.h:a.w,k=Number(new Date),f=h&&
| + | |
- | m&&a.animatingTo===a.last?0:h&&m?a.limit-(a.itemW+c.itemMargin)*a.move*a.animatingTo:h&&a.currentSlide===a.last?a.limit:h?(a.itemW+c.itemMargin)*a.move*a.currentSlide:m?(a.last-a.currentSlide+a.cloneOffset)*o:(a.currentSlide+a.cloneOffset)*o,d=l?j.touches[0].pageY:j.touches[0].pageX,e=l?j.touches[0].pageX:j.touches[0].pageY,i.addEventListener("touchmove",b,!1),i.addEventListener("touchend",g,!1))},!1)},resize:function(){!a.animating&&a.is(":visible")&&(h||a.doMath(),q?f.smoothHeight():h?(a.slides.width(a.computedW),
| + | |
- | a.update(a.pagingCount),a.setProps()):l?(a.viewport.height(a.h),a.setProps(a.h,"setTotal")):(c.smoothHeight&&f.smoothHeight(),a.newSlides.width(a.computedW),a.setProps(a.computedW,"setTotal")))},smoothHeight:function(b){if(!l||q){var c=q?a:a.viewport;b?c.animate({height:a.slides.eq(a.animatingTo).height()},b):c.height(a.slides.eq(a.animatingTo).height())}},sync:function(b){var g=d(c.sync).data("flexslider"),e=a.animatingTo;switch(b){case "animate":g.flexAnimate(e,c.pauseOnAction,!1,!0);break;case "play":!g.playing&&
| + | |
- | !g.asNav&&g.play();break;case "pause":g.pause()}}};a.flexAnimate=function(b,g,n,i,k){p&&1===a.pagingCount&&(a.direction=a.currentItem<b?"next":"prev");if(!a.animating&&(a.canAdvance(b,k)||n)&&a.is(":visible")){if(p&&i)if(n=d(c.asNavFor).data("flexslider"),a.atEnd=0===b||b===a.count-1,n.flexAnimate(b,!0,!1,!0,k),a.direction=a.currentItem<b?"next":"prev",n.direction=a.direction,Math.ceil((b+1)/a.visible)-1!==a.currentSlide&&0!==b)a.currentItem=b,a.slides.removeClass(e+"active-slide").eq(b).addClass(e+
| + | |
- | "active-slide"),b=Math.floor(b/a.visible);else return a.currentItem=b,a.slides.removeClass(e+"active-slide").eq(b).addClass(e+"active-slide"),!1;a.animating=!0;a.animatingTo=b;c.before(a);g&&a.pause();a.syncExists&&!k&&f.sync("animate");c.controlNav&&f.controlNav.active();h||a.slides.removeClass(e+"active-slide").eq(b).addClass(e+"active-slide");a.atEnd=0===b||b===a.last;c.directionNav&&f.directionNav.update();b===a.last&&(c.end(a),c.animationLoop||a.pause());if(q)a.slides.eq(a.currentSlide).fadeOut(c.animationSpeed,
| + | |
- | c.easing),a.slides.eq(b).fadeIn(c.animationSpeed,c.easing,a.wrapup);else{var o=l?a.slides.filter(":first").height():a.computedW;h?(b=c.itemWidth>a.w?2*c.itemMargin:c.itemMargin,b=(a.itemW+b)*a.move*a.animatingTo,b=b>a.limit&&1!==a.visible?a.limit:b):b=0===a.currentSlide&&b===a.count-1&&c.animationLoop&&"next"!==a.direction?m?(a.count+a.cloneOffset)*o:0:a.currentSlide===a.last&&0===b&&c.animationLoop&&"prev"!==a.direction?m?0:(a.count+1)*o:m?(a.count-1-b+a.cloneOffset)*o:(b+a.cloneOffset)*o;a.setProps(b,
| + | |
- | "",c.animationSpeed);if(a.transitions){if(!c.animationLoop||!a.atEnd)a.animating=!1,a.currentSlide=a.animatingTo;a.container.unbind("webkitTransitionEnd transitionend");a.container.bind("webkitTransitionEnd transitionend",function(){a.wrapup(o)})}else a.container.animate(a.args,c.animationSpeed,c.easing,function(){a.wrapup(o)})}c.smoothHeight&&f.smoothHeight(c.animationSpeed)}};a.wrapup=function(b){!q&&!h&&(0===a.currentSlide&&a.animatingTo===a.last&&c.animationLoop?a.setProps(b,"jumpEnd"):a.currentSlide===
| + | |
- | a.last&&(0===a.animatingTo&&c.animationLoop)&&a.setProps(b,"jumpStart"));a.animating=!1;a.currentSlide=a.animatingTo;c.after(a)};a.animateSlides=function(){a.animating||a.flexAnimate(a.getTarget("next"))};a.pause=function(){clearInterval(a.animatedSlides);a.playing=!1;c.pausePlay&&f.pausePlay.update("play");a.syncExists&&f.sync("pause")};a.play=function(){a.animatedSlides=setInterval(a.animateSlides,c.slideshowSpeed);a.playing=!0;c.pausePlay&&f.pausePlay.update("pause");a.syncExists&&f.sync("play")};
| + | |
- | a.canAdvance=function(b,g){var d=p?a.pagingCount-1:a.last;return g?!0:p&&a.currentItem===a.count-1&&0===b&&"prev"===a.direction?!0:p&&0===a.currentItem&&b===a.pagingCount-1&&"next"!==a.direction?!1:b===a.currentSlide&&!p?!1:c.animationLoop?!0:a.atEnd&&0===a.currentSlide&&b===d&&"next"!==a.direction?!1:a.atEnd&&a.currentSlide===d&&0===b&&"next"===a.direction?!1:!0};a.getTarget=function(b){a.direction=b;return"next"===b?a.currentSlide===a.last?0:a.currentSlide+1:0===a.currentSlide?a.last:a.currentSlide-
| + | |
- | 1};a.setProps=function(b,g,d){var e,f=b?b:(a.itemW+c.itemMargin)*a.move*a.animatingTo;e=-1*function(){if(h)return"setTouch"===g?b:m&&a.animatingTo===a.last?0:m?a.limit-(a.itemW+c.itemMargin)*a.move*a.animatingTo:a.animatingTo===a.last?a.limit:f;switch(g){case "setTotal":return m?(a.count-1-a.currentSlide+a.cloneOffset)*b:(a.currentSlide+a.cloneOffset)*b;case "setTouch":return b;case "jumpEnd":return m?b:a.count*b;case "jumpStart":return m?a.count*b:b;default:return b}}()+"px";a.transitions&&(e=l?
| + | |
- | "translate3d(0,"+e+",0)":"translate3d("+e+",0,0)",d=void 0!==d?d/1E3+"s":"0s",a.container.css("-"+a.pfx+"-transition-duration",d));a.args[a.prop]=e;(a.transitions||void 0===d)&&a.container.css(a.args)};a.setup=function(b){if(q)a.slides.css({width:"100%","float":"left",marginRight:"-100%",position:"relative"}),"init"===b&&a.slides.eq(a.currentSlide).fadeIn(c.animationSpeed,c.easing),c.smoothHeight&&f.smoothHeight();else{var g,n;"init"===b&&(a.viewport=d('<div class="'+e+'viewport"></div>').css({overflow:"hidden",
| + | |
- | position:"relative"}).appendTo(a).append(a.container),a.cloneCount=0,a.cloneOffset=0,m&&(n=d.makeArray(a.slides).reverse(),a.slides=d(n),a.container.empty().append(a.slides)));c.animationLoop&&!h&&(a.cloneCount=2,a.cloneOffset=1,"init"!==b&&a.container.find(".clone").remove(),a.container.append(a.slides.first().clone().addClass("clone")).prepend(a.slides.last().clone().addClass("clone")));a.newSlides=d(c.selector,a);g=m?a.count-1-a.currentSlide+a.cloneOffset:a.currentSlide+a.cloneOffset;l&&!h?(a.container.height(200*
| + | |
- | (a.count+a.cloneCount)+"%").css("position","absolute").width("100%"),setTimeout(function(){a.newSlides.css({display:"block"});a.doMath();a.viewport.height(a.h);a.setProps(g*a.h,"init")},"init"===b?100:0)):(a.container.width(200*(a.count+a.cloneCount)+"%"),a.setProps(g*a.computedW,"init"),setTimeout(function(){a.doMath();a.newSlides.css({width:a.computedW,"float":"left",display:"block"});c.smoothHeight&&f.smoothHeight()},"init"===b?100:0))}h||a.slides.removeClass(e+"active-slide").eq(a.currentSlide).addClass(e+
| + | |
- | "active-slide")};a.doMath=function(){var b=a.slides.first(),d=c.itemMargin,e=c.minItems,f=c.maxItems;a.w=a.width();a.h=b.height();a.boxPadding=b.outerWidth()-b.width();h?(a.itemT=c.itemWidth+d,a.minW=e?e*a.itemT:a.w,a.maxW=f?f*a.itemT:a.w,a.itemW=a.minW>a.w?(a.w-d*e)/e:a.maxW<a.w?(a.w-d*f)/f:c.itemWidth>a.w?a.w:c.itemWidth,a.visible=Math.floor(a.w/(a.itemW+d)),a.move=0<c.move&&c.move<a.visible?c.move:a.visible,a.pagingCount=Math.ceil((a.count-a.visible)/a.move+1),a.last=a.pagingCount-1,a.limit=1===
| + | |
- | a.pagingCount?0:c.itemWidth>a.w?(a.itemW+2*d)*a.count-a.w-d:(a.itemW+d)*a.count-a.w-d):(a.itemW=a.w,a.pagingCount=a.count,a.last=a.count-1);a.computedW=a.itemW-a.boxPadding};a.update=function(b,d){a.doMath();h||(b<a.currentSlide?a.currentSlide+=1:b<=a.currentSlide&&0!==b&&(a.currentSlide-=1),a.animatingTo=a.currentSlide);if(c.controlNav&&!a.manualControls)if("add"===d&&!h||a.pagingCount>a.controlNav.length)f.controlNav.update("add");else if("remove"===d&&!h||a.pagingCount<a.controlNav.length)h&&a.currentSlide>
| + | |
- | a.last&&(a.currentSlide-=1,a.animatingTo-=1),f.controlNav.update("remove",a.last);c.directionNav&&f.directionNav.update()};a.addSlide=function(b,e){var f=d(b);a.count+=1;a.last=a.count-1;l&&m?void 0!==e?a.slides.eq(a.count-e).after(f):a.container.prepend(f):void 0!==e?a.slides.eq(e).before(f):a.container.append(f);a.update(e,"add");a.slides=d(c.selector+":not(.clone)",a);a.setup();c.added(a)};a.removeSlide=function(b){var e=isNaN(b)?a.slides.index(d(b)):b;a.count-=1;a.last=a.count-1;isNaN(b)?d(b,
| + | |
- | a.slides).remove():l&&m?a.slides.eq(a.last).remove():a.slides.eq(b).remove();a.doMath();a.update(e,"remove");a.slides=d(c.selector+":not(.clone)",a);a.setup();c.removed(a)};f.init()};d.flexslider.defaults={namespace:"flex-",selector:".slides > li",animation:"fade",easing:"swing",direction:"horizontal",reverse:!1,animationLoop:!0,smoothHeight:!1,startAt:0,slideshow:!0,slideshowSpeed:7E3,animationSpeed:600,initDelay:0,randomize:!1,pauseOnAction:!0,pauseOnHover:!1,useCSS:!0,touch:!0,video:!1,controlNav:!0,
| + | |
- | directionNav:!0,prevText:"Previous",nextText:"Next",keyboard:!0,multipleKeyboard:!1,mousewheel:!1,pausePlay:!1,pauseText:"Pause",playText:"Play",controlsContainer:"",manualControls:"",sync:"",asNavFor:"",itemWidth:0,itemMargin:0,minItems:0,maxItems:0,move:0,start:function(){},before:function(){},after:function(){},end:function(){},added:function(){},removed:function(){}};d.fn.flexslider=function(i){void 0===i&&(i={});if("object"===typeof i)return this.each(function(){var a=d(this),c=a.find(i.selector?
| + | |
- | i.selector:".slides > li");1===c.length?(c.fadeIn(400),i.start&&i.start(a)):void 0===a.data("flexslider")&&new d.flexslider(this,i)});var k=d(this).data("flexslider");switch(i){case "play":k.play();break;case "pause":k.pause();break;case "next":k.flexAnimate(k.getTarget("next"),!0);break;case "prev":case "previous":k.flexAnimate(k.getTarget("prev"),!0);break;default:"number"===typeof i&&k.flexAnimate(i,!0)}}})(jQuery);
| + | |
- | | + | |
- | </script> | + | |
- | | + | |
- | | + | |
- | <script>
| + | |
- | // Can also be used with $(document).ready()
| + | |
- | jQuery(window).load(function() {
| + | |
- | jQuery('#slider').flexslider({
| + | |
- | animation: "slide"
| + | |
- | });
| + | |
- | jQuery('#slider img').removeAttr('width').removeAttr('height');
| + | |
- | });
| + | |
- | </script>
| + | |
- | | + | |
- | <script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script> | + | |
- | | + | |
- | | + | |
- | | + | |
| | | |
| </html> | | </html> |