diff --git a/README.md b/README.md index 0d893b32..733c11e9 100644 --- a/README.md +++ b/README.md @@ -526,7 +526,7 @@ your changes merged back into core is as follows: $ gem push gollum-X.Y.Z.gem ## BUILDING THE GEM FROM MASTER - + $ gem uninstall -aix gollum $ git clone https://github.com/github/gollum.git $ cd gollum gollum$ rake build diff --git a/bin/gollum b/bin/gollum index a496e5bd..f4ef13fb 100755 --- a/bin/gollum +++ b/bin/gollum @@ -48,11 +48,15 @@ opts = OptionParser.new do |opts| opts.on("--page-file-dir [PATH]", "Specify the sub directory for all page files (default: repository root).") do |path| wiki_options[:page_file_dir] = path end - + opts.on("--base-path [PATH]", "Specify the base path.") do |path| wiki_options[:base_path] = path end + opts.on("--gollum-path [PATH]", "Specify the gollum path.") do |path| + wiki_options[:gollum_path] = path + end + opts.on("--ref [REF]", "Specify the repository ref to use (default: master).") do |ref| wiki_options[:ref] = ref end @@ -75,7 +79,10 @@ rescue OptionParser::InvalidOption exit end -gollum_path = ARGV[0] || Dir.pwd +# --gollum-path wins over ARGV[0] +gollum_path = wiki_options[:gollum_path] ? + wiki_options[:gollum_path] : + ARGV[0] || Dir.pwd if options['irb'] require 'irb' diff --git a/gollum.gemspec b/gollum.gemspec index cd03bc2c..53b2ba75 100644 --- a/gollum.gemspec +++ b/gollum.gemspec @@ -33,6 +33,7 @@ Gem::Specification.new do |s| s.add_dependency('sanitize', "~> 2.0.0") s.add_dependency('nokogiri', "~> 1.4") s.add_dependency('useragent', "~> 0.4.9") + s.add_dependency('stringex', "~> 1.4.0") s.add_development_dependency('RedCloth') s.add_development_dependency('mocha') diff --git a/lib/gollum/file_view.rb b/lib/gollum/file_view.rb index 624b991d..6af63caf 100644 --- a/lib/gollum/file_view.rb +++ b/lib/gollum/file_view.rb @@ -15,19 +15,19 @@ module Gollum def new_page page name = page.name - %Q(
  • #{name}
  • \n) + url = page.filename_stripped + %Q(
  • #{name}
  • \n) end - def new_folder page - new_sub_folder ::File.dirname(page.path), page.name + def new_folder folder_path + new_sub_folder folder_path end - def new_sub_folder path, name + def new_sub_folder path <<-HTML
    1. -
    2. #{name}
    3. HTML end @@ -65,11 +65,12 @@ module Gollum if (count - folder_start == 1) page = @pages[ folder_start ] name = page.name + url = page.filename_stripped html += <<-HTML
      1. -
      2. #{name}
      3. +
      4. #{name}
    4. HTML @@ -99,54 +100,38 @@ module Gollum end end - # Process first folder - page = @pages[ sorted_folders[ 0 ][1] ] - html += new_folder page - - last_folder = ::File.dirname page.path # define last_folder - # keep track of folder depth, 0 = at root. - depth = 0 + cwd_array = [] + changed = false # process rest of folders - 1.upto(sorted_folders.size - 1) do | index | - page = @pages[ sorted_folders[ index ][1] ] + (0...sorted_folders.size).each do | index | + page = @pages[ sorted_folders[ index ][ 1 ] ] path = page.path folder = ::File.dirname path - if last_folder == folder - # same folder - html += new_page page - elsif folder.include?('/') - # check if we're going up or down a depth level - if last_folder.scan('/').size > folder.scan('/').size - # end tag for 1 subfolder & 1 parent folder - # so emit 2 end tags - 2.times { html += end_folder; } - depth -= 1 - else - depth += 1 + tmp_array = folder.split '/' + + (0...tmp_array.size).each do | index | + if cwd_array[ index ].nil? || changed + html += new_sub_folder tmp_array[ index ] + next end - # subfolder - html += new_sub_folder ::File.dirname(page.path).split('/').last, page.name - else - # depth+1 because we need an additional end_folder - (depth+1).times { html += end_folder; } - depth = 0 - # New root folder - html += new_folder page + if cwd_array[ index ] != tmp_array[ index ] + changed = true + (cwd_array.size - index).times do + html += end_folder + end + html += new_sub_folder tmp_array[ index ] + end end - last_folder = folder + html += new_page page + cwd_array = tmp_array + changed = false end - # Process last folder's ending tags. - (depth+1).times { - depth.times { html += end_folder; } - depth = 0 - } - # return the completed html enclose_tree html end # end render_files diff --git a/lib/gollum/frontend/app.rb b/lib/gollum/frontend/app.rb index 6f6e683f..5b6e25e6 100644 --- a/lib/gollum/frontend/app.rb +++ b/lib/gollum/frontend/app.rb @@ -3,6 +3,7 @@ require 'sinatra' require 'gollum' require 'mustache/sinatra' require 'useragent' +require 'stringex' require 'gollum/frontend/views/layout' require 'gollum/frontend/views/editable' @@ -11,6 +12,17 @@ require 'gollum/frontend/views/has_page' require File.expand_path '../uri_encode_component', __FILE__ require File.expand_path '../helpers', __FILE__ +# Fix to_url +class String + alias :upstream_to_url :to_url + # _Header => header which causes errors + def to_url + return nil if self.nil? + return self if ['_Header', '_Footer', '_Sidebar'].include? self + upstream_to_url + end +end + # Run the frontend, based on Sinatra # # There are a number of wiki options that can be set for the frontend @@ -30,15 +42,17 @@ module Precious dir = File.dirname(File.expand_path(__FILE__)) # Detect unsupported browsers. - @@supported_browsers = ['Firefox', 'Chrome', 'Safari'] Browser = Struct.new(:browser, :version) - @@ie9 = Browser.new('Internet Explorer', '9.0') + + @@min_ua = [ + Browser.new('Internet Explorer', '10.0'), + Browser.new('Chrome', '7.0'), + Browser.new('Firefox', '4.0'), + ] def supported_useragent?(user_agent) ua = UserAgent.parse(user_agent) - return true if ua >= @@ie9 - - @@supported_browsers.include? ua.browser + @@min_ua.detect {|min| ua >= min } end # We want to serve public assets for now @@ -102,7 +116,8 @@ module Precious else @page = page @page.version = wiki.repo.log(wiki.ref, @page.path).first - @content = page.raw_data + raw_data = page.raw_data + @content = raw_data.respond_to?(:force_encoding) ? raw_data.force_encoding('UTF-8') : raw_data mustache :edit end else @@ -111,11 +126,12 @@ module Precious end post '/edit/*' do - path = sanitize_empty_params(params[:path]) + path = extract_path(sanitize_empty_params(params[:path])) wiki_options = settings.wiki_options.merge({ :page_file_dir => path }) wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options) page = wiki.page(CGI.unescape(params[:page])) - name = params[:rename] || page.name + rename = params[:rename].to_url if params[:rename] + name = rename || page.name committer = Gollum::Committer.new(wiki, commit_message) commit = {:committer => committer} @@ -125,23 +141,38 @@ module Precious update_wiki_page(wiki, page.sidebar, params[:sidebar], commit) if params[:sidebar] committer.commit - page = wiki.page(params[:rename]) if params[:rename] + page = wiki.page(rename) if rename redirect to("/#{page.escaped_url_path}") end - + + get '/delete/*' do + @path = extract_path(params[:splat].first) + @name = extract_name(params[:splat].first) + wiki_options = settings.wiki_options.merge({ :page_file_dir => @path }) + wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options) + @page = wiki.page(@name) + wiki.delete_page(@page, { :message => "Destroyed #{@name} (#{@page.format})" }) + + redirect '/' + end + get '/create/*' do - wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options) - @name = params[:splat].first - if wiki.page(@name) - redirect "/#{CGI.escape(@name)}" + @path = extract_path(params[:splat].first) + @name = extract_name(params[:splat].first).to_url + wiki_options = settings.wiki_options.merge({ :page_file_dir => @path }) + wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options) + + page = wiki.page(@name) + if page + redirect "/#{page.escaped_url_path}" else mustache :create end end - + post '/create' do - name = params[:page] + name = params[:page].to_url path = sanitize_empty_params(params[:path]) format = params[:format].intern @@ -314,17 +345,18 @@ module Precious content_type file.mime_type file.raw_data else - redirect "/create/#{CGI.escape(name)}" + page_path = [path, name].compact.join('/') + redirect "/create/#{CGI.escape(page_path).gsub('%2F','/')}" end end - def update_wiki_page(wiki, page, content, commit_message, name = nil, format = nil) + def update_wiki_page(wiki, page, content, commit, name = nil, format = nil) return if !page || ((!content || page.raw_data == content) && page.format == format) name ||= page.name format = (format || page.format).to_sym content ||= page.raw_data - wiki.update_page(page, name, format, content.to_s, commit_message) + wiki.update_page(page, name, format, content.to_s, commit) end def commit_message diff --git a/lib/gollum/frontend/helpers.rb b/lib/gollum/frontend/helpers.rb index 1e78f617..845a0c7a 100644 --- a/lib/gollum/frontend/helpers.rb +++ b/lib/gollum/frontend/helpers.rb @@ -2,6 +2,7 @@ module Precious module Helpers # Extract the path string that Gollum::Wiki expects def extract_path(file_path) + return nil if file_path.nil? last_slash = file_path.rindex("/") if last_slash file_path[0, last_slash] diff --git a/lib/gollum/frontend/public/gollum/css/_styles.css b/lib/gollum/frontend/public/gollum/css/_styles.css index f2ce367f..092263c4 100644 --- a/lib/gollum/frontend/public/gollum/css/_styles.css +++ b/lib/gollum/frontend/public/gollum/css/_styles.css @@ -1,6 +1,6 @@ -/* Just some base styles not needed for example to function */ -*, html { font-family: Verdana, Arial, Helvetica, sans-serif; } - +*, html { + font-family: Verdana, Arial, Helvetica, sans-serif; +} #results a:hover { background-color: #4c4c4c; @@ -13,9 +13,8 @@ } #home_button .minibutton { -/* controls size of home btn */ -font-size: 1em; -text-align: center; + font-size: 1em; + text-align: center; } #results { @@ -24,87 +23,99 @@ text-align: center; left: 10px; } - -body, form, ul, li, p, h1, h2, h3, h4, h5 -{ - margin: 0; - padding: 0; +body, form, ul, li, p, h1, h2, h3, h4, h5 { + margin: 0; + padding: 0; } -body { background-color: #606061; color: #ffffff; margin: 0; } -img { border: none; } -p -{ - font-size: 1em; - margin: 0 0 1em 0; + +body { + background-color: #606061; + color: #ffffff; + margin: 0; +} + +img { + border: none; +} + +p { + font-size: 1em; + margin: 0 0 1em 0; } html { font-size: 100%; /* IE hack */ } body { font-size: 1em; /* Sets base font size to 16px */ } table { font-size: 100%; /* IE hack */ } input, select, textarea, th, td { font-size: 1em; } - + +/* Prevent wrapping on large file names. */ +li.file { + white-space: nowrap; +} + /* CSS Tree menu styles */ ol.tree { - padding: 0 0 0 30px; - width: 300px; + padding: 0 0 0 30px; + width: 300px; } - li - { - position: relative; - margin-left: -15px; - list-style: none; - } - li.file - { - margin-left: -1px !important; + li + { + position: relative; + margin-left: -15px; + list-style: none; + } + li.file + { + margin-left: -1px !important; height: 1.5em; - } - li.file a - { - background: url(../images/fileview/document.png) 0 0 no-repeat; - color: #fff; - padding-left: 21px; - text-decoration: none; - display: block; - } - li.file a[href *= '.pdf'] { background: url(../images/fileview/document.png) 0 0 no-repeat; } - li.file a[href *= '.html'] { background: url(../images/fileview/document.png) 0 0 no-repeat; } - li.file a[href $= '.css'] { background: url(../images/fileview/document.png) 0 0 no-repeat; } - li.file a[href $= '.js'] { background: url(../images/fileview/document.png) 0 0 no-repeat; } - li input - { - position: absolute; - left: 0; - margin-left: 0; - opacity: 0; - z-index: 2; - cursor: pointer; - height: 1em; - width: 1em; - top: 0; - } - li input + ol - { - background: url(../images/fileview/toggle-small-expand.png) 40px 0 no-repeat; - margin: -1.188em 0 0 -44px; /* 15px */ - height: 1.5em; - } - li input + ol > li { display: none; margin-left: -14px !important; padding-left: 1px; } - li label - { - background: url(../images/fileview/folder-horizontal.png) 15px 1px no-repeat; - cursor: pointer; - display: block; - padding-left: 37px; - } + } + li.file a + { + background: url(../images/fileview/document.png) 0 0 no-repeat; + color: #fff; + padding-left: 21px; + text-decoration: none; + display: block; + } + li.file a[href *= '.pdf'] { background: url(../images/fileview/document.png) 0 0 no-repeat; } + li.file a[href *= '.html'] { background: url(../images/fileview/document.png) 0 0 no-repeat; } + li.file a[href $= '.css'] { background: url(../images/fileview/document.png) 0 0 no-repeat; } + li.file a[href $= '.js'] { background: url(../images/fileview/document.png) 0 0 no-repeat; } + li input + { + position: absolute; + left: 0; + margin-left: 0; + opacity: 0; + z-index: 2; + cursor: pointer; + height: 1em; + width: 1em; + top: 0; + } + li input + ol + { + background: url(../images/fileview/toggle-small-expand.png) 40px 0 no-repeat; + margin: -1.188em 0 0 -44px; /* 15px */ + height: 1.5em; + } + li input + ol > li { display: none; margin-left: -14px !important; padding-left: 1px; } + li label + { + background: url(../images/fileview/folder-horizontal.png) 15px 1px no-repeat; + cursor: pointer; + display: block; + padding-left: 37px; + } + + li input:checked + ol + { + background: url(../images/fileview/toggle-small.png) 40px 5px no-repeat; + margin: -1.5em 0 0 -44px; /* 20px */ + padding: 1.563em 0 0 80px; + height: auto; + } + li input:checked + ol > li { display: block; margin: 0 0 0.125em; /* 2px */} + li input:checked + ol > li:last-child { margin: 0 0 0.063em; /* 1px */ } - li input:checked + ol - { - background: url(../images/fileview/toggle-small.png) 40px 5px no-repeat; - margin: -1.5em 0 0 -44px; /* 20px */ - padding: 1.563em 0 0 80px; - height: auto; - } - li input:checked + ol > li { display: block; margin: 0 0 0.125em; /* 2px */} - li input:checked + ol > li:last-child { margin: 0 0 0.063em; /* 1px */ } diff --git a/lib/gollum/frontend/public/gollum/css/template.css b/lib/gollum/frontend/public/gollum/css/template.css index b2b059d2..7e9ff541 100644 --- a/lib/gollum/frontend/public/gollum/css/template.css +++ b/lib/gollum/frontend/public/gollum/css/template.css @@ -226,6 +226,8 @@ a.absent { } .markdown-body table { padding: 0; + border-collapse: collapse; + border-spacing: 0; } .markdown-body table tr { border-top: 1px solid #ccc; diff --git a/lib/gollum/frontend/public/gollum/javascript/editor/gollum.editor.js b/lib/gollum/frontend/public/gollum/javascript/editor/gollum.editor.js index 2cd547bf..d24af06f 100755 --- a/lib/gollum/frontend/public/gollum/javascript/editor/gollum.editor.js +++ b/lib/gollum/frontend/public/gollum/javascript/editor/gollum.editor.js @@ -24,7 +24,6 @@ * You don't need to do anything. Just run this on DOM ready. */ $.GollumEditor = function( IncomingOptions ) { - ActiveOptions = $.extend( DefaultOptions, IncomingOptions ); debug('GollumEditor loading'); @@ -96,11 +95,8 @@ $('#gollum-editor-help').hide(); $('#gollum-editor-help').removeClass('jaws'); } - - } - // EditorHas.functionBar - } - // EditorHas.baseEditorMarkup + } // EditorHas.functionBar + } // EditorHas.baseEditorMarkup }; @@ -199,6 +195,18 @@ if(LanguageDefinition.getHookFunctionFor("activate")) { LanguageDefinition.getHookFunctionFor("activate")(); } + + function hotkey( cmd ) { + var def = LanguageDefinition.getDefinitionFor( cmd ); + if ( typeof def == 'object' ) { + FunctionBar.executeAction( def ); + } + // Prevent bubbling of hotkey. + return false; + } + + Mousetrap.bind(['command+b', 'ctrl+b'], function(){ hotkey('function-bold'); }); + Mousetrap.bind(['command+i', 'ctrl+i'], function(){ hotkey('function-italic'); }); } ); } else { LanguageDefinition._ACTIVE_LANG = name; diff --git a/lib/gollum/frontend/public/gollum/javascript/editor/langs/markdown.js b/lib/gollum/frontend/public/gollum/javascript/editor/langs/markdown.js index 923a5458..851b7381 100644 --- a/lib/gollum/frontend/public/gollum/javascript/editor/langs/markdown.js +++ b/lib/gollum/frontend/public/gollum/javascript/editor/langs/markdown.js @@ -32,7 +32,7 @@ var MarkDown = { }, 'function-code' : { - search: /(^[\n]+)([\n\s]*)/g, + search: /([^\n]+)([\n\s]*)/g, replace: "`$1`$2" }, @@ -44,11 +44,22 @@ var MarkDown = { search: /(.+)([\n]?)/g, replace: "* $1$2" }, - - /* This looks silly but is completely valid Markdown */ + /* based on rdoc.js */ 'function-ol' : { - search: /(.+)([\n]?)/g, - replace: "1. $1$2" + exec: function( txt, selText, $field ) { + var count = 1; + // split into lines + var repText = ''; + var lines = selText.split("\n"); + var hasContent = /[\w]+/; + for ( var i = 0; i < lines.length; i++ ) { + if ( hasContent.test(lines[i]) ) { + repText += (i + 1).toString() + '. ' + + lines[i] + "\n"; + } + } + $.GollumEditor.replaceSelection( repText ); + } }, 'function-blockquote' : { diff --git a/lib/gollum/frontend/public/gollum/javascript/gollum.js b/lib/gollum/frontend/public/gollum/javascript/gollum.js index 98c5d440..4ef94204 100755 --- a/lib/gollum/frontend/public/gollum/javascript/gollum.js +++ b/lib/gollum/frontend/public/gollum/javascript/gollum.js @@ -1,5 +1,21 @@ // ua $(document).ready(function() { + $('#delete-link').click( function(e) { + var ok = confirm($(this).data('confirm')); + if ( ok ) { + var href = window.location.href; + var index = href.lastIndexOf('/'); + // /home + var page = href.substr(index); + // http://localhost:4567/ + var host = href.substr(0, index+1); + var loc = host + 'delete' + page; + window.location = loc; + } + // Don't navigate on cancel. + e.preventDefault(); + } ); + var nodeSelector = { node1: null, node2: null, @@ -97,31 +113,71 @@ $(document).ready(function() { } } + if ($('#minibutton-rename-page').length) { + $('#minibutton-rename-page').removeClass('jaws'); + $('#minibutton-rename-page').click(function(e) { + e.preventDefault(); + + var path = window.location.pathname; + var oldName = path.substring(path.lastIndexOf('/')+1); + + $.GollumDialog.init({ + title: 'Rename Page', + fields: [ + { + id: 'name', + name: 'Rename to', + type: 'text', + defaultValue: oldName || '' + } + ], + OK: function( res ) { + var name = 'Rename Page'; + if ( res['name'] ) { + name = res['name']; + } + + var msg = 'Renamed ' + oldName + ' to ' + name; + jQuery.ajax( { + type: 'POST', + url: '/edit/' + oldName, + // omit path: pathName until https://github.com/github/gollum/issues/446 is fixed. + data: { rename: name, page: oldName, message: msg }, + success: function() { + window.location = '/' + encodeURIComponent(name); + } + }); + } + }); + }); + } + if ($('#minibutton-new-page').length) { $('#minibutton-new-page').removeClass('jaws'); $('#minibutton-new-page').click(function(e) { e.preventDefault(); + + var path = $(this).data('path'); + if (path) { + path = path + '/'; + } + $.GollumDialog.init({ title: 'Create New Page', fields: [ { id: 'name', name: 'Page Name', - type: 'text' + type: 'text', + defaultValue: path || '' } ], OK: function( res ) { var name = 'New Page'; if ( res['name'] ) { - var name = res['name']; + name = res['name']; } - - var url = baseUrl; - var path = $('#minibutton-new-page').data('path'); - if (path) { - url += '/' + encodeURIComponent(path) - } - window.location = url + '/' + encodeURIComponent(name); + window.location = baseUrl + '/' + encodeURIComponent(name); } }); }); diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/jquery/jquery-1.7.2.min.js b/lib/gollum/frontend/public/gollum/javascript/jquery-1.7.2.min.js similarity index 100% rename from lib/gollum/frontend/public/gollum/livepreview/js/jquery/jquery-1.7.2.min.js rename to lib/gollum/frontend/public/gollum/javascript/jquery-1.7.2.min.js diff --git a/lib/gollum/frontend/public/gollum/javascript/jquery.js b/lib/gollum/frontend/public/gollum/javascript/jquery.js deleted file mode 100644 index c53482c8..00000000 --- a/lib/gollum/frontend/public/gollum/javascript/jquery.js +++ /dev/null @@ -1,7179 +0,0 @@ -/*! - * jQuery JavaScript Library v1.4.4 - * http://jquery.com/ - * - * Copyright 2010, John Resig - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * Includes Sizzle.js - * http://sizzlejs.com/ - * Copyright 2010, The Dojo Foundation - * Released under the MIT, BSD, and GPL Licenses. - * - * Date: Thu Nov 11 19:04:53 2010 -0500 - */ -(function( window, undefined ) { - -// Use the correct document accordingly with window argument (sandbox) -var document = window.document; -var jQuery = (function() { - -// Define a local copy of jQuery -var jQuery = function( selector, context ) { - // The jQuery object is actually just the init constructor 'enhanced' - return new jQuery.fn.init( selector, context ); - }, - - // Map over jQuery in case of overwrite - _jQuery = window.jQuery, - - // Map over the $ in case of overwrite - _$ = window.$, - - // A central reference to the root jQuery(document) - rootjQuery, - - // A simple way to check for HTML strings or ID strings - // (both of which we optimize for) - quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/, - - // Is it a simple selector - isSimple = /^.[^:#\[\.,]*$/, - - // Check if a string has a non-whitespace character in it - rnotwhite = /\S/, - rwhite = /\s/, - - // Used for trimming whitespace - trimLeft = /^\s+/, - trimRight = /\s+$/, - - // Check for non-word characters - rnonword = /\W/, - - // Check for digits - rdigit = /\d/, - - // Match a standalone tag - rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/, - - // JSON RegExp - rvalidchars = /^[\],:{}\s]*$/, - rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, - rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, - rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, - - // Useragent RegExp - rwebkit = /(webkit)[ \/]([\w.]+)/, - ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/, - rmsie = /(msie) ([\w.]+)/, - rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/, - - // Keep a UserAgent string for use with jQuery.browser - userAgent = navigator.userAgent, - - // For matching the engine and version of the browser - browserMatch, - - // Has the ready events already been bound? - readyBound = false, - - // The functions to execute on DOM ready - readyList = [], - - // The ready event handler - DOMContentLoaded, - - // Save a reference to some core methods - toString = Object.prototype.toString, - hasOwn = Object.prototype.hasOwnProperty, - push = Array.prototype.push, - slice = Array.prototype.slice, - trim = String.prototype.trim, - indexOf = Array.prototype.indexOf, - - // [[Class]] -> type pairs - class2type = {}; - -jQuery.fn = jQuery.prototype = { - init: function( selector, context ) { - var match, elem, ret, doc; - - // Handle $(""), $(null), or $(undefined) - if ( !selector ) { - return this; - } - - // Handle $(DOMElement) - if ( selector.nodeType ) { - this.context = this[0] = selector; - this.length = 1; - return this; - } - - // The body element only exists once, optimize finding it - if ( selector === "body" && !context && document.body ) { - this.context = document; - this[0] = document.body; - this.selector = "body"; - this.length = 1; - return this; - } - - // Handle HTML strings - if ( typeof selector === "string" ) { - // Are we dealing with HTML string or an ID? - match = quickExpr.exec( selector ); - - // Verify a match, and that no context was specified for #id - if ( match && (match[1] || !context) ) { - - // HANDLE: $(html) -> $(array) - if ( match[1] ) { - doc = (context ? context.ownerDocument || context : document); - - // If a single string is passed in and it's a single tag - // just do a createElement and skip the rest - ret = rsingleTag.exec( selector ); - - if ( ret ) { - if ( jQuery.isPlainObject( context ) ) { - selector = [ document.createElement( ret[1] ) ]; - jQuery.fn.attr.call( selector, context, true ); - - } else { - selector = [ doc.createElement( ret[1] ) ]; - } - - } else { - ret = jQuery.buildFragment( [ match[1] ], [ doc ] ); - selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes; - } - - return jQuery.merge( this, selector ); - - // HANDLE: $("#id") - } else { - elem = document.getElementById( match[2] ); - - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - if ( elem && elem.parentNode ) { - // Handle the case where IE and Opera return items - // by name instead of ID - if ( elem.id !== match[2] ) { - return rootjQuery.find( selector ); - } - - // Otherwise, we inject the element directly into the jQuery object - this.length = 1; - this[0] = elem; - } - - this.context = document; - this.selector = selector; - return this; - } - - // HANDLE: $("TAG") - } else if ( !context && !rnonword.test( selector ) ) { - this.selector = selector; - this.context = document; - selector = document.getElementsByTagName( selector ); - return jQuery.merge( this, selector ); - - // HANDLE: $(expr, $(...)) - } else if ( !context || context.jquery ) { - return (context || rootjQuery).find( selector ); - - // HANDLE: $(expr, context) - // (which is just equivalent to: $(context).find(expr) - } else { - return jQuery( context ).find( selector ); - } - - // HANDLE: $(function) - // Shortcut for document ready - } else if ( jQuery.isFunction( selector ) ) { - return rootjQuery.ready( selector ); - } - - if (selector.selector !== undefined) { - this.selector = selector.selector; - this.context = selector.context; - } - - return jQuery.makeArray( selector, this ); - }, - - // Start with an empty selector - selector: "", - - // The current version of jQuery being used - jquery: "1.4.4", - - // The default length of a jQuery object is 0 - length: 0, - - // The number of elements contained in the matched element set - size: function() { - return this.length; - }, - - toArray: function() { - return slice.call( this, 0 ); - }, - - // Get the Nth element in the matched element set OR - // Get the whole matched element set as a clean array - get: function( num ) { - return num == null ? - - // Return a 'clean' array - this.toArray() : - - // Return just the object - ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] ); - }, - - // Take an array of elements and push it onto the stack - // (returning the new matched element set) - pushStack: function( elems, name, selector ) { - // Build a new jQuery matched element set - var ret = jQuery(); - - if ( jQuery.isArray( elems ) ) { - push.apply( ret, elems ); - - } else { - jQuery.merge( ret, elems ); - } - - // Add the old object onto the stack (as a reference) - ret.prevObject = this; - - ret.context = this.context; - - if ( name === "find" ) { - ret.selector = this.selector + (this.selector ? " " : "") + selector; - } else if ( name ) { - ret.selector = this.selector + "." + name + "(" + selector + ")"; - } - - // Return the newly-formed element set - return ret; - }, - - // Execute a callback for every element in the matched set. - // (You can seed the arguments with an array of args, but this is - // only used internally.) - each: function( callback, args ) { - return jQuery.each( this, callback, args ); - }, - - ready: function( fn ) { - // Attach the listeners - jQuery.bindReady(); - - // If the DOM is already ready - if ( jQuery.isReady ) { - // Execute the function immediately - fn.call( document, jQuery ); - - // Otherwise, remember the function for later - } else if ( readyList ) { - // Add the function to the wait list - readyList.push( fn ); - } - - return this; - }, - - eq: function( i ) { - return i === -1 ? - this.slice( i ) : - this.slice( i, +i + 1 ); - }, - - first: function() { - return this.eq( 0 ); - }, - - last: function() { - return this.eq( -1 ); - }, - - slice: function() { - return this.pushStack( slice.apply( this, arguments ), - "slice", slice.call(arguments).join(",") ); - }, - - map: function( callback ) { - return this.pushStack( jQuery.map(this, function( elem, i ) { - return callback.call( elem, i, elem ); - })); - }, - - end: function() { - return this.prevObject || jQuery(null); - }, - - // For internal use only. - // Behaves like an Array's method, not like a jQuery method. - push: push, - sort: [].sort, - splice: [].splice -}; - -// Give the init function the jQuery prototype for later instantiation -jQuery.fn.init.prototype = jQuery.fn; - -jQuery.extend = jQuery.fn.extend = function() { - var options, name, src, copy, copyIsArray, clone, - target = arguments[0] || {}, - i = 1, - length = arguments.length, - deep = false; - - // Handle a deep copy situation - if ( typeof target === "boolean" ) { - deep = target; - target = arguments[1] || {}; - // skip the boolean and the target - i = 2; - } - - // Handle case when target is a string or something (possible in deep copy) - if ( typeof target !== "object" && !jQuery.isFunction(target) ) { - target = {}; - } - - // extend jQuery itself if only one argument is passed - if ( length === i ) { - target = this; - --i; - } - - for ( ; i < length; i++ ) { - // Only deal with non-null/undefined values - if ( (options = arguments[ i ]) != null ) { - // Extend the base object - for ( name in options ) { - src = target[ name ]; - copy = options[ name ]; - - // Prevent never-ending loop - if ( target === copy ) { - continue; - } - - // Recurse if we're merging plain objects or arrays - if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { - if ( copyIsArray ) { - copyIsArray = false; - clone = src && jQuery.isArray(src) ? src : []; - - } else { - clone = src && jQuery.isPlainObject(src) ? src : {}; - } - - // Never move original objects, clone them - target[ name ] = jQuery.extend( deep, clone, copy ); - - // Don't bring in undefined values - } else if ( copy !== undefined ) { - target[ name ] = copy; - } - } - } - } - - // Return the modified object - return target; -}; - -jQuery.extend({ - noConflict: function( deep ) { - window.$ = _$; - - if ( deep ) { - window.jQuery = _jQuery; - } - - return jQuery; - }, - - // Is the DOM ready to be used? Set to true once it occurs. - isReady: false, - - // A counter to track how many items to wait for before - // the ready event fires. See #6781 - readyWait: 1, - - // Handle when the DOM is ready - ready: function( wait ) { - // A third-party is pushing the ready event forwards - if ( wait === true ) { - jQuery.readyWait--; - } - - // Make sure that the DOM is not already loaded - if ( !jQuery.readyWait || (wait !== true && !jQuery.isReady) ) { - // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). - if ( !document.body ) { - return setTimeout( jQuery.ready, 1 ); - } - - // Remember that the DOM is ready - jQuery.isReady = true; - - // If a normal DOM Ready event fired, decrement, and wait if need be - if ( wait !== true && --jQuery.readyWait > 0 ) { - return; - } - - // If there are functions bound, to execute - if ( readyList ) { - // Execute all of them - var fn, - i = 0, - ready = readyList; - - // Reset the list of functions - readyList = null; - - while ( (fn = ready[ i++ ]) ) { - fn.call( document, jQuery ); - } - - // Trigger any bound ready events - if ( jQuery.fn.trigger ) { - jQuery( document ).trigger( "ready" ).unbind( "ready" ); - } - } - } - }, - - bindReady: function() { - if ( readyBound ) { - return; - } - - readyBound = true; - - // Catch cases where $(document).ready() is called after the - // browser event has already occurred. - if ( document.readyState === "complete" ) { - // Handle it asynchronously to allow scripts the opportunity to delay ready - return setTimeout( jQuery.ready, 1 ); - } - - // Mozilla, Opera and webkit nightlies currently support this event - if ( document.addEventListener ) { - // Use the handy event callback - document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); - - // A fallback to window.onload, that will always work - window.addEventListener( "load", jQuery.ready, false ); - - // If IE event model is used - } else if ( document.attachEvent ) { - // ensure firing before onload, - // maybe late but safe also for iframes - document.attachEvent("onreadystatechange", DOMContentLoaded); - - // A fallback to window.onload, that will always work - window.attachEvent( "onload", jQuery.ready ); - - // If IE and not a frame - // continually check to see if the document is ready - var toplevel = false; - - try { - toplevel = window.frameElement == null; - } catch(e) {} - - if ( document.documentElement.doScroll && toplevel ) { - doScrollCheck(); - } - } - }, - - // See test/unit/core.js for details concerning isFunction. - // Since version 1.3, DOM methods and functions like alert - // aren't supported. They return false on IE (#2968). - isFunction: function( obj ) { - return jQuery.type(obj) === "function"; - }, - - isArray: Array.isArray || function( obj ) { - return jQuery.type(obj) === "array"; - }, - - // A crude way of determining if an object is a window - isWindow: function( obj ) { - return obj && typeof obj === "object" && "setInterval" in obj; - }, - - isNaN: function( obj ) { - return obj == null || !rdigit.test( obj ) || isNaN( obj ); - }, - - type: function( obj ) { - return obj == null ? - String( obj ) : - class2type[ toString.call(obj) ] || "object"; - }, - - isPlainObject: function( obj ) { - // Must be an Object. - // Because of IE, we also have to check the presence of the constructor property. - // Make sure that DOM nodes and window objects don't pass through, as well - if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { - return false; - } - - // Not own constructor property must be Object - if ( obj.constructor && - !hasOwn.call(obj, "constructor") && - !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { - return false; - } - - // Own properties are enumerated firstly, so to speed up, - // if last one is own, then all properties are own. - - var key; - for ( key in obj ) {} - - return key === undefined || hasOwn.call( obj, key ); - }, - - isEmptyObject: function( obj ) { - for ( var name in obj ) { - return false; - } - return true; - }, - - error: function( msg ) { - throw msg; - }, - - parseJSON: function( data ) { - if ( typeof data !== "string" || !data ) { - return null; - } - - // Make sure leading/trailing whitespace is removed (IE can't handle it) - data = jQuery.trim( data ); - - // Make sure the incoming data is actual JSON - // Logic borrowed from http://json.org/json2.js - if ( rvalidchars.test(data.replace(rvalidescape, "@") - .replace(rvalidtokens, "]") - .replace(rvalidbraces, "")) ) { - - // Try to use the native JSON parser first - return window.JSON && window.JSON.parse ? - window.JSON.parse( data ) : - (new Function("return " + data))(); - - } else { - jQuery.error( "Invalid JSON: " + data ); - } - }, - - noop: function() {}, - - // Evalulates a script in a global context - globalEval: function( data ) { - if ( data && rnotwhite.test(data) ) { - // Inspired by code by Andrea Giammarchi - // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html - var head = document.getElementsByTagName("head")[0] || document.documentElement, - script = document.createElement("script"); - - script.type = "text/javascript"; - - if ( jQuery.support.scriptEval ) { - script.appendChild( document.createTextNode( data ) ); - } else { - script.text = data; - } - - // Use insertBefore instead of appendChild to circumvent an IE6 bug. - // This arises when a base node is used (#2709). - head.insertBefore( script, head.firstChild ); - head.removeChild( script ); - } - }, - - nodeName: function( elem, name ) { - return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); - }, - - // args is for internal usage only - each: function( object, callback, args ) { - var name, i = 0, - length = object.length, - isObj = length === undefined || jQuery.isFunction(object); - - if ( args ) { - if ( isObj ) { - for ( name in object ) { - if ( callback.apply( object[ name ], args ) === false ) { - break; - } - } - } else { - for ( ; i < length; ) { - if ( callback.apply( object[ i++ ], args ) === false ) { - break; - } - } - } - - // A special, fast, case for the most common use of each - } else { - if ( isObj ) { - for ( name in object ) { - if ( callback.call( object[ name ], name, object[ name ] ) === false ) { - break; - } - } - } else { - for ( var value = object[0]; - i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {} - } - } - - return object; - }, - - // Use native String.trim function wherever possible - trim: trim ? - function( text ) { - return text == null ? - "" : - trim.call( text ); - } : - - // Otherwise use our own trimming functionality - function( text ) { - return text == null ? - "" : - text.toString().replace( trimLeft, "" ).replace( trimRight, "" ); - }, - - // results is for internal usage only - makeArray: function( array, results ) { - var ret = results || []; - - if ( array != null ) { - // The window, strings (and functions) also have 'length' - // The extra typeof function check is to prevent crashes - // in Safari 2 (See: #3039) - // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 - var type = jQuery.type(array); - - if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) { - push.call( ret, array ); - } else { - jQuery.merge( ret, array ); - } - } - - return ret; - }, - - inArray: function( elem, array ) { - if ( array.indexOf ) { - return array.indexOf( elem ); - } - - for ( var i = 0, length = array.length; i < length; i++ ) { - if ( array[ i ] === elem ) { - return i; - } - } - - return -1; - }, - - merge: function( first, second ) { - var i = first.length, - j = 0; - - if ( typeof second.length === "number" ) { - for ( var l = second.length; j < l; j++ ) { - first[ i++ ] = second[ j ]; - } - - } else { - while ( second[j] !== undefined ) { - first[ i++ ] = second[ j++ ]; - } - } - - first.length = i; - - return first; - }, - - grep: function( elems, callback, inv ) { - var ret = [], retVal; - inv = !!inv; - - // Go through the array, only saving the items - // that pass the validator function - for ( var i = 0, length = elems.length; i < length; i++ ) { - retVal = !!callback( elems[ i ], i ); - if ( inv !== retVal ) { - ret.push( elems[ i ] ); - } - } - - return ret; - }, - - // arg is for internal usage only - map: function( elems, callback, arg ) { - var ret = [], value; - - // Go through the array, translating each of the items to their - // new value (or values). - for ( var i = 0, length = elems.length; i < length; i++ ) { - value = callback( elems[ i ], i, arg ); - - if ( value != null ) { - ret[ ret.length ] = value; - } - } - - return ret.concat.apply( [], ret ); - }, - - // A global GUID counter for objects - guid: 1, - - proxy: function( fn, proxy, thisObject ) { - if ( arguments.length === 2 ) { - if ( typeof proxy === "string" ) { - thisObject = fn; - fn = thisObject[ proxy ]; - proxy = undefined; - - } else if ( proxy && !jQuery.isFunction( proxy ) ) { - thisObject = proxy; - proxy = undefined; - } - } - - if ( !proxy && fn ) { - proxy = function() { - return fn.apply( thisObject || this, arguments ); - }; - } - - // Set the guid of unique handler to the same of original handler, so it can be removed - if ( fn ) { - proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++; - } - - // So proxy can be declared as an argument - return proxy; - }, - - // Mutifunctional method to get and set values to a collection - // The value/s can be optionally by executed if its a function - access: function( elems, key, value, exec, fn, pass ) { - var length = elems.length; - - // Setting many attributes - if ( typeof key === "object" ) { - for ( var k in key ) { - jQuery.access( elems, k, key[k], exec, fn, value ); - } - return elems; - } - - // Setting one attribute - if ( value !== undefined ) { - // Optionally, function values get executed if exec is true - exec = !pass && exec && jQuery.isFunction(value); - - for ( var i = 0; i < length; i++ ) { - fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); - } - - return elems; - } - - // Getting an attribute - return length ? fn( elems[0], key ) : undefined; - }, - - now: function() { - return (new Date()).getTime(); - }, - - // Use of jQuery.browser is frowned upon. - // More details: http://docs.jquery.com/Utilities/jQuery.browser - uaMatch: function( ua ) { - ua = ua.toLowerCase(); - - var match = rwebkit.exec( ua ) || - ropera.exec( ua ) || - rmsie.exec( ua ) || - ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) || - []; - - return { browser: match[1] || "", version: match[2] || "0" }; - }, - - browser: {} -}); - -// Populate the class2type map -jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) { - class2type[ "[object " + name + "]" ] = name.toLowerCase(); -}); - -browserMatch = jQuery.uaMatch( userAgent ); -if ( browserMatch.browser ) { - jQuery.browser[ browserMatch.browser ] = true; - jQuery.browser.version = browserMatch.version; -} - -// Deprecated, use jQuery.browser.webkit instead -if ( jQuery.browser.webkit ) { - jQuery.browser.safari = true; -} - -if ( indexOf ) { - jQuery.inArray = function( elem, array ) { - return indexOf.call( array, elem ); - }; -} - -// Verify that \s matches non-breaking spaces -// (IE fails on this test) -if ( !rwhite.test( "\xA0" ) ) { - trimLeft = /^[\s\xA0]+/; - trimRight = /[\s\xA0]+$/; -} - -// All jQuery objects should point back to these -rootjQuery = jQuery(document); - -// Cleanup functions for the document ready method -if ( document.addEventListener ) { - DOMContentLoaded = function() { - document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); - jQuery.ready(); - }; - -} else if ( document.attachEvent ) { - DOMContentLoaded = function() { - // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). - if ( document.readyState === "complete" ) { - document.detachEvent( "onreadystatechange", DOMContentLoaded ); - jQuery.ready(); - } - }; -} - -// The DOM ready check for Internet Explorer -function doScrollCheck() { - if ( jQuery.isReady ) { - return; - } - - try { - // If IE is used, use the trick by Diego Perini - // http://javascript.nwbox.com/IEContentLoaded/ - document.documentElement.doScroll("left"); - } catch(e) { - setTimeout( doScrollCheck, 1 ); - return; - } - - // and execute any waiting functions - jQuery.ready(); -} - -// Expose jQuery to the global object -return (window.jQuery = window.$ = jQuery); - -})(); - - -(function() { - - jQuery.support = {}; - - var root = document.documentElement, - script = document.createElement("script"), - div = document.createElement("div"), - id = "script" + jQuery.now(); - - div.style.display = "none"; - div.innerHTML = "
      a"; - - var all = div.getElementsByTagName("*"), - a = div.getElementsByTagName("a")[0], - select = document.createElement("select"), - opt = select.appendChild( document.createElement("option") ); - - // Can't get basic test support - if ( !all || !all.length || !a ) { - return; - } - - jQuery.support = { - // IE strips leading whitespace when .innerHTML is used - leadingWhitespace: div.firstChild.nodeType === 3, - - // Make sure that tbody elements aren't automatically inserted - // IE will insert them into empty tables - tbody: !div.getElementsByTagName("tbody").length, - - // Make sure that link elements get serialized correctly by innerHTML - // This requires a wrapper element in IE - htmlSerialize: !!div.getElementsByTagName("link").length, - - // Get the style information from getAttribute - // (IE uses .cssText insted) - style: /red/.test( a.getAttribute("style") ), - - // Make sure that URLs aren't manipulated - // (IE normalizes it by default) - hrefNormalized: a.getAttribute("href") === "/a", - - // Make sure that element opacity exists - // (IE uses filter instead) - // Use a regex to work around a WebKit issue. See #5145 - opacity: /^0.55$/.test( a.style.opacity ), - - // Verify style float existence - // (IE uses styleFloat instead of cssFloat) - cssFloat: !!a.style.cssFloat, - - // Make sure that if no value is specified for a checkbox - // that it defaults to "on". - // (WebKit defaults to "" instead) - checkOn: div.getElementsByTagName("input")[0].value === "on", - - // Make sure that a selected-by-default option has a working selected property. - // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) - optSelected: opt.selected, - - // Will be defined later - deleteExpando: true, - optDisabled: false, - checkClone: false, - scriptEval: false, - noCloneEvent: true, - boxModel: null, - inlineBlockNeedsLayout: false, - shrinkWrapBlocks: false, - reliableHiddenOffsets: true - }; - - // Make sure that the options inside disabled selects aren't marked as disabled - // (WebKit marks them as diabled) - select.disabled = true; - jQuery.support.optDisabled = !opt.disabled; - - script.type = "text/javascript"; - try { - script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); - } catch(e) {} - - root.insertBefore( script, root.firstChild ); - - // Make sure that the execution of code works by injecting a script - // tag with appendChild/createTextNode - // (IE doesn't support this, fails, and uses .text instead) - if ( window[ id ] ) { - jQuery.support.scriptEval = true; - delete window[ id ]; - } - - // Test to see if it's possible to delete an expando from an element - // Fails in Internet Explorer - try { - delete script.test; - - } catch(e) { - jQuery.support.deleteExpando = false; - } - - root.removeChild( script ); - - if ( div.attachEvent && div.fireEvent ) { - div.attachEvent("onclick", function click() { - // Cloning a node shouldn't copy over any - // bound event handlers (IE does this) - jQuery.support.noCloneEvent = false; - div.detachEvent("onclick", click); - }); - div.cloneNode(true).fireEvent("onclick"); - } - - div = document.createElement("div"); - div.innerHTML = ""; - - var fragment = document.createDocumentFragment(); - fragment.appendChild( div.firstChild ); - - // WebKit doesn't clone checked state correctly in fragments - jQuery.support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked; - - // Figure out if the W3C box model works as expected - // document.body must exist before we can do this - jQuery(function() { - var div = document.createElement("div"); - div.style.width = div.style.paddingLeft = "1px"; - - document.body.appendChild( div ); - jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2; - - if ( "zoom" in div.style ) { - // Check if natively block-level elements act like inline-block - // elements when setting their display to 'inline' and giving - // them layout - // (IE < 8 does this) - div.style.display = "inline"; - div.style.zoom = 1; - jQuery.support.inlineBlockNeedsLayout = div.offsetWidth === 2; - - // Check if elements with layout shrink-wrap their children - // (IE 6 does this) - div.style.display = ""; - div.innerHTML = "
      "; - jQuery.support.shrinkWrapBlocks = div.offsetWidth !== 2; - } - - div.innerHTML = "
      t
      "; - var tds = div.getElementsByTagName("td"); - - // Check if table cells still have offsetWidth/Height when they are set - // to display:none and there are still other visible table cells in a - // table row; if so, offsetWidth/Height are not reliable for use when - // determining if an element has been hidden directly using - // display:none (it is still safe to use offsets if a parent element is - // hidden; don safety goggles and see bug #4512 for more information). - // (only IE 8 fails this test) - jQuery.support.reliableHiddenOffsets = tds[0].offsetHeight === 0; - - tds[0].style.display = ""; - tds[1].style.display = "none"; - - // Check if empty table cells still have offsetWidth/Height - // (IE < 8 fail this test) - jQuery.support.reliableHiddenOffsets = jQuery.support.reliableHiddenOffsets && tds[0].offsetHeight === 0; - div.innerHTML = ""; - - document.body.removeChild( div ).style.display = "none"; - div = tds = null; - }); - - // Technique from Juriy Zaytsev - // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/ - var eventSupported = function( eventName ) { - var el = document.createElement("div"); - eventName = "on" + eventName; - - var isSupported = (eventName in el); - if ( !isSupported ) { - el.setAttribute(eventName, "return;"); - isSupported = typeof el[eventName] === "function"; - } - el = null; - - return isSupported; - }; - - jQuery.support.submitBubbles = eventSupported("submit"); - jQuery.support.changeBubbles = eventSupported("change"); - - // release memory in IE - root = script = div = all = a = null; -})(); - - - -var windowData = {}, - rbrace = /^(?:\{.*\}|\[.*\])$/; - -jQuery.extend({ - cache: {}, - - // Please use with caution - uuid: 0, - - // Unique for each copy of jQuery on the page - expando: "jQuery" + jQuery.now(), - - // The following elements throw uncatchable exceptions if you - // attempt to add expando properties to them. - noData: { - "embed": true, - // Ban all objects except for Flash (which handle expandos) - "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", - "applet": true - }, - - data: function( elem, name, data ) { - if ( !jQuery.acceptData( elem ) ) { - return; - } - - elem = elem == window ? - windowData : - elem; - - var isNode = elem.nodeType, - id = isNode ? elem[ jQuery.expando ] : null, - cache = jQuery.cache, thisCache; - - if ( isNode && !id && typeof name === "string" && data === undefined ) { - return; - } - - // Get the data from the object directly - if ( !isNode ) { - cache = elem; - - // Compute a unique ID for the element - } else if ( !id ) { - elem[ jQuery.expando ] = id = ++jQuery.uuid; - } - - // Avoid generating a new cache unless none exists and we - // want to manipulate it. - if ( typeof name === "object" ) { - if ( isNode ) { - cache[ id ] = jQuery.extend(cache[ id ], name); - - } else { - jQuery.extend( cache, name ); - } - - } else if ( isNode && !cache[ id ] ) { - cache[ id ] = {}; - } - - thisCache = isNode ? cache[ id ] : cache; - - // Prevent overriding the named cache with undefined values - if ( data !== undefined ) { - thisCache[ name ] = data; - } - - return typeof name === "string" ? thisCache[ name ] : thisCache; - }, - - removeData: function( elem, name ) { - if ( !jQuery.acceptData( elem ) ) { - return; - } - - elem = elem == window ? - windowData : - elem; - - var isNode = elem.nodeType, - id = isNode ? elem[ jQuery.expando ] : elem, - cache = jQuery.cache, - thisCache = isNode ? cache[ id ] : id; - - // If we want to remove a specific section of the element's data - if ( name ) { - if ( thisCache ) { - // Remove the section of cache data - delete thisCache[ name ]; - - // If we've removed all the data, remove the element's cache - if ( isNode && jQuery.isEmptyObject(thisCache) ) { - jQuery.removeData( elem ); - } - } - - // Otherwise, we want to remove all of the element's data - } else { - if ( isNode && jQuery.support.deleteExpando ) { - delete elem[ jQuery.expando ]; - - } else if ( elem.removeAttribute ) { - elem.removeAttribute( jQuery.expando ); - - // Completely remove the data cache - } else if ( isNode ) { - delete cache[ id ]; - - // Remove all fields from the object - } else { - for ( var n in elem ) { - delete elem[ n ]; - } - } - } - }, - - // A method for determining if a DOM node can handle the data expando - acceptData: function( elem ) { - if ( elem.nodeName ) { - var match = jQuery.noData[ elem.nodeName.toLowerCase() ]; - - if ( match ) { - return !(match === true || elem.getAttribute("classid") !== match); - } - } - - return true; - } -}); - -jQuery.fn.extend({ - data: function( key, value ) { - var data = null; - - if ( typeof key === "undefined" ) { - if ( this.length ) { - var attr = this[0].attributes, name; - data = jQuery.data( this[0] ); - - for ( var i = 0, l = attr.length; i < l; i++ ) { - name = attr[i].name; - - if ( name.indexOf( "data-" ) === 0 ) { - name = name.substr( 5 ); - dataAttr( this[0], name, data[ name ] ); - } - } - } - - return data; - - } else if ( typeof key === "object" ) { - return this.each(function() { - jQuery.data( this, key ); - }); - } - - var parts = key.split("."); - parts[1] = parts[1] ? "." + parts[1] : ""; - - if ( value === undefined ) { - data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); - - // Try to fetch any internally stored data first - if ( data === undefined && this.length ) { - data = jQuery.data( this[0], key ); - data = dataAttr( this[0], key, data ); - } - - return data === undefined && parts[1] ? - this.data( parts[0] ) : - data; - - } else { - return this.each(function() { - var $this = jQuery( this ), - args = [ parts[0], value ]; - - $this.triggerHandler( "setData" + parts[1] + "!", args ); - jQuery.data( this, key, value ); - $this.triggerHandler( "changeData" + parts[1] + "!", args ); - }); - } - }, - - removeData: function( key ) { - return this.each(function() { - jQuery.removeData( this, key ); - }); - } -}); - -function dataAttr( elem, key, data ) { - // If nothing was found internally, try to fetch any - // data from the HTML5 data-* attribute - if ( data === undefined && elem.nodeType === 1 ) { - data = elem.getAttribute( "data-" + key ); - - if ( typeof data === "string" ) { - try { - data = data === "true" ? true : - data === "false" ? false : - data === "null" ? null : - !jQuery.isNaN( data ) ? parseFloat( data ) : - rbrace.test( data ) ? jQuery.parseJSON( data ) : - data; - } catch( e ) {} - - // Make sure we set the data so it isn't changed later - jQuery.data( elem, key, data ); - - } else { - data = undefined; - } - } - - return data; -} - - - - -jQuery.extend({ - queue: function( elem, type, data ) { - if ( !elem ) { - return; - } - - type = (type || "fx") + "queue"; - var q = jQuery.data( elem, type ); - - // Speed up dequeue by getting out quickly if this is just a lookup - if ( !data ) { - return q || []; - } - - if ( !q || jQuery.isArray(data) ) { - q = jQuery.data( elem, type, jQuery.makeArray(data) ); - - } else { - q.push( data ); - } - - return q; - }, - - dequeue: function( elem, type ) { - type = type || "fx"; - - var queue = jQuery.queue( elem, type ), - fn = queue.shift(); - - // If the fx queue is dequeued, always remove the progress sentinel - if ( fn === "inprogress" ) { - fn = queue.shift(); - } - - if ( fn ) { - // Add a progress sentinel to prevent the fx queue from being - // automatically dequeued - if ( type === "fx" ) { - queue.unshift("inprogress"); - } - - fn.call(elem, function() { - jQuery.dequeue(elem, type); - }); - } - } -}); - -jQuery.fn.extend({ - queue: function( type, data ) { - if ( typeof type !== "string" ) { - data = type; - type = "fx"; - } - - if ( data === undefined ) { - return jQuery.queue( this[0], type ); - } - return this.each(function( i ) { - var queue = jQuery.queue( this, type, data ); - - if ( type === "fx" && queue[0] !== "inprogress" ) { - jQuery.dequeue( this, type ); - } - }); - }, - dequeue: function( type ) { - return this.each(function() { - jQuery.dequeue( this, type ); - }); - }, - - // Based off of the plugin by Clint Helfers, with permission. - // http://blindsignals.com/index.php/2009/07/jquery-delay/ - delay: function( time, type ) { - time = jQuery.fx ? jQuery.fx.speeds[time] || time : time; - type = type || "fx"; - - return this.queue( type, function() { - var elem = this; - setTimeout(function() { - jQuery.dequeue( elem, type ); - }, time ); - }); - }, - - clearQueue: function( type ) { - return this.queue( type || "fx", [] ); - } -}); - - - - -var rclass = /[\n\t]/g, - rspaces = /\s+/, - rreturn = /\r/g, - rspecialurl = /^(?:href|src|style)$/, - rtype = /^(?:button|input)$/i, - rfocusable = /^(?:button|input|object|select|textarea)$/i, - rclickable = /^a(?:rea)?$/i, - rradiocheck = /^(?:radio|checkbox)$/i; - -jQuery.props = { - "for": "htmlFor", - "class": "className", - readonly: "readOnly", - maxlength: "maxLength", - cellspacing: "cellSpacing", - rowspan: "rowSpan", - colspan: "colSpan", - tabindex: "tabIndex", - usemap: "useMap", - frameborder: "frameBorder" -}; - -jQuery.fn.extend({ - attr: function( name, value ) { - return jQuery.access( this, name, value, true, jQuery.attr ); - }, - - removeAttr: function( name, fn ) { - return this.each(function(){ - jQuery.attr( this, name, "" ); - if ( this.nodeType === 1 ) { - this.removeAttribute( name ); - } - }); - }, - - addClass: function( value ) { - if ( jQuery.isFunction(value) ) { - return this.each(function(i) { - var self = jQuery(this); - self.addClass( value.call(this, i, self.attr("class")) ); - }); - } - - if ( value && typeof value === "string" ) { - var classNames = (value || "").split( rspaces ); - - for ( var i = 0, l = this.length; i < l; i++ ) { - var elem = this[i]; - - if ( elem.nodeType === 1 ) { - if ( !elem.className ) { - elem.className = value; - - } else { - var className = " " + elem.className + " ", - setClass = elem.className; - - for ( var c = 0, cl = classNames.length; c < cl; c++ ) { - if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) { - setClass += " " + classNames[c]; - } - } - elem.className = jQuery.trim( setClass ); - } - } - } - } - - return this; - }, - - removeClass: function( value ) { - if ( jQuery.isFunction(value) ) { - return this.each(function(i) { - var self = jQuery(this); - self.removeClass( value.call(this, i, self.attr("class")) ); - }); - } - - if ( (value && typeof value === "string") || value === undefined ) { - var classNames = (value || "").split( rspaces ); - - for ( var i = 0, l = this.length; i < l; i++ ) { - var elem = this[i]; - - if ( elem.nodeType === 1 && elem.className ) { - if ( value ) { - var className = (" " + elem.className + " ").replace(rclass, " "); - for ( var c = 0, cl = classNames.length; c < cl; c++ ) { - className = className.replace(" " + classNames[c] + " ", " "); - } - elem.className = jQuery.trim( className ); - - } else { - elem.className = ""; - } - } - } - } - - return this; - }, - - toggleClass: function( value, stateVal ) { - var type = typeof value, - isBool = typeof stateVal === "boolean"; - - if ( jQuery.isFunction( value ) ) { - return this.each(function(i) { - var self = jQuery(this); - self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal ); - }); - } - - return this.each(function() { - if ( type === "string" ) { - // toggle individual class names - var className, - i = 0, - self = jQuery( this ), - state = stateVal, - classNames = value.split( rspaces ); - - while ( (className = classNames[ i++ ]) ) { - // check each className given, space seperated list - state = isBool ? state : !self.hasClass( className ); - self[ state ? "addClass" : "removeClass" ]( className ); - } - - } else if ( type === "undefined" || type === "boolean" ) { - if ( this.className ) { - // store className if set - jQuery.data( this, "__className__", this.className ); - } - - // toggle whole className - this.className = this.className || value === false ? "" : jQuery.data( this, "__className__" ) || ""; - } - }); - }, - - hasClass: function( selector ) { - var className = " " + selector + " "; - for ( var i = 0, l = this.length; i < l; i++ ) { - if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) { - return true; - } - } - - return false; - }, - - val: function( value ) { - if ( !arguments.length ) { - var elem = this[0]; - - if ( elem ) { - if ( jQuery.nodeName( elem, "option" ) ) { - // attributes.value is undefined in Blackberry 4.7 but - // uses .value. See #6932 - var val = elem.attributes.value; - return !val || val.specified ? elem.value : elem.text; - } - - // We need to handle select boxes special - if ( jQuery.nodeName( elem, "select" ) ) { - var index = elem.selectedIndex, - values = [], - options = elem.options, - one = elem.type === "select-one"; - - // Nothing was selected - if ( index < 0 ) { - return null; - } - - // Loop through all the selected options - for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { - var option = options[ i ]; - - // Don't return options that are disabled or in a disabled optgroup - if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && - (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { - - // Get the specific value for the option - value = jQuery(option).val(); - - // We don't need an array for one selects - if ( one ) { - return value; - } - - // Multi-Selects return an array - values.push( value ); - } - } - - return values; - } - - // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified - if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) { - return elem.getAttribute("value") === null ? "on" : elem.value; - } - - - // Everything else, we just grab the value - return (elem.value || "").replace(rreturn, ""); - - } - - return undefined; - } - - var isFunction = jQuery.isFunction(value); - - return this.each(function(i) { - var self = jQuery(this), val = value; - - if ( this.nodeType !== 1 ) { - return; - } - - if ( isFunction ) { - val = value.call(this, i, self.val()); - } - - // Treat null/undefined as ""; convert numbers to string - if ( val == null ) { - val = ""; - } else if ( typeof val === "number" ) { - val += ""; - } else if ( jQuery.isArray(val) ) { - val = jQuery.map(val, function (value) { - return value == null ? "" : value + ""; - }); - } - - if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) { - this.checked = jQuery.inArray( self.val(), val ) >= 0; - - } else if ( jQuery.nodeName( this, "select" ) ) { - var values = jQuery.makeArray(val); - - jQuery( "option", this ).each(function() { - this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0; - }); - - if ( !values.length ) { - this.selectedIndex = -1; - } - - } else { - this.value = val; - } - }); - } -}); - -jQuery.extend({ - attrFn: { - val: true, - css: true, - html: true, - text: true, - data: true, - width: true, - height: true, - offset: true - }, - - attr: function( elem, name, value, pass ) { - // don't set attributes on text and comment nodes - if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) { - return undefined; - } - - if ( pass && name in jQuery.attrFn ) { - return jQuery(elem)[name](value); - } - - var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ), - // Whether we are setting (or getting) - set = value !== undefined; - - // Try to normalize/fix the name - name = notxml && jQuery.props[ name ] || name; - - // These attributes require special treatment - var special = rspecialurl.test( name ); - - // Safari mis-reports the default selected property of an option - // Accessing the parent's selectedIndex property fixes it - if ( name === "selected" && !jQuery.support.optSelected ) { - var parent = elem.parentNode; - if ( parent ) { - parent.selectedIndex; - - // Make sure that it also works with optgroups, see #5701 - if ( parent.parentNode ) { - parent.parentNode.selectedIndex; - } - } - } - - // If applicable, access the attribute via the DOM 0 way - // 'in' checks fail in Blackberry 4.7 #6931 - if ( (name in elem || elem[ name ] !== undefined) && notxml && !special ) { - if ( set ) { - // We can't allow the type property to be changed (since it causes problems in IE) - if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) { - jQuery.error( "type property can't be changed" ); - } - - if ( value === null ) { - if ( elem.nodeType === 1 ) { - elem.removeAttribute( name ); - } - - } else { - elem[ name ] = value; - } - } - - // browsers index elements by id/name on forms, give priority to attributes. - if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) { - return elem.getAttributeNode( name ).nodeValue; - } - - // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set - // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ - if ( name === "tabIndex" ) { - var attributeNode = elem.getAttributeNode( "tabIndex" ); - - return attributeNode && attributeNode.specified ? - attributeNode.value : - rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? - 0 : - undefined; - } - - return elem[ name ]; - } - - if ( !jQuery.support.style && notxml && name === "style" ) { - if ( set ) { - elem.style.cssText = "" + value; - } - - return elem.style.cssText; - } - - if ( set ) { - // convert the value to a string (all browsers do this but IE) see #1070 - elem.setAttribute( name, "" + value ); - } - - // Ensure that missing attributes return undefined - // Blackberry 4.7 returns "" from getAttribute #6938 - if ( !elem.attributes[ name ] && (elem.hasAttribute && !elem.hasAttribute( name )) ) { - return undefined; - } - - var attr = !jQuery.support.hrefNormalized && notxml && special ? - // Some attributes require a special call on IE - elem.getAttribute( name, 2 ) : - elem.getAttribute( name ); - - // Non-existent attributes return null, we normalize to undefined - return attr === null ? undefined : attr; - } -}); - - - - -var rnamespaces = /\.(.*)$/, - rformElems = /^(?:textarea|input|select)$/i, - rperiod = /\./g, - rspace = / /g, - rescape = /[^\w\s.|`]/g, - fcleanup = function( nm ) { - return nm.replace(rescape, "\\$&"); - }, - focusCounts = { focusin: 0, focusout: 0 }; - -/* - * A number of helper functions used for managing events. - * Many of the ideas behind this code originated from - * Dean Edwards' addEvent library. - */ -jQuery.event = { - - // Bind an event to an element - // Original by Dean Edwards - add: function( elem, types, handler, data ) { - if ( elem.nodeType === 3 || elem.nodeType === 8 ) { - return; - } - - // For whatever reason, IE has trouble passing the window object - // around, causing it to be cloned in the process - if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) { - elem = window; - } - - if ( handler === false ) { - handler = returnFalse; - } else if ( !handler ) { - // Fixes bug #7229. Fix recommended by jdalton - return; - } - - var handleObjIn, handleObj; - - if ( handler.handler ) { - handleObjIn = handler; - handler = handleObjIn.handler; - } - - // Make sure that the function being executed has a unique ID - if ( !handler.guid ) { - handler.guid = jQuery.guid++; - } - - // Init the element's event structure - var elemData = jQuery.data( elem ); - - // If no elemData is found then we must be trying to bind to one of the - // banned noData elements - if ( !elemData ) { - return; - } - - // Use a key less likely to result in collisions for plain JS objects. - // Fixes bug #7150. - var eventKey = elem.nodeType ? "events" : "__events__", - events = elemData[ eventKey ], - eventHandle = elemData.handle; - - if ( typeof events === "function" ) { - // On plain objects events is a fn that holds the the data - // which prevents this data from being JSON serialized - // the function does not need to be called, it just contains the data - eventHandle = events.handle; - events = events.events; - - } else if ( !events ) { - if ( !elem.nodeType ) { - // On plain objects, create a fn that acts as the holder - // of the values to avoid JSON serialization of event data - elemData[ eventKey ] = elemData = function(){}; - } - - elemData.events = events = {}; - } - - if ( !eventHandle ) { - elemData.handle = eventHandle = function() { - // Handle the second event of a trigger and when - // an event is called after a page has unloaded - return typeof jQuery !== "undefined" && !jQuery.event.triggered ? - jQuery.event.handle.apply( eventHandle.elem, arguments ) : - undefined; - }; - } - - // Add elem as a property of the handle function - // This is to prevent a memory leak with non-native events in IE. - eventHandle.elem = elem; - - // Handle multiple events separated by a space - // jQuery(...).bind("mouseover mouseout", fn); - types = types.split(" "); - - var type, i = 0, namespaces; - - while ( (type = types[ i++ ]) ) { - handleObj = handleObjIn ? - jQuery.extend({}, handleObjIn) : - { handler: handler, data: data }; - - // Namespaced event handlers - if ( type.indexOf(".") > -1 ) { - namespaces = type.split("."); - type = namespaces.shift(); - handleObj.namespace = namespaces.slice(0).sort().join("."); - - } else { - namespaces = []; - handleObj.namespace = ""; - } - - handleObj.type = type; - if ( !handleObj.guid ) { - handleObj.guid = handler.guid; - } - - // Get the current list of functions bound to this event - var handlers = events[ type ], - special = jQuery.event.special[ type ] || {}; - - // Init the event handler queue - if ( !handlers ) { - handlers = events[ type ] = []; - - // Check for a special event handler - // Only use addEventListener/attachEvent if the special - // events handler returns false - if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { - // Bind the global event handler to the element - if ( elem.addEventListener ) { - elem.addEventListener( type, eventHandle, false ); - - } else if ( elem.attachEvent ) { - elem.attachEvent( "on" + type, eventHandle ); - } - } - } - - if ( special.add ) { - special.add.call( elem, handleObj ); - - if ( !handleObj.handler.guid ) { - handleObj.handler.guid = handler.guid; - } - } - - // Add the function to the element's handler list - handlers.push( handleObj ); - - // Keep track of which events have been used, for global triggering - jQuery.event.global[ type ] = true; - } - - // Nullify elem to prevent memory leaks in IE - elem = null; - }, - - global: {}, - - // Detach an event or set of events from an element - remove: function( elem, types, handler, pos ) { - // don't do events on text and comment nodes - if ( elem.nodeType === 3 || elem.nodeType === 8 ) { - return; - } - - if ( handler === false ) { - handler = returnFalse; - } - - var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType, - eventKey = elem.nodeType ? "events" : "__events__", - elemData = jQuery.data( elem ), - events = elemData && elemData[ eventKey ]; - - if ( !elemData || !events ) { - return; - } - - if ( typeof events === "function" ) { - elemData = events; - events = events.events; - } - - // types is actually an event object here - if ( types && types.type ) { - handler = types.handler; - types = types.type; - } - - // Unbind all events for the element - if ( !types || typeof types === "string" && types.charAt(0) === "." ) { - types = types || ""; - - for ( type in events ) { - jQuery.event.remove( elem, type + types ); - } - - return; - } - - // Handle multiple events separated by a space - // jQuery(...).unbind("mouseover mouseout", fn); - types = types.split(" "); - - while ( (type = types[ i++ ]) ) { - origType = type; - handleObj = null; - all = type.indexOf(".") < 0; - namespaces = []; - - if ( !all ) { - // Namespaced event handlers - namespaces = type.split("."); - type = namespaces.shift(); - - namespace = new RegExp("(^|\\.)" + - jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)"); - } - - eventType = events[ type ]; - - if ( !eventType ) { - continue; - } - - if ( !handler ) { - for ( j = 0; j < eventType.length; j++ ) { - handleObj = eventType[ j ]; - - if ( all || namespace.test( handleObj.namespace ) ) { - jQuery.event.remove( elem, origType, handleObj.handler, j ); - eventType.splice( j--, 1 ); - } - } - - continue; - } - - special = jQuery.event.special[ type ] || {}; - - for ( j = pos || 0; j < eventType.length; j++ ) { - handleObj = eventType[ j ]; - - if ( handler.guid === handleObj.guid ) { - // remove the given handler for the given type - if ( all || namespace.test( handleObj.namespace ) ) { - if ( pos == null ) { - eventType.splice( j--, 1 ); - } - - if ( special.remove ) { - special.remove.call( elem, handleObj ); - } - } - - if ( pos != null ) { - break; - } - } - } - - // remove generic event handler if no more handlers exist - if ( eventType.length === 0 || pos != null && eventType.length === 1 ) { - if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { - jQuery.removeEvent( elem, type, elemData.handle ); - } - - ret = null; - delete events[ type ]; - } - } - - // Remove the expando if it's no longer used - if ( jQuery.isEmptyObject( events ) ) { - var handle = elemData.handle; - if ( handle ) { - handle.elem = null; - } - - delete elemData.events; - delete elemData.handle; - - if ( typeof elemData === "function" ) { - jQuery.removeData( elem, eventKey ); - - } else if ( jQuery.isEmptyObject( elemData ) ) { - jQuery.removeData( elem ); - } - } - }, - - // bubbling is internal - trigger: function( event, data, elem /*, bubbling */ ) { - // Event object or event type - var type = event.type || event, - bubbling = arguments[3]; - - if ( !bubbling ) { - event = typeof event === "object" ? - // jQuery.Event object - event[ jQuery.expando ] ? event : - // Object literal - jQuery.extend( jQuery.Event(type), event ) : - // Just the event type (string) - jQuery.Event(type); - - if ( type.indexOf("!") >= 0 ) { - event.type = type = type.slice(0, -1); - event.exclusive = true; - } - - // Handle a global trigger - if ( !elem ) { - // Don't bubble custom events when global (to avoid too much overhead) - event.stopPropagation(); - - // Only trigger if we've ever bound an event for it - if ( jQuery.event.global[ type ] ) { - jQuery.each( jQuery.cache, function() { - if ( this.events && this.events[type] ) { - jQuery.event.trigger( event, data, this.handle.elem ); - } - }); - } - } - - // Handle triggering a single element - - // don't do events on text and comment nodes - if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) { - return undefined; - } - - // Clean up in case it is reused - event.result = undefined; - event.target = elem; - - // Clone the incoming data, if any - data = jQuery.makeArray( data ); - data.unshift( event ); - } - - event.currentTarget = elem; - - // Trigger the event, it is assumed that "handle" is a function - var handle = elem.nodeType ? - jQuery.data( elem, "handle" ) : - (jQuery.data( elem, "__events__" ) || {}).handle; - - if ( handle ) { - handle.apply( elem, data ); - } - - var parent = elem.parentNode || elem.ownerDocument; - - // Trigger an inline bound script - try { - if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) { - if ( elem[ "on" + type ] && elem[ "on" + type ].apply( elem, data ) === false ) { - event.result = false; - event.preventDefault(); - } - } - - // prevent IE from throwing an error for some elements with some event types, see #3533 - } catch (inlineError) {} - - if ( !event.isPropagationStopped() && parent ) { - jQuery.event.trigger( event, data, parent, true ); - - } else if ( !event.isDefaultPrevented() ) { - var old, - target = event.target, - targetType = type.replace( rnamespaces, "" ), - isClick = jQuery.nodeName( target, "a" ) && targetType === "click", - special = jQuery.event.special[ targetType ] || {}; - - if ( (!special._default || special._default.call( elem, event ) === false) && - !isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) { - - try { - if ( target[ targetType ] ) { - // Make sure that we don't accidentally re-trigger the onFOO events - old = target[ "on" + targetType ]; - - if ( old ) { - target[ "on" + targetType ] = null; - } - - jQuery.event.triggered = true; - target[ targetType ](); - } - - // prevent IE from throwing an error for some elements with some event types, see #3533 - } catch (triggerError) {} - - if ( old ) { - target[ "on" + targetType ] = old; - } - - jQuery.event.triggered = false; - } - } - }, - - handle: function( event ) { - var all, handlers, namespaces, namespace_re, events, - namespace_sort = [], - args = jQuery.makeArray( arguments ); - - event = args[0] = jQuery.event.fix( event || window.event ); - event.currentTarget = this; - - // Namespaced event handlers - all = event.type.indexOf(".") < 0 && !event.exclusive; - - if ( !all ) { - namespaces = event.type.split("."); - event.type = namespaces.shift(); - namespace_sort = namespaces.slice(0).sort(); - namespace_re = new RegExp("(^|\\.)" + namespace_sort.join("\\.(?:.*\\.)?") + "(\\.|$)"); - } - - event.namespace = event.namespace || namespace_sort.join("."); - - events = jQuery.data(this, this.nodeType ? "events" : "__events__"); - - if ( typeof events === "function" ) { - events = events.events; - } - - handlers = (events || {})[ event.type ]; - - if ( events && handlers ) { - // Clone the handlers to prevent manipulation - handlers = handlers.slice(0); - - for ( var j = 0, l = handlers.length; j < l; j++ ) { - var handleObj = handlers[ j ]; - - // Filter the functions by class - if ( all || namespace_re.test( handleObj.namespace ) ) { - // Pass in a reference to the handler function itself - // So that we can later remove it - event.handler = handleObj.handler; - event.data = handleObj.data; - event.handleObj = handleObj; - - var ret = handleObj.handler.apply( this, args ); - - if ( ret !== undefined ) { - event.result = ret; - if ( ret === false ) { - event.preventDefault(); - event.stopPropagation(); - } - } - - if ( event.isImmediatePropagationStopped() ) { - break; - } - } - } - } - - return event.result; - }, - - props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "), - - fix: function( event ) { - if ( event[ jQuery.expando ] ) { - return event; - } - - // store a copy of the original event object - // and "clone" to set read-only properties - var originalEvent = event; - event = jQuery.Event( originalEvent ); - - for ( var i = this.props.length, prop; i; ) { - prop = this.props[ --i ]; - event[ prop ] = originalEvent[ prop ]; - } - - // Fix target property, if necessary - if ( !event.target ) { - // Fixes #1925 where srcElement might not be defined either - event.target = event.srcElement || document; - } - - // check if target is a textnode (safari) - if ( event.target.nodeType === 3 ) { - event.target = event.target.parentNode; - } - - // Add relatedTarget, if necessary - if ( !event.relatedTarget && event.fromElement ) { - event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement; - } - - // Calculate pageX/Y if missing and clientX/Y available - if ( event.pageX == null && event.clientX != null ) { - var doc = document.documentElement, - body = document.body; - - event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0); - event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); - } - - // Add which for key events - if ( event.which == null && (event.charCode != null || event.keyCode != null) ) { - event.which = event.charCode != null ? event.charCode : event.keyCode; - } - - // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs) - if ( !event.metaKey && event.ctrlKey ) { - event.metaKey = event.ctrlKey; - } - - // Add which for click: 1 === left; 2 === middle; 3 === right - // Note: button is not normalized, so don't use it - if ( !event.which && event.button !== undefined ) { - event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) )); - } - - return event; - }, - - // Deprecated, use jQuery.guid instead - guid: 1E8, - - // Deprecated, use jQuery.proxy instead - proxy: jQuery.proxy, - - special: { - ready: { - // Make sure the ready event is setup - setup: jQuery.bindReady, - teardown: jQuery.noop - }, - - live: { - add: function( handleObj ) { - jQuery.event.add( this, - liveConvert( handleObj.origType, handleObj.selector ), - jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) ); - }, - - remove: function( handleObj ) { - jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj ); - } - }, - - beforeunload: { - setup: function( data, namespaces, eventHandle ) { - // We only want to do this special case on windows - if ( jQuery.isWindow( this ) ) { - this.onbeforeunload = eventHandle; - } - }, - - teardown: function( namespaces, eventHandle ) { - if ( this.onbeforeunload === eventHandle ) { - this.onbeforeunload = null; - } - } - } - } -}; - -jQuery.removeEvent = document.removeEventListener ? - function( elem, type, handle ) { - if ( elem.removeEventListener ) { - elem.removeEventListener( type, handle, false ); - } - } : - function( elem, type, handle ) { - if ( elem.detachEvent ) { - elem.detachEvent( "on" + type, handle ); - } - }; - -jQuery.Event = function( src ) { - // Allow instantiation without the 'new' keyword - if ( !this.preventDefault ) { - return new jQuery.Event( src ); - } - - // Event object - if ( src && src.type ) { - this.originalEvent = src; - this.type = src.type; - // Event type - } else { - this.type = src; - } - - // timeStamp is buggy for some events on Firefox(#3843) - // So we won't rely on the native value - this.timeStamp = jQuery.now(); - - // Mark it as fixed - this[ jQuery.expando ] = true; -}; - -function returnFalse() { - return false; -} -function returnTrue() { - return true; -} - -// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding -// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html -jQuery.Event.prototype = { - preventDefault: function() { - this.isDefaultPrevented = returnTrue; - - var e = this.originalEvent; - if ( !e ) { - return; - } - - // if preventDefault exists run it on the original event - if ( e.preventDefault ) { - e.preventDefault(); - - // otherwise set the returnValue property of the original event to false (IE) - } else { - e.returnValue = false; - } - }, - stopPropagation: function() { - this.isPropagationStopped = returnTrue; - - var e = this.originalEvent; - if ( !e ) { - return; - } - // if stopPropagation exists run it on the original event - if ( e.stopPropagation ) { - e.stopPropagation(); - } - // otherwise set the cancelBubble property of the original event to true (IE) - e.cancelBubble = true; - }, - stopImmediatePropagation: function() { - this.isImmediatePropagationStopped = returnTrue; - this.stopPropagation(); - }, - isDefaultPrevented: returnFalse, - isPropagationStopped: returnFalse, - isImmediatePropagationStopped: returnFalse -}; - -// Checks if an event happened on an element within another element -// Used in jQuery.event.special.mouseenter and mouseleave handlers -var withinElement = function( event ) { - // Check if mouse(over|out) are still within the same parent element - var parent = event.relatedTarget; - - // Firefox sometimes assigns relatedTarget a XUL element - // which we cannot access the parentNode property of - try { - // Traverse up the tree - while ( parent && parent !== this ) { - parent = parent.parentNode; - } - - if ( parent !== this ) { - // set the correct event type - event.type = event.data; - - // handle event if we actually just moused on to a non sub-element - jQuery.event.handle.apply( this, arguments ); - } - - // assuming we've left the element since we most likely mousedover a xul element - } catch(e) { } -}, - -// In case of event delegation, we only need to rename the event.type, -// liveHandler will take care of the rest. -delegate = function( event ) { - event.type = event.data; - jQuery.event.handle.apply( this, arguments ); -}; - -// Create mouseenter and mouseleave events -jQuery.each({ - mouseenter: "mouseover", - mouseleave: "mouseout" -}, function( orig, fix ) { - jQuery.event.special[ orig ] = { - setup: function( data ) { - jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig ); - }, - teardown: function( data ) { - jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement ); - } - }; -}); - -// submit delegation -if ( !jQuery.support.submitBubbles ) { - - jQuery.event.special.submit = { - setup: function( data, namespaces ) { - if ( this.nodeName.toLowerCase() !== "form" ) { - jQuery.event.add(this, "click.specialSubmit", function( e ) { - var elem = e.target, - type = elem.type; - - if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) { - e.liveFired = undefined; - return trigger( "submit", this, arguments ); - } - }); - - jQuery.event.add(this, "keypress.specialSubmit", function( e ) { - var elem = e.target, - type = elem.type; - - if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) { - e.liveFired = undefined; - return trigger( "submit", this, arguments ); - } - }); - - } else { - return false; - } - }, - - teardown: function( namespaces ) { - jQuery.event.remove( this, ".specialSubmit" ); - } - }; - -} - -// change delegation, happens here so we have bind. -if ( !jQuery.support.changeBubbles ) { - - var changeFilters, - - getVal = function( elem ) { - var type = elem.type, val = elem.value; - - if ( type === "radio" || type === "checkbox" ) { - val = elem.checked; - - } else if ( type === "select-multiple" ) { - val = elem.selectedIndex > -1 ? - jQuery.map( elem.options, function( elem ) { - return elem.selected; - }).join("-") : - ""; - - } else if ( elem.nodeName.toLowerCase() === "select" ) { - val = elem.selectedIndex; - } - - return val; - }, - - testChange = function testChange( e ) { - var elem = e.target, data, val; - - if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) { - return; - } - - data = jQuery.data( elem, "_change_data" ); - val = getVal(elem); - - // the current data will be also retrieved by beforeactivate - if ( e.type !== "focusout" || elem.type !== "radio" ) { - jQuery.data( elem, "_change_data", val ); - } - - if ( data === undefined || val === data ) { - return; - } - - if ( data != null || val ) { - e.type = "change"; - e.liveFired = undefined; - return jQuery.event.trigger( e, arguments[1], elem ); - } - }; - - jQuery.event.special.change = { - filters: { - focusout: testChange, - - beforedeactivate: testChange, - - click: function( e ) { - var elem = e.target, type = elem.type; - - if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) { - return testChange.call( this, e ); - } - }, - - // Change has to be called before submit - // Keydown will be called before keypress, which is used in submit-event delegation - keydown: function( e ) { - var elem = e.target, type = elem.type; - - if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") || - (e.keyCode === 32 && (type === "checkbox" || type === "radio")) || - type === "select-multiple" ) { - return testChange.call( this, e ); - } - }, - - // Beforeactivate happens also before the previous element is blurred - // with this event you can't trigger a change event, but you can store - // information - beforeactivate: function( e ) { - var elem = e.target; - jQuery.data( elem, "_change_data", getVal(elem) ); - } - }, - - setup: function( data, namespaces ) { - if ( this.type === "file" ) { - return false; - } - - for ( var type in changeFilters ) { - jQuery.event.add( this, type + ".specialChange", changeFilters[type] ); - } - - return rformElems.test( this.nodeName ); - }, - - teardown: function( namespaces ) { - jQuery.event.remove( this, ".specialChange" ); - - return rformElems.test( this.nodeName ); - } - }; - - changeFilters = jQuery.event.special.change.filters; - - // Handle when the input is .focus()'d - changeFilters.focus = changeFilters.beforeactivate; -} - -function trigger( type, elem, args ) { - args[0].type = type; - return jQuery.event.handle.apply( elem, args ); -} - -// Create "bubbling" focus and blur events -if ( document.addEventListener ) { - jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { - jQuery.event.special[ fix ] = { - setup: function() { - if ( focusCounts[fix]++ === 0 ) { - document.addEventListener( orig, handler, true ); - } - }, - teardown: function() { - if ( --focusCounts[fix] === 0 ) { - document.removeEventListener( orig, handler, true ); - } - } - }; - - function handler( e ) { - e = jQuery.event.fix( e ); - e.type = fix; - return jQuery.event.trigger( e, null, e.target ); - } - }); -} - -jQuery.each(["bind", "one"], function( i, name ) { - jQuery.fn[ name ] = function( type, data, fn ) { - // Handle object literals - if ( typeof type === "object" ) { - for ( var key in type ) { - this[ name ](key, data, type[key], fn); - } - return this; - } - - if ( jQuery.isFunction( data ) || data === false ) { - fn = data; - data = undefined; - } - - var handler = name === "one" ? jQuery.proxy( fn, function( event ) { - jQuery( this ).unbind( event, handler ); - return fn.apply( this, arguments ); - }) : fn; - - if ( type === "unload" && name !== "one" ) { - this.one( type, data, fn ); - - } else { - for ( var i = 0, l = this.length; i < l; i++ ) { - jQuery.event.add( this[i], type, handler, data ); - } - } - - return this; - }; -}); - -jQuery.fn.extend({ - unbind: function( type, fn ) { - // Handle object literals - if ( typeof type === "object" && !type.preventDefault ) { - for ( var key in type ) { - this.unbind(key, type[key]); - } - - } else { - for ( var i = 0, l = this.length; i < l; i++ ) { - jQuery.event.remove( this[i], type, fn ); - } - } - - return this; - }, - - delegate: function( selector, types, data, fn ) { - return this.live( types, data, fn, selector ); - }, - - undelegate: function( selector, types, fn ) { - if ( arguments.length === 0 ) { - return this.unbind( "live" ); - - } else { - return this.die( types, null, fn, selector ); - } - }, - - trigger: function( type, data ) { - return this.each(function() { - jQuery.event.trigger( type, data, this ); - }); - }, - - triggerHandler: function( type, data ) { - if ( this[0] ) { - var event = jQuery.Event( type ); - event.preventDefault(); - event.stopPropagation(); - jQuery.event.trigger( event, data, this[0] ); - return event.result; - } - }, - - toggle: function( fn ) { - // Save reference to arguments for access in closure - var args = arguments, - i = 1; - - // link all the functions, so any of them can unbind this click handler - while ( i < args.length ) { - jQuery.proxy( fn, args[ i++ ] ); - } - - return this.click( jQuery.proxy( fn, function( event ) { - // Figure out which function to execute - var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i; - jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 ); - - // Make sure that clicks stop - event.preventDefault(); - - // and execute the function - return args[ lastToggle ].apply( this, arguments ) || false; - })); - }, - - hover: function( fnOver, fnOut ) { - return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); - } -}); - -var liveMap = { - focus: "focusin", - blur: "focusout", - mouseenter: "mouseover", - mouseleave: "mouseout" -}; - -jQuery.each(["live", "die"], function( i, name ) { - jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) { - var type, i = 0, match, namespaces, preType, - selector = origSelector || this.selector, - context = origSelector ? this : jQuery( this.context ); - - if ( typeof types === "object" && !types.preventDefault ) { - for ( var key in types ) { - context[ name ]( key, data, types[key], selector ); - } - - return this; - } - - if ( jQuery.isFunction( data ) ) { - fn = data; - data = undefined; - } - - types = (types || "").split(" "); - - while ( (type = types[ i++ ]) != null ) { - match = rnamespaces.exec( type ); - namespaces = ""; - - if ( match ) { - namespaces = match[0]; - type = type.replace( rnamespaces, "" ); - } - - if ( type === "hover" ) { - types.push( "mouseenter" + namespaces, "mouseleave" + namespaces ); - continue; - } - - preType = type; - - if ( type === "focus" || type === "blur" ) { - types.push( liveMap[ type ] + namespaces ); - type = type + namespaces; - - } else { - type = (liveMap[ type ] || type) + namespaces; - } - - if ( name === "live" ) { - // bind live handler - for ( var j = 0, l = context.length; j < l; j++ ) { - jQuery.event.add( context[j], "live." + liveConvert( type, selector ), - { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } ); - } - - } else { - // unbind live handler - context.unbind( "live." + liveConvert( type, selector ), fn ); - } - } - - return this; - }; -}); - -function liveHandler( event ) { - var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret, - elems = [], - selectors = [], - events = jQuery.data( this, this.nodeType ? "events" : "__events__" ); - - if ( typeof events === "function" ) { - events = events.events; - } - - // Make sure we avoid non-left-click bubbling in Firefox (#3861) - if ( event.liveFired === this || !events || !events.live || event.button && event.type === "click" ) { - return; - } - - if ( event.namespace ) { - namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)"); - } - - event.liveFired = this; - - var live = events.live.slice(0); - - for ( j = 0; j < live.length; j++ ) { - handleObj = live[j]; - - if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) { - selectors.push( handleObj.selector ); - - } else { - live.splice( j--, 1 ); - } - } - - match = jQuery( event.target ).closest( selectors, event.currentTarget ); - - for ( i = 0, l = match.length; i < l; i++ ) { - close = match[i]; - - for ( j = 0; j < live.length; j++ ) { - handleObj = live[j]; - - if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) ) { - elem = close.elem; - related = null; - - // Those two events require additional checking - if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) { - event.type = handleObj.preType; - related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0]; - } - - if ( !related || related !== elem ) { - elems.push({ elem: elem, handleObj: handleObj, level: close.level }); - } - } - } - } - - for ( i = 0, l = elems.length; i < l; i++ ) { - match = elems[i]; - - if ( maxLevel && match.level > maxLevel ) { - break; - } - - event.currentTarget = match.elem; - event.data = match.handleObj.data; - event.handleObj = match.handleObj; - - ret = match.handleObj.origHandler.apply( match.elem, arguments ); - - if ( ret === false || event.isPropagationStopped() ) { - maxLevel = match.level; - - if ( ret === false ) { - stop = false; - } - if ( event.isImmediatePropagationStopped() ) { - break; - } - } - } - - return stop; -} - -function liveConvert( type, selector ) { - return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspace, "&"); -} - -jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + - "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + - "change select submit keydown keypress keyup error").split(" "), function( i, name ) { - - // Handle event binding - jQuery.fn[ name ] = function( data, fn ) { - if ( fn == null ) { - fn = data; - data = null; - } - - return arguments.length > 0 ? - this.bind( name, data, fn ) : - this.trigger( name ); - }; - - if ( jQuery.attrFn ) { - jQuery.attrFn[ name ] = true; - } -}); - -// Prevent memory leaks in IE -// Window isn't included so as not to unbind existing unload events -// More info: -// - http://isaacschlueter.com/2006/10/msie-memory-leaks/ -if ( window.attachEvent && !window.addEventListener ) { - jQuery(window).bind("unload", function() { - for ( var id in jQuery.cache ) { - if ( jQuery.cache[ id ].handle ) { - // Try/Catch is to handle iframes being unloaded, see #4280 - try { - jQuery.event.remove( jQuery.cache[ id ].handle.elem ); - } catch(e) {} - } - } - }); -} - - -/*! - * Sizzle CSS Selector Engine - v1.0 - * Copyright 2009, The Dojo Foundation - * Released under the MIT, BSD, and GPL Licenses. - * More information: http://sizzlejs.com/ - */ -(function(){ - -var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, - done = 0, - toString = Object.prototype.toString, - hasDuplicate = false, - baseHasDuplicate = true; - -// Here we check if the JavaScript engine is using some sort of -// optimization where it does not always call our comparision -// function. If that is the case, discard the hasDuplicate value. -// Thus far that includes Google Chrome. -[0, 0].sort(function() { - baseHasDuplicate = false; - return 0; -}); - -var Sizzle = function( selector, context, results, seed ) { - results = results || []; - context = context || document; - - var origContext = context; - - if ( context.nodeType !== 1 && context.nodeType !== 9 ) { - return []; - } - - if ( !selector || typeof selector !== "string" ) { - return results; - } - - var m, set, checkSet, extra, ret, cur, pop, i, - prune = true, - contextXML = Sizzle.isXML( context ), - parts = [], - soFar = selector; - - // Reset the position of the chunker regexp (start from head) - do { - chunker.exec( "" ); - m = chunker.exec( soFar ); - - if ( m ) { - soFar = m[3]; - - parts.push( m[1] ); - - if ( m[2] ) { - extra = m[3]; - break; - } - } - } while ( m ); - - if ( parts.length > 1 && origPOS.exec( selector ) ) { - - if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { - set = posProcess( parts[0] + parts[1], context ); - - } else { - set = Expr.relative[ parts[0] ] ? - [ context ] : - Sizzle( parts.shift(), context ); - - while ( parts.length ) { - selector = parts.shift(); - - if ( Expr.relative[ selector ] ) { - selector += parts.shift(); - } - - set = posProcess( selector, set ); - } - } - - } else { - // Take a shortcut and set the context if the root selector is an ID - // (but not if it'll be faster if the inner selector is an ID) - if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && - Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { - - ret = Sizzle.find( parts.shift(), context, contextXML ); - context = ret.expr ? - Sizzle.filter( ret.expr, ret.set )[0] : - ret.set[0]; - } - - if ( context ) { - ret = seed ? - { expr: parts.pop(), set: makeArray(seed) } : - Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); - - set = ret.expr ? - Sizzle.filter( ret.expr, ret.set ) : - ret.set; - - if ( parts.length > 0 ) { - checkSet = makeArray( set ); - - } else { - prune = false; - } - - while ( parts.length ) { - cur = parts.pop(); - pop = cur; - - if ( !Expr.relative[ cur ] ) { - cur = ""; - } else { - pop = parts.pop(); - } - - if ( pop == null ) { - pop = context; - } - - Expr.relative[ cur ]( checkSet, pop, contextXML ); - } - - } else { - checkSet = parts = []; - } - } - - if ( !checkSet ) { - checkSet = set; - } - - if ( !checkSet ) { - Sizzle.error( cur || selector ); - } - - if ( toString.call(checkSet) === "[object Array]" ) { - if ( !prune ) { - results.push.apply( results, checkSet ); - - } else if ( context && context.nodeType === 1 ) { - for ( i = 0; checkSet[i] != null; i++ ) { - if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) { - results.push( set[i] ); - } - } - - } else { - for ( i = 0; checkSet[i] != null; i++ ) { - if ( checkSet[i] && checkSet[i].nodeType === 1 ) { - results.push( set[i] ); - } - } - } - - } else { - makeArray( checkSet, results ); - } - - if ( extra ) { - Sizzle( extra, origContext, results, seed ); - Sizzle.uniqueSort( results ); - } - - return results; -}; - -Sizzle.uniqueSort = function( results ) { - if ( sortOrder ) { - hasDuplicate = baseHasDuplicate; - results.sort( sortOrder ); - - if ( hasDuplicate ) { - for ( var i = 1; i < results.length; i++ ) { - if ( results[i] === results[ i - 1 ] ) { - results.splice( i--, 1 ); - } - } - } - } - - return results; -}; - -Sizzle.matches = function( expr, set ) { - return Sizzle( expr, null, null, set ); -}; - -Sizzle.matchesSelector = function( node, expr ) { - return Sizzle( expr, null, null, [node] ).length > 0; -}; - -Sizzle.find = function( expr, context, isXML ) { - var set; - - if ( !expr ) { - return []; - } - - for ( var i = 0, l = Expr.order.length; i < l; i++ ) { - var match, - type = Expr.order[i]; - - if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { - var left = match[1]; - match.splice( 1, 1 ); - - if ( left.substr( left.length - 1 ) !== "\\" ) { - match[1] = (match[1] || "").replace(/\\/g, ""); - set = Expr.find[ type ]( match, context, isXML ); - - if ( set != null ) { - expr = expr.replace( Expr.match[ type ], "" ); - break; - } - } - } - } - - if ( !set ) { - set = context.getElementsByTagName( "*" ); - } - - return { set: set, expr: expr }; -}; - -Sizzle.filter = function( expr, set, inplace, not ) { - var match, anyFound, - old = expr, - result = [], - curLoop = set, - isXMLFilter = set && set[0] && Sizzle.isXML( set[0] ); - - while ( expr && set.length ) { - for ( var type in Expr.filter ) { - if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) { - var found, item, - filter = Expr.filter[ type ], - left = match[1]; - - anyFound = false; - - match.splice(1,1); - - if ( left.substr( left.length - 1 ) === "\\" ) { - continue; - } - - if ( curLoop === result ) { - result = []; - } - - if ( Expr.preFilter[ type ] ) { - match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); - - if ( !match ) { - anyFound = found = true; - - } else if ( match === true ) { - continue; - } - } - - if ( match ) { - for ( var i = 0; (item = curLoop[i]) != null; i++ ) { - if ( item ) { - found = filter( item, match, i, curLoop ); - var pass = not ^ !!found; - - if ( inplace && found != null ) { - if ( pass ) { - anyFound = true; - - } else { - curLoop[i] = false; - } - - } else if ( pass ) { - result.push( item ); - anyFound = true; - } - } - } - } - - if ( found !== undefined ) { - if ( !inplace ) { - curLoop = result; - } - - expr = expr.replace( Expr.match[ type ], "" ); - - if ( !anyFound ) { - return []; - } - - break; - } - } - } - - // Improper expression - if ( expr === old ) { - if ( anyFound == null ) { - Sizzle.error( expr ); - - } else { - break; - } - } - - old = expr; - } - - return curLoop; -}; - -Sizzle.error = function( msg ) { - throw "Syntax error, unrecognized expression: " + msg; -}; - -var Expr = Sizzle.selectors = { - order: [ "ID", "NAME", "TAG" ], - - match: { - ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, - CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, - NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, - ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/, - TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, - CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+\-]*)\))?/, - POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/, - PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ - }, - - leftMatch: {}, - - attrMap: { - "class": "className", - "for": "htmlFor" - }, - - attrHandle: { - href: function( elem ) { - return elem.getAttribute( "href" ); - } - }, - - relative: { - "+": function(checkSet, part){ - var isPartStr = typeof part === "string", - isTag = isPartStr && !/\W/.test( part ), - isPartStrNotTag = isPartStr && !isTag; - - if ( isTag ) { - part = part.toLowerCase(); - } - - for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { - if ( (elem = checkSet[i]) ) { - while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} - - checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ? - elem || false : - elem === part; - } - } - - if ( isPartStrNotTag ) { - Sizzle.filter( part, checkSet, true ); - } - }, - - ">": function( checkSet, part ) { - var elem, - isPartStr = typeof part === "string", - i = 0, - l = checkSet.length; - - if ( isPartStr && !/\W/.test( part ) ) { - part = part.toLowerCase(); - - for ( ; i < l; i++ ) { - elem = checkSet[i]; - - if ( elem ) { - var parent = elem.parentNode; - checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false; - } - } - - } else { - for ( ; i < l; i++ ) { - elem = checkSet[i]; - - if ( elem ) { - checkSet[i] = isPartStr ? - elem.parentNode : - elem.parentNode === part; - } - } - - if ( isPartStr ) { - Sizzle.filter( part, checkSet, true ); - } - } - }, - - "": function(checkSet, part, isXML){ - var nodeCheck, - doneName = done++, - checkFn = dirCheck; - - if ( typeof part === "string" && !/\W/.test(part) ) { - part = part.toLowerCase(); - nodeCheck = part; - checkFn = dirNodeCheck; - } - - checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML ); - }, - - "~": function( checkSet, part, isXML ) { - var nodeCheck, - doneName = done++, - checkFn = dirCheck; - - if ( typeof part === "string" && !/\W/.test( part ) ) { - part = part.toLowerCase(); - nodeCheck = part; - checkFn = dirNodeCheck; - } - - checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML ); - } - }, - - find: { - ID: function( match, context, isXML ) { - if ( typeof context.getElementById !== "undefined" && !isXML ) { - var m = context.getElementById(match[1]); - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - return m && m.parentNode ? [m] : []; - } - }, - - NAME: function( match, context ) { - if ( typeof context.getElementsByName !== "undefined" ) { - var ret = [], - results = context.getElementsByName( match[1] ); - - for ( var i = 0, l = results.length; i < l; i++ ) { - if ( results[i].getAttribute("name") === match[1] ) { - ret.push( results[i] ); - } - } - - return ret.length === 0 ? null : ret; - } - }, - - TAG: function( match, context ) { - return context.getElementsByTagName( match[1] ); - } - }, - preFilter: { - CLASS: function( match, curLoop, inplace, result, not, isXML ) { - match = " " + match[1].replace(/\\/g, "") + " "; - - if ( isXML ) { - return match; - } - - for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { - if ( elem ) { - if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n]/g, " ").indexOf(match) >= 0) ) { - if ( !inplace ) { - result.push( elem ); - } - - } else if ( inplace ) { - curLoop[i] = false; - } - } - } - - return false; - }, - - ID: function( match ) { - return match[1].replace(/\\/g, ""); - }, - - TAG: function( match, curLoop ) { - return match[1].toLowerCase(); - }, - - CHILD: function( match ) { - if ( match[1] === "nth" ) { - // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' - var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec( - match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || - !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); - - // calculate the numbers (first)n+(last) including if they are negative - match[2] = (test[1] + (test[2] || 1)) - 0; - match[3] = test[3] - 0; - } - - // TODO: Move to normal caching system - match[0] = done++; - - return match; - }, - - ATTR: function( match, curLoop, inplace, result, not, isXML ) { - var name = match[1].replace(/\\/g, ""); - - if ( !isXML && Expr.attrMap[name] ) { - match[1] = Expr.attrMap[name]; - } - - if ( match[2] === "~=" ) { - match[4] = " " + match[4] + " "; - } - - return match; - }, - - PSEUDO: function( match, curLoop, inplace, result, not ) { - if ( match[1] === "not" ) { - // If we're dealing with a complex expression, or a simple one - if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) { - match[3] = Sizzle(match[3], null, null, curLoop); - - } else { - var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); - - if ( !inplace ) { - result.push.apply( result, ret ); - } - - return false; - } - - } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { - return true; - } - - return match; - }, - - POS: function( match ) { - match.unshift( true ); - - return match; - } - }, - - filters: { - enabled: function( elem ) { - return elem.disabled === false && elem.type !== "hidden"; - }, - - disabled: function( elem ) { - return elem.disabled === true; - }, - - checked: function( elem ) { - return elem.checked === true; - }, - - selected: function( elem ) { - // Accessing this property makes selected-by-default - // options in Safari work properly - elem.parentNode.selectedIndex; - - return elem.selected === true; - }, - - parent: function( elem ) { - return !!elem.firstChild; - }, - - empty: function( elem ) { - return !elem.firstChild; - }, - - has: function( elem, i, match ) { - return !!Sizzle( match[3], elem ).length; - }, - - header: function( elem ) { - return (/h\d/i).test( elem.nodeName ); - }, - - text: function( elem ) { - return "text" === elem.type; - }, - radio: function( elem ) { - return "radio" === elem.type; - }, - - checkbox: function( elem ) { - return "checkbox" === elem.type; - }, - - file: function( elem ) { - return "file" === elem.type; - }, - password: function( elem ) { - return "password" === elem.type; - }, - - submit: function( elem ) { - return "submit" === elem.type; - }, - - image: function( elem ) { - return "image" === elem.type; - }, - - reset: function( elem ) { - return "reset" === elem.type; - }, - - button: function( elem ) { - return "button" === elem.type || elem.nodeName.toLowerCase() === "button"; - }, - - input: function( elem ) { - return (/input|select|textarea|button/i).test( elem.nodeName ); - } - }, - setFilters: { - first: function( elem, i ) { - return i === 0; - }, - - last: function( elem, i, match, array ) { - return i === array.length - 1; - }, - - even: function( elem, i ) { - return i % 2 === 0; - }, - - odd: function( elem, i ) { - return i % 2 === 1; - }, - - lt: function( elem, i, match ) { - return i < match[3] - 0; - }, - - gt: function( elem, i, match ) { - return i > match[3] - 0; - }, - - nth: function( elem, i, match ) { - return match[3] - 0 === i; - }, - - eq: function( elem, i, match ) { - return match[3] - 0 === i; - } - }, - filter: { - PSEUDO: function( elem, match, i, array ) { - var name = match[1], - filter = Expr.filters[ name ]; - - if ( filter ) { - return filter( elem, i, match, array ); - - } else if ( name === "contains" ) { - return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0; - - } else if ( name === "not" ) { - var not = match[3]; - - for ( var j = 0, l = not.length; j < l; j++ ) { - if ( not[j] === elem ) { - return false; - } - } - - return true; - - } else { - Sizzle.error( "Syntax error, unrecognized expression: " + name ); - } - }, - - CHILD: function( elem, match ) { - var type = match[1], - node = elem; - - switch ( type ) { - case "only": - case "first": - while ( (node = node.previousSibling) ) { - if ( node.nodeType === 1 ) { - return false; - } - } - - if ( type === "first" ) { - return true; - } - - node = elem; - - case "last": - while ( (node = node.nextSibling) ) { - if ( node.nodeType === 1 ) { - return false; - } - } - - return true; - - case "nth": - var first = match[2], - last = match[3]; - - if ( first === 1 && last === 0 ) { - return true; - } - - var doneName = match[0], - parent = elem.parentNode; - - if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { - var count = 0; - - for ( node = parent.firstChild; node; node = node.nextSibling ) { - if ( node.nodeType === 1 ) { - node.nodeIndex = ++count; - } - } - - parent.sizcache = doneName; - } - - var diff = elem.nodeIndex - last; - - if ( first === 0 ) { - return diff === 0; - - } else { - return ( diff % first === 0 && diff / first >= 0 ); - } - } - }, - - ID: function( elem, match ) { - return elem.nodeType === 1 && elem.getAttribute("id") === match; - }, - - TAG: function( elem, match ) { - return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match; - }, - - CLASS: function( elem, match ) { - return (" " + (elem.className || elem.getAttribute("class")) + " ") - .indexOf( match ) > -1; - }, - - ATTR: function( elem, match ) { - var name = match[1], - result = Expr.attrHandle[ name ] ? - Expr.attrHandle[ name ]( elem ) : - elem[ name ] != null ? - elem[ name ] : - elem.getAttribute( name ), - value = result + "", - type = match[2], - check = match[4]; - - return result == null ? - type === "!=" : - type === "=" ? - value === check : - type === "*=" ? - value.indexOf(check) >= 0 : - type === "~=" ? - (" " + value + " ").indexOf(check) >= 0 : - !check ? - value && result !== false : - type === "!=" ? - value !== check : - type === "^=" ? - value.indexOf(check) === 0 : - type === "$=" ? - value.substr(value.length - check.length) === check : - type === "|=" ? - value === check || value.substr(0, check.length + 1) === check + "-" : - false; - }, - - POS: function( elem, match, i, array ) { - var name = match[2], - filter = Expr.setFilters[ name ]; - - if ( filter ) { - return filter( elem, i, match, array ); - } - } - } -}; - -var origPOS = Expr.match.POS, - fescape = function(all, num){ - return "\\" + (num - 0 + 1); - }; - -for ( var type in Expr.match ) { - Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) ); - Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) ); -} - -var makeArray = function( array, results ) { - array = Array.prototype.slice.call( array, 0 ); - - if ( results ) { - results.push.apply( results, array ); - return results; - } - - return array; -}; - -// Perform a simple check to determine if the browser is capable of -// converting a NodeList to an array using builtin methods. -// Also verifies that the returned array holds DOM nodes -// (which is not the case in the Blackberry browser) -try { - Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType; - -// Provide a fallback method if it does not work -} catch( e ) { - makeArray = function( array, results ) { - var i = 0, - ret = results || []; - - if ( toString.call(array) === "[object Array]" ) { - Array.prototype.push.apply( ret, array ); - - } else { - if ( typeof array.length === "number" ) { - for ( var l = array.length; i < l; i++ ) { - ret.push( array[i] ); - } - - } else { - for ( ; array[i]; i++ ) { - ret.push( array[i] ); - } - } - } - - return ret; - }; -} - -var sortOrder, siblingCheck; - -if ( document.documentElement.compareDocumentPosition ) { - sortOrder = function( a, b ) { - if ( a === b ) { - hasDuplicate = true; - return 0; - } - - if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { - return a.compareDocumentPosition ? -1 : 1; - } - - return a.compareDocumentPosition(b) & 4 ? -1 : 1; - }; - -} else { - sortOrder = function( a, b ) { - var al, bl, - ap = [], - bp = [], - aup = a.parentNode, - bup = b.parentNode, - cur = aup; - - // The nodes are identical, we can exit early - if ( a === b ) { - hasDuplicate = true; - return 0; - - // If the nodes are siblings (or identical) we can do a quick check - } else if ( aup === bup ) { - return siblingCheck( a, b ); - - // If no parents were found then the nodes are disconnected - } else if ( !aup ) { - return -1; - - } else if ( !bup ) { - return 1; - } - - // Otherwise they're somewhere else in the tree so we need - // to build up a full list of the parentNodes for comparison - while ( cur ) { - ap.unshift( cur ); - cur = cur.parentNode; - } - - cur = bup; - - while ( cur ) { - bp.unshift( cur ); - cur = cur.parentNode; - } - - al = ap.length; - bl = bp.length; - - // Start walking down the tree looking for a discrepancy - for ( var i = 0; i < al && i < bl; i++ ) { - if ( ap[i] !== bp[i] ) { - return siblingCheck( ap[i], bp[i] ); - } - } - - // We ended someplace up the tree so do a sibling check - return i === al ? - siblingCheck( a, bp[i], -1 ) : - siblingCheck( ap[i], b, 1 ); - }; - - siblingCheck = function( a, b, ret ) { - if ( a === b ) { - return ret; - } - - var cur = a.nextSibling; - - while ( cur ) { - if ( cur === b ) { - return -1; - } - - cur = cur.nextSibling; - } - - return 1; - }; -} - -// Utility function for retreiving the text value of an array of DOM nodes -Sizzle.getText = function( elems ) { - var ret = "", elem; - - for ( var i = 0; elems[i]; i++ ) { - elem = elems[i]; - - // Get the text from text nodes and CDATA nodes - if ( elem.nodeType === 3 || elem.nodeType === 4 ) { - ret += elem.nodeValue; - - // Traverse everything else, except comment nodes - } else if ( elem.nodeType !== 8 ) { - ret += Sizzle.getText( elem.childNodes ); - } - } - - return ret; -}; - -// Check to see if the browser returns elements by name when -// querying by getElementById (and provide a workaround) -(function(){ - // We're going to inject a fake input element with a specified name - var form = document.createElement("div"), - id = "script" + (new Date()).getTime(), - root = document.documentElement; - - form.innerHTML = ""; - - // Inject it into the root element, check its status, and remove it quickly - root.insertBefore( form, root.firstChild ); - - // The workaround has to do additional checks after a getElementById - // Which slows things down for other browsers (hence the branching) - if ( document.getElementById( id ) ) { - Expr.find.ID = function( match, context, isXML ) { - if ( typeof context.getElementById !== "undefined" && !isXML ) { - var m = context.getElementById(match[1]); - - return m ? - m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? - [m] : - undefined : - []; - } - }; - - Expr.filter.ID = function( elem, match ) { - var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); - - return elem.nodeType === 1 && node && node.nodeValue === match; - }; - } - - root.removeChild( form ); - - // release memory in IE - root = form = null; -})(); - -(function(){ - // Check to see if the browser returns only elements - // when doing getElementsByTagName("*") - - // Create a fake element - var div = document.createElement("div"); - div.appendChild( document.createComment("") ); - - // Make sure no comments are found - if ( div.getElementsByTagName("*").length > 0 ) { - Expr.find.TAG = function( match, context ) { - var results = context.getElementsByTagName( match[1] ); - - // Filter out possible comments - if ( match[1] === "*" ) { - var tmp = []; - - for ( var i = 0; results[i]; i++ ) { - if ( results[i].nodeType === 1 ) { - tmp.push( results[i] ); - } - } - - results = tmp; - } - - return results; - }; - } - - // Check to see if an attribute returns normalized href attributes - div.innerHTML = ""; - - if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && - div.firstChild.getAttribute("href") !== "#" ) { - - Expr.attrHandle.href = function( elem ) { - return elem.getAttribute( "href", 2 ); - }; - } - - // release memory in IE - div = null; -})(); - -if ( document.querySelectorAll ) { - (function(){ - var oldSizzle = Sizzle, - div = document.createElement("div"), - id = "__sizzle__"; - - div.innerHTML = "

      "; - - // Safari can't handle uppercase or unicode characters when - // in quirks mode. - if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { - return; - } - - Sizzle = function( query, context, extra, seed ) { - context = context || document; - - // Make sure that attribute selectors are quoted - query = query.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); - - // Only use querySelectorAll on non-XML documents - // (ID selectors don't work in non-HTML documents) - if ( !seed && !Sizzle.isXML(context) ) { - if ( context.nodeType === 9 ) { - try { - return makeArray( context.querySelectorAll(query), extra ); - } catch(qsaError) {} - - // qSA works strangely on Element-rooted queries - // We can work around this by specifying an extra ID on the root - // and working up from there (Thanks to Andrew Dupont for the technique) - // IE 8 doesn't work on object elements - } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { - var old = context.getAttribute( "id" ), - nid = old || id; - - if ( !old ) { - context.setAttribute( "id", nid ); - } - - try { - return makeArray( context.querySelectorAll( "#" + nid + " " + query ), extra ); - - } catch(pseudoError) { - } finally { - if ( !old ) { - context.removeAttribute( "id" ); - } - } - } - } - - return oldSizzle(query, context, extra, seed); - }; - - for ( var prop in oldSizzle ) { - Sizzle[ prop ] = oldSizzle[ prop ]; - } - - // release memory in IE - div = null; - })(); -} - -(function(){ - var html = document.documentElement, - matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector, - pseudoWorks = false; - - try { - // This should fail with an exception - // Gecko does not error, returns false instead - matches.call( document.documentElement, "[test!='']:sizzle" ); - - } catch( pseudoError ) { - pseudoWorks = true; - } - - if ( matches ) { - Sizzle.matchesSelector = function( node, expr ) { - // Make sure that attribute selectors are quoted - expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); - - if ( !Sizzle.isXML( node ) ) { - try { - if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { - return matches.call( node, expr ); - } - } catch(e) {} - } - - return Sizzle(expr, null, null, [node]).length > 0; - }; - } -})(); - -(function(){ - var div = document.createElement("div"); - - div.innerHTML = "
      "; - - // Opera can't find a second classname (in 9.6) - // Also, make sure that getElementsByClassName actually exists - if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) { - return; - } - - // Safari caches class attributes, doesn't catch changes (in 3.2) - div.lastChild.className = "e"; - - if ( div.getElementsByClassName("e").length === 1 ) { - return; - } - - Expr.order.splice(1, 0, "CLASS"); - Expr.find.CLASS = function( match, context, isXML ) { - if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { - return context.getElementsByClassName(match[1]); - } - }; - - // release memory in IE - div = null; -})(); - -function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { - for ( var i = 0, l = checkSet.length; i < l; i++ ) { - var elem = checkSet[i]; - - if ( elem ) { - var match = false; - - elem = elem[dir]; - - while ( elem ) { - if ( elem.sizcache === doneName ) { - match = checkSet[elem.sizset]; - break; - } - - if ( elem.nodeType === 1 && !isXML ){ - elem.sizcache = doneName; - elem.sizset = i; - } - - if ( elem.nodeName.toLowerCase() === cur ) { - match = elem; - break; - } - - elem = elem[dir]; - } - - checkSet[i] = match; - } - } -} - -function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { - for ( var i = 0, l = checkSet.length; i < l; i++ ) { - var elem = checkSet[i]; - - if ( elem ) { - var match = false; - - elem = elem[dir]; - - while ( elem ) { - if ( elem.sizcache === doneName ) { - match = checkSet[elem.sizset]; - break; - } - - if ( elem.nodeType === 1 ) { - if ( !isXML ) { - elem.sizcache = doneName; - elem.sizset = i; - } - - if ( typeof cur !== "string" ) { - if ( elem === cur ) { - match = true; - break; - } - - } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { - match = elem; - break; - } - } - - elem = elem[dir]; - } - - checkSet[i] = match; - } - } -} - -if ( document.documentElement.contains ) { - Sizzle.contains = function( a, b ) { - return a !== b && (a.contains ? a.contains(b) : true); - }; - -} else if ( document.documentElement.compareDocumentPosition ) { - Sizzle.contains = function( a, b ) { - return !!(a.compareDocumentPosition(b) & 16); - }; - -} else { - Sizzle.contains = function() { - return false; - }; -} - -Sizzle.isXML = function( elem ) { - // documentElement is verified for cases where it doesn't yet exist - // (such as loading iframes in IE - #4833) - var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; - - return documentElement ? documentElement.nodeName !== "HTML" : false; -}; - -var posProcess = function( selector, context ) { - var match, - tmpSet = [], - later = "", - root = context.nodeType ? [context] : context; - - // Position selectors must be done after the filter - // And so must :not(positional) so we move all PSEUDOs to the end - while ( (match = Expr.match.PSEUDO.exec( selector )) ) { - later += match[0]; - selector = selector.replace( Expr.match.PSEUDO, "" ); - } - - selector = Expr.relative[selector] ? selector + "*" : selector; - - for ( var i = 0, l = root.length; i < l; i++ ) { - Sizzle( selector, root[i], tmpSet ); - } - - return Sizzle.filter( later, tmpSet ); -}; - -// EXPOSE -jQuery.find = Sizzle; -jQuery.expr = Sizzle.selectors; -jQuery.expr[":"] = jQuery.expr.filters; -jQuery.unique = Sizzle.uniqueSort; -jQuery.text = Sizzle.getText; -jQuery.isXMLDoc = Sizzle.isXML; -jQuery.contains = Sizzle.contains; - - -})(); - - -var runtil = /Until$/, - rparentsprev = /^(?:parents|prevUntil|prevAll)/, - // Note: This RegExp should be improved, or likely pulled from Sizzle - rmultiselector = /,/, - isSimple = /^.[^:#\[\.,]*$/, - slice = Array.prototype.slice, - POS = jQuery.expr.match.POS; - -jQuery.fn.extend({ - find: function( selector ) { - var ret = this.pushStack( "", "find", selector ), - length = 0; - - for ( var i = 0, l = this.length; i < l; i++ ) { - length = ret.length; - jQuery.find( selector, this[i], ret ); - - if ( i > 0 ) { - // Make sure that the results are unique - for ( var n = length; n < ret.length; n++ ) { - for ( var r = 0; r < length; r++ ) { - if ( ret[r] === ret[n] ) { - ret.splice(n--, 1); - break; - } - } - } - } - } - - return ret; - }, - - has: function( target ) { - var targets = jQuery( target ); - return this.filter(function() { - for ( var i = 0, l = targets.length; i < l; i++ ) { - if ( jQuery.contains( this, targets[i] ) ) { - return true; - } - } - }); - }, - - not: function( selector ) { - return this.pushStack( winnow(this, selector, false), "not", selector); - }, - - filter: function( selector ) { - return this.pushStack( winnow(this, selector, true), "filter", selector ); - }, - - is: function( selector ) { - return !!selector && jQuery.filter( selector, this ).length > 0; - }, - - closest: function( selectors, context ) { - var ret = [], i, l, cur = this[0]; - - if ( jQuery.isArray( selectors ) ) { - var match, selector, - matches = {}, - level = 1; - - if ( cur && selectors.length ) { - for ( i = 0, l = selectors.length; i < l; i++ ) { - selector = selectors[i]; - - if ( !matches[selector] ) { - matches[selector] = jQuery.expr.match.POS.test( selector ) ? - jQuery( selector, context || this.context ) : - selector; - } - } - - while ( cur && cur.ownerDocument && cur !== context ) { - for ( selector in matches ) { - match = matches[selector]; - - if ( match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match) ) { - ret.push({ selector: selector, elem: cur, level: level }); - } - } - - cur = cur.parentNode; - level++; - } - } - - return ret; - } - - var pos = POS.test( selectors ) ? - jQuery( selectors, context || this.context ) : null; - - for ( i = 0, l = this.length; i < l; i++ ) { - cur = this[i]; - - while ( cur ) { - if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) { - ret.push( cur ); - break; - - } else { - cur = cur.parentNode; - if ( !cur || !cur.ownerDocument || cur === context ) { - break; - } - } - } - } - - ret = ret.length > 1 ? jQuery.unique(ret) : ret; - - return this.pushStack( ret, "closest", selectors ); - }, - - // Determine the position of an element within - // the matched set of elements - index: function( elem ) { - if ( !elem || typeof elem === "string" ) { - return jQuery.inArray( this[0], - // If it receives a string, the selector is used - // If it receives nothing, the siblings are used - elem ? jQuery( elem ) : this.parent().children() ); - } - // Locate the position of the desired element - return jQuery.inArray( - // If it receives a jQuery object, the first element is used - elem.jquery ? elem[0] : elem, this ); - }, - - add: function( selector, context ) { - var set = typeof selector === "string" ? - jQuery( selector, context || this.context ) : - jQuery.makeArray( selector ), - all = jQuery.merge( this.get(), set ); - - return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? - all : - jQuery.unique( all ) ); - }, - - andSelf: function() { - return this.add( this.prevObject ); - } -}); - -// A painfully simple check to see if an element is disconnected -// from a document (should be improved, where feasible). -function isDisconnected( node ) { - return !node || !node.parentNode || node.parentNode.nodeType === 11; -} - -jQuery.each({ - parent: function( elem ) { - var parent = elem.parentNode; - return parent && parent.nodeType !== 11 ? parent : null; - }, - parents: function( elem ) { - return jQuery.dir( elem, "parentNode" ); - }, - parentsUntil: function( elem, i, until ) { - return jQuery.dir( elem, "parentNode", until ); - }, - next: function( elem ) { - return jQuery.nth( elem, 2, "nextSibling" ); - }, - prev: function( elem ) { - return jQuery.nth( elem, 2, "previousSibling" ); - }, - nextAll: function( elem ) { - return jQuery.dir( elem, "nextSibling" ); - }, - prevAll: function( elem ) { - return jQuery.dir( elem, "previousSibling" ); - }, - nextUntil: function( elem, i, until ) { - return jQuery.dir( elem, "nextSibling", until ); - }, - prevUntil: function( elem, i, until ) { - return jQuery.dir( elem, "previousSibling", until ); - }, - siblings: function( elem ) { - return jQuery.sibling( elem.parentNode.firstChild, elem ); - }, - children: function( elem ) { - return jQuery.sibling( elem.firstChild ); - }, - contents: function( elem ) { - return jQuery.nodeName( elem, "iframe" ) ? - elem.contentDocument || elem.contentWindow.document : - jQuery.makeArray( elem.childNodes ); - } -}, function( name, fn ) { - jQuery.fn[ name ] = function( until, selector ) { - var ret = jQuery.map( this, fn, until ); - - if ( !runtil.test( name ) ) { - selector = until; - } - - if ( selector && typeof selector === "string" ) { - ret = jQuery.filter( selector, ret ); - } - - ret = this.length > 1 ? jQuery.unique( ret ) : ret; - - if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) { - ret = ret.reverse(); - } - - return this.pushStack( ret, name, slice.call(arguments).join(",") ); - }; -}); - -jQuery.extend({ - filter: function( expr, elems, not ) { - if ( not ) { - expr = ":not(" + expr + ")"; - } - - return elems.length === 1 ? - jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : - jQuery.find.matches(expr, elems); - }, - - dir: function( elem, dir, until ) { - var matched = [], - cur = elem[ dir ]; - - while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { - if ( cur.nodeType === 1 ) { - matched.push( cur ); - } - cur = cur[dir]; - } - return matched; - }, - - nth: function( cur, result, dir, elem ) { - result = result || 1; - var num = 0; - - for ( ; cur; cur = cur[dir] ) { - if ( cur.nodeType === 1 && ++num === result ) { - break; - } - } - - return cur; - }, - - sibling: function( n, elem ) { - var r = []; - - for ( ; n; n = n.nextSibling ) { - if ( n.nodeType === 1 && n !== elem ) { - r.push( n ); - } - } - - return r; - } -}); - -// Implement the identical functionality for filter and not -function winnow( elements, qualifier, keep ) { - if ( jQuery.isFunction( qualifier ) ) { - return jQuery.grep(elements, function( elem, i ) { - var retVal = !!qualifier.call( elem, i, elem ); - return retVal === keep; - }); - - } else if ( qualifier.nodeType ) { - return jQuery.grep(elements, function( elem, i ) { - return (elem === qualifier) === keep; - }); - - } else if ( typeof qualifier === "string" ) { - var filtered = jQuery.grep(elements, function( elem ) { - return elem.nodeType === 1; - }); - - if ( isSimple.test( qualifier ) ) { - return jQuery.filter(qualifier, filtered, !keep); - } else { - qualifier = jQuery.filter( qualifier, filtered ); - } - } - - return jQuery.grep(elements, function( elem, i ) { - return (jQuery.inArray( elem, qualifier ) >= 0) === keep; - }); -} - - - - -var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, - rleadingWhitespace = /^\s+/, - rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig, - rtagName = /<([\w:]+)/, - rtbody = /\s]+\/)>/g, - wrapMap = { - option: [ 1, "" ], - legend: [ 1, "
      ", "
      " ], - thead: [ 1, "", "
      " ], - tr: [ 2, "", "
      " ], - td: [ 3, "", "
      " ], - col: [ 2, "", "
      " ], - area: [ 1, "", "" ], - _default: [ 0, "", "" ] - }; - -wrapMap.optgroup = wrapMap.option; -wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; -wrapMap.th = wrapMap.td; - -// IE can't serialize and - - - - - - - + + + + + + + diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/commands/multi_select_commands.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/commands/multi_select_commands.js index ed396fb3..ebac5cc7 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/commands/multi_select_commands.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/commands/multi_select_commands.js @@ -92,7 +92,7 @@ exports.multiSelectCommands = [{ bindKey: "esc", exec: function(editor) { editor.exitMultiSelectMode(); }, readonly: true, - isAvailable: function(editor) {return editor.inMultiSelectMode} + isAvailable: function(editor) {return editor && editor.inMultiSelectMode} }]; var HashHandler = require("../keyboard/hash_handler").HashHandler; diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/config.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/config.js index 73a83d51..0bdaf786 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/config.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/config.js @@ -97,10 +97,9 @@ exports.init = function() { } } - var m = src.match(/^(?:(.*\/)ace\.js)(?:\?|$)/); - if (m) { - scriptUrl = m[1] || m[2]; - } + var m = src.match(/^(.*)\/ace(\-\w+)?\.js(\?|$)/); + if (m) + scriptUrl = m[1]; } if (scriptUrl) { diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/css/editor.css b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/css/editor.css index c1cd0f0c..0a668fff 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/css/editor.css +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/css/editor.css @@ -50,9 +50,11 @@ .ace_gutter-cell.ace_info { background-image: url("data:image/gif;base64,R0lGODlhEAAQAMQAAAAAAEFBQVJSUl5eXmRkZGtra39/f4WFhYmJiZGRkaampry8vMPDw8zMzNXV1dzc3OTk5Orq6vDw8P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABQALAAAAAAQABAAAAUuICWOZGmeaBml5XGwFCQSBGyXRSAwtqQIiRuiwIM5BoYVbEFIyGCQoeJGrVptIQA7"); - background-repeat: no-repeat; background-position: 2px center; } +.ace_dark .ace_gutter-cell.ace_info { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpGRTk5MTVGREIxNDkxMUUxOTc5Q0FFREQyMTNGMjBFQyIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpGRTk5MTVGRUIxNDkxMUUxOTc5Q0FFREQyMTNGMjBFQyI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkZFOTkxNUZCQjE0OTExRTE5NzlDQUVERDIxM0YyMEVDIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkZFOTkxNUZDQjE0OTExRTE5NzlDQUVERDIxM0YyMEVDIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+SIDkjAAAAJ1JREFUeNpi/P//PwMlgImBQkB7A6qrq/+DMC55FkIGKCoq4pVnpFkgTp069f/+/fv/r1u37r+tre1/kg0A+ptn9uzZYLaRkRHpLvjw4cNXWVlZhufPnzOcO3eOdAO0tbVPAjHDmzdvGA4fPsxIsgGSkpJmv379Ynj37h2DjIyMCMkG3LhxQ/T27dsMampqDHZ2dq/pH41DxwCAAAMAFdc68dUsFZgAAAAASUVORK5CYII="); +} .ace_editor .ace_sb { position: absolute; @@ -246,9 +248,11 @@ background-image: url("data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%00%05%08%06%00%00%00%8Do%26%E5%00%00%004IDATx%DAe%8A%B1%0D%000%0C%C2%F2%2CK%96%BC%D0%8F9%81%88H%E9%D0%0E%96%C0%10%92%3E%02%80%5E%82%E4%A9*-%EEsw%C8%CC%11%EE%96w%D8%DC%E9*Eh%0C%151(%00%00%00%00IEND%AEB%60%82"); background-repeat: no-repeat; - background-position: center 5px; + background-position: center 4px; border-radius: 3px; + + border: 1px solid transparent; } .ace_fold-widget.end { @@ -262,11 +266,8 @@ .ace_fold-widget:hover { border: 1px solid rgba(0, 0, 0, 0.3); background-color: rgba(255, 255, 255, 0.2); - -moz-box-shadow:inset 0 1px 1px rgba(255, 255, 255, 0.7); -moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7); - -webkit-box-shadow:inset 0 1px 1px rgba(255, 255, 255, 0.7); -webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7); - box-shadow:inset 0 1px 1px rgba(255, 255, 255, 0.7); box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7); background-position: center 4px; } @@ -274,14 +275,34 @@ .ace_fold-widget:active { border: 1px solid rgba(0, 0, 0, 0.4); background-color: rgba(0, 0, 0, 0.05); - -moz-box-shadow:inset 0 1px 1px rgba(255, 255, 255); -moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8); - -webkit-box-shadow:inset 0 1px 1px rgba(255, 255, 255); -webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8); - box-shadow:inset 0 1px 1px rgba(255, 255, 255); box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8); } - +/** + * Dark version for fold widgets + */ +.ace_dark .ace_fold-widget { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC"); +} +.ace_dark .ace_fold-widget.end { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg=="); +} +.ace_dark .ace_fold-widget.closed { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg=="); +} +.ace_dark .ace_fold-widget:hover { + box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2); + background-color: rgba(255, 255, 255, 0.1); +} +.ace_dark .ace_fold-widget:active { + -moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2); + -webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2); + box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2); +} + + + .ace_fold-widget.invalid { background-color: #FFB4B4; border-color: #DE5555; diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/edit_session/bracket_match.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/edit_session/bracket_match.js index 83c8f572..9b977b8c 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/edit_session/bracket_match.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/edit_session/bracket_match.js @@ -94,7 +94,7 @@ function BracketMatch() { var match = chr && chr.match(/([\(\[\{])|([\)\]\}])/); if (!match) { chr = line.charAt(pos.column); - pos.column++; + pos = {row: pos.row, column: pos.column + 1}; match = chr && chr.match(/([\(\[\{])|([\)\]\}])/); before = false; } @@ -123,9 +123,6 @@ function BracketMatch() { range.cursor = range.start; } - if (!before) - pos.column--; - return range; }; @@ -194,7 +191,7 @@ function BracketMatch() { return null; }; - this.$findClosingBracket = function(bracket, position, typeRe, allowBlankLine) { + this.$findClosingBracket = function(bracket, position, typeRe) { var closingBracket = this.$brackets[bracket]; var depth = 1; @@ -239,12 +236,6 @@ function BracketMatch() { // whose type matches typeRe do { token = iterator.stepForward(); - if (allowBlankLine) { - // if you've reached the doc end, or, you match a new content line - if (token === null || token.type == "string") { - return {row: iterator.getCurrentTokenRow() + (token === null ? 1 : -1), column: 0}; - } - } } while (token && !typeRe.test(token.type)); if (token == null) diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/editor.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/editor.js index 1efac5fc..5b387f98 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/editor.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/editor.js @@ -1772,7 +1772,7 @@ var Editor = function(renderer, session) { var range = this.session.getBracketRange(cursor); if (!range) { - range = editor.find({ + range = this.find({ needle: /[{}()\[\]]/g, preventScroll:true, start: {row: cursor.row, column: cursor.column - 1} @@ -1787,10 +1787,10 @@ var Editor = function(renderer, session) { pos = range && range.cursor || pos; if (pos) { if (select) { - if (range && range.isEqual(editor.getSelectionRange())) + if (range && range.isEqual(this.getSelectionRange())) this.clearSelection(); else - this.selection.selectTo(pos.row, pos.column); + this.selection.selectTo(pos.row, pos.column); } else { this.clearSelection(); this.moveCursorTo(pos.row, pos.column); diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/keyboard/state_handler.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/keyboard/state_handler.js index c7efe552..fa7e5d5c 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/keyboard/state_handler.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/keyboard/state_handler.js @@ -105,7 +105,7 @@ StateHandler.prototype = { var bufferObj = { bufferToUse: bufferToUse, - symbolicName: symbolicName, + symbolicName: symbolicName }; if (e) { diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/layer/marker.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/layer/marker.js index f5999338..127cf7f3 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/layer/marker.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/layer/marker.js @@ -73,7 +73,7 @@ var Marker = function(parentEl) { var html = []; - for ( var key in this.markers) { + for (var key in this.markers) { var marker = this.markers[key]; if (!marker.range) { @@ -140,29 +140,25 @@ var Marker = function(parentEl) { } }; - // Draws a multi line marker, where lines span the full width - this.drawMultiLineMarker = function(stringBuilder, range, clazz, layerConfig, type) { + // Draws a multi line marker, where lines span the full width + this.drawMultiLineMarker = function(stringBuilder, range, clazz, config, type) { var padding = type === "background" ? 0 : this.$padding; - var layerWidth = layerConfig.width + 2 * this.$padding - padding; // from selection start to the end of the line - var height = layerConfig.lineHeight; - var width = Math.round(layerWidth - (range.start.column * layerConfig.characterWidth)); - var top = this.$getTop(range.start.row, layerConfig); - var left = Math.round( - padding + range.start.column * layerConfig.characterWidth - ); + var height = config.lineHeight; + var top = this.$getTop(range.start.row, config); + var left = Math.round(padding + range.start.column * config.characterWidth); stringBuilder.push( "
      " ); // from start of the last line to the selection end - top = this.$getTop(range.end.row, layerConfig); - width = Math.round(range.end.column * layerConfig.characterWidth); + top = this.$getTop(range.end.row, config); + var width = Math.round(range.end.column * config.characterWidth); stringBuilder.push( "
      " ); diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/layer/text.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/layer/text.js index 92683967..e96dff28 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/layer/text.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/layer/text.js @@ -131,7 +131,7 @@ var Text = function(parentEl) { container.appendChild(measureNode); } } - + // Size and width can be null if the editor is not visible or // detached from the document if (!this.element.offsetWidth) @@ -153,7 +153,7 @@ var Text = function(parentEl) { return null; return size; - } + } : function() { if (!this.$measureNode) { var measureNode = this.$measureNode = dom.createElement("div"); @@ -178,7 +178,7 @@ var Text = function(parentEl) { container.appendChild(measureNode); } - + var rect = this.$measureNode.getBoundingClientRect(); var size = { @@ -382,7 +382,7 @@ var Text = function(parentEl) { "lparen": true }; - this.$renderToken = function(stringBuilder, screenColumn, token, value) { + this.$renderToken = function(stringBuilder, screenColumn, token, value) { var self = this; var replaceReg = /\t|&|<|( +)|([\u0000-\u0019\u00a0\u1680\u180E\u2000-\u200b\u2028\u2029\u202F\u205F\u3000\uFEFF])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g; var replaceFunc = function(c, a, b, tabIdx, idx4) { @@ -447,7 +447,7 @@ var Text = function(parentEl) { "'>" ); } - + for (var i = 0; i < tokens.length; i++) { var token = tokens[i]; var value = token.value; @@ -461,12 +461,12 @@ var Text = function(parentEl) { else { while (chars + value.length >= splitChars) { screenColumn = self.$renderToken( - stringBuilder, screenColumn, + stringBuilder, screenColumn, token, value.substring(0, splitChars - chars) ); value = value.substring(splitChars - chars); chars = splitChars; - + if (!onlyContents) { stringBuilder.push("", "
      + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../../lib/oop"); +var XmlBehaviour = require("../behaviour/xml").XmlBehaviour; +var CstyleBehaviour = require("./cstyle").CstyleBehaviour; +var TokenIterator = require("../../token_iterator").TokenIterator; +var voidElements = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr']; + +function hasType(token, type) { + var hasType = true; + var typeList = token.type.split('.'); + var needleList = type.split('.'); + needleList.forEach(function(needle){ + if (typeList.indexOf(needle) == -1) { + hasType = false; + return false; + } + }); + return hasType; +} + +var HtmlBehaviour = function () { + + this.inherit(XmlBehaviour); // Get xml behaviour + + this.add("autoclosing", "insertion", function (state, action, editor, session, text) { + if (text == '>') { + var position = editor.getCursorPosition(); + var iterator = new TokenIterator(session, position.row, position.column); + var token = iterator.getCurrentToken(); + var atCursor = false; + if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){ + do { + token = iterator.stepBackward(); + } while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text'))); + } else { + atCursor = true; + } + if (!token || !hasType(token, 'meta.tag-name') || iterator.stepBackward().value.match('/')) { + return + } + var element = token.value; + if (atCursor){ + var element = element.substring(0, position.column - token.start); + } + if (voidElements.indexOf(element) !== -1){ + return; + } + return { + text: '>' + '', + selection: [1, 1] + } + } + }); +} +oop.inherits(HtmlBehaviour, XmlBehaviour); + +exports.HtmlBehaviour = HtmlBehaviour; +}); diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/behaviour/xml.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/behaviour/xml.js index bdfa9d82..34e8510b 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/behaviour/xml.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/behaviour/xml.js @@ -42,34 +42,55 @@ define(function(require, exports, module) { var oop = require("../../lib/oop"); var Behaviour = require("../behaviour").Behaviour; var CstyleBehaviour = require("./cstyle").CstyleBehaviour; +var TokenIterator = require("../../token_iterator").TokenIterator; + +function hasType(token, type) { + var hasType = true; + var typeList = token.type.split('.'); + var needleList = type.split('.'); + needleList.forEach(function(needle){ + if (typeList.indexOf(needle) == -1) { + hasType = false; + return false; + } + }); + return hasType; +} var XmlBehaviour = function () { this.inherit(CstyleBehaviour, ["string_dquotes"]); // Get string behaviour - this.add("brackets", "insertion", function (state, action, editor, session, text) { - if (text == '<') { - var selection = editor.getSelectionRange(); - var selected = session.doc.getTextRange(selection); - if (selected !== "") { - return false; + this.add("autoclosing", "insertion", function (state, action, editor, session, text) { + if (text == '>') { + var position = editor.getCursorPosition(); + var iterator = new TokenIterator(session, position.row, position.column); + var token = iterator.getCurrentToken(); + var atCursor = false; + if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){ + do { + token = iterator.stepBackward(); + } while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text'))); } else { - return { - text: '<>', - selection: [1, 1] - } + atCursor = true; } - } else if (text == '>') { - var cursor = editor.getCursorPosition(); - var line = session.doc.getLine(cursor.row); - var rightChar = line.substring(cursor.column, cursor.column + 1); - if (rightChar == '>') { // need some kind of matching check here - return { - text: '', - selection: [1, 1] - } + if (!token || !hasType(token, 'meta.tag-name') || iterator.stepBackward().value.match('/')) { + return } - } else if (text == "\n") { + var tag = token.value; + if (atCursor){ + var tag = tag.substring(0, position.column - token.start); + } + + return { + text: '>' + '', + selection: [1, 1] + } + } + }); + + this.add('autoindent', 'insertion', function (state, action, editor, session, text) { + if (text == "\n") { var cursor = editor.getCursorPosition(); var line = session.doc.getLine(cursor.row); var rightChars = line.substring(cursor.column, cursor.column + 2); diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/c9search.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/c9search.js index cff2b22a..37a89aab 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/c9search.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/c9search.js @@ -56,18 +56,6 @@ oop.inherits(Mode, TextMode); this.getNextLineIndent = function(state, line, tab) { var indent = this.$getIndent(line); - - // ignore braces in comments - var tokens = this.$tokenizer.getLineTokens(line, state).tokens; - if (tokens.length && tokens[tokens.length-1].type == "comment") { - return indent; - } - - var match = line.match(/^.*\{\s*$/); - if (match) { - indent += tab; - } - return indent; }; diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/c9search_highlight_rules.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/c9search_highlight_rules.js index c16b48c0..f5aae9b2 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/c9search_highlight_rules.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/c9search_highlight_rules.js @@ -48,7 +48,7 @@ var C9SearchHighlightRules = function() { this.$rules = { "start" : [ { - token : ["constant.numeric", "text", "text"], + token : ["c9searchresults.constant.numeric", "c9searchresults.text", "c9searchresults.text"], regex : "(^\\s+[0-9]+)(:\\s*)(.+)" }, { diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/coffee.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/coffee.js index 4afc2896..9d265b67 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/coffee.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/coffee.js @@ -41,7 +41,7 @@ define(function(require, exports, module) { var Tokenizer = require("../tokenizer").Tokenizer; var Rules = require("./coffee_highlight_rules").CoffeeHighlightRules; var Outdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var PythonFoldMode = require("./folding/pythonic").FoldMode; +var PythonFoldMode = require("./folding/coffee").FoldMode; var Range = require("../range").Range; var TextMode = require("./text").Mode; var WorkerClient = require("../worker/worker_client").WorkerClient; diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/coffee_highlight_rules.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/coffee_highlight_rules.js index 2772edf3..d3fe7884 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/coffee_highlight_rules.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/coffee_highlight_rules.js @@ -153,7 +153,7 @@ define(function(require, exports, module) { regex : "\\?|\\:|\\,|\\." }, { token : "keyword.operator", - regex : "(?:[\\-=]>|[-+*/%<>&|^!?=]=|>>>=?|\\-\\-|\\+\\+|::|&&=|\\|\\|=|<<=|>>=|\\?\\.|\\.{2,3}|\\!)" + regex : "(?:[\\-=]>|[-+*/%<>&|^!?=]=|>>>=?|\\-\\-|\\+\\+|::|&&=|\\|\\|=|<<=|>>=|\\?\\.|\\.{2,3}|[!*+-=><])" }, { token : "paren.lparen", regex : "[({[]" diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/c9search.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/c9search.js index dd501153..2c9828de 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/c9search.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/c9search.js @@ -19,7 +19,7 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Fabian Jakobs + * Garen J. Torikian * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -48,46 +48,32 @@ oop.inherits(FoldMode, BaseFoldMode); (function() { - this.foldingStartMarker = /[a-zA-Z](:)\s*$/; - this.foldingStopMarker = /^(\s*)$/; + this.foldingStartMarker = /^(\w.*\:|Searching for.*)$/; + this.foldingStopMarker = /^(\s+|Found.*)$/; this.getFoldWidgetRange = function(session, foldStyle, row) { var line = session.getLine(row); - var match = line.match(this.foldingStartMarker); - if (match) { - var i = match.index; + var level1 = /^(Found.*|Searching for.*)$/; + var level2 = /^(\w.*\:|\s*)$/; + var re = level1.test(line) ? level1 : level2; - if (match[1]) - return this.openingBracketBlock(session, match[1], row, i, false, true); - - var range = session.getCommentFoldRange(row, i + match[0].length); - range.end.column -= 2; - return range; - } - - if (foldStyle !== "markbeginend") - return; - - var match = line.match(this.foldingStopMarker); - if (match) { - var i = match.index + match[0].length; - - if (match[2]) { - var range = session.getCommentFoldRange(row, i); - range.end.column -= 2; - return range; + if (this.foldingStartMarker.test(line)) { + for (var i = row + 1, l = session.getLength(); i < l; i++) { + if (re.test(session.getLine(i))) + break; } - var end = {row: row, column: i}; - var start = session.$findOpeningBracket(match[1], end); - - if (!start) - return; + return new Range(row, line.length, i, 0); + } - start.column++; - end.column--; + if (this.foldingStopMarker.test(line)) { + for (var i = row - 1; i >= 0; i--) { + line = session.getLine(i); + if (re.test(line)) + break; + } - return Range.fromPoints(start, end); + return new Range(i, line.length, row, 0); } }; diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/coffee.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/coffee.js new file mode 100644 index 00000000..b502afc4 --- /dev/null +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/coffee.js @@ -0,0 +1,127 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (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.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../../lib/oop"); +var BaseFoldMode = require("./fold_mode").FoldMode; +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var range = this.indentationBlock(session, row); + if (range) + return range; + + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1 || line[startLevel] != "#") + return; + + var startColumn = line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + line = session.getLine(row); + var level = line.search(re); + + if (level == -1) + continue; + + if (line[level] != "#") + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + var indent = line.search(/\S/); + var next = session.getLine(row + 1); + var prev = session.getLine(row - 1); + var prevIndent = prev.search(/\S/); + var nextIndent = next.search(/\S/); + + if (indent == -1) { + session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : ""; + return ""; + } + + // documentation comments + if (prevIndent == -1) { + if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") { + session.foldWidgets[row - 1] = ""; + session.foldWidgets[row + 1] = ""; + return "start"; + } + } else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") { + if (session.getLine(row - 2).search(/\S/) == -1) { + session.foldWidgets[row - 1] = "start"; + session.foldWidgets[row + 1] = ""; + return "" + } + } + + if (prevIndent!= -1 && prevIndent < indent) + session.foldWidgets[row - 1] = "start"; + else + session.foldWidgets[row - 1] = ""; + + if (indent < nextIndent) + return "start"; + else + return ""; + }; + +}).call(FoldMode.prototype); + +}); diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/coffee_test.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/coffee_test.js new file mode 100644 index 00000000..41c440a2 --- /dev/null +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/coffee_test.js @@ -0,0 +1,108 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (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.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +if (typeof process !== "undefined") + require("amd-loader"); + +define(function(require, exports, module) { +"use strict"; + +var CoffeeMode = require("../coffee").Mode; +var EditSession = require("../../edit_session").EditSession; +var assert = require("../../test/assertions"); +function testFoldWidgets(array) { + var session = array.filter(function(_, i){return i % 2 == 1}); + session = new EditSession(session); + var mode = new CoffeeMode(); + session.setFoldStyle("markbeginend"); + session.setMode(mode); + + var widgets = array.filter(function(_, i){return i % 2 == 0}); + widgets.forEach(function(w, i){ + session.foldWidgets[i] = session.getFoldWidget(i); + }) + widgets.forEach(function(w, i){ + w = w.split(","); + var type = w[0] == ">" ? "start" : w[0] == "<" ? "end" : ""; + assert.equal(session.foldWidgets[i], type); + if (!type) + return; + var range = session.getFoldWidgetRange(i); + if (!w[1]) { + assert.equal(range, null); + return; + } + assert.equal(range.start.row, i); + assert.equal(range.end.row - range.start.row, parseInt(w[1])); + testColumn(w[2], range.start); + testColumn(w[3], range.end); + }); + + function testColumn(w, pos) { + if (!w) + return; + if (w == "l") + w = session.getLine(pos.row).length; + else + w = parseInt(w); + assert.equal(pos.column, w); + } +} +module.exports = { + "test: coffee script indentation based folding": function() { + testFoldWidgets([ + '>,1,l,l', ' ## indented comment', + '', ' # ', + '', '', + '>,1,l,l', ' # plain comment', + '', ' # ', + '>,2', ' function (x)=>', + '', ' ', + '', ' x++', + '', ' ', + '', ' ', + '>,2', ' bar = ', + '', ' foo: 1', + '', ' baz: lighter' + ]); + } +}; + +}); + +if (typeof module !== "undefined" && module === require.main) + require("asyncjs").test.testcase(module.exports).exec(); diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/fold_mode.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/fold_mode.js index 849526c7..25407569 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/fold_mode.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/fold_mode.js @@ -58,25 +58,27 @@ var FoldMode = exports.FoldMode = function() {}; return "end"; return ""; }; - + this.getFoldWidgetRange = function(session, foldStyle, row) { return null; }; this.indentationBlock = function(session, row, column) { - var re = /^\s*/; + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); var startRow = row; var endRow = row; - var line = session.getLine(row); - var startColumn = column || line.length; - var startLevel = line.match(re)[0].length; - var maxRow = session.getLength() - - while (++row < maxRow) { - line = session.getLine(row); - var level = line.match(re)[0].length; - if (level == line.length) + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) continue; if (level <= startLevel) @@ -91,9 +93,9 @@ var FoldMode = exports.FoldMode = function() {}; } }; - this.openingBracketBlock = function(session, bracket, row, column, typeRe, allowBlankLine) { + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { var start = {row: row, column: column + 1}; - var end = session.$findClosingBracket(bracket, start, typeRe, allowBlankLine); + var end = session.$findClosingBracket(bracket, start, typeRe); if (!end) return; @@ -101,7 +103,7 @@ var FoldMode = exports.FoldMode = function() {}; if (fw == null) fw = this.getFoldWidget(session, end.row); - if (fw == "start") { + if (fw == "start" && end.row > start.row) { end.row --; end.column = session.getLine(end.row).length; } diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/pythonic.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/pythonic.js index 90ab2aad..529cc797 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/pythonic.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/pythonic.js @@ -42,7 +42,7 @@ var oop = require("../../lib/oop"); var BaseFoldMode = require("./fold_mode").FoldMode; var FoldMode = exports.FoldMode = function(markers) { - this.foldingStartMarker = new RegExp("(?:([\\[{])|(" + markers + "))(?:\\s*)(?:#.*)?$"); + this.foldingStartMarker = new RegExp("([\\[{])(?:\\s*)$|(" + markers + ")(?:\\s*)(?:#.*)?$"); }; oop.inherits(FoldMode, BaseFoldMode); diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/pythonic_test.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/pythonic_test.js index 6cfb1f77..ca853715 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/pythonic_test.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/pythonic_test.js @@ -49,11 +49,12 @@ module.exports = { "test: bracket folding": function() { var session = new EditSession([ - '[ #-', + '[ ', 'stuff', ']', '[ ', - '{ ' + '{ ', + '[ #-', ]); var mode = new PythonMode(); @@ -65,9 +66,11 @@ module.exports = { assert.equal(session.getFoldWidget(2), ""); assert.equal(session.getFoldWidget(3), "start"); assert.equal(session.getFoldWidget(4), "start"); + assert.equal(session.getFoldWidget(5), ""); assert.range(session.getFoldWidgetRange(0), 0, 1, 2, 0); assert.equal(session.getFoldWidgetRange(3), null); + assert.equal(session.getFoldWidgetRange(5), null); }, "test: indentation folding": function() { diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/html.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/html.js index 13062a41..70a178e1 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/html.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/html.js @@ -44,13 +44,13 @@ var JavaScriptMode = require("./javascript").Mode; var CssMode = require("./css").Mode; var Tokenizer = require("../tokenizer").Tokenizer; var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules; -var XmlBehaviour = require("./behaviour/xml").XmlBehaviour; +var HtmlBehaviour = require("./behaviour/html").HtmlBehaviour; var HtmlFoldMode = require("./folding/html").FoldMode; var Mode = function() { var highlighter = new HtmlHighlightRules(); this.$tokenizer = new Tokenizer(highlighter.getRules()); - this.$behaviour = new XmlBehaviour(); + this.$behaviour = new HtmlBehaviour(); this.$embeds = highlighter.getEmbeds(); this.createModeDelegates({ diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/html_highlight_rules.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/html_highlight_rules.js index 24165fc2..4f51df77 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/html_highlight_rules.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/html_highlight_rules.js @@ -44,6 +44,25 @@ var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScrip var xmlUtil = require("./xml_util"); var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; +var tagMap = { + a : 'anchor', + button : 'form', + form : 'form', + img : 'image', + input : 'form', + label : 'form', + script : 'script', + select : 'form', + textarea : 'form', + style : 'style', + table : 'table', + tbody : 'table', + td : 'table', + tfoot : 'table', + th : 'table', + tr : 'table' +}; + var HtmlHighlightRules = function() { // regexp must not have capturing parentheses @@ -113,9 +132,9 @@ var HtmlHighlightRules = function() { } ] }; - xmlUtil.tag(this.$rules, "tag", "start"); - xmlUtil.tag(this.$rules, "style", "css-start"); - xmlUtil.tag(this.$rules, "script", "js-start"); + xmlUtil.tag(this.$rules, "tag", "start", tagMap); + xmlUtil.tag(this.$rules, "style", "css-start", tagMap); + xmlUtil.tag(this.$rules, "script", "js-start", tagMap); this.embedRules(JavaScriptHighlightRules, "js-", [{ token: "comment", diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/javascript_highlight_rules.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/javascript_highlight_rules.js index 63348303..ad3efba8 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/javascript_highlight_rules.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/javascript_highlight_rules.js @@ -380,7 +380,7 @@ var JavaScriptHighlightRules = function() { "function_arguments": [ { token: "variable.parameter", - regex: identifierRe, + regex: identifierRe }, { token: "punctuation.operator", regex: "[, ]+", diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/luapage.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/luapage.js index 03ee19d1..4a03444c 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/luapage.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/luapage.js @@ -1,4 +1,4 @@ -define(function(require, exports, module) { +define(function(require, exports, module) { "use strict"; var oop = require("../lib/oop"); diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/luapage_highlight_rules.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/luapage_highlight_rules.js index d79581c3..6a79102f 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/luapage_highlight_rules.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/luapage_highlight_rules.js @@ -1,4 +1,4 @@ -// LuaPage implements the LuaPage markup as described by the Kepler Project's CGILua +// LuaPage implements the LuaPage markup as described by the Kepler Project's CGILua // documentation: http://keplerproject.github.com/cgilua/manual.html#templates define(function(require, exports, module) { "use strict"; diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xml_util.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xml_util.js index b58df44f..6aaaeb94 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xml_util.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xml_util.js @@ -38,16 +38,6 @@ define(function(require, exports, module) { "use strict"; -var lang = require("../lib/lang"); - -var formTags = lang.arrayToMap( - ("button|form|input|label|select|textarea").split("|") -); - -var tableTags = lang.arrayToMap( - ("table|tbody|td|tfoot|th|tr").split("|") -); - function string(state) { return [{ token : "string", @@ -81,7 +71,7 @@ function multiLineString(quote, state) { }]; } -exports.tag = function(states, name, nextState) { +exports.tag = function(states, name, nextState, tagMap) { states[name] = [{ token : "text", regex : "\\s+" @@ -89,26 +79,10 @@ exports.tag = function(states, name, nextState) { //token : "meta.tag", token : function(value) { - if ( value==='a' ) { - return "meta.tag.anchor"; - } - else if ( value==='img' ) { - return "meta.tag.image"; - } - else if ( value==='script' ) { - return "meta.tag.script"; - } - else if ( value==='style' ) { - return "meta.tag.style"; - } - else if (formTags.hasOwnProperty(value.toLowerCase())) { - return "meta.tag.form"; - } - else if (tableTags.hasOwnProperty(value.toLowerCase())) { - return "meta.tag.table"; - } - else { - return "meta.tag"; + if (tagMap && tagMap[value]) { + return "meta.tag.tag-name" + '.' + tagMap[value]; + } else { + return "meta.tag.tag-name"; } }, merge : true, diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mouse/default_gutter_handler.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mouse/default_gutter_handler.js index fc9b012b..21c792a1 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mouse/default_gutter_handler.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mouse/default_gutter_handler.js @@ -58,13 +58,10 @@ function GutterHandler(mouseHandler) { var row = e.getDocumentPosition().row; var selection = editor.session.selection; - if (e.getShiftKey()) { + if (e.getShiftKey()) selection.selectTo(row, 0); - } else { - selection.moveCursorTo(row, 0); - selection.selectLine(); - mouseHandler.$clickSelection = selection.getRange(); - } + else + mouseHandler.$clickSelection = editor.selection.getLineRange(row); mouseHandler.captureMouse(e, "selectByLines"); return e.preventDefault(); diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mouse/default_handlers.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mouse/default_handlers.js index 1b916801..7fabf75d 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mouse/default_handlers.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mouse/default_handlers.js @@ -65,7 +65,7 @@ function DefaultHandlers(mouseHandler) { mouseHandler.selectByLines = this.extendSelectionBy.bind(mouseHandler, "getLineRange"); mouseHandler.selectByWords = this.extendSelectionBy.bind(mouseHandler, "getWordRange"); - + mouseHandler.$focusWaitTimout = 250; } @@ -163,10 +163,12 @@ function DefaultHandlers(mouseHandler) { if (cmpStart == -1 && cmpEnd <= 0) { anchor = this.$clickSelection.end; - cursor = range.start; + if (range.end.row != cursor.row || range.end.column != cursor.column) + cursor = range.start; } else if (cmpEnd == 1 && cmpStart >= 0) { anchor = this.$clickSelection.start; - cursor = range.end; + if (range.start.row != cursor.row || range.start.column != cursor.column) + cursor = range.end; } else if (cmpStart == -1 && cmpEnd == 1) { cursor = range.end; anchor = range.start; @@ -286,7 +288,7 @@ function DefaultHandlers(mouseHandler) { this.setState("select"); return; } - + this.$clickSelection = editor.selection.getWordRange(pos.row, pos.column); this.setState("selectByWords"); }; @@ -296,10 +298,7 @@ function DefaultHandlers(mouseHandler) { var editor = this.editor; this.setState("selectByLines"); - - editor.moveCursorToPosition(pos); - editor.selection.selectLine(); - this.$clickSelection = editor.getSelectionRange(); + this.$clickSelection = editor.selection.getLineRange(pos.row); }; this.onQuadClick = function(ev) { @@ -345,7 +344,7 @@ function calcRangeOrientation(range, cursor) { var cmp = 2 * cursor.column - range.start.column - range.end.column; else var cmp = 2 * cursor.row - range.start.row - range.end.row; - + if (cmp < 0) return {cursor: range.start, anchor: range.end}; else diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/requirejs/text.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/requirejs/text.js index cf7ef666..6d6f59ce 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/requirejs/text.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/requirejs/text.js @@ -41,17 +41,17 @@ (function() { -var globalRequire = require; +var globalRequire = typeof require != "undefined" && require; define(function (require, exports, module) { "use strict"; exports.load = function (name, req, onLoad, config) { - if (req.isBrowser) - require("ace/lib/net").get(req.toUrl(name), onLoad); + //Using special require.nodeRequire, something added by r.js. + if (globalRequire && globalRequire.nodeRequire) + onLoad(('fs').readFileSync(req.toUrl(name), 'utf8')); else - //Using special require.nodeRequire, something added by r.js. - onLoad(globalRequire.nodeRequire('fs').readFileSync(req.toUrl(name), 'utf8')); + require("ace/lib/net").get(req.toUrl(name), onLoad); }; }); diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/test/all_browser.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/test/all_browser.js index 934149e4..f1f68c81 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/test/all_browser.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/test/all_browser.js @@ -42,6 +42,7 @@ var testNames = [ "ace/mode/folding/html_test", "ace/mode/folding/pythonic_test", "ace/mode/folding/xml_test", + "ace/mode/folding/coffee_test", "ace/multi_select_test", "ace/range_test", "ace/range_list_test", diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/chrome.css b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/chrome.css index 5997f57c..425071dc 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/chrome.css +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/chrome.css @@ -7,7 +7,7 @@ } .ace-chrome .ace_gutter { - background: #e8e8e8; + background: #ebebeb; color: #333; overflow : hidden; } @@ -18,7 +18,6 @@ } .ace-chrome .ace_text-layer { - cursor: text; } .ace-chrome .ace_cursor { @@ -151,7 +150,10 @@ color:#FD971F; color: rgb(255, 0, 0) } -.ace-chrome .ace_line .ace_string, +.ace-chrome .ace_line .ace_string{ + color: #1A1AA6; +} + .ace-chrome .ace_entity.ace_other.ace_attribute-name{ color: #994409; } \ No newline at end of file diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/clouds.css b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/clouds.css index e490c386..1622cec2 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/clouds.css +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/clouds.css @@ -8,7 +8,7 @@ } .ace-clouds .ace_gutter { - background: #e8e8e8; + background: #ebebeb; color: #333; } @@ -22,7 +22,6 @@ } .ace-clouds .ace_text-layer { - cursor: text; color: #000000; } diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/clouds_midnight.css b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/clouds_midnight.css index 69ed51db..b42113d7 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/clouds_midnight.css +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/clouds_midnight.css @@ -8,13 +8,13 @@ } .ace-clouds-midnight .ace_gutter { - background: #e8e8e8; - color: #333; + background: #232323; + color: #929292; } .ace-clouds-midnight .ace_print_margin { width: 1px; - background: #e8e8e8; + background: #232323; } .ace-clouds-midnight .ace_scroller { @@ -22,7 +22,6 @@ } .ace-clouds-midnight .ace_text-layer { - cursor: text; color: #929292; } @@ -58,7 +57,7 @@ } .ace-clouds-midnight .ace_gutter_active_line { - background-color : #dcdcdc; + background-color: rgba(215, 215, 215, 0.031); } .ace-clouds-midnight .ace_marker-layer .ace_selected_word { diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/cobalt.css b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/cobalt.css index 5c9a7328..2a4aaed0 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/cobalt.css +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/cobalt.css @@ -8,13 +8,13 @@ } .ace-cobalt .ace_gutter { - background: #e8e8e8; - color: #333; + background: #011e3a; + color: #fff; } .ace-cobalt .ace_print_margin { width: 1px; - background: #e8e8e8; + background: #011e3a; } .ace-cobalt .ace_scroller { @@ -22,7 +22,6 @@ } .ace-cobalt .ace_text-layer { - cursor: text; color: #FFFFFF; } @@ -58,7 +57,7 @@ } .ace-cobalt .ace_gutter_active_line { - background-color : #dcdcdc; + background-color : rgba(0, 0, 0, 0.35); } .ace-cobalt .ace_marker-layer .ace_selected_word { diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/crimson_editor.css b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/crimson_editor.css index e38910aa..1ed6783a 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/crimson_editor.css +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/crimson_editor.css @@ -7,7 +7,7 @@ } .ace-crimson-editor .ace_gutter { - background: #e8e8e8; + background: #ebebeb; color: #333; overflow : hidden; } @@ -23,7 +23,6 @@ } .ace-crimson-editor .ace_text-layer { - cursor: text; color: rgb(64, 64, 64); } @@ -134,6 +133,10 @@ background: rgb(232, 242, 254); } +.ace-crimson-editor .ace_gutter_active_line { + background-color : #dcdcdc; +} + .ace-crimson-editor .ace_meta.ace_tag { color:rgb(28, 2, 255); } diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/dawn.css b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/dawn.css index 85d48623..94cbd1c3 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/dawn.css +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/dawn.css @@ -8,7 +8,7 @@ } .ace-dawn .ace_gutter { - background: #e8e8e8; + background: #ebebeb; color: #333; } @@ -22,7 +22,6 @@ } .ace-dawn .ace_text-layer { - cursor: text; color: #080808; } diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/dreamweaver.css b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/dreamweaver.css index b44699af..46ac475c 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/dreamweaver.css +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/dreamweaver.css @@ -21,7 +21,6 @@ } .ace-dreamweaver .ace_text-layer { - cursor: text; } .ace-dreamweaver .ace_cursor { diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/eclipse.css b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/eclipse.css index c39a8470..f02283b2 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/eclipse.css +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/eclipse.css @@ -7,14 +7,14 @@ } .ace-eclipse .ace_gutter { - background: rgb(227, 227, 227); + background: #ebebeb; border-right: 1px solid rgb(159, 159, 159); color: rgb(136, 136, 136); } .ace-eclipse .ace_print_margin { width: 1px; - background: #b1b4ba; + background: #ebebeb; } .ace-eclipse .ace_fold { @@ -22,7 +22,6 @@ } .ace-eclipse .ace_text-layer { - cursor: text; } .ace-eclipse .ace_cursor { diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/github.css b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/github.css index 5f1ab474..935990fa 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/github.css +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/github.css @@ -13,6 +13,15 @@ margin-bottom: 15px; } +.ace-github .ace_gutter { + background: #e8e8e8; + color: #AAA; +} + +.ace-github .ace_scroller { + background: #fff; +} + .ace-github .ace_keyword { font-weight: bold; } @@ -29,6 +38,14 @@ color: #099; } +.ace-github .ace_constant.ace_buildin { + color: #0086B3; +} + +.ace-github .ace_support.ace_function { + color: #0086B3; +} + .ace-github .ace_comment { color: #998; font-style: italic; @@ -38,12 +55,11 @@ color: #0086B3; } -.ace-github .ace_paren.ace_lparen, -.ace-github .ace_paren.ace_rparen { +.ace-github .ace_paren { font-weight: bold; } -.ace-github .ace_constant.ace_language.ace_boolean { +.ace-github .ace_boolean { font-weight: bold; } @@ -61,7 +77,6 @@ } .ace-github .ace_text-layer { - cursor: text; } .ace-github .ace_cursor { @@ -73,10 +88,46 @@ border-bottom: 1px solid black; } +.ace-github .ace_marker-layer .ace_active_line { + background: rgb(255, 255, 204); +} .ace-github .ace_marker-layer .ace_selection { background: rgb(181, 213, 255); } .ace-github.multiselect .ace_selection.start { box-shadow: 0 0 3px 0px white; border-radius: 2px; +} +/* bold keywords cause cursor issues for some fonts */ +/* this disables bold style for editor and keeps for static highlighter */ +.ace-github.ace_editor .ace_line > span { + font-weight: normal !important; +} + +.ace-github .ace_marker-layer .ace_step { + background: rgb(252, 255, 0); +} + +.ace-github .ace_marker-layer .ace_stack { + background: rgb(164, 229, 101); +} + +.ace-github .ace_marker-layer .ace_bracket { + margin: -1px 0 0 -1px; + border: 1px solid rgb(192, 192, 192); +} + +.ace-github .ace_gutter_active_line{ + background-color : rgba(0, 0, 0, 0.07); +} + +.ace-github .ace_marker-layer .ace_selected_word { + background: rgb(250, 250, 255); + border: 1px solid rgb(200, 200, 250); + +} + +.ace-github .ace_print_margin { + width: 1px; + background: #e8e8e8; } \ No newline at end of file diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/github.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/github.js index b81731f3..a655724e 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/github.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/github.js @@ -37,7 +37,7 @@ define(function(require, exports, module) { -exports.isDark = true; +exports.isDark = false; exports.cssClass = "ace-github"; exports.cssText = require('ace/requirejs/text!./github.css'); diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/idle_fingers.css b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/idle_fingers.css index 4ad6ff23..ba753f20 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/idle_fingers.css +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/idle_fingers.css @@ -8,13 +8,13 @@ } .ace-idle-fingers .ace_gutter { - background: #e8e8e8; - color: #333; + background: #3b3b3b; + color: #fff; } .ace-idle-fingers .ace_print_margin { width: 1px; - background: #e8e8e8; + background: #3b3b3b; } .ace-idle-fingers .ace_scroller { @@ -22,7 +22,6 @@ } .ace-idle-fingers .ace_text-layer { - cursor: text; color: #FFFFFF; } @@ -58,7 +57,7 @@ } .ace-idle-fingers .ace_gutter_active_line { - background-color : #dcdcdc; + background-color: #353637; } .ace-idle-fingers .ace_marker-layer .ace_selected_word { diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/kr_theme.css b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/kr_theme.css index aa6c2e37..3e5f7332 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/kr_theme.css +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/kr_theme.css @@ -8,13 +8,13 @@ } .ace-kr-theme .ace_gutter { - background: #e8e8e8; - color: #333; + background: #1c1917; + color: #FCFFE0; } .ace-kr-theme .ace_print_margin { width: 1px; - background: #e8e8e8; + background: #1c1917; } .ace-kr-theme .ace_scroller { @@ -22,7 +22,6 @@ } .ace-kr-theme .ace_text-layer { - cursor: text; color: #FCFFE0; } @@ -58,7 +57,7 @@ } .ace-kr-theme .ace_gutter_active_line { - background-color : #dcdcdc; + background-color : #38403D; } .ace-kr-theme .ace_marker-layer .ace_selected_word { diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/merbivore.css b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/merbivore.css index fe957fba..1048600a 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/merbivore.css +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/merbivore.css @@ -8,8 +8,8 @@ } .ace-merbivore .ace_gutter { - background: #e8e8e8; - color: #333; + background: #202020; + color: #E6E1DC; } .ace-merbivore .ace_print_margin { @@ -22,7 +22,6 @@ } .ace-merbivore .ace_text-layer { - cursor: text; color: #E6E1DC; } @@ -58,7 +57,7 @@ } .ace-merbivore .ace_gutter_active_line { - background-color : #dcdcdc; + background-color : #333435; } .ace-merbivore .ace_marker-layer .ace_selected_word { diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/merbivore_soft.css b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/merbivore_soft.css index 4b7e91f2..8e1d24a5 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/merbivore_soft.css +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/merbivore_soft.css @@ -8,13 +8,13 @@ } .ace-merbivore-soft .ace_gutter { - background: #e8e8e8; - color: #333; + background: #262424; + color: #E6E1DC; } .ace-merbivore-soft .ace_print_margin { width: 1px; - background: #e8e8e8; + background: #262424; } .ace-merbivore-soft .ace_scroller { @@ -22,7 +22,6 @@ } .ace-merbivore-soft .ace_text-layer { - cursor: text; color: #E6E1DC; } @@ -58,7 +57,7 @@ } .ace-merbivore-soft .ace_gutter_active_line { - background-color : #dcdcdc; + background-color: #333435; } .ace-merbivore-soft .ace_marker-layer .ace_selected_word { diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/mono_industrial.css b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/mono_industrial.css index 1e2d06ba..a8af1bcd 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/mono_industrial.css +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/mono_industrial.css @@ -8,8 +8,8 @@ } .ace-mono-industrial .ace_gutter { - background: #e8e8e8; - color: #333; + background: #1d2521; + color: #fff; } .ace-mono-industrial .ace_print_margin { @@ -22,7 +22,6 @@ } .ace-mono-industrial .ace_text-layer { - cursor: text; color: #FFFFFF; } @@ -58,7 +57,7 @@ } .ace-mono-industrial .ace_gutter_active_line { - background-color : #dcdcdc; + background-color: rgba(12, 13, 12, 0.25); } .ace-mono-industrial .ace_marker-layer .ace_selected_word { diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/monokai.css b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/monokai.css index 5597ab01..cae92734 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/monokai.css +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/monokai.css @@ -8,7 +8,7 @@ } .ace-monokai .ace_gutter { - background: #292a24; + background: #2f3129; color: #f1f1f1; } @@ -22,7 +22,6 @@ } .ace-monokai .ace_text-layer { - cursor: text; color: #F8F8F2; } diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/pastel_on_dark.css b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/pastel_on_dark.css index fc5155a4..e220569c 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/pastel_on_dark.css +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/pastel_on_dark.css @@ -8,13 +8,13 @@ } .ace-pastel-on-dark .ace_gutter { - background: #e8e8e8; - color: #333; + background: #353030; + color: #8F938F; } .ace-pastel-on-dark .ace_print_margin { width: 1px; - background: #e8e8e8; + background: #353030; } .ace-pastel-on-dark .ace_scroller { @@ -22,7 +22,6 @@ } .ace-pastel-on-dark .ace_text-layer { - cursor: text; color: #8F938F; } @@ -58,7 +57,7 @@ } .ace-pastel-on-dark .ace_gutter_active_line { - background-color : #dcdcdc; + background-color: rgba(255, 255, 255, 0.031); } .ace-pastel-on-dark .ace_marker-layer .ace_selected_word { diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/solarized_dark.css b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/solarized_dark.css index 31eed2bd..df259e8b 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/solarized_dark.css +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/solarized_dark.css @@ -8,7 +8,7 @@ } .ace-solarized-dark .ace_gutter { - background: #09222b; + background: #01313f; color: #d0edf7; } @@ -22,7 +22,6 @@ } .ace-solarized-dark .ace_text-layer { - cursor: text; color: #93A1A1; } diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/solarized_light.css b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/solarized_light.css index cc1c8699..1bd26c83 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/solarized_light.css +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/solarized_light.css @@ -8,7 +8,7 @@ } .ace-solarized-light .ace_gutter { - background: #e8e8e8; + background: #fbf1d3; color: #333; } @@ -22,7 +22,6 @@ } .ace-solarized-light .ace_text-layer { - cursor: text; color: #586E75; } diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/textmate.css b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/textmate.css index dafb9fa1..c23c30f1 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/textmate.css +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/textmate.css @@ -7,7 +7,7 @@ } .ace-tm .ace_gutter { - background: #e8e8e8; + background: #f0f0f0; color: #333; } @@ -21,7 +21,6 @@ } .ace-tm .ace_text-layer { - cursor: text; } .ace-tm .ace_cursor { @@ -147,7 +146,8 @@ .ace-tm .ace_marker-layer .ace_active_line { background: rgba(0, 0, 0, 0.07); } -.ace-tm .ace_gutter_active_line{ + +.ace-tm .ace_gutter_active_line { background-color : #dcdcdc; } diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow.css b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow.css index 95c9c0d4..e65d3a5a 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow.css +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow.css @@ -8,13 +8,13 @@ } .ace-tomorrow .ace_gutter { - background: #e8e8e8; - color: #333; + background: #f6f6f6; + color: #4D4D4C; } .ace-tomorrow .ace_print_margin { width: 1px; - background: #e8e8e8; + background: #f6f6f6; } .ace-tomorrow .ace_scroller { @@ -22,7 +22,6 @@ } .ace-tomorrow .ace_text-layer { - cursor: text; color: #4D4D4C; } diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night.css b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night.css index 2e74d864..3ac694f5 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night.css +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night.css @@ -8,13 +8,13 @@ } .ace-tomorrow-night .ace_gutter { - background: #e8e8e8; - color: #333; + background: #25282c; + color: #C5C8C6; } .ace-tomorrow-night .ace_print_margin { width: 1px; - background: #e8e8e8; + background: #25282c; } .ace-tomorrow-night .ace_scroller { @@ -22,7 +22,6 @@ } .ace-tomorrow-night .ace_text-layer { - cursor: text; color: #C5C8C6; } @@ -58,7 +57,7 @@ } .ace-tomorrow-night .ace_gutter_active_line { - background-color : #dcdcdc; + background-color: #282A2E; } .ace-tomorrow-night .ace_marker-layer .ace_selected_word { diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night_blue.css b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night_blue.css index 10c58165..1bcc86c3 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night_blue.css +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night_blue.css @@ -8,13 +8,13 @@ } .ace-tomorrow-night-blue .ace_gutter { - background: #022346; + background: #00204b; color: #7388b5; } .ace-tomorrow-night-blue .ace_print_margin { width: 1px; - background: #e8e8e8; + background: #00204b; } .ace-tomorrow-night-blue .ace_scroller { @@ -22,7 +22,6 @@ } .ace-tomorrow-night-blue .ace_text-layer { - cursor: text; color: #FFFFFF; } diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night_bright.css b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night_bright.css index 21a928be..7cee6607 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night_bright.css +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night_bright.css @@ -8,13 +8,13 @@ } .ace-tomorrow-night-bright .ace_gutter { - background: #e8e8e8; - color: #333; + background: #1a1a1a; + color: #DEDEDE; } .ace-tomorrow-night-bright .ace_print_margin { width: 1px; - background: #e8e8e8; + background: #1a1a1a; } .ace-tomorrow-night-bright .ace_scroller { @@ -22,7 +22,6 @@ } .ace-tomorrow-night-bright .ace_text-layer { - cursor: text; color: #DEDEDE; } @@ -58,7 +57,7 @@ } .ace-tomorrow-night-bright .ace_gutter_active_line { - background-color : #dcdcdc; + background-color: #2A2A2A; } .ace-tomorrow-night-bright .ace_marker-layer .ace_selected_word { diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night_eighties.css b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night_eighties.css index 93f2d3b6..ce5ef317 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night_eighties.css +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night_eighties.css @@ -8,13 +8,13 @@ } .ace-tomorrow-night-eighties .ace_gutter { - background: #e8e8e8; - color: #333; + background: #272727; + color: #CCC; } .ace-tomorrow-night-eighties .ace_print_margin { width: 1px; - background: #e8e8e8; + background: #272727; } .ace-tomorrow-night-eighties .ace_scroller { @@ -22,7 +22,6 @@ } .ace-tomorrow-night-eighties .ace_text-layer { - cursor: text; color: #CCCCCC; } @@ -58,7 +57,7 @@ } .ace-tomorrow-night-eighties .ace_gutter_active_line { - background-color : #dcdcdc; + background-color: #393939; } .ace-tomorrow-night-eighties .ace_marker-layer .ace_selected_word { diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/twilight.css b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/twilight.css index 6d81e4a5..28d1ffa6 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/twilight.css +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/twilight.css @@ -8,13 +8,13 @@ } .ace-twilight .ace_gutter { - background: #e8e8e8; - color: #333; + background: #232323; + color: #F8F8F8; } .ace-twilight .ace_print_margin { width: 1px; - background: #e8e8e8; + background: #232323; } .ace-twilight .ace_scroller { @@ -22,7 +22,6 @@ } .ace-twilight .ace_text-layer { - cursor: text; color: #F8F8F8; } @@ -58,7 +57,7 @@ } .ace-twilight .ace_gutter_active_line { - background-color : #dcdcdc; + background-color: rgba(255, 255, 255, 0.031); } .ace-twilight .ace_marker-layer .ace_selected_word { diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/vibrant_ink.css b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/vibrant_ink.css index 81c54d71..3677a28e 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/vibrant_ink.css +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/vibrant_ink.css @@ -8,13 +8,13 @@ } .ace-vibrant-ink .ace_gutter { - background: #e8e8e8; - color: #333; + background: #1a1a1a; + color: white; } .ace-vibrant-ink .ace_print_margin { width: 1px; - background: #e8e8e8; + background: #1a1a1a; } .ace-vibrant-ink .ace_scroller { @@ -22,7 +22,6 @@ } .ace-vibrant-ink .ace_text-layer { - cursor: text; color: #FFFFFF; } @@ -58,7 +57,7 @@ } .ace-vibrant-ink .ace_gutter_active_line { - background-color : #dcdcdc; + background-color: #333333; } .ace-vibrant-ink .ace_marker-layer .ace_selected_word { diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/virtual_renderer.js b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/virtual_renderer.js index 18408b98..eb6a17c7 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/virtual_renderer.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/virtual_renderer.js @@ -263,8 +263,13 @@ var VirtualRenderer = function(container, theme) { * * Triggers a full update of all the layers, for all the rows. **/ - this.updateFull = function() { - this.$loop.schedule(this.CHANGE_FULL); + this.updateFull = function(force) { + if (force){ + this.$renderChanges(this.CHANGE_FULL, true); + } + else { + this.$loop.schedule(this.CHANGE_FULL); + } }; /** @@ -282,11 +287,19 @@ var VirtualRenderer = function(container, theme) { * * [Triggers a resize of the editor.]{: #VirtualRenderer.onResize} **/ - this.onResize = function(force) { + this.onResize = function(force, gutterWidth, width, height) { var changes = this.CHANGE_SIZE; var size = this.$size; - var height = dom.getInnerHeight(this.container); + if (this.resizing > 2) + return; + else if (this.resizing > 1) + this.resizing++; + else + this.resizing = force ? 1 : 0; + + if (!height) + height = dom.getInnerHeight(this.container); if (force || size.height != height) { size.height = height; @@ -300,20 +313,27 @@ var VirtualRenderer = function(container, theme) { } } - var width = dom.getInnerWidth(this.container); - if (force || size.width != width) { + if (!width) + width = dom.getInnerWidth(this.container); + if (force || this.resizing > 1 || size.width != width) { size.width = width; var gutterWidth = this.showGutter ? this.$gutter.offsetWidth : 0; this.scroller.style.left = gutterWidth + "px"; size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBar.getWidth()); - this.scroller.style.width = size.scrollerWidth + "px"; + this.scroller.style.right = this.scrollBar.getWidth() + "px"; if (this.session.getUseWrapMode() && this.adjustWrapLimit() || force) changes = changes | this.CHANGE_FULL; } - this.$loop.schedule(changes); + if (force) + this.$renderChanges(changes, true); + else + this.$loop.schedule(changes); + + if (force) + delete this.resizing; }; /** @@ -642,8 +662,8 @@ var VirtualRenderer = function(container, theme) { this.scrollBar.setScrollTop(this.scrollTop); }; - this.$renderChanges = function(changes) { - if (!changes || !this.session || !this.container.offsetWidth) + this.$renderChanges = function(changes, force) { + if (!force && (!changes || !this.session || !this.container.offsetWidth)) return; // text, scrolling and resize changes can cause the view port size to change diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/debounce/jquery.ba-throttle-debounce.js b/lib/gollum/frontend/public/gollum/livepreview/js/debounce/jquery.ba-throttle-debounce.js deleted file mode 100644 index fa30bdff..00000000 --- a/lib/gollum/frontend/public/gollum/livepreview/js/debounce/jquery.ba-throttle-debounce.js +++ /dev/null @@ -1,252 +0,0 @@ -/*! - * jQuery throttle / debounce - v1.1 - 3/7/2010 - * http://benalman.com/projects/jquery-throttle-debounce-plugin/ - * - * Copyright (c) 2010 "Cowboy" Ben Alman - * Dual licensed under the MIT and GPL licenses. - * http://benalman.com/about/license/ - */ - -// Script: jQuery throttle / debounce: Sometimes, less is more! -// -// *Version: 1.1, Last updated: 3/7/2010* -// -// Project Home - http://benalman.com/projects/jquery-throttle-debounce-plugin/ -// GitHub - http://github.com/cowboy/jquery-throttle-debounce/ -// Source - http://github.com/cowboy/jquery-throttle-debounce/raw/master/jquery.ba-throttle-debounce.js -// (Minified) - http://github.com/cowboy/jquery-throttle-debounce/raw/master/jquery.ba-throttle-debounce.min.js (0.7kb) -// -// About: License -// -// Copyright (c) 2010 "Cowboy" Ben Alman, -// Dual licensed under the MIT and GPL licenses. -// http://benalman.com/about/license/ -// -// About: Examples -// -// These working examples, complete with fully commented code, illustrate a few -// ways in which this plugin can be used. -// -// Throttle - http://benalman.com/code/projects/jquery-throttle-debounce/examples/throttle/ -// Debounce - http://benalman.com/code/projects/jquery-throttle-debounce/examples/debounce/ -// -// About: Support and Testing -// -// Information about what version or versions of jQuery this plugin has been -// tested with, what browsers it has been tested in, and where the unit tests -// reside (so you can test it yourself). -// -// jQuery Versions - none, 1.3.2, 1.4.2 -// Browsers Tested - Internet Explorer 6-8, Firefox 2-3.6, Safari 3-4, Chrome 4-5, Opera 9.6-10.1. -// Unit Tests - http://benalman.com/code/projects/jquery-throttle-debounce/unit/ -// -// About: Release History -// -// 1.1 - (3/7/2010) Fixed a bug in where trailing callbacks -// executed later than they should. Reworked a fair amount of internal -// logic as well. -// 1.0 - (3/6/2010) Initial release as a stand-alone project. Migrated over -// from jquery-misc repo v0.4 to jquery-throttle repo v1.0, added the -// no_trailing throttle parameter and debounce functionality. -// -// Topic: Note for non-jQuery users -// -// jQuery isn't actually required for this plugin, because nothing internal -// uses any jQuery methods or properties. jQuery is just used as a namespace -// under which these methods can exist. -// -// Since jQuery isn't actually required for this plugin, if jQuery doesn't exist -// when this plugin is loaded, the method described below will be created in -// the `Cowboy` namespace. Usage will be exactly the same, but instead of -// $.method() or jQuery.method(), you'll need to use Cowboy.method(). - -(function(window,undefined){ - '$:nomunge'; // Used by YUI compressor. - - // Since jQuery really isn't required for this plugin, use `jQuery` as the - // namespace only if it already exists, otherwise use the `Cowboy` namespace, - // creating it if necessary. - var $ = window.jQuery || window.Cowboy || ( window.Cowboy = {} ), - - // Internal method reference. - jq_throttle; - - // Method: jQuery.throttle - // - // Throttle execution of a function. Especially useful for rate limiting - // execution of handlers on events like resize and scroll. If you want to - // rate-limit execution of a function to a single time, see the - // method. - // - // In this visualization, | is a throttled-function call and X is the actual - // callback execution: - // - // > Throttled with `no_trailing` specified as false or unspecified: - // > ||||||||||||||||||||||||| (pause) ||||||||||||||||||||||||| - // > X X X X X X X X X X X X - // > - // > Throttled with `no_trailing` specified as true: - // > ||||||||||||||||||||||||| (pause) ||||||||||||||||||||||||| - // > X X X X X X X X X X - // - // Usage: - // - // > var throttled = jQuery.throttle( delay, [ no_trailing, ] callback ); - // > - // > jQuery('selector').bind( 'someevent', throttled ); - // > jQuery('selector').unbind( 'someevent', throttled ); - // - // This also works in jQuery 1.4+: - // - // > jQuery('selector').bind( 'someevent', jQuery.throttle( delay, [ no_trailing, ] callback ) ); - // > jQuery('selector').unbind( 'someevent', callback ); - // - // Arguments: - // - // delay - (Number) A zero-or-greater delay in milliseconds. For event - // callbacks, values around 100 or 250 (or even higher) are most useful. - // no_trailing - (Boolean) Optional, defaults to false. If no_trailing is - // true, callback will only execute every `delay` milliseconds while the - // throttled-function is being called. If no_trailing is false or - // unspecified, callback will be executed one final time after the last - // throttled-function call. (After the throttled-function has not been - // called for `delay` milliseconds, the internal counter is reset) - // callback - (Function) A function to be executed after delay milliseconds. - // The `this` context and all arguments are passed through, as-is, to - // `callback` when the throttled-function is executed. - // - // Returns: - // - // (Function) A new, throttled, function. - - $.throttle = jq_throttle = function( delay, no_trailing, callback, debounce_mode ) { - // After wrapper has stopped being called, this timeout ensures that - // `callback` is executed at the proper times in `throttle` and `end` - // debounce modes. - var timeout_id, - - // Keep track of the last time `callback` was executed. - last_exec = 0; - - // `no_trailing` defaults to falsy. - if ( typeof no_trailing !== 'boolean' ) { - debounce_mode = callback; - callback = no_trailing; - no_trailing = undefined; - } - - // The `wrapper` function encapsulates all of the throttling / debouncing - // functionality and when executed will limit the rate at which `callback` - // is executed. - function wrapper() { - var that = this, - elapsed = +new Date() - last_exec, - args = arguments; - - // Execute `callback` and update the `last_exec` timestamp. - function exec() { - last_exec = +new Date(); - callback.apply( that, args ); - }; - - // If `debounce_mode` is true (at_begin) this is used to clear the flag - // to allow future `callback` executions. - function clear() { - timeout_id = undefined; - }; - - if ( debounce_mode && !timeout_id ) { - // Since `wrapper` is being called for the first time and - // `debounce_mode` is true (at_begin), execute `callback`. - exec(); - } - - // Clear any existing timeout. - timeout_id && clearTimeout( timeout_id ); - - if ( debounce_mode === undefined && elapsed > delay ) { - // In throttle mode, if `delay` time has been exceeded, execute - // `callback`. - exec(); - - } else if ( no_trailing !== true ) { - // In trailing throttle mode, since `delay` time has not been - // exceeded, schedule `callback` to execute `delay` ms after most - // recent execution. - // - // If `debounce_mode` is true (at_begin), schedule `clear` to execute - // after `delay` ms. - // - // If `debounce_mode` is false (at end), schedule `callback` to - // execute after `delay` ms. - timeout_id = setTimeout( debounce_mode ? clear : exec, debounce_mode === undefined ? delay - elapsed : delay ); - } - }; - - // Set the guid of `wrapper` function to the same of original callback, so - // it can be removed in jQuery 1.4+ .unbind or .die by using the original - // callback as a reference. - if ( $.guid ) { - wrapper.guid = callback.guid = callback.guid || $.guid++; - } - - // Return the wrapper function. - return wrapper; - }; - - // Method: jQuery.debounce - // - // Debounce execution of a function. Debouncing, unlike throttling, - // guarantees that a function is only executed a single time, either at the - // very beginning of a series of calls, or at the very end. If you want to - // simply rate-limit execution of a function, see the - // method. - // - // In this visualization, | is a debounced-function call and X is the actual - // callback execution: - // - // > Debounced with `at_begin` specified as false or unspecified: - // > ||||||||||||||||||||||||| (pause) ||||||||||||||||||||||||| - // > X X - // > - // > Debounced with `at_begin` specified as true: - // > ||||||||||||||||||||||||| (pause) ||||||||||||||||||||||||| - // > X X - // - // Usage: - // - // > var debounced = jQuery.debounce( delay, [ at_begin, ] callback ); - // > - // > jQuery('selector').bind( 'someevent', debounced ); - // > jQuery('selector').unbind( 'someevent', debounced ); - // - // This also works in jQuery 1.4+: - // - // > jQuery('selector').bind( 'someevent', jQuery.debounce( delay, [ at_begin, ] callback ) ); - // > jQuery('selector').unbind( 'someevent', callback ); - // - // Arguments: - // - // delay - (Number) A zero-or-greater delay in milliseconds. For event - // callbacks, values around 100 or 250 (or even higher) are most useful. - // at_begin - (Boolean) Optional, defaults to false. If at_begin is false or - // unspecified, callback will only be executed `delay` milliseconds after - // the last debounced-function call. If at_begin is true, callback will be - // executed only at the first debounced-function call. (After the - // throttled-function has not been called for `delay` milliseconds, the - // internal counter is reset) - // callback - (Function) A function to be executed after delay milliseconds. - // The `this` context and all arguments are passed through, as-is, to - // `callback` when the debounced-function is executed. - // - // Returns: - // - // (Function) A new, debounced, function. - - $.debounce = function( delay, at_begin, callback ) { - return callback === undefined - ? jq_throttle( delay, at_begin, false ) - : jq_throttle( delay, callback, at_begin !== false ); - }; - -})(this); diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/jquery.ba-throttle-debounce.min.js b/lib/gollum/frontend/public/gollum/livepreview/js/jquery.ba-throttle-debounce.min.js new file mode 100644 index 00000000..702954d4 --- /dev/null +++ b/lib/gollum/frontend/public/gollum/livepreview/js/jquery.ba-throttle-debounce.min.js @@ -0,0 +1,2 @@ +(function(window,undefined){"$:nomunge";var $=window.jQuery||window.Cowboy||(window.Cowboy={}),jq_throttle;$.throttle=jq_throttle=function(delay,no_trailing,callback,debounce_mode){var timeout_id,last_exec=0;if(typeof no_trailing!=="boolean"){debounce_mode=callback;callback=no_trailing;no_trailing=undefined}function wrapper(){var that=this,elapsed=+new Date-last_exec,args=arguments;function exec(){last_exec=+new Date;callback.apply(that,args)}function clear(){timeout_id=undefined}if(debounce_mode&& +!timeout_id)exec();timeout_id&&clearTimeout(timeout_id);if(debounce_mode===undefined&&elapsed>delay)exec();else if(no_trailing!==true)timeout_id=setTimeout(debounce_mode?clear:exec,debounce_mode===undefined?delay-elapsed:delay)}if($.guid)wrapper.guid=callback.guid=callback.guid||$.guid++;return wrapper};$.debounce=function(delay,at_begin,callback){return callback===undefined?jq_throttle(delay,at_begin,false):jq_throttle(delay,callback,at_begin!==false)}})(this); diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/livepreview/livepreview.js b/lib/gollum/frontend/public/gollum/livepreview/js/livepreview.js similarity index 89% rename from lib/gollum/frontend/public/gollum/livepreview/js/livepreview/livepreview.js rename to lib/gollum/frontend/public/gollum/livepreview/js/livepreview.js index c473d6c8..c1941944 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/livepreview/livepreview.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/livepreview.js @@ -1,6 +1,7 @@ -require([ 'ace/ext/static_highlight', 'ace/theme/github', 'ace/editor', 'ace/virtual_renderer', 'ace/mode/markdown', 'ace/theme/twilight', +require([ 'ace/undomanager', 'ace/ext/static_highlight', 'ace/theme/github', 'ace/editor', 'ace/virtual_renderer', 'ace/mode/markdown', 'ace/theme/twilight', 'ace/mode/c_cpp', 'ace/mode/clojure', 'ace/mode/coffee', 'ace/mode/coldfusion', 'ace/mode/csharp', 'ace/mode/css', 'ace/mode/diff', 'ace/mode/golang', 'ace/mode/groovy', 'ace/mode/haxe', 'ace/mode/html', 'ace/mode/java', 'ace/mode/javascript', 'ace/mode/json', 'ace/mode/latex', 'ace/mode/less', 'ace/mode/liquid', 'ace/mode/lua', 'ace/mode/markdown', 'ace/mode/ocaml', 'ace/mode/perl', 'ace/mode/pgsql', 'ace/mode/php', 'ace/mode/powershell', 'ace/mode/python', 'ace/mode/ruby', 'ace/mode/scad', 'ace/mode/scala', 'ace/mode/scss', 'ace/mode/sh', 'ace/mode/sql', 'ace/mode/svg', 'ace/mode/textile', 'ace/mode/text', 'ace/mode/xml', 'ace/mode/xquery', 'ace/mode/yaml' ], function() { +var UndoManager = require("ace/undomanager").UndoManager; var Renderer = require( 'ace/virtual_renderer' ).VirtualRenderer; var Editor = require( 'ace/editor' ).Editor; var dom = require( 'ace/lib/dom' ); @@ -11,7 +12,6 @@ var doc = document; win.onbeforeunload = function() { return 'Leaving Live Preview will discard all edits!' }; -var converter = Markdown.getSanitizingConverter(); var editor = new Editor( new Renderer( doc.getElementById( 'editor' ) ));//ace.edit( 'editor' ); var editorSession = editor.getSession(); $.editorSession = editorSession; // for testing @@ -35,6 +35,7 @@ win.jsm.toggleLeftRight = function() { var MarkdownMode = require( 'ace/mode/markdown' ).Mode; function initAce( editor, editorSession ) { + editorSession.setUndoManager(new UndoManager()); editor.setTheme( 'ace/theme/twilight' ); editorSession.setMode( new MarkdownMode() ); // Gutter shows line numbers @@ -72,7 +73,7 @@ var create = $.key( 'create' ); var pageName = $.key( 'page' ); var pathName = $.key( 'path' ); -if (pathName === 0) { +if ( pathName === 0 ) { pathName = undefined; } @@ -96,11 +97,12 @@ $.save = function( commitMessage ) { var markdown = 'markdown'; var txt = editorSession.getValue(); var msg = defaultCommitMessage(); - var newLocation = location.protocol + '//' + location.host + baseUrl; + if (pathName) { newLocation += '/' + pathName; } + newLocation += '/' + pageName; // if &create=true then handle create instead of edit. @@ -224,18 +226,24 @@ function highlight( element, language ) { // '>' and '>'. // Firefox does not support innerText. var data = element.innerText || element.textContent; + data = data.trim(); var mode = getLang( language ); // input, mode, theme, lineStart, disableGutter var color = staticHighlight.render( data, mode, githubTheme, 1, true ); var newDiv = doc.createElement('div'); newDiv.innerHTML = color.html; - element.parentNode.replaceChild( newDiv, element ); + element.parentNode.parentNode.replaceChild( newDiv, element.parentNode ); } var makePreviewHtml = function () { var text = editorSession.getValue(); + if ( text == undefined || text == '' ) { + previewSet( '' ); + return; + } + if (text && text == oldInputText) { return; // Input text hasn't changed. } @@ -244,8 +252,7 @@ var makePreviewHtml = function () { } var prevTime = new Date().getTime(); - - text = converter.makeHtml( text ); + text = md_to_html( text ); // Calculate the processing time of the HTML creation. // It's used as the delay time in the event listener. @@ -255,7 +262,8 @@ var makePreviewHtml = function () { // Update the text using feature detection to support IE. // preview.innerHTML = text; // this doesn't work on IE. previewSet( text ); - MathJax.Hub.Typeset( content ); + // MathJax is loaded asynchronously. + if (typeof MathJax != 'undefined') { MathJax.Hub.Typeset( content ); } // highlight code blocks. var codeElements = preview.getElementsByTagName( 'pre' ); @@ -266,50 +274,40 @@ var makePreviewHtml = function () { for ( var idx = 0; idx < codeElementsLength; idx++ ) { // highlight removes an element so 0 is always the correct index. // Skipped tags are not removed so they must be added. - var element = codeElements[ 0 + skipped ]; + var element = codeElements[ 0 + skipped ].firstChild; + if ( element == undefined ) { + skipped++; + continue; + } var codeHTML = element.innerHTML; - - // Only use pre tags marked containing code. - if ( codeHTML[ 0 ] !== '`' ) - continue; - + if ( codeHTML == undefined ) { + skipped++; + continue; + } var txt = codeHTML.split( /\b/ ); // the syntax for code highlighting means all code, even one line, contains newlines. if ( txt.length > 1 && codeHTML.match( /\n/ ) ) { - var declaredLanguage = txt[ 1 ]; + var declaredLanguage = element.className.toLowerCase(); var aceMode = declaredLanguage; // GitHub supports 'c', 'c++', 'cpp' // which must trigger the 'c_cpp' mode in Ace. - if ( declaredLanguage === 'cpp' ) { + if ( declaredLanguage === 'c' || + declaredLanguage === 'c++' || + declaredLanguage === 'cpp' ) { aceMode = 'c_cpp'; } - // '`c++'.split( /\b/ ) - // ["`", "c", "++"] - if ( declaredLanguage === 'c' ) { - aceMode = 'c_cpp'; - if ( txt.length > 2 && txt[ 2 ].substring( 0, 2 ) === '++' ) { - declaredLanguage += '++'; - } - } - - // txt[0] must be '`' - // txt[0] = '`'; txt[1] = 'ruby' - if ( txt[ 0 ] !== '`' || $.inArray( declaredLanguage, languages ) === -1 ) { + if ( $.inArray( declaredLanguage, languages ) === -1 ) { // Unsupported language. skipped++; - element.innerHTML = codeHTML.substring( 1 ).trim(); continue; } - // length + 1 for the marker character. - element.innerHTML = codeHTML.substring( declaredLanguage.length + 1 ).trim(); // highlight: element highlight( element, aceMode ); } else { // Highlighting is not for `code` inline syntax. For example `puts "string"`. skipped++; - element.innerHTML = codeHTML.substring( 1 ).trim(); } } } @@ -330,14 +328,18 @@ var applyTimeout = function () { timeout = setTimeout( makePreviewHtml, elapsedTime ); }; - /* Load markdown from /data/page into the ace editor. */ - jQuery.ajax( { - type: 'GET', - url: baseUrl + '/data/' + $.key( 'page' ), - success: function( data ) { - editorSession.setValue( data ); - } - }); + /* Load markdown from /data/page into the ace editor. + ~-1 == false; !~-1 == true; + */ + if ( !~location.host.indexOf('github.com') ) { + jQuery.ajax( { + type: 'GET', + url: baseUrl + '/data/' + $.key( 'page' ), + success: function( data ) { + editorSession.setValue( data ); + } + }); + } $( '#save' ).click( function() { $.save(); diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/md_sundown.js b/lib/gollum/frontend/public/gollum/livepreview/js/md_sundown.js new file mode 100644 index 00000000..66579044 --- /dev/null +++ b/lib/gollum/frontend/public/gollum/livepreview/js/md_sundown.js @@ -0,0 +1,22 @@ +// Define one global function that renders markdown. +(function() { + // Grab functions from emscripten + var Pointer_stringify = Module.Pointer_stringify; + var _str_to_html = Module._str_to_html; + var malloc = Module._malloc; + var realloc = Module._realloc; + var writeStringToMemory = Module.writeStringToMemory; + var allocSize = 2048; + var pointer = malloc( allocSize ) ; + + window.md_to_html = function( text ) { + var textLength = text.length; + while ( textLength > allocSize ) { + allocSize <<= 1; // double + pointer = realloc( pointer, allocSize ); + } + + writeStringToMemory( text, pointer ); + return Pointer_stringify( _str_to_html( pointer ) ); + }; +})(); diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/pagedown/Markdown.Converter.js b/lib/gollum/frontend/public/gollum/livepreview/js/pagedown/Markdown.Converter.js deleted file mode 100644 index 3bfc6a28..00000000 --- a/lib/gollum/frontend/public/gollum/livepreview/js/pagedown/Markdown.Converter.js +++ /dev/null @@ -1,1355 +0,0 @@ -var Markdown; - -if (typeof exports === "object" && typeof require === "function") // we're in a CommonJS (e.g. Node.js) module - Markdown = exports; -else - Markdown = {}; - -// The following text is included for historical reasons, but should -// be taken with a pinch of salt; it's not all true anymore. - -// -// Wherever possible, Showdown is a straight, line-by-line port -// of the Perl version of Markdown. -// -// This is not a normal parser design; it's basically just a -// series of string substitutions. It's hard to read and -// maintain this way, but keeping Showdown close to the original -// design makes it easier to port new features. -// -// More importantly, Showdown behaves like markdown.pl in most -// edge cases. So web applications can do client-side preview -// in Javascript, and then build identical HTML on the server. -// -// This port needs the new RegExp functionality of ECMA 262, -// 3rd Edition (i.e. Javascript 1.5). Most modern web browsers -// should do fine. Even with the new regular expression features, -// We do a lot of work to emulate Perl's regex functionality. -// The tricky changes in this file mostly have the "attacklab:" -// label. Major or self-explanatory changes don't. -// -// Smart diff tools like Araxis Merge will be able to match up -// this file with markdown.pl in a useful way. A little tweaking -// helps: in a copy of markdown.pl, replace "#" with "//" and -// replace "$text" with "text". Be sure to ignore whitespace -// and line endings. -// - - -// -// Usage: -// -// var text = "Markdown *rocks*."; -// -// var converter = new Markdown.Converter(); -// var html = converter.makeHtml(text); -// -// alert(html); -// -// Note: move the sample code to the bottom of this -// file before uncommenting it. -// - -(function () { - - function identity(x) { return x; } - function returnFalse(x) { return false; } - - function HookCollection() { } - - HookCollection.prototype = { - - chain: function (hookname, func) { - var original = this[hookname]; - if (!original) - throw new Error("unknown hook " + hookname); - - if (original === identity) - this[hookname] = func; - else - this[hookname] = function (x) { return func(original(x)); } - }, - set: function (hookname, func) { - if (!this[hookname]) - throw new Error("unknown hook " + hookname); - this[hookname] = func; - }, - addNoop: function (hookname) { - this[hookname] = identity; - }, - addFalse: function (hookname) { - this[hookname] = returnFalse; - } - }; - - Markdown.HookCollection = HookCollection; - - // g_urls and g_titles allow arbitrary user-entered strings as keys. This - // caused an exception (and hence stopped the rendering) when the user entered - // e.g. [push] or [__proto__]. Adding a prefix to the actual key prevents this - // (since no builtin property starts with "s_"). See - // http://meta.stackoverflow.com/questions/64655/strange-wmd-bug - // (granted, switching from Array() to Object() alone would have left only __proto__ - // to be a problem) - function SaveHash() { } - SaveHash.prototype = { - set: function (key, value) { - this["s_" + key] = value; - }, - get: function (key) { - return this["s_" + key]; - } - }; - - Markdown.Converter = function () { - var pluginHooks = this.hooks = new HookCollection(); - pluginHooks.addNoop("plainLinkText"); // given a URL that was encountered by itself (without markup), should return the link text that's to be given to this link - pluginHooks.addNoop("preConversion"); // called with the orignal text as given to makeHtml. The result of this plugin hook is the actual markdown source that will be cooked - pluginHooks.addNoop("postConversion"); // called with the final cooked HTML code. The result of this plugin hook is the actual output of makeHtml - - // - // Private state of the converter instance: - // - - // Global hashes, used by various utility routines - var g_urls; - var g_titles; - var g_html_blocks; - - // Used to track when we're inside an ordered or unordered list - // (see _ProcessListItems() for details): - var g_list_level; - - this.makeHtml = function (text) { - - // - // Main function. The order in which other subs are called here is - // essential. Link and image substitutions need to happen before - // _EscapeSpecialCharsWithinTagAttributes(), so that any *'s or _'s in the - // and tags get encoded. - // - - // This will only happen if makeHtml on the same converter instance is called from a plugin hook. - // Don't do that. - if (g_urls) - throw new Error("Recursive call to converter.makeHtml"); - - // Create the private state objects. - g_urls = new SaveHash(); - g_titles = new SaveHash(); - g_html_blocks = []; - g_list_level = 0; - - text = pluginHooks.preConversion(text); - - // attacklab: Replace ~ with ~T - // This lets us use tilde as an escape char to avoid md5 hashes - // The choice of character is arbitray; anything that isn't - // magic in Markdown will work. - text = text.replace(/~/g, "~T"); - - // attacklab: Replace $ with ~D - // RegExp interprets $ as a special character - // when it's in a replacement string - text = text.replace(/\$/g, "~D"); - - // Standardize line endings - text = text.replace(/\r\n/g, "\n"); // DOS to Unix - text = text.replace(/\r/g, "\n"); // Mac to Unix - - // Make sure text begins and ends with a couple of newlines: - text = "\n\n" + text + "\n\n"; - - // Convert all tabs to spaces. - text = _Detab(text); - - // Strip any lines consisting only of spaces and tabs. - // This makes subsequent regexen easier to write, because we can - // match consecutive blank lines with /\n+/ instead of something - // contorted like /[ \t]*\n+/ . - text = text.replace(/^[ \t]+$/mg, ""); - - // Turn block-level HTML blocks into hash entries - text = _HashHTMLBlocks(text); - - // Strip link definitions, store in hashes. - text = _StripLinkDefinitions(text); - - // Process gollum style code highlighting. - text = _DoCodeSpansGollum(text); - - text = _RunBlockGamut(text); - - text = _UnescapeSpecialChars(text); - - // attacklab: Restore dollar signs - text = text.replace(/~D/g, "$$"); - - // attacklab: Restore tildes - text = text.replace(/~T/g, "~"); - - text = pluginHooks.postConversion(text); - - g_html_blocks = g_titles = g_urls = null; - - return text; - }; - - function _StripLinkDefinitions(text) { - // - // Strips link definitions from text, stores the URLs and titles in - // hash references. - // - - // Link defs are in the form: ^[id]: url "optional title" - - /* - text = text.replace(/ - ^[ ]{0,3}\[(.+)\]: // id = $1 attacklab: g_tab_width - 1 - [ \t]* - \n? // maybe *one* newline - [ \t]* - ? // url = $2 - (?=\s|$) // lookahead for whitespace instead of the lookbehind removed below - [ \t]* - \n? // maybe one newline - [ \t]* - ( // (potential) title = $3 - (\n*) // any lines skipped = $4 attacklab: lookbehind removed - [ \t]+ - ["(] - (.+?) // title = $5 - [")] - [ \t]* - )? // title is optional - (?:\n+|$) - /gm, function(){...}); - */ - - text = text.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*?(?=\s|$)[ \t]*\n?[ \t]*((\n*)["(](.+?)[")][ \t]*)?(?:\n+)/gm, - function (wholeMatch, m1, m2, m3, m4, m5) { - m1 = m1.toLowerCase(); - g_urls.set(m1, _EncodeAmpsAndAngles(m2)); // Link IDs are case-insensitive - if (m4) { - // Oops, found blank lines, so it's not a title. - // Put back the parenthetical statement we stole. - return m3; - } else if (m5) { - g_titles.set(m1, m5.replace(/"/g, """)); - } - - // Completely remove the definition from the text - return ""; - } - ); - - return text; - } - - function _HashHTMLBlocks(text) { - - // Hashify HTML blocks: - // We only want to do this for block-level HTML tags, such as headers, - // lists, and tables. That's because we still want to wrap

      s around - // "paragraphs" that are wrapped in non-block-level tags, such as anchors, - // phrase emphasis, and spans. The list of tags we're looking for is - // hard-coded: - var block_tags_a = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del" - var block_tags_b = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math" - - // First, look for nested blocks, e.g.: - //

      - //
      - // tags for inner block must be indented. - //
      - //
      - // - // The outermost tags must start at the left margin for this to match, and - // the inner nested divs must be indented. - // We need to do this before the next, more liberal match, because the next - // match will start at the first `
      ` and stop at the first `
      `. - - // attacklab: This regex can be expensive when it fails. - - /* - text = text.replace(/ - ( // save in $1 - ^ // start of line (with /m) - <($block_tags_a) // start tag = $2 - \b // word break - // attacklab: hack around khtml/pcre bug... - [^\r]*?\n // any number of lines, minimally matching - // the matching end tag - [ \t]* // trailing spaces/tabs - (?=\n+) // followed by a newline - ) // attacklab: there are sentinel newlines at end of document - /gm,function(){...}}; - */ - text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm, hashElement); - - // - // Now match more liberally, simply from `\n` to `\n` - // - - /* - text = text.replace(/ - ( // save in $1 - ^ // start of line (with /m) - <($block_tags_b) // start tag = $2 - \b // word break - // attacklab: hack around khtml/pcre bug... - [^\r]*? // any number of lines, minimally matching - .* // the matching end tag - [ \t]* // trailing spaces/tabs - (?=\n+) // followed by a newline - ) // attacklab: there are sentinel newlines at end of document - /gm,function(){...}}; - */ - text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm, hashElement); - - // Special case just for
      . It was easier to make a special case than - // to make the other regex more complicated. - - /* - text = text.replace(/ - \n // Starting after a blank line - [ ]{0,3} - ( // save in $1 - (<(hr) // start tag = $2 - \b // word break - ([^<>])*? - \/?>) // the matching end tag - [ \t]* - (?=\n{2,}) // followed by a blank line - ) - /g,hashElement); - */ - text = text.replace(/\n[ ]{0,3}((<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g, hashElement); - - // Special case for standalone HTML comments: - - /* - text = text.replace(/ - \n\n // Starting after a blank line - [ ]{0,3} // attacklab: g_tab_width - 1 - ( // save in $1 - -]|-[^>])(?:[^-]|-[^-])*)--) // see http://www.w3.org/TR/html-markup/syntax.html#comments and http://meta.stackoverflow.com/q/95256 - > - [ \t]* - (?=\n{2,}) // followed by a blank line - ) - /g,hashElement); - */ - text = text.replace(/\n\n[ ]{0,3}(-]|-[^>])(?:[^-]|-[^-])*)--)>[ \t]*(?=\n{2,}))/g, hashElement); - - // PHP and ASP-style processor instructions ( and <%...%>) - - /* - text = text.replace(/ - (?: - \n\n // Starting after a blank line - ) - ( // save in $1 - [ ]{0,3} // attacklab: g_tab_width - 1 - (?: - <([?%]) // $2 - [^\r]*? - \2> - ) - [ \t]* - (?=\n{2,}) // followed by a blank line - ) - /g,hashElement); - */ - text = text.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g, hashElement); - - return text; - } - - function hashElement(wholeMatch, m1) { - var blockText = m1; - - // Undo double lines - blockText = blockText.replace(/^\n+/, ""); - - // strip trailing blank lines - blockText = blockText.replace(/\n+$/g, ""); - - // Replace the element text with a marker ("~KxK" where x is its key) - blockText = "\n\n~K" + (g_html_blocks.push(blockText) - 1) + "K\n\n"; - - return blockText; - } - - function _RunBlockGamut(text, doNotUnhash) { - // - // These are all the transformations that form block-level - // tags like paragraphs, headers, and list items. - // - text = _DoHeaders(text); - - // Do Horizontal Rules: - var replacement = "
      \n"; - text = text.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm, replacement); - text = text.replace(/^[ ]{0,2}([ ]?-[ ]?){3,}[ \t]*$/gm, replacement); - text = text.replace(/^[ ]{0,2}([ ]?_[ ]?){3,}[ \t]*$/gm, replacement); - - text = _DoLists(text); - text = _DoCodeBlocks(text); - text = _DoBlockQuotes(text); - - // We already ran _HashHTMLBlocks() before, in Markdown(), but that - // was to escape raw HTML in the original Markdown source. This time, - // we're escaping the markup we've just created, so that we don't wrap - //

      tags around block-level tags. - text = _HashHTMLBlocks(text); - text = _FormParagraphs(text, doNotUnhash); - - return text; - } - - function _RunSpanGamut(text) { - // - // These are all the transformations that occur *within* block-level - // tags like paragraphs, headers, and list items. - // - - text = _DoCodeSpans(text); - text = _EscapeSpecialCharsWithinTagAttributes(text); - text = _EncodeBackslashEscapes(text); - - // Process anchor and image tags. Images must come first, - // because ![foo][f] looks like an anchor. - text = _DoImages(text); - text = _DoAnchors(text); - - // Make links out of things like `` - // Must come after _DoAnchors(), because you can use < and > - // delimiters in inline links like [this](). - text = _DoAutoLinks(text); - - text = text.replace(/~P/g, "://"); // put in place to prevent autolinking; reset now - - text = _EncodeAmpsAndAngles(text); - text = _DoItalicsAndBold(text); - - // Do hard breaks: - text = text.replace(/ +\n/g, "
      \n"); - - return text; - } - - function _EscapeSpecialCharsWithinTagAttributes(text) { - // - // Within tags -- meaning between < and > -- encode [\ ` * _] so they - // don't conflict with their use in Markdown for code, italics and strong. - // - - // Build a regex to find HTML tags and comments. See Friedl's - // "Mastering Regular Expressions", 2nd Ed., pp. 200-201. - - // SE: changed the comment part of the regex - - var regex = /(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|-]|-[^>])(?:[^-]|-[^-])*)--)>)/gi; - - text = text.replace(regex, function (wholeMatch) { - var tag = wholeMatch.replace(/(.)<\/?code>(?=.)/g, "$1`"); - tag = escapeCharacters(tag, wholeMatch.charAt(1) == "!" ? "\\`*_/" : "\\`*_"); // also escape slashes in comments to prevent autolinking there -- http://meta.stackoverflow.com/questions/95987 - return tag; - }); - - return text; - } - - function _DoAnchors(text) { - // - // Turn Markdown link shortcuts into XHTML
      tags. - // - // - // First, handle reference-style links: [link text] [id] - // - - /* - text = text.replace(/ - ( // wrap whole match in $1 - \[ - ( - (?: - \[[^\]]*\] // allow brackets nested one level - | - [^\[] // or anything else - )* - ) - \] - - [ ]? // one optional space - (?:\n[ ]*)? // one optional newline followed by spaces - - \[ - (.*?) // id = $3 - \] - ) - ()()()() // pad remaining backreferences - /g, writeAnchorTag); - */ - text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g, writeAnchorTag); - - // - // Next, inline-style links: [link text](url "optional title") - // - - /* - text = text.replace(/ - ( // wrap whole match in $1 - \[ - ( - (?: - \[[^\]]*\] // allow brackets nested one level - | - [^\[\]] // or anything else - )* - ) - \] - \( // literal paren - [ \t]* - () // no id, so leave $3 empty - ? - [ \t]* - ( // $5 - (['"]) // quote char = $6 - (.*?) // Title = $7 - \6 // matching quote - [ \t]* // ignore any spaces/tabs between closing quote and ) - )? // title is optional - \) - ) - /g, writeAnchorTag); - */ - - text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g, writeAnchorTag); - - // - // Last, handle reference-style shortcuts: [link text] - // These must come last in case you've also got [link test][1] - // or [link test](/foo) - // - - /* - text = text.replace(/ - ( // wrap whole match in $1 - \[ - ([^\[\]]+) // link text = $2; can't contain '[' or ']' - \] - ) - ()()()()() // pad rest of backreferences - /g, writeAnchorTag); - */ - text = text.replace(/(\[([^\[\]]+)\])()()()()()/g, writeAnchorTag); - - return text; - } - - function writeAnchorTag(wholeMatch, m1, m2, m3, m4, m5, m6, m7) { - if (m7 == undefined) m7 = ""; - var whole_match = m1; - var link_text = m2.replace(/:\/\//g, "~P"); // to prevent auto-linking withing the link. will be converted back after the auto-linker runs - var link_id = m3.toLowerCase(); - var url = m4; - var title = m7; - - if (url == "") { - if (link_id == "") { - // lower-case and turn embedded newlines into spaces - link_id = link_text.toLowerCase().replace(/ ?\n/g, " "); - } - url = "#" + link_id; - - if (g_urls.get(link_id) != undefined) { - url = g_urls.get(link_id); - if (g_titles.get(link_id) != undefined) { - title = g_titles.get(link_id); - } - } - else { - if (whole_match.search(/\(\s*\)$/m) > -1) { - // Special case for explicit empty url - url = ""; - } else { - return whole_match; - } - } - } - url = encodeProblemUrlChars(url); - url = escapeCharacters(url, "*_"); - var result = ""; - - return result; - } - - function _DoImages(text) { - // - // Turn Markdown image shortcuts into tags. - // - - // - // First, handle reference-style labeled images: ![alt text][id] - // - - /* - text = text.replace(/ - ( // wrap whole match in $1 - !\[ - (.*?) // alt text = $2 - \] - - [ ]? // one optional space - (?:\n[ ]*)? // one optional newline followed by spaces - - \[ - (.*?) // id = $3 - \] - ) - ()()()() // pad rest of backreferences - /g, writeImageTag); - */ - text = text.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g, writeImageTag); - - // - // Next, handle inline images: ![alt text](url "optional title") - // Don't forget: encode * and _ - - /* - text = text.replace(/ - ( // wrap whole match in $1 - !\[ - (.*?) // alt text = $2 - \] - \s? // One optional whitespace character - \( // literal paren - [ \t]* - () // no id, so leave $3 empty - ? // src url = $4 - [ \t]* - ( // $5 - (['"]) // quote char = $6 - (.*?) // title = $7 - \6 // matching quote - [ \t]* - )? // title is optional - \) - ) - /g, writeImageTag); - */ - text = text.replace(/(!\[(.*?)\]\s?\([ \t]*()?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g, writeImageTag); - - return text; - } - - function attributeEncode(text) { - // unconditionally replace angle brackets here -- what ends up in an attribute (e.g. alt or title) - // never makes sense to have verbatim HTML in it (and the sanitizer would totally break it) - return text.replace(/>/g, ">").replace(/" + _RunSpanGamut(m1) + "\n\n"; } - ); - - text = text.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm, - function (matchFound, m1) { return "

      " + _RunSpanGamut(m1) + "

      \n\n"; } - ); - - // atx-style headers: - // # Header 1 - // ## Header 2 - // ## Header 2 with closing hashes ## - // ... - // ###### Header 6 - // - - /* - text = text.replace(/ - ^(\#{1,6}) // $1 = string of #'s - [ \t]* - (.+?) // $2 = Header text - [ \t]* - \#* // optional closing #'s (not counted) - \n+ - /gm, function() {...}); - */ - - text = text.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm, - function (wholeMatch, m1, m2) { - var h_level = m1.length; - return "" + _RunSpanGamut(m2) + "\n\n"; - } - ); - - return text; - } - - function _DoLists(text) { - // - // Form HTML ordered (numbered) and unordered (bulleted) lists. - // - - // attacklab: add sentinel to hack around khtml/safari bug: - // http://bugs.webkit.org/show_bug.cgi?id=11231 - text += "~0"; - - // Re-usable pattern to match any entirel ul or ol list: - - /* - var whole_list = / - ( // $1 = whole list - ( // $2 - [ ]{0,3} // attacklab: g_tab_width - 1 - ([*+-]|\d+[.]) // $3 = first list item marker - [ \t]+ - ) - [^\r]+? - ( // $4 - ~0 // sentinel for workaround; should be $ - | - \n{2,} - (?=\S) - (?! // Negative lookahead for another list item marker - [ \t]* - (?:[*+-]|\d+[.])[ \t]+ - ) - ) - ) - /g - */ - var whole_list = /^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm; - - if (g_list_level) { - text = text.replace(whole_list, function (wholeMatch, m1, m2) { - var list = m1; - var list_type = (m2.search(/[*+-]/g) > -1) ? "ul" : "ol"; - - var result = _ProcessListItems(list, list_type); - - // Trim any trailing whitespace, to put the closing `` - // up on the preceding line, to get it past the current stupid - // HTML block parser. This is a hack to work around the terrible - // hack that is the HTML block parser. - result = result.replace(/\s+$/, ""); - result = "<" + list_type + ">" + result + "\n"; - return result; - }); - } else { - whole_list = /(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g; - text = text.replace(whole_list, function (wholeMatch, m1, m2, m3) { - var runup = m1; - var list = m2; - - var list_type = (m3.search(/[*+-]/g) > -1) ? "ul" : "ol"; - var result = _ProcessListItems(list, list_type); - result = runup + "<" + list_type + ">\n" + result + "\n"; - return result; - }); - } - - // attacklab: strip sentinel - text = text.replace(/~0/, ""); - - return text; - } - - var _listItemMarkers = { ol: "\\d+[.]", ul: "[*+-]" }; - - function _ProcessListItems(list_str, list_type) { - // - // Process the contents of a single ordered or unordered list, splitting it - // into individual list items. - // - // list_type is either "ul" or "ol". - - // The $g_list_level global keeps track of when we're inside a list. - // Each time we enter a list, we increment it; when we leave a list, - // we decrement. If it's zero, we're not in a list anymore. - // - // We do this because when we're not inside a list, we want to treat - // something like this: - // - // I recommend upgrading to version - // 8. Oops, now this line is treated - // as a sub-list. - // - // As a single paragraph, despite the fact that the second line starts - // with a digit-period-space sequence. - // - // Whereas when we're inside a list (or sub-list), that line will be - // treated as the start of a sub-list. What a kludge, huh? This is - // an aspect of Markdown's syntax that's hard to parse perfectly - // without resorting to mind-reading. Perhaps the solution is to - // change the syntax rules such that sub-lists must start with a - // starting cardinal number; e.g. "1." or "a.". - - g_list_level++; - - // trim trailing blank lines: - list_str = list_str.replace(/\n{2,}$/, "\n"); - - // attacklab: add sentinel to emulate \z - list_str += "~0"; - - // In the original attacklab showdown, list_type was not given to this function, and anything - // that matched /[*+-]|\d+[.]/ would just create the next
    5. , causing this mismatch: - // - // Markdown rendered by WMD rendered by MarkdownSharp - // ------------------------------------------------------------------ - // 1. first 1. first 1. first - // 2. second 2. second 2. second - // - third 3. third * third - // - // We changed this to behave identical to MarkdownSharp. This is the constructed RegEx, - // with {MARKER} being one of \d+[.] or [*+-], depending on list_type: - - /* - list_str = list_str.replace(/ - (^[ \t]*) // leading whitespace = $1 - ({MARKER}) [ \t]+ // list marker = $2 - ([^\r]+? // list item text = $3 - (\n+) - ) - (?= - (~0 | \2 ({MARKER}) [ \t]+) - ) - /gm, function(){...}); - */ - - var marker = _listItemMarkers[list_type]; - var re = new RegExp("(^[ \\t]*)(" + marker + ")[ \\t]+([^\\r]+?(\\n+))(?=(~0|\\1(" + marker + ")[ \\t]+))", "gm"); - var last_item_had_a_double_newline = false; - list_str = list_str.replace(re, - function (wholeMatch, m1, m2, m3) { - var item = m3; - var leading_space = m1; - var ends_with_double_newline = /\n\n$/.test(item); - var contains_double_newline = ends_with_double_newline || item.search(/\n{2,}/) > -1; - - if (contains_double_newline || last_item_had_a_double_newline) { - item = _RunBlockGamut(_Outdent(item), /* doNotUnhash = */true); - } - else { - // Recursion for sub-lists: - item = _DoLists(_Outdent(item)); - item = item.replace(/\n$/, ""); // chomp(item) - item = _RunSpanGamut(item); - } - last_item_had_a_double_newline = ends_with_double_newline; - return "
    6. " + item + "
    7. \n"; - } - ); - - // attacklab: strip sentinel - list_str = list_str.replace(/~0/g, ""); - - g_list_level--; - return list_str; - } - - function _DoCodeBlocks(text) { - // - // Process Markdown `
      ` blocks.
      -            //  
      -
      -            /*
      -            text = text.replace(/
      -                (?:\n\n|^)
      -                (                               // $1 = the code block -- one or more lines, starting with a space/tab
      -                    (?:
      -                        (?:[ ]{4}|\t)           // Lines must start with a tab or a tab-width of spaces - attacklab: g_tab_width
      -                        .*\n+
      -                    )+
      -                )
      -                (\n*[ ]{0,3}[^ \t\n]|(?=~0))    // attacklab: g_tab_width
      -            /g ,function(){...});
      -            */
      -
      -            // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
      -            text += "~0";
      -
      -            text = text.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,
      -                function (wholeMatch, m1, m2) {
      -                    var codeblock = m1;
      -                    var nextChar = m2;
      -
      -                    codeblock = _EncodeCode(_Outdent(codeblock));
      -                    codeblock = _Detab(codeblock);
      -                    codeblock = codeblock.replace(/^\n+/g, ""); // trim leading newlines
      -                    codeblock = codeblock.replace(/\n+$/g, ""); // trim trailing whitespace
      -
      -                    codeblock = "
      " + codeblock + "\n
      "; - - return "\n\n" + codeblock + "\n\n" + nextChar; - } - ); - - // attacklab: strip sentinel - text = text.replace(/~0/, ""); - - return text; - } - - function hashBlock(text) { - text = text.replace(/(^\n+|\n+$)/g, ""); - return "\n\n~K" + (g_html_blocks.push(text) - 1) + "K\n\n"; - } - - function _DoCodeSpans(text) { - // - // * Backtick quotes are used for spans. - // - // * You can use multiple backticks as the delimiters if you want to - // include literal backticks in the code span. So, this input: - // - // Just type ``foo `bar` baz`` at the prompt. - // - // Will translate to: - // - //

      Just type foo `bar` baz at the prompt.

      - // - // There's no arbitrary limit to the number of backticks you - // can use as delimters. If you need three consecutive backticks - // in your code, use four for delimiters, etc. - // - // * You can use spaces to get literal backticks at the edges: - // - // ... type `` `bar` `` ... - // - // Turns to: - // - // ... type `bar` ... - // - - /* - text = text.replace(/ - (^|[^\\]) // Character before opening ` can't be a backslash - (`+) // $2 = Opening run of ` - ( // $3 = The code block - [^\r]*? - [^`] // attacklab: work around lack of lookbehind - ) - \2 // Matching closer - (?!`) - /gm, function(){...}); - */ - - text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm, - function (wholeMatch, m1, m2, m3, m4) { - var c = m3; - c = c.replace(/^([ \t]*)/g, ""); // leading whitespace - c = c.replace(/[ \t]*$/g, ""); // trailing whitespace - c = _EncodeCode(c); - c = c.replace(/:\/\//g, "~P"); // to prevent auto-linking. Not necessary in code *blocks*, but in code spans. Will be converted back after the auto-linker runs. - return m1 + "" + c + ""; - } - ); - - return text; - } - - function _DoCodeSpansGollum(text) { - // - // Gollum wraps code in one pre. Use ` to mark code pre. - // Gollum requires exactly three starting and ending `. - // - text = text.replace(/(^|[^\\])(`{3})([^\r]*?[^`])\2(?!`)/gm, - function (wholeMatch, m1, m2, m3, m4) { - var c = m3; - c = c.replace(/^([ \t]*)/g, ""); // leading whitespace - c = c.replace(/[ \t]*$/g, ""); // trailing whitespace - c = _EncodeCode(c); - // Set to use 'm' multiline option. - c = c.replace(/:\/\//gm, "~P"); // to prevent auto-linking. Not necessary in code *blocks*, but in code spans. Will be converted back after the auto-linker runs. - return m1 + hashBlock("
      `" + c + "
      "); - } - ); - - return text; - } - - function _EncodeCode(text) { - // - // Encode/escape certain characters inside Markdown code runs. - // The point is that in code, these characters are literals, - // and lose their special Markdown meanings. - // - // Encode all ampersands; HTML entities are not - // entities within a Markdown code span. - text = text.replace(/&/g, "&"); - - // Do the angle bracket song and dance: - text = text.replace(//g, ">"); - - // Now, escape characters that are magic in Markdown: - text = escapeCharacters(text, "\*_{}[]\\", false); - - // jj the line above breaks this: - //--- - - //* Item - - // 1. Subitem - - // special char: * - //--- - - return text; - } - - function _DoItalicsAndBold(text) { - - // must go first: - text = text.replace(/([\W_]|^)(\*\*|__)(?=\S)([^\r]*?\S[\*_]*)\2([\W_]|$)/g, - "$1$3$4"); - - text = text.replace(/([\W_]|^)(\*|_)(?=\S)([^\r\*_]*?\S)\2([\W_]|$)/g, - "$1$3$4"); - - return text; - } - - function _DoBlockQuotes(text) { - - /* - text = text.replace(/ - ( // Wrap whole match in $1 - ( - ^[ \t]*>[ \t]? // '>' at the start of a line - .+\n // rest of the first line - (.+\n)* // subsequent consecutive lines - \n* // blanks - )+ - ) - /gm, function(){...}); - */ - - text = text.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm, - function (wholeMatch, m1) { - var bq = m1; - - // attacklab: hack around Konqueror 3.5.4 bug: - // "----------bug".replace(/^-/g,"") == "bug" - - bq = bq.replace(/^[ \t]*>[ \t]?/gm, "~0"); // trim one level of quoting - - // attacklab: clean up hack - bq = bq.replace(/~0/g, ""); - - bq = bq.replace(/^[ \t]+$/gm, ""); // trim whitespace-only lines - bq = _RunBlockGamut(bq); // recurse - - bq = bq.replace(/(^|\n)/g, "$1 "); - // These leading spaces screw with
       content, so we need to fix that:
      -                    bq = bq.replace(
      -                            /(\s*
      [^\r]+?<\/pre>)/gm,
      -                        function (wholeMatch, m1) {
      -                            var pre = m1;
      -                            // attacklab: hack around Konqueror 3.5.4 bug:
      -                            pre = pre.replace(/^  /mg, "~0");
      -                            pre = pre.replace(/~0/g, "");
      -                            return pre;
      -                        });
      -
      -                    return hashBlock("
      \n" + bq + "\n
      "); - } - ); - return text; - } - - function _FormParagraphs(text, doNotUnhash) { - // - // Params: - // $text - string to process with html

      tags - // - - // Strip leading and trailing lines: - text = text.replace(/^\n+/g, ""); - text = text.replace(/\n+$/g, ""); - - var grafs = text.split(/\n{2,}/g); - var grafsOut = []; - - var markerRe = /~K(\d+)K/; - - // - // Wrap

      tags. - // - var end = grafs.length; - for (var i = 0; i < end; i++) { - var str = grafs[i]; - - // if this is an HTML marker, copy it - if (markerRe.test(str)) { - grafsOut.push(str); - } - else if (/\S/.test(str)) { - str = _RunSpanGamut(str); - str = str.replace(/^([ \t]*)/g, "

      "); - str += "

      " - grafsOut.push(str); - } - - } - // - // Unhashify HTML blocks - // - if (!doNotUnhash) { - end = grafsOut.length; - for (var i = 0; i < end; i++) { - var foundAny = true; - while (foundAny) { // we may need several runs, since the data may be nested - foundAny = false; - grafsOut[i] = grafsOut[i].replace(/~K(\d+)K/g, function (wholeMatch, id) { - foundAny = true; - return g_html_blocks[id]; - }); - } - } - } - return grafsOut.join("\n\n"); - } - - function _EncodeAmpsAndAngles(text) { - // Smart processing for ampersands and angle brackets that need to be encoded. - - // Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin: - // http://bumppo.net/projects/amputator/ - text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g, "&"); - - // Encode naked <'s - text = text.replace(/<(?![a-z\/?\$!])/gi, "<"); - - return text; - } - - function _EncodeBackslashEscapes(text) { - // - // Parameter: String. - // Returns: The string, with after processing the following backslash - // escape sequences. - // - - // attacklab: The polite way to do this is with the new - // escapeCharacters() function: - // - // text = escapeCharacters(text,"\\",true); - // text = escapeCharacters(text,"`*_{}[]()>#+-.!",true); - // - // ...but we're sidestepping its use of the (slow) RegExp constructor - // as an optimization for Firefox. This function gets called a LOT. - - text = text.replace(/\\(\\)/g, escapeCharacters_callback); - text = text.replace(/\\([`*_{}\[\]()>#+-.!])/g, escapeCharacters_callback); - return text; - } - - function _DoAutoLinks(text) { - - // note that at this point, all other URL in the text are already hyperlinked as
      - // *except* for the case - - // automatically add < and > around unadorned raw hyperlinks - // must be preceded by space/BOF and followed by non-word/EOF character - text = text.replace(/(^|\s)(https?|ftp)(:\/\/[-A-Z0-9+&@#\/%?=~_|\[\]\(\)!:,\.;]*[-A-Z0-9+&@#\/%=~_|\[\]])($|\W)/gi, "$1<$2$3>$4"); - - // autolink anything like - - var replacer = function (wholematch, m1) { return "" + pluginHooks.plainLinkText(m1) + ""; } - text = text.replace(/<((https?|ftp):[^'">\s]+)>/gi, replacer); - - // Email addresses: - /* - text = text.replace(/ - < - (?:mailto:)? - ( - [-.\w]+ - \@ - [-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+ - ) - > - /gi, _DoAutoLinks_callback()); - */ - - /* disabling email autolinking, since we don't do that on the server, either - text = text.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi, - function(wholeMatch,m1) { - return _EncodeEmailAddress( _UnescapeSpecialChars(m1) ); - } - ); - */ - return text; - } - - function _UnescapeSpecialChars(text) { - // - // Swap back in all the special characters we've hidden. - // - text = text.replace(/~E(\d+)E/g, - function (wholeMatch, m1) { - var charCodeToReplace = parseInt(m1); - return String.fromCharCode(charCodeToReplace); - } - ); - return text; - } - - function _Outdent(text) { - // - // Remove one level of line-leading tabs or spaces - // - - // attacklab: hack around Konqueror 3.5.4 bug: - // "----------bug".replace(/^-/g,"") == "bug" - - text = text.replace(/^(\t|[ ]{1,4})/gm, "~0"); // attacklab: g_tab_width - - // attacklab: clean up hack - text = text.replace(/~0/g, "") - - return text; - } - - function _Detab(text) { - if (!/\t/.test(text)) - return text; - - var spaces = [" ", " ", " ", " "], - skew = 0, - v; - - return text.replace(/[\n\t]/g, function (match, offset) { - if (match === "\n") { - skew = offset + 1; - return match; - } - v = (offset - skew) % 4; - skew = offset + 1; - return spaces[v]; - }); - } - - // - // attacklab: Utility functions - // - - var _problemUrlChars = /(?:["'*()[\]:]|~D)/g; - - // hex-encodes some unusual "problem" chars in URLs to avoid URL detection problems - function encodeProblemUrlChars(url) { - if (!url) - return ""; - - var len = url.length; - - return url.replace(_problemUrlChars, function (match, offset) { - if (match == "~D") // escape for dollar - return "%24"; - if (match == ":") { - if (offset == len - 1 || /[0-9\/]/.test(url.charAt(offset + 1))) - return ":" - } - return "%" + match.charCodeAt(0).toString(16); - }); - } - - - function escapeCharacters(text, charsToEscape, afterBackslash) { - // First we have to escape the escape characters so that - // we can build a character class out of them - var regexString = "([" + charsToEscape.replace(/([\[\]\\])/g, "\\$1") + "])"; - - if (afterBackslash) { - regexString = "\\\\" + regexString; - } - - var regex = new RegExp(regexString, "g"); - text = text.replace(regex, escapeCharacters_callback); - - return text; - } - - - function escapeCharacters_callback(wholeMatch, m1) { - var charCodeToEscape = m1.charCodeAt(0); - return "~E" + charCodeToEscape + "E"; - } - - }; // end of the Markdown.Converter constructor - -})(); diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/pagedown/Markdown.Sanitizer.js b/lib/gollum/frontend/public/gollum/livepreview/js/pagedown/Markdown.Sanitizer.js deleted file mode 100644 index b6709b9c..00000000 --- a/lib/gollum/frontend/public/gollum/livepreview/js/pagedown/Markdown.Sanitizer.js +++ /dev/null @@ -1,109 +0,0 @@ -(function () { - var output, Converter; - if (typeof exports === "object" && typeof require === "function") { // we're in a CommonJS (e.g. Node.js) module - output = exports; - Converter = require("./Markdown.Converter").Converter; - } else { - output = window.Markdown; - Converter = output.Converter; - } - - output.getSanitizingConverter = function () { - var converter = new Converter(); - converter.hooks.chain("postConversion", sanitizeHtml); - converter.hooks.chain("postConversion", balanceTags); - return converter; - } - - function sanitizeHtml(html) { - return html.replace(/<[^>]*>?/gi, sanitizeTag); - } - - // (tags that can be opened/closed) | (tags that stand alone) - var basic_tag_whitelist = /^(<\/?(b|blockquote|code|del|dd|dl|dt|em|h1|h2|h3|h4|h5|h6|i|kbd|li|ol|p|pre|s|sup|sub|strong|strike|ul)>|<(br|hr)\s?\/?>)$/i; - // | - // Make https:// ftp:// prefix optional so relative links work. page one - var a_white = /^(]+")?\s?>|<\/a>)$/i; - - // ]*")?(\stitle="[^"<>]*")?\s?\/?>)$/i; - - function sanitizeTag(tag) { - if (tag.match(basic_tag_whitelist) || tag.match(a_white) || tag.match(img_white)) - return tag; - else - return ""; - } - - /// - /// attempt to balance HTML tags in the html string - /// by removing any unmatched opening or closing tags - /// IMPORTANT: we *assume* HTML has *already* been - /// sanitized and is safe/sane before balancing! - /// - /// adapted from CODESNIPPET: A8591DBA-D1D3-11DE-947C-BA5556D89593 - /// - function balanceTags(html) { - - if (html == "") - return ""; - - var re = /<\/?\w+[^>]*(\s|$|>)/g; - // convert everything to lower case; this makes - // our case insensitive comparisons easier - var tags = html.toLowerCase().match(re); - - // no HTML tags present? nothing to do; exit now - var tagcount = (tags || []).length; - if (tagcount == 0) - return html; - - var tagname, tag; - var ignoredtags = "



    8. "; - var match; - var tagpaired = []; - var tagremove = []; - var needsRemoval = false; - - // loop through matched tags in forward order - for (var ctag = 0; ctag < tagcount; ctag++) { - tagname = tags[ctag].replace(/<\/?(\w+).*/, "$1"); - // skip any already paired tags - // and skip tags in our ignore list; assume they're self-closed - if (tagpaired[ctag] || ignoredtags.search("<" + tagname + ">") > -1) - continue; - - tag = tags[ctag]; - match = -1; - - if (!/^<\//.test(tag)) { - // this is an opening tag - // search forwards (next tags), look for closing tags - for (var ntag = ctag + 1; ntag < tagcount; ntag++) { - if (!tagpaired[ntag] && tags[ntag] == "") { - match = ntag; - break; - } - } - } - - if (match == -1) - needsRemoval = tagremove[ctag] = true; // mark for removal - else - tagpaired[match] = true; // mark paired - } - - if (!needsRemoval) - return html; - - // delete all orphaned tags from the string - - var ctag = 0; - html = html.replace(re, function (match) { - var res = tagremove[ctag] ? "" : match; - ctag++; - return res; - }); - return html; - } -})(); diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/requirejs.min.js b/lib/gollum/frontend/public/gollum/livepreview/js/requirejs.min.js new file mode 100644 index 00000000..4e0dea6d --- /dev/null +++ b/lib/gollum/frontend/public/gollum/livepreview/js/requirejs.min.js @@ -0,0 +1,35 @@ +/* + RequireJS 2.0.4 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved. + Available via the MIT or new BSD license. + see: http://github.com/jrburke/requirejs for details +*/ +var requirejs,require,define; +(function(Y){function x(b){return J.call(b)==="[object Function]"}function G(b){return J.call(b)==="[object Array]"}function q(b,c){if(b){var e;for(e=0;e-1;e-=1)if(b[e]&&c(b[e],e,b))break}}function y(b,c){for(var e in b)if(b.hasOwnProperty(e)&&c(b[e],e))break}function K(b,c,e,i){c&&y(c,function(c,j){if(e||!b.hasOwnProperty(j))i&&typeof c!=="string"?(b[j]||(b[j]={}),K(b[j],c,e,i)):b[j]=c});return b}function s(b, +c){return function(){return c.apply(b,arguments)}}function Z(b){if(!b)return b;var c=Y;q(b.split("."),function(b){c=c[b]});return c}function $(b,c,e){return function(){var i=fa.call(arguments,0),g;if(e&&x(g=i[i.length-1]))g.__requireJsBuild=!0;i.push(c);return b.apply(null,i)}}function aa(b,c,e){q([["toUrl"],["undef"],["defined","requireDefined"],["specified","requireSpecified"]],function(i){var g=i[1]||i[0];b[i[0]]=c?$(c[g],e):function(){var b=z[O];return b[g].apply(b,arguments)}})}function H(b, +c,e,i){c=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+b);c.requireType=b;c.requireModules=i;if(e)c.originalError=e;return c}function ga(){if(I&&I.readyState==="interactive")return I;N(document.getElementsByTagName("script"),function(b){if(b.readyState==="interactive")return I=b});return I}var ha=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,ia=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,ba=/\.js$/,ja=/^\.\//,J=Object.prototype.toString,A=Array.prototype,fa=A.slice,ka=A.splice,w=!!(typeof window!== +"undefined"&&navigator&&document),ca=!w&&typeof importScripts!=="undefined",la=w&&navigator.platform==="PLAYSTATION 3"?/^complete$/:/^(complete|loaded)$/,O="_",S=typeof opera!=="undefined"&&opera.toString()==="[object Opera]",z={},p={},P=[],L=!1,j,t,C,u,D,I,E,da,ea;if(typeof define==="undefined"){if(typeof requirejs!=="undefined"){if(x(requirejs))return;p=requirejs;requirejs=void 0}typeof require!=="undefined"&&!x(require)&&(p=require,require=void 0);j=requirejs=function(b,c,e,i){var g=O,r;!G(b)&& +typeof b!=="string"&&(r=b,G(c)?(b=c,c=e,e=i):b=[]);if(r&&r.context)g=r.context;(i=z[g])||(i=z[g]=j.s.newContext(g));r&&i.configure(r);return i.require(b,c,e)};j.config=function(b){return j(b)};require||(require=j);j.version="2.0.4";j.jsExtRegExp=/^\/|:|\?|\.js$/;j.isBrowser=w;A=j.s={contexts:z,newContext:function(b){function c(a,d,o){var l=d&&d.split("/"),f=l,b=k.map,c=b&&b["*"],e,g,h;if(a&&a.charAt(0)===".")if(d){f=k.pkgs[d]?l=[d]:l.slice(0,l.length-1);d=a=f.concat(a.split("/"));for(f=0;d[f];f+= +1)if(e=d[f],e===".")d.splice(f,1),f-=1;else if(e==="..")if(f===1&&(d[2]===".."||d[0]===".."))break;else f>0&&(d.splice(f-1,2),f-=2);f=k.pkgs[d=a[0]];a=a.join("/");f&&a===d+"/"+f.main&&(a=d)}else a.indexOf("./")===0&&(a=a.substring(2));if(o&&(l||c)&&b){d=a.split("/");for(f=d.length;f>0;f-=1){g=d.slice(0,f).join("/");if(l)for(e=l.length;e>0;e-=1)if(o=b[l.slice(0,e).join("/")])if(o=o[g]){h=o;break}!h&&c&&c[g]&&(h=c[g]);if(h){d.splice(0,f,h);a=d.join("/");break}}}return a}function e(a){w&&q(document.getElementsByTagName("script"), +function(d){if(d.getAttribute("data-requiremodule")===a&&d.getAttribute("data-requirecontext")===h.contextName)return d.parentNode.removeChild(d),!0})}function i(a){var d=k.paths[a];if(d&&G(d)&&d.length>1)return e(a),d.shift(),h.undef(a),h.require([a]),!0}function g(a,d,o,b){var f=a?a.indexOf("!"):-1,v=null,e=d?d.name:null,g=a,i=!0,j="",k,m;a||(i=!1,a="_@r"+(N+=1));f!==-1&&(v=a.substring(0,f),a=a.substring(f+1,a.length));v&&(v=c(v,e,b),m=n[v]);a&&(v?j=m&&m.normalize?m.normalize(a,function(a){return c(a, +e,b)}):c(a,e,b):(j=c(a,e,b),k=h.nameToUrl(j)));a=v&&!m&&!o?"_unnormalized"+(O+=1):"";return{prefix:v,name:j,parentMap:d,unnormalized:!!a,url:k,originalName:g,isDefine:i,id:(v?v+"!"+j:j)+a}}function r(a){var d=a.id,o=m[d];o||(o=m[d]=new h.Module(a));return o}function p(a,d,o){var b=a.id,f=m[b];if(n.hasOwnProperty(b)&&(!f||f.defineEmitComplete))d==="defined"&&o(n[b]);else r(a).on(d,o)}function B(a,d){var b=a.requireModules,l=!1;if(d)d(a);else if(q(b,function(d){if(d=m[d])d.error=a,d.events.error&&(l= +!0,d.emit("error",a))}),!l)j.onError(a)}function u(){P.length&&(ka.apply(F,[F.length-1,0].concat(P)),P=[])}function t(a,d,b){a=a&&a.map;d=$(b||h.require,a,d);aa(d,h,a);d.isBrowser=w;return d}function z(a){delete m[a];q(M,function(d,b){if(d.map.id===a)return M.splice(b,1),d.defined||(h.waitCount-=1),!0})}function A(a,d){var b=a.map.id,l=a.depMaps,f;if(a.inited){if(d[b])return a;d[b]=!0;q(l,function(a){if(a=m[a.id])return!a.inited||!a.enabled?(f=null,delete d[b],!0):f=A(a,K({},d))});return f}}function C(a, +d,b){var l=a.map.id,f=a.depMaps;if(a.inited&&a.map.isDefine){if(d[l])return n[l];d[l]=a;q(f,function(f){var f=f.id,c=m[f];!Q[f]&&c&&(!c.inited||!c.enabled?b[l]=!0:(c=C(c,d,b),b[f]||a.defineDepById(f,c)))});a.check(!0);return n[l]}}function D(a){a.check()}function E(){var a=k.waitSeconds*1E3,d=a&&h.startTime+a<(new Date).getTime(),b=[],l=!1,f=!0,c,g,j;if(!T){T=!0;y(m,function(a){c=a.map;g=c.id;if(a.enabled&&!a.error)if(!a.inited&&d)i(g)?l=j=!0:(b.push(g),e(g));else if(!a.inited&&a.fetched&&c.isDefine&& +(l=!0,!c.prefix))return f=!1});if(d&&b.length)return a=H("timeout","Load timeout for modules: "+b,null,b),a.contextName=h.contextName,B(a);f&&(q(M,function(a){if(!a.defined){var a=A(a,{}),d={};a&&(C(a,d,{}),y(d,D))}}),y(m,D));if((!d||j)&&l)if((w||ca)&&!U)U=setTimeout(function(){U=0;E()},50);T=!1}}function V(a){r(g(a[0],null,!0)).init(a[1],a[2])}function J(a){var a=a.currentTarget||a.srcElement,d=h.onScriptLoad;a.detachEvent&&!S?a.detachEvent("onreadystatechange",d):a.removeEventListener("load",d, +!1);d=h.onScriptError;a.detachEvent&&!S||a.removeEventListener("error",d,!1);return{node:a,id:a&&a.getAttribute("data-requiremodule")}}var k={waitSeconds:7,baseUrl:"./",paths:{},pkgs:{},shim:{}},m={},W={},F=[],n={},R={},N=1,O=1,M=[],T,X,h,Q,U;Q={require:function(a){return t(a)},exports:function(a){a.usingExports=!0;if(a.map.isDefine)return a.exports=n[a.map.id]={}},module:function(a){return a.module={id:a.map.id,uri:a.map.url,config:function(){return k.config&&k.config[a.map.id]||{}},exports:n[a.map.id]}}}; +X=function(a){this.events=W[a.id]||{};this.map=a;this.shim=k.shim[a.id];this.depExports=[];this.depMaps=[];this.depMatched=[];this.pluginMaps={};this.depCount=0};X.prototype={init:function(a,d,b,l){l=l||{};if(!this.inited){this.factory=d;if(b)this.on("error",b);else this.events.error&&(b=s(this,function(a){this.emit("error",a)}));this.depMaps=a&&a.slice(0);this.depMaps.rjsSkipMap=a.rjsSkipMap;this.errback=b;this.inited=!0;this.ignore=l.ignore;l.enabled||this.enabled?this.enable():this.check()}},defineDepById:function(a, +d){var b;q(this.depMaps,function(d,f){if(d.id===a)return b=f,!0});return this.defineDep(b,d)},defineDep:function(a,d){this.depMatched[a]||(this.depMatched[a]=!0,this.depCount-=1,this.depExports[a]=d)},fetch:function(){if(!this.fetched){this.fetched=!0;h.startTime=(new Date).getTime();var a=this.map;if(this.shim)t(this,!0)(this.shim.deps||[],s(this,function(){return a.prefix?this.callPlugin():this.load()}));else return a.prefix?this.callPlugin():this.load()}},load:function(){var a=this.map.url;R[a]|| +(R[a]=!0,h.load(this.map.id,a))},check:function(a){if(this.enabled&&!this.enabling){var d=this.map.id,b=this.depExports,c=this.exports,f=this.factory,e;if(this.inited)if(this.error)this.emit("error",this.error);else{if(!this.defining){this.defining=!0;if(this.depCount<1&&!this.defined){if(x(f)){if(this.events.error)try{c=h.execCb(d,f,b,c)}catch(g){e=g}else c=h.execCb(d,f,b,c);if(this.map.isDefine)if((b=this.module)&&b.exports!==void 0&&b.exports!==this.exports)c=b.exports;else if(c===void 0&&this.usingExports)c= +this.exports;if(e)return e.requireMap=this.map,e.requireModules=[this.map.id],e.requireType="define",B(this.error=e)}else c=f;this.exports=c;if(this.map.isDefine&&!this.ignore&&(n[d]=c,j.onResourceLoad))j.onResourceLoad(h,this.map,this.depMaps);delete m[d];this.defined=!0;h.waitCount-=1;h.waitCount===0&&(M=[])}this.defining=!1;if(!a&&this.defined&&!this.defineEmitted)this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0}}else this.fetch()}},callPlugin:function(){var a= +this.map,d=a.id,b=g(a.prefix,null,!1,!0);p(b,"defined",s(this,function(b){var f=this.map.name,e=this.map.parentMap?this.map.parentMap.name:null;if(this.map.unnormalized){if(b.normalize&&(f=b.normalize(f,function(a){return c(a,e,!0)})||""),b=g(a.prefix+"!"+f,this.map.parentMap,!1,!0),p(b,"defined",s(this,function(a){this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),b=m[b.id]){if(this.events.error)b.on("error",s(this,function(a){this.emit("error",a)}));b.enable()}}else f=s(this,function(a){this.init([], +function(){return a},null,{enabled:!0})}),f.error=s(this,function(a){this.inited=!0;this.error=a;a.requireModules=[d];y(m,function(a){a.map.id.indexOf(d+"_unnormalized")===0&&z(a.map.id)});B(a)}),f.fromText=function(a,d){var b=L;b&&(L=!1);r(g(a));j.exec(d);b&&(L=!0);h.completeLoad(a)},b.load(a.name,t(a.parentMap,!0,function(a,d){a.rjsSkipMap=!0;return h.require(a,d)}),f,k)}));h.enable(b,this);this.pluginMaps[b.id]=b},enable:function(){this.enabled=!0;if(!this.waitPushed)M.push(this),h.waitCount+= +1,this.waitPushed=!0;this.enabling=!0;q(this.depMaps,s(this,function(a,d){var b,c;if(typeof a==="string"){a=g(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.depMaps.rjsSkipMap);this.depMaps[d]=a;if(b=Q[a.id]){this.depExports[d]=b(this);return}this.depCount+=1;p(a,"defined",s(this,function(a){this.defineDep(d,a);this.check()}));this.errback&&p(a,"error",this.errback)}b=a.id;c=m[b];!Q[b]&&c&&!c.enabled&&h.enable(a,this)}));y(this.pluginMaps,s(this,function(a){var b=m[a.id];b&&!b.enabled&& +h.enable(a,this)}));this.enabling=!1;this.check()},on:function(a,b){var c=this.events[a];c||(c=this.events[a]=[]);c.push(b)},emit:function(a,b){q(this.events[a],function(a){a(b)});a==="error"&&delete this.events[a]}};return h={config:k,contextName:b,registry:m,defined:n,urlFetched:R,waitCount:0,defQueue:F,Module:X,makeModuleMap:g,configure:function(a){a.baseUrl&&a.baseUrl.charAt(a.baseUrl.length-1)!=="/"&&(a.baseUrl+="/");var b=k.pkgs,c=k.shim,e=k.paths,f=k.map;K(k,a,!0);k.paths=K(e,a.paths,!0);if(a.map)k.map= +K(f||{},a.map,!0,!0);if(a.shim)y(a.shim,function(a,b){G(a)&&(a={deps:a});if(a.exports&&!a.exports.__buildReady)a.exports=h.makeShimExports(a.exports);c[b]=a}),k.shim=c;if(a.packages)q(a.packages,function(a){a=typeof a==="string"?{name:a}:a;b[a.name]={name:a.name,location:a.location||a.name,main:(a.main||"main").replace(ja,"").replace(ba,"")}}),k.pkgs=b;y(m,function(a,b){a.map=g(b)});if(a.deps||a.callback)h.require(a.deps||[],a.callback)},makeShimExports:function(a){var b;return typeof a==="string"? +(b=function(){return Z(a)},b.exports=a,b):function(){return a.apply(Y,arguments)}},requireDefined:function(a,b){var c=g(a,b,!1,!0).id;return n.hasOwnProperty(c)},requireSpecified:function(a,b){a=g(a,b,!1,!0).id;return n.hasOwnProperty(a)||m.hasOwnProperty(a)},require:function(a,d,c,e){var f;if(typeof a==="string"){if(x(d))return B(H("requireargs","Invalid require call"),c);if(j.get)return j.get(h,a,d);a=g(a,d,!1,!0);a=a.id;return!n.hasOwnProperty(a)?B(H("notloaded",'Module name "'+a+'" has not been loaded yet for context: '+ +b)):n[a]}c&&!x(c)&&(e=c,c=void 0);d&&!x(d)&&(e=d,d=void 0);for(u();F.length;)if(f=F.shift(),f[0]===null)return B(H("mismatch","Mismatched anonymous define() module: "+f[f.length-1]));else V(f);r(g(null,e)).init(a,d,c,{enabled:!0});E();return h.require},undef:function(a){var b=g(a,null,!0),c=m[a];delete n[a];delete R[b.url];delete W[a];if(c){if(c.events.defined)W[a]=c.events;z(a)}},enable:function(a){m[a.id]&&r(a).enable()},completeLoad:function(a){var b=k.shim[a]||{},c=b.exports&&b.exports.exports, +e,f;for(u();F.length;){f=F.shift();if(f[0]===null){f[0]=a;if(e)break;e=!0}else f[0]===a&&(e=!0);V(f)}f=m[a];if(!e&&!n[a]&&f&&!f.inited)if(k.enforceDefine&&(!c||!Z(c)))if(i(a))return;else return B(H("nodefine","No define call for "+a,null,[a]));else V([a,b.deps||[],b.exports]);E()},toUrl:function(a,b){var e=a.lastIndexOf("."),g=null;e!==-1&&(g=a.substring(e,a.length),a=a.substring(0,e));return h.nameToUrl(c(a,b&&b.id,!0),g)},nameToUrl:function(a,b){var c,e,f,g,h,i;if(j.jsExtRegExp.test(a))g=a+(b|| +"");else{c=k.paths;e=k.pkgs;g=a.split("/");for(h=g.length;h>0;h-=1)if(i=g.slice(0,h).join("/"),f=e[i],i=c[i]){G(i)&&(i=i[0]);g.splice(0,h,i);break}else if(f){c=a===f.name?f.location+"/"+f.main:f.location;g.splice(0,h,c);break}g=g.join("/")+(b||".js");g=(g.charAt(0)==="/"||g.match(/^[\w\+\.\-]+:/)?"":k.baseUrl)+g}return k.urlArgs?g+((g.indexOf("?")===-1?"?":"&")+k.urlArgs):g},load:function(a,b){j.load(h,a,b)},execCb:function(a,b,c,e){return b.apply(e,c)},onScriptLoad:function(a){if(a.type==="load"|| +la.test((a.currentTarget||a.srcElement).readyState))I=null,a=J(a),h.completeLoad(a.id)},onScriptError:function(a){var b=J(a);if(!i(b.id))return B(H("scripterror","Script error",a,[b.id]))}}}};j({});aa(j);if(w&&(t=A.head=document.getElementsByTagName("head")[0],C=document.getElementsByTagName("base")[0]))t=A.head=C.parentNode;j.onError=function(b){throw b;};j.load=function(b,c,e){var i=b&&b.config||{},g;if(w)return g=i.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script"), +g.type=i.scriptType||"text/javascript",g.charset="utf-8",g.async=!0,g.setAttribute("data-requirecontext",b.contextName),g.setAttribute("data-requiremodule",c),g.attachEvent&&!(g.attachEvent.toString&&g.attachEvent.toString().indexOf("[native code")<0)&&!S?(L=!0,g.attachEvent("onreadystatechange",b.onScriptLoad)):(g.addEventListener("load",b.onScriptLoad,!1),g.addEventListener("error",b.onScriptError,!1)),g.src=e,E=g,C?t.insertBefore(g,C):t.appendChild(g),E=null,g;else ca&&(importScripts(e),b.completeLoad(c))}; +w&&N(document.getElementsByTagName("script"),function(b){if(!t)t=b.parentNode;if(u=b.getAttribute("data-main")){if(!p.baseUrl)D=u.split("/"),da=D.pop(),ea=D.length?D.join("/")+"/":"./",p.baseUrl=ea,u=da;u=u.replace(ba,"");p.deps=p.deps?p.deps.concat(u):[u];return!0}});define=function(b,c,e){var i,g;typeof b!=="string"&&(e=c,c=b,b=null);G(c)||(e=c,c=[]);!c.length&&x(e)&&e.length&&(e.toString().replace(ha,"").replace(ia,function(b,e){c.push(e)}),c=(e.length===1?["require"]:["require","exports","module"]).concat(c)); +if(L&&(i=E||ga()))b||(b=i.getAttribute("data-requiremodule")),g=z[i.getAttribute("data-requirecontext")];(g?g.defQueue:P).push([b,c,e])};define.amd={jQuery:!0};j.exec=function(b){return eval(b)};j(p)}})(this); diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/requirejs/require.js b/lib/gollum/frontend/public/gollum/livepreview/js/requirejs/require.js deleted file mode 100644 index d016e1da..00000000 --- a/lib/gollum/frontend/public/gollum/livepreview/js/requirejs/require.js +++ /dev/null @@ -1,1988 +0,0 @@ -/** vim: et:ts=4:sw=4:sts=4 - * @license RequireJS 2.0.1 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved. - * Available via the MIT or new BSD license. - * see: http://github.com/jrburke/requirejs for details - */ -/*jslint regexp: true, nomen: true */ -/*global window, navigator, document, importScripts, jQuery, setTimeout, opera */ - -var requirejs, require, define; -(function (global) { - 'use strict'; - - var version = '2.0.1', - commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg, - cjsRequireRegExp = /require\s*\(\s*["']([^'"\s]+)["']\s*\)/g, - jsSuffixRegExp = /\.js$/, - currDirRegExp = /^\.\//, - ostring = Object.prototype.toString, - ap = Array.prototype, - aps = ap.slice, - apsp = ap.splice, - isBrowser = !!(typeof window !== 'undefined' && navigator && document), - isWebWorker = !isBrowser && typeof importScripts !== 'undefined', - //PS3 indicates loaded and complete, but need to wait for complete - //specifically. Sequence is 'loading', 'loaded', execution, - // then 'complete'. The UA check is unfortunate, but not sure how - //to feature test w/o causing perf issues. - readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ? - /^complete$/ : /^(complete|loaded)$/, - defContextName = '_', - //Oh the tragedy, detecting opera. See the usage of isOpera for reason. - isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]', - contexts = {}, - cfg = {}, - globalDefQueue = [], - useInteractive = false, - req, s, head, baseElement, dataMain, src, - interactiveScript, currentlyAddingScript, mainScript, subPath; - - function isFunction(it) { - return ostring.call(it) === '[object Function]'; - } - - function isArray(it) { - return ostring.call(it) === '[object Array]'; - } - - /** - * Helper function for iterating over an array. If the func returns - * a true value, it will break out of the loop. - */ - function each(ary, func) { - if (ary) { - var i; - for (i = 0; i < ary.length; i += 1) { - if (func(ary[i], i, ary)) { - break; - } - } - } - } - - /** - * Helper function for iterating over an array backwards. If the func - * returns a true value, it will break out of the loop. - */ - function eachReverse(ary, func) { - if (ary) { - var i; - for (i = ary.length - 1; i > -1; i -= 1) { - if (func(ary[i], i, ary)) { - break; - } - } - } - } - - function hasProp(obj, prop) { - return obj.hasOwnProperty(prop); - } - - /** - * Cycles over properties in an object and calls a function for each - * property value. If the function returns a truthy value, then the - * iteration is stopped. - */ - function eachProp(obj, func) { - var prop; - for (prop in obj) { - if (obj.hasOwnProperty(prop)) { - if (func(obj[prop], prop)) { - break; - } - } - } - } - - /** - * Simple function to mix in properties from source into target, - * but only if target does not already have a property of the same name. - * This is not robust in IE for transferring methods that match - * Object.prototype names, but the uses of mixin here seem unlikely to - * trigger a problem related to that. - */ - function mixin(target, source, force) { - if (source) { - eachProp(source, function (value, prop) { - if (force || !hasProp(target, prop)) { - target[prop] = value; - } - }); - } - } - - //Similar to Function.prototype.bind, but the 'this' object is specified - //first, since it is easier to read/figure out what 'this' will be. - function bind(obj, fn) { - return function () { - return fn.apply(obj, arguments); - }; - } - - function scripts() { - return document.getElementsByTagName('script'); - } - - //Allow getting a global that expressed in - //dot notation, like 'a.b.c'. - function getGlobal(value) { - if (!value) { - return value; - } - var g = global; - each(value.split('.'), function (part) { - g = g[part]; - }); - return g; - } - - function makeContextModuleFunc(func, relMap, enableBuildCallback) { - return function () { - //A version of a require function that passes a moduleName - //value for items that may need to - //look up paths relative to the moduleName - var args = aps.call(arguments, 0), lastArg; - if (enableBuildCallback && - isFunction((lastArg = args[args.length - 1]))) { - lastArg.__requireJsBuild = true; - } - args.push(relMap); - return func.apply(null, args); - }; - } - - function addRequireMethods(req, context, relMap) { - each([ - ['toUrl'], - ['undef'], - ['defined', 'requireDefined'], - ['specified', 'requireSpecified'] - ], function (item) { - req[item[0]] = makeContextModuleFunc(context[item[1] || item[0]], relMap); - }); - } - - /** - * Constructs an error with a pointer to an URL with more information. - * @param {String} id the error ID that maps to an ID on a web page. - * @param {String} message human readable error. - * @param {Error} [err] the original error, if there is one. - * - * @returns {Error} - */ - function makeError(id, msg, err, requireModules) { - var e = new Error(msg + '\nhttp://requirejs.org/docs/errors.html#' + id); - e.requireType = id; - e.requireModules = requireModules; - if (err) { - e.originalError = err; - } - return e; - } - - if (typeof define !== 'undefined') { - //If a define is already in play via another AMD loader, - //do not overwrite. - return; - } - - if (typeof requirejs !== 'undefined') { - if (isFunction(requirejs)) { - //Do not overwrite and existing requirejs instance. - return; - } - cfg = requirejs; - requirejs = undefined; - } - - //Allow for a require config object - if (typeof require !== 'undefined' && !isFunction(require)) { - //assume it is a config object. - cfg = require; - require = undefined; - } - - function newContext(contextName) { - var config = { - waitSeconds: 7, - baseUrl: './', - paths: {}, - pkgs: {}, - shim: {} - }, - registry = {}, - undefEvents = {}, - defQueue = [], - defined = {}, - urlMap = {}, - urlFetched = {}, - requireCounter = 1, - unnormalizedCounter = 1, - //Used to track the order in which modules - //should be executed, by the order they - //load. Important for consistent cycle resolution - //behavior. - waitAry = [], - inCheckLoaded, Module, context, handlers, - checkLoadedTimeoutId; - - /** - * Trims the . and .. from an array of path segments. - * It will keep a leading path segment if a .. will become - * the first path segment, to help with module name lookups, - * which act like paths, but can be remapped. But the end result, - * all paths that use this function should look normalized. - * NOTE: this method MODIFIES the input array. - * @param {Array} ary the array of path segments. - */ - function trimDots(ary) { - var i, part; - for (i = 0; ary[i]; i+= 1) { - part = ary[i]; - if (part === '.') { - ary.splice(i, 1); - i -= 1; - } else if (part === '..') { - if (i === 1 && (ary[2] === '..' || ary[0] === '..')) { - //End of the line. Keep at least one non-dot - //path segment at the front so it can be mapped - //correctly to disk. Otherwise, there is likely - //no path mapping for a path starting with '..'. - //This can still fail, but catches the most reasonable - //uses of .. - break; - } else if (i > 0) { - ary.splice(i - 1, 2); - i -= 2; - } - } - } - } - - /** - * Given a relative module name, like ./something, normalize it to - * a real name that can be mapped to a path. - * @param {String} name the relative name - * @param {String} baseName a real name that the name arg is relative - * to. - * @param {Boolean} applyMap apply the map config to the value. Should - * only be done if this normalization is for a dependency ID. - * @returns {String} normalized name - */ - function normalize(name, baseName, applyMap) { - var baseParts = baseName && baseName.split('/'), - map = config.map, - starMap = map && map['*'], - pkgName, pkgConfig, mapValue, nameParts, i, j, nameSegment, - foundMap; - - //Adjust any relative paths. - if (name && name.charAt(0) === '.') { - //If have a base name, try to normalize against it, - //otherwise, assume it is a top-level require that will - //be relative to baseUrl in the end. - if (baseName) { - if (config.pkgs[baseName]) { - //If the baseName is a package name, then just treat it as one - //name to concat the name with. - baseParts = [baseName]; - } else { - //Convert baseName to array, and lop off the last part, - //so that . matches that 'directory' and not name of the baseName's - //module. For instance, baseName of 'one/two/three', maps to - //'one/two/three.js', but we want the directory, 'one/two' for - //this normalization. - baseParts = baseParts.slice(0, baseParts.length - 1); - } - - name = baseParts.concat(name.split('/')); - trimDots(name); - - //Some use of packages may use a . path to reference the - //'main' module name, so normalize for that. - pkgConfig = config.pkgs[(pkgName = name[0])]; - name = name.join('/'); - if (pkgConfig && name === pkgName + '/' + pkgConfig.main) { - name = pkgName; - } - } else if (name.indexOf('./') === 0) { - // No baseName, so this is ID is resolved relative - // to baseUrl, pull off the leading dot. - name = name.substring(2); - } - } - - //Apply map config if available. - if (applyMap && (baseParts || starMap) && map) { - nameParts = name.split('/'); - - for (i = nameParts.length; i > 0; i -= 1) { - nameSegment = nameParts.slice(0, i).join('/'); - - if (baseParts) { - //Find the longest baseName segment match in the config. - //So, do joins on the biggest to smallest lengths of baseParts. - for (j = baseParts.length; j > 0; j -= 1) { - mapValue = map[baseParts.slice(0, j).join('/')]; - - //baseName segment has config, find if it has one for - //this name. - if (mapValue) { - mapValue = mapValue[nameSegment]; - if (mapValue) { - //Match, update name to the new value. - foundMap = mapValue; - break; - } - } - } - } - - if (!foundMap && starMap && starMap[nameSegment]) { - foundMap = starMap[nameSegment]; - } - - if (foundMap) { - nameParts.splice(0, i, foundMap); - name = nameParts.join('/'); - break; - } - } - } - - return name; - } - - function removeScript(name) { - if (isBrowser) { - each(scripts(), function (scriptNode) { - if (scriptNode.getAttribute('data-requiremodule') === name && - scriptNode.getAttribute('data-requirecontext') === context.contextName) { - scriptNode.parentNode.removeChild(scriptNode); - return true; - } - }); - } - } - - function hasPathFallback(id) { - var pathConfig = config.paths[id]; - if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) { - removeScript(id); - //Pop off the first array value, since it failed, and - //retry - pathConfig.shift(); - context.undef(id); - context.require([id]); - return true; - } - } - - /** - * Creates a module mapping that includes plugin prefix, module - * name, and path. If parentModuleMap is provided it will - * also normalize the name via require.normalize() - * - * @param {String} name the module name - * @param {String} [parentModuleMap] parent module map - * for the module name, used to resolve relative names. - * @param {Boolean} isNormalized: is the ID already normalized. - * This is true if this call is done for a define() module ID. - * @param {Boolean} applyMap: apply the map config to the ID. - * Should only be true if this map is for a dependency. - * - * @returns {Object} - */ - function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) { - var index = name ? name.indexOf('!') : -1, - prefix = null, - parentName = parentModuleMap ? parentModuleMap.name : null, - originalName = name, - isDefine = true, - normalizedName = '', - url, pluginModule, suffix; - - //If no name, then it means it is a require call, generate an - //internal name. - if (!name) { - isDefine = false; - name = '_@r' + (requireCounter += 1); - } - - if (index !== -1) { - prefix = name.substring(0, index); - name = name.substring(index + 1, name.length); - } - - if (prefix) { - prefix = normalize(prefix, parentName, applyMap); - pluginModule = defined[prefix]; - } - - //Account for relative paths if there is a base name. - if (name) { - if (prefix) { - if (pluginModule && pluginModule.normalize) { - //Plugin is loaded, use its normalize method. - normalizedName = pluginModule.normalize(name, function (name) { - return normalize(name, parentName, applyMap); - }); - } else { - normalizedName = normalize(name, parentName, applyMap); - } - } else { - //A regular module. - normalizedName = normalize(name, parentName, applyMap); - - url = urlMap[normalizedName]; - if (!url) { - //Calculate url for the module, if it has a name. - //Use name here since nameToUrl also calls normalize, - //and for relative names that are outside the baseUrl - //this causes havoc. Was thinking of just removing - //parentModuleMap to avoid extra normalization, but - //normalize() still does a dot removal because of - //issue #142, so just pass in name here and redo - //the normalization. Paths outside baseUrl are just - //messy to support. - url = context.nameToUrl(name, null, parentModuleMap); - - //Store the URL mapping for later. - urlMap[normalizedName] = url; - } - } - } - - //If the id is a plugin id that cannot be determined if it needs - //normalization, stamp it with a unique ID so two matching relative - //ids that may conflict can be separate. - suffix = prefix && !pluginModule && !isNormalized ? - '_unnormalized' + (unnormalizedCounter += 1) : - ''; - - return { - prefix: prefix, - name: normalizedName, - parentMap: parentModuleMap, - unnormalized: !!suffix, - url: url, - originalName: originalName, - isDefine: isDefine, - id: (prefix ? - prefix + '!' + normalizedName : - normalizedName) + suffix - }; - } - - function getModule(depMap) { - var id = depMap.id, - mod = registry[id]; - - if (!mod) { - mod = registry[id] = new context.Module(depMap); - } - - return mod; - } - - function on(depMap, name, fn) { - var id = depMap.id, - mod = registry[id]; - - if (hasProp(defined, id) && - (!mod || mod.defineEmitComplete)) { - if (name === 'defined') { - fn(defined[id]); - } - } else { - getModule(depMap).on(name, fn); - } - } - - function onError(err, errback) { - var ids = err.requireModules, - notified = false; - - if (errback) { - errback(err); - } else { - each(ids, function (id) { - var mod = registry[id]; - if (mod) { - //Set error on module, so it skips timeout checks. - mod.error = err; - if (mod.events.error) { - notified = true; - mod.emit('error', err); - } - } - }); - - if (!notified) { - req.onError(err); - } - } - } - - /** - * Internal method to transfer globalQueue items to this context's - * defQueue. - */ - function takeGlobalQueue() { - //Push all the globalDefQueue items into the context's defQueue - if (globalDefQueue.length) { - //Array splice in the values since the context code has a - //local var ref to defQueue, so cannot just reassign the one - //on context. - apsp.apply(defQueue, - [defQueue.length - 1, 0].concat(globalDefQueue)); - globalDefQueue = []; - } - } - - /** - * Helper function that creates a require function object to give to - * modules that ask for it as a dependency. It needs to be specific - * per module because of the implication of path mappings that may - * need to be relative to the module name. - */ - function makeRequire(mod, enableBuildCallback, altRequire) { - var relMap = mod && mod.map, - modRequire = makeContextModuleFunc(altRequire || context.require, - relMap, - enableBuildCallback); - - addRequireMethods(modRequire, context, relMap); - modRequire.isBrowser = isBrowser; - - return modRequire; - } - - handlers = { - 'require': function (mod) { - return makeRequire(mod); - }, - 'exports': function (mod) { - mod.usingExports = true; - if (mod.map.isDefine) { - return (mod.exports = defined[mod.map.id] = {}); - } - }, - 'module': function (mod) { - return (mod.module = { - id: mod.map.id, - uri: mod.map.url, - config: function () { - return (config.config && config.config[mod.map.id]) || {}; - }, - exports: defined[mod.map.id] - }); - } - }; - - function removeWaiting(id) { - //Clean up machinery used for waiting modules. - delete registry[id]; - - each(waitAry, function (mod, i) { - if (mod.map.id === id) { - waitAry.splice(i, 1); - if (!mod.defined) { - context.waitCount -= 1; - } - return true; - } - }); - } - - function findCycle(mod, traced) { - var id = mod.map.id, - depArray = mod.depMaps, - foundModule; - - //Do not bother with unitialized modules or not yet enabled - //modules. - if (!mod.inited) { - return; - } - - //Found the cycle. - if (traced[id]) { - return mod; - } - - traced[id] = true; - - //Trace through the dependencies. - each(depArray, function (depMap) { - var depId = depMap.id, - depMod = registry[depId]; - - if (!depMod) { - return; - } - - if (!depMod.inited || !depMod.enabled) { - //Dependency is not inited, so this cannot - //be used to determine a cycle. - foundModule = null; - delete traced[id]; - return true; - } - - return (foundModule = findCycle(depMod, traced)); - }); - - return foundModule; - } - - function forceExec(mod, traced, uninited) { - var id = mod.map.id, - depArray = mod.depMaps; - - if (!mod.inited || !mod.map.isDefine) { - return; - } - - if (traced[id]) { - return defined[id]; - } - - traced[id] = mod; - - each(depArray, function(depMap) { - var depId = depMap.id, - depMod = registry[depId], - value; - - if (handlers[depId]) { - return; - } - - if (depMod) { - if (!depMod.inited || !depMod.enabled) { - //Dependency is not inited, - //so this module cannot be - //given a forced value yet. - uninited[id] = true; - return; - } - - //Get the value for the current dependency - value = forceExec(depMod, traced, uninited); - - //Even with forcing it may not be done, - //in particular if the module is waiting - //on a plugin resource. - if (!uninited[depId]) { - mod.defineDepById(depId, value); - } - } - }); - - mod.check(true); - - return defined[id]; - } - - function modCheck(mod) { - mod.check(); - } - - function checkLoaded() { - var waitInterval = config.waitSeconds * 1000, - //It is possible to disable the wait interval by using waitSeconds of 0. - expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(), - noLoads = [], - stillLoading = false, - needCycleCheck = true, - map, modId, err, usingPathFallback; - - //Do not bother if this call was a result of a cycle break. - if (inCheckLoaded) { - return; - } - - inCheckLoaded = true; - - //Figure out the state of all the modules. - eachProp(registry, function (mod) { - map = mod.map; - modId = map.id; - - //Skip things that are not enabled or in error state. - if (!mod.enabled) { - return; - } - - if (!mod.error) { - //If the module should be executed, and it has not - //been inited and time is up, remember it. - if (!mod.inited && expired) { - if (hasPathFallback(modId)) { - usingPathFallback = true; - stillLoading = true; - } else { - noLoads.push(modId); - removeScript(modId); - } - } else if (!mod.inited && mod.fetched && map.isDefine) { - stillLoading = true; - if (!map.prefix) { - //No reason to keep looking for unfinished - //loading. If the only stillLoading is a - //plugin resource though, keep going, - //because it may be that a plugin resource - //is waiting on a non-plugin cycle. - return (needCycleCheck = false); - } - } - } - }); - - if (expired && noLoads.length) { - //If wait time expired, throw error of unloaded modules. - err = makeError('timeout', 'Load timeout for modules: ' + noLoads, null, noLoads); - err.contextName = context.contextName; - return onError(err); - } - - //Not expired, check for a cycle. - if (needCycleCheck) { - - each(waitAry, function (mod) { - if (mod.defined) { - return; - } - - var cycleMod = findCycle(mod, {}), - traced = {}; - - if (cycleMod) { - forceExec(cycleMod, traced, {}); - - //traced modules may have been - //removed from the registry, but - //their listeners still need to - //be called. - eachProp(traced, modCheck); - } - }); - - //Now that dependencies have - //been satisfied, trigger the - //completion check that then - //notifies listeners. - eachProp(registry, modCheck); - } - - //If still waiting on loads, and the waiting load is something - //other than a plugin resource, or there are still outstanding - //scripts, then just try back later. - if ((!expired || usingPathFallback) && stillLoading) { - //Something is still waiting to load. Wait for it, but only - //if a timeout is not already in effect. - if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) { - checkLoadedTimeoutId = setTimeout(function () { - checkLoadedTimeoutId = 0; - checkLoaded(); - }, 50); - } - } - - inCheckLoaded = false; - } - - Module = function (map) { - this.events = undefEvents[map.id] || {}; - this.map = map; - this.shim = config.shim[map.id]; - this.depExports = []; - this.depMaps = []; - this.depMatched = []; - this.pluginMaps = {}; - this.depCount = 0; - - /* this.exports this.factory - this.depMaps = [], - this.enabled, this.fetched - */ - }; - - Module.prototype = { - init: function(depMaps, factory, errback, options) { - options = options || {}; - - //Do not do more inits if already done. Can happen if there - //are multiple define calls for the same module. That is not - //a normal, common case, but it is also not unexpected. - if (this.inited) { - return; - } - - this.factory = factory; - - if (errback) { - //Register for errors on this module. - this.on('error', errback); - } else if (this.events.error) { - //If no errback already, but there are error listeners - //on this module, set up an errback to pass to the deps. - errback = bind(this, function (err) { - this.emit('error', err); - }); - } - - each(depMaps, bind(this, function (depMap, i) { - if (typeof depMap === 'string') { - depMap = makeModuleMap(depMap, - (this.map.isDefine ? this.map : this.map.parentMap), - false, - true); - this.depMaps.push(depMap); - } - - var handler = handlers[depMap.id]; - - if (handler) { - this.depExports[i] = handler(this); - return; - } - - this.depCount += 1; - - on(depMap, 'defined', bind(this, function (depExports) { - this.defineDep(i, depExports); - this.check(); - })); - - if (errback) { - on(depMap, 'error', errback); - } - })); - - //Indicate this module has be initialized - this.inited = true; - - this.ignore = options.ignore; - - //Could have option to init this module in enabled mode, - //or could have been previously marked as enabled. However, - //the dependencies are not known until init is called. So - //if enabled previously, now trigger dependencies as enabled. - if (options.enabled || this.enabled) { - //Enable this module and dependencies. - //Will call this.check() - this.enable(); - } else { - this.check(); - } - }, - - defineDepById: function (id, depExports) { - var i; - - //Find the index for this dependency. - each(this.depMaps, function (map, index) { - if (map.id === id) { - i = index; - return true; - } - }); - - return this.defineDep(i, depExports); - }, - - defineDep: function (i, depExports) { - //Because of cycles, defined callback for a given - //export can be called more than once. - if (!this.depMatched[i]) { - this.depMatched[i] = true; - this.depCount -= 1; - this.depExports[i] = depExports; - } - }, - - fetch: function () { - if (this.fetched) { - return; - } - this.fetched = true; - - context.startTime = (new Date()).getTime(); - - var map = this.map; - - //If the manager is for a plugin managed resource, - //ask the plugin to load it now. - if (map.prefix) { - this.callPlugin(); - } else if (this.shim) { - makeRequire(this, true)(this.shim.deps || [], bind(this, function () { - this.load(); - })); - } else { - //Regular dependency. - this.load(); - } - }, - - load: function() { - var url = this.map.url; - - //Regular dependency. - if (!urlFetched[url]) { - urlFetched[url] = true; - context.load(this.map.id, url); - } - }, - - /** - * Checks is the module is ready to define itself, and if so, - * define it. If the silent argument is true, then it will just - * define, but not notify listeners, and not ask for a context-wide - * check of all loaded modules. That is useful for cycle breaking. - */ - check: function (silent) { - if (!this.enabled) { - return; - } - - var id = this.map.id, - depExports = this.depExports, - exports = this.exports, - factory = this.factory, - err, cjsModule; - - if (!this.inited) { - this.fetch(); - } else if (this.error) { - this.emit('error', this.error); - } else if (!this.defining) { - //The factory could trigger another require call - //that would result in checking this module to - //define itself again. If already in the process - //of doing that, skip this work. - this.defining = true; - - if (this.depCount < 1 && !this.defined) { - if (isFunction(factory)) { - //If there is an error listener, favor passing - //to that instead of throwing an error. - if (this.events.error) { - try { - exports = context.execCb(id, factory, depExports, exports); - } catch (e) { - err = e; - } - } else { - exports = context.execCb(id, factory, depExports, exports); - } - - if (this.map.isDefine) { - //If setting exports via 'module' is in play, - //favor that over return value and exports. After that, - //favor a non-undefined return value over exports use. - cjsModule = this.module; - if (cjsModule && - cjsModule.exports !== undefined && - //Make sure it is not already the exports value - cjsModule.exports !== this.exports) { - exports = cjsModule.exports; - } else if (exports === undefined && this.usingExports) { - //exports already set the defined value. - exports = this.exports; - } - } - - if (err) { - err.requireMap = this.map; - err.requireModules = [this.map.id]; - err.requireType = 'define'; - return onError((this.error = err)); - } - - } else { - //Just a literal value - exports = factory; - } - - this.exports = exports; - - if (this.map.isDefine && !this.ignore) { - defined[id] = exports; - - if (req.onResourceLoad) { - req.onResourceLoad(context, this.map, this.depMaps); - } - } - - //Clean up - delete registry[id]; - - this.defined = true; - context.waitCount -= 1; - if (context.waitCount === 0) { - //Clear the wait array used for cycles. - waitAry = []; - } - } - - //Finished the define stage. Allow calling check again - //to allow define notifications below in the case of a - //cycle. - this.defining = false; - - if (!silent) { - if (this.defined && !this.defineEmitted) { - this.defineEmitted = true; - this.emit('defined', this.exports); - this.defineEmitComplete = true; - } - } - } - }, - - callPlugin: function() { - var map = this.map, - id = map.id, - pluginMap = makeModuleMap(map.prefix, null, false, true); - - on(pluginMap, 'defined', bind(this, function (plugin) { - var name = this.map.name, - parentName = this.map.parentMap ? this.map.parentMap.name : null, - load, normalizedMap, normalizedMod; - - //If current map is not normalized, wait for that - //normalized name to load instead of continuing. - if (this.map.unnormalized) { - //Normalize the ID if the plugin allows it. - if (plugin.normalize) { - name = plugin.normalize(name, function (name) { - return normalize(name, parentName, true); - }) || ''; - } - - normalizedMap = makeModuleMap(map.prefix + '!' + name); - on(normalizedMap, - 'defined', bind(this, function (value) { - this.init([], function () { return value; }, null, { - enabled: true, - ignore: true - }); - })); - normalizedMod = registry[normalizedMap.id]; - if (normalizedMod) { - if (this.events.error) { - normalizedMod.on('error', bind(this, function (err) { - this.emit('error', err); - })); - } - normalizedMod.enable(); - } - - return; - } - - load = bind(this, function (value) { - this.init([], function () { return value; }, null, { - enabled: true - }); - }); - - load.error = bind(this, function (err) { - this.inited = true; - this.error = err; - err.requireModules = [id]; - - //Remove temp unnormalized modules for this module, - //since they will never be resolved otherwise now. - eachProp(registry, function (mod) { - if (mod.map.id.indexOf(id + '_unnormalized') === 0) { - removeWaiting(mod.map.id); - } - }); - - onError(err); - }); - - //Allow plugins to load other code without having to know the - //context or how to 'complete' the load. - load.fromText = function (moduleName, text) { - /*jslint evil: true */ - var hasInteractive = useInteractive; - - //Turn off interactive script matching for IE for any define - //calls in the text, then turn it back on at the end. - if (hasInteractive) { - useInteractive = false; - } - - req.exec(text); - - if (hasInteractive) { - useInteractive = true; - } - - //Support anonymous modules. - context.completeLoad(moduleName); - }; - - //Use parentName here since the plugin's name is not reliable, - //could be some weird string with no path that actually wants to - //reference the parentName's path. - plugin.load(map.name, makeRequire(map.parentMap, true, function (deps, cb) { - return context.require(deps, cb); - }), load, config); - })); - - context.enable(pluginMap, this); - this.pluginMaps[pluginMap.id] = pluginMap; - }, - - enable: function () { - this.enabled = true; - - if (!this.waitPushed) { - waitAry.push(this); - context.waitCount += 1; - this.waitPushed = true; - } - - //Enable each dependency - each(this.depMaps, bind(this, function (map) { - var id = map.id, - mod = registry[id]; - //Skip special modules like 'require', 'exports', 'module' - //Also, don't call enable if it is already enabled, - //important in circular dependency cases. - if (!handlers[id] && mod && !mod.enabled) { - context.enable(map, this); - } - })); - - //Enable each plugin that is used in - //a dependency - eachProp(this.pluginMaps, bind(this, function (pluginMap) { - var mod = registry[pluginMap.id]; - if (mod && !mod.enabled) { - context.enable(pluginMap, this); - } - })); - - this.check(); - }, - - on: function(name, cb) { - var cbs = this.events[name]; - if (!cbs) { - cbs = this.events[name] = []; - } - cbs.push(cb); - }, - - emit: function (name, evt) { - each(this.events[name], function (cb) { - cb(evt); - }); - if (name === 'error') { - //Now that the error handler was triggered, remove - //the listeners, since this broken Module instance - //can stay around for a while in the registry/waitAry. - delete this.events[name]; - } - } - }; - - function callGetModule(args) { - getModule(makeModuleMap(args[0], null, true)).init(args[1], args[2]); - } - - function removeListener(node, func, name, ieName) { - //Favor detachEvent because of IE9 - //issue, see attachEvent/addEventListener comment elsewhere - //in this file. - if (node.detachEvent && !isOpera) { - //Probably IE. If not it will throw an error, which will be - //useful to know. - if (ieName) { - node.detachEvent(ieName, func); - } - } else { - node.removeEventListener(name, func, false); - } - } - - /** - * Given an event from a script node, get the requirejs info from it, - * and then removes the event listeners on the node. - * @param {Event} evt - * @returns {Object} - */ - function getScriptData(evt) { - //Using currentTarget instead of target for Firefox 2.0's sake. Not - //all old browsers will be supported, but this one was easy enough - //to support and still makes sense. - var node = evt.currentTarget || evt.srcElement; - - //Remove the listeners once here. - removeListener(node, context.onScriptLoad, 'load', 'onreadystatechange'); - removeListener(node, context.onScriptError, 'error'); - - return { - node: node, - id: node && node.getAttribute('data-requiremodule') - }; - } - - return (context = { - config: config, - contextName: contextName, - registry: registry, - defined: defined, - urlMap: urlMap, - urlFetched: urlFetched, - waitCount: 0, - defQueue: defQueue, - Module: Module, - makeModuleMap: makeModuleMap, - - /** - * Set a configuration for the context. - * @param {Object} cfg config object to integrate. - */ - configure: function (cfg) { - //Make sure the baseUrl ends in a slash. - if (cfg.baseUrl) { - if (cfg.baseUrl.charAt(cfg.baseUrl.length - 1) !== '/') { - cfg.baseUrl += '/'; - } - } - - //Save off the paths and packages since they require special processing, - //they are additive. - var paths = config.paths, - pkgs = config.pkgs, - shim = config.shim, - map = config.map || {}; - - //Mix in the config values, favoring the new values over - //existing ones in context.config. - mixin(config, cfg, true); - - //Merge paths. - mixin(paths, cfg.paths, true); - config.paths = paths; - - //Merge map - if (cfg.map) { - mixin(map, cfg.map, true); - config.map = map; - } - - //Merge shim - if (cfg.shim) { - eachProp(cfg.shim, function (value, id) { - //Normalize the structure - if (isArray(value)) { - value = { - deps: value - }; - } - if (value.exports && !value.exports.__buildReady) { - value.exports = context.makeShimExports(value.exports); - } - shim[id] = value; - }); - config.shim = shim; - } - - //Adjust packages if necessary. - if (cfg.packages) { - each(cfg.packages, function (pkgObj) { - var location; - - pkgObj = typeof pkgObj === 'string' ? { name: pkgObj } : pkgObj; - location = pkgObj.location; - - //Create a brand new object on pkgs, since currentPackages can - //be passed in again, and config.pkgs is the internal transformed - //state for all package configs. - pkgs[pkgObj.name] = { - name: pkgObj.name, - location: location || pkgObj.name, - //Remove leading dot in main, so main paths are normalized, - //and remove any trailing .js, since different package - //envs have different conventions: some use a module name, - //some use a file name. - main: (pkgObj.main || 'main') - .replace(currDirRegExp, '') - .replace(jsSuffixRegExp, '') - }; - }); - - //Done with modifications, assing packages back to context config - config.pkgs = pkgs; - } - - //If a deps array or a config callback is specified, then call - //require with those args. This is useful when require is defined as a - //config object before require.js is loaded. - if (cfg.deps || cfg.callback) { - context.require(cfg.deps || [], cfg.callback); - } - }, - - makeShimExports: function (exports) { - var func; - if (typeof exports === 'string') { - func = function () { - return getGlobal(exports); - }; - //Save the exports for use in nodefine checking. - func.exports = exports; - return func; - } else { - return function () { - return exports.apply(global, arguments); - }; - } - }, - - requireDefined: function (id, relMap) { - return hasProp(defined, makeModuleMap(id, relMap, false, true).id); - }, - - requireSpecified: function (id, relMap) { - id = makeModuleMap(id, relMap, false, true).id; - return hasProp(defined, id) || hasProp(registry, id); - }, - - require: function (deps, callback, errback, relMap) { - var moduleName, id, map, requireMod, args; - if (typeof deps === 'string') { - if (isFunction(callback)) { - //Invalid call - return onError(makeError('requireargs', 'Invalid require call'), errback); - } - - //Synchronous access to one module. If require.get is - //available (as in the Node adapter), prefer that. - //In this case deps is the moduleName and callback is - //the relMap - if (req.get) { - return req.get(context, deps, callback); - } - - //Just return the module wanted. In this scenario, the - //second arg (if passed) is just the relMap. - moduleName = deps; - relMap = callback; - - //Normalize module name, if it contains . or .. - map = makeModuleMap(moduleName, relMap, false, true); - id = map.id; - - if (!hasProp(defined, id)) { - return onError(makeError('notloaded', 'Module name "' + - id + - '" has not been loaded yet for context: ' + - contextName)); - } - return defined[id]; - } - - //Callback require. Normalize args. if callback or errback is - //not a function, it means it is a relMap. Test errback first. - if (errback && !isFunction(errback)) { - relMap = errback; - errback = undefined; - } - if (callback && !isFunction(callback)) { - relMap = callback; - callback = undefined; - } - - //Any defined modules in the global queue, intake them now. - takeGlobalQueue(); - - //Make sure any remaining defQueue items get properly processed. - while (defQueue.length) { - args = defQueue.shift(); - if (args[0] === null) { - return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + args[args.length - 1])); - } else { - //args are id, deps, factory. Should be normalized by the - //define() function. - callGetModule(args); - } - } - - //Mark all the dependencies as needing to be loaded. - requireMod = getModule(makeModuleMap(null, relMap)); - - requireMod.init(deps, callback, errback, { - enabled: true - }); - - checkLoaded(); - - return context.require; - }, - - undef: function (id) { - var map = makeModuleMap(id, null, true), - mod = registry[id]; - - delete defined[id]; - delete urlMap[id]; - delete urlFetched[map.url]; - delete undefEvents[id]; - - if (mod) { - //Hold on to listeners in case the - //module will be attempted to be reloaded - //using a different config. - if (mod.events.defined) { - undefEvents[id] = mod.events; - } - - removeWaiting(id); - } - }, - - /** - * Called to enable a module if it is still in the registry - * awaiting enablement. parent module is passed in for context, - * used by the optimizer. - */ - enable: function (depMap, parent) { - var mod = registry[depMap.id]; - if (mod) { - getModule(depMap).enable(); - } - }, - - /** - * Internal method used by environment adapters to complete a load event. - * A load event could be a script load or just a load pass from a synchronous - * load call. - * @param {String} moduleName the name of the module to potentially complete. - */ - completeLoad: function (moduleName) { - var shim = config.shim[moduleName] || {}, - shExports = shim.exports && shim.exports.exports, - found, args, mod; - - takeGlobalQueue(); - - while (defQueue.length) { - args = defQueue.shift(); - if (args[0] === null) { - args[0] = moduleName; - //If already found an anonymous module and bound it - //to this name, then this is some other anon module - //waiting for its completeLoad to fire. - if (found) { - break; - } - found = true; - } else if (args[0] === moduleName) { - //Found matching define call for this script! - found = true; - } - - callGetModule(args); - } - - //Do this after the cycle of callGetModule in case the result - //of those calls/init calls changes the registry. - mod = registry[moduleName]; - - if (!found && - !defined[moduleName] && - mod && !mod.inited) { - if (config.enforceDefine && (!shExports || !getGlobal(shExports))) { - if (hasPathFallback(moduleName)) { - return; - } else { - return onError(makeError('nodefine', - 'No define call for ' + moduleName, - null, - [moduleName])); - } - } else { - //A script that does not call define(), so just simulate - //the call for it. - callGetModule([moduleName, (shim.deps || []), shim.exports]); - } - } - - checkLoaded(); - }, - - /** - * Converts a module name + .extension into an URL path. - * *Requires* the use of a module name. It does not support using - * plain URLs like nameToUrl. - */ - toUrl: function (moduleNamePlusExt, relModuleMap) { - var index = moduleNamePlusExt.lastIndexOf('.'), - ext = null; - - if (index !== -1) { - ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length); - moduleNamePlusExt = moduleNamePlusExt.substring(0, index); - } - - return context.nameToUrl(moduleNamePlusExt, ext, relModuleMap); - }, - - /** - * Converts a module name to a file path. Supports cases where - * moduleName may actually be just an URL. - */ - nameToUrl: function (moduleName, ext, relModuleMap) { - var paths, pkgs, pkg, pkgPath, syms, i, parentModule, url, - parentPath; - - //Normalize module name if have a base relative module name to work from. - moduleName = normalize(moduleName, relModuleMap && relModuleMap.id, true); - - //If a colon is in the URL, it indicates a protocol is used and it is just - //an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?) - //or ends with .js, then assume the user meant to use an url and not a module id. - //The slash is important for protocol-less URLs as well as full paths. - if (req.jsExtRegExp.test(moduleName)) { - //Just a plain path, not module name lookup, so just return it. - //Add extension if it is included. This is a bit wonky, only non-.js things pass - //an extension, this method probably needs to be reworked. - url = moduleName + (ext || ''); - } else { - //A module that needs to be converted to a path. - paths = config.paths; - pkgs = config.pkgs; - - syms = moduleName.split('/'); - //For each module name segment, see if there is a path - //registered for it. Start with most specific name - //and work up from it. - for (i = syms.length; i > 0; i -= 1) { - parentModule = syms.slice(0, i).join('/'); - pkg = pkgs[parentModule]; - parentPath = paths[parentModule]; - if (parentPath) { - //If an array, it means there are a few choices, - //Choose the one that is desired - if (isArray(parentPath)) { - parentPath = parentPath[0]; - } - syms.splice(0, i, parentPath); - break; - } else if (pkg) { - //If module name is just the package name, then looking - //for the main module. - if (moduleName === pkg.name) { - pkgPath = pkg.location + '/' + pkg.main; - } else { - pkgPath = pkg.location; - } - syms.splice(0, i, pkgPath); - break; - } - } - - //Join the path parts together, then figure out if baseUrl is needed. - url = syms.join('/') + (ext || '.js'); - url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url; - } - - return config.urlArgs ? url + - ((url.indexOf('?') === -1 ? '?' : '&') + - config.urlArgs) : url; - }, - - //Delegates to req.load. Broken out as a separate function to - //allow overriding in the optimizer. - load: function (id, url) { - req.load(context, id, url); - }, - - /** - * Executes a module callack function. Broken out as a separate function - * solely to allow the build system to sequence the files in the built - * layer in the right sequence. - * - * @private - */ - execCb: function (name, callback, args, exports) { - return callback.apply(exports, args); - }, - - /** - * callback for script loads, used to check status of loading. - * - * @param {Event} evt the event from the browser for the script - * that was loaded. - */ - onScriptLoad: function (evt) { - //Using currentTarget instead of target for Firefox 2.0's sake. Not - //all old browsers will be supported, but this one was easy enough - //to support and still makes sense. - if (evt.type === 'load' || - (readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) { - //Reset interactive script so a script node is not held onto for - //to long. - interactiveScript = null; - - //Pull out the name of the module and the context. - var data = getScriptData(evt); - context.completeLoad(data.id); - } - }, - - /** - * Callback for script errors. - */ - onScriptError: function (evt) { - var data = getScriptData(evt); - if (!hasPathFallback(data.id)) { - return onError(makeError('scripterror', 'Script error', evt, [data.id])); - } - } - }); - } - - /** - * Main entry point. - * - * If the only argument to require is a string, then the module that - * is represented by that string is fetched for the appropriate context. - * - * If the first argument is an array, then it will be treated as an array - * of dependency string names to fetch. An optional function callback can - * be specified to execute when all of those dependencies are available. - * - * Make a local req variable to help Caja compliance (it assumes things - * on a require that are not standardized), and to give a short - * name for minification/local scope use. - */ - req = requirejs = function (deps, callback, errback, optional) { - - //Find the right context, use default - var contextName = defContextName, - context, config; - - // Determine if have config object in the call. - if (!isArray(deps) && typeof deps !== 'string') { - // deps is a config object - config = deps; - if (isArray(callback)) { - // Adjust args if there are dependencies - deps = callback; - callback = errback; - errback = optional; - } else { - deps = []; - } - } - - if (config && config.context) { - contextName = config.context; - } - - context = contexts[contextName]; - if (!context) { - context = contexts[contextName] = req.s.newContext(contextName); - } - - if (config) { - context.configure(config); - } - - return context.require(deps, callback, errback); - }; - - /** - * Support require.config() to make it easier to cooperate with other - * AMD loaders on globally agreed names. - */ - req.config = function (config) { - return req(config); - }; - - /** - * Export require as a global, but only if it does not already exist. - */ - if (!require) { - require = req; - } - - req.version = version; - - //Used to filter out dependencies that are already paths. - req.jsExtRegExp = /^\/|:|\?|\.js$/; - req.isBrowser = isBrowser; - s = req.s = { - contexts: contexts, - newContext: newContext - }; - - //Create default context. - req({}); - - //Exports some context-sensitive methods on global require, using - //default context if no context specified. - addRequireMethods(req, contexts[defContextName]); - - if (isBrowser) { - head = s.head = document.getElementsByTagName('head')[0]; - //If BASE tag is in play, using appendChild is a problem for IE6. - //When that browser dies, this can be removed. Details in this jQuery bug: - //http://dev.jquery.com/ticket/2709 - baseElement = document.getElementsByTagName('base')[0]; - if (baseElement) { - head = s.head = baseElement.parentNode; - } - } - - /** - * Any errors that require explicitly generates will be passed to this - * function. Intercept/override it if you want custom error handling. - * @param {Error} err the error object. - */ - req.onError = function (err) { - throw err; - }; - - /** - * Does the request to load a module for the browser case. - * Make this a separate function to allow other environments - * to override it. - * - * @param {Object} context the require context to find state. - * @param {String} moduleName the name of the module. - * @param {Object} url the URL to the module. - */ - req.load = function (context, moduleName, url) { - var config = (context && context.config) || {}, - node; - if (isBrowser) { - //In the browser so use a script tag - node = config.xhtml ? - document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') : - document.createElement('script'); - node.type = config.scriptType || 'text/javascript'; - node.charset = 'utf-8'; - - node.setAttribute('data-requirecontext', context.contextName); - node.setAttribute('data-requiremodule', moduleName); - - //Set up load listener. Test attachEvent first because IE9 has - //a subtle issue in its addEventListener and script onload firings - //that do not match the behavior of all other browsers with - //addEventListener support, which fire the onload event for a - //script right after the script execution. See: - //https://connect.microsoft.com/IE/feedback/details/648057/script-onload-event-is-not-fired-immediately-after-script-execution - //UNFORTUNATELY Opera implements attachEvent but does not follow the script - //script execution mode. - if (node.attachEvent && - //Check if node.attachEvent is artificially added by custom script or - //natively supported by browser - //read https://github.com/jrburke/requirejs/issues/187 - //if we can NOT find [native code] then it must NOT natively supported. - //in IE8, node.attachEvent does not have toString() - //Note the test for "[native code" with no closing brace, see: - //https://github.com/jrburke/requirejs/issues/273 - !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) && - !isOpera) { - //Probably IE. IE (at least 6-8) do not fire - //script onload right after executing the script, so - //we cannot tie the anonymous define call to a name. - //However, IE reports the script as being in 'interactive' - //readyState at the time of the define call. - useInteractive = true; - - node.attachEvent('onreadystatechange', context.onScriptLoad); - //It would be great to add an error handler here to catch - //404s in IE9+. However, onreadystatechange will fire before - //the error handler, so that does not help. If addEvenListener - //is used, then IE will fire error before load, but we cannot - //use that pathway given the connect.microsoft.com issue - //mentioned above about not doing the 'script execute, - //then fire the script load event listener before execute - //next script' that other browsers do. - //Best hope: IE10 fixes the issues, - //and then destroys all installs of IE 6-9. - //node.attachEvent('onerror', context.onScriptError); - } else { - node.addEventListener('load', context.onScriptLoad, false); - node.addEventListener('error', context.onScriptError, false); - } - node.src = url; - - //For some cache cases in IE 6-8, the script executes before the end - //of the appendChild execution, so to tie an anonymous define - //call to the module name (which is stored on the node), hold on - //to a reference to this node, but clear after the DOM insertion. - currentlyAddingScript = node; - if (baseElement) { - head.insertBefore(node, baseElement); - } else { - head.appendChild(node); - } - currentlyAddingScript = null; - - return node; - } else if (isWebWorker) { - //In a web worker, use importScripts. This is not a very - //efficient use of importScripts, importScripts will block until - //its script is downloaded and evaluated. However, if web workers - //are in play, the expectation that a build has been done so that - //only one script needs to be loaded anyway. This may need to be - //reevaluated if other use cases become common. - importScripts(url); - - //Account for anonymous modules - context.completeLoad(moduleName); - } - }; - - function getInteractiveScript() { - if (interactiveScript && interactiveScript.readyState === 'interactive') { - return interactiveScript; - } - - eachReverse(scripts(), function (script) { - if (script.readyState === 'interactive') { - return (interactiveScript = script); - } - }); - return interactiveScript; - } - - //Look for a data-main script attribute, which could also adjust the baseUrl. - if (isBrowser) { - //Figure out baseUrl. Get it from the script tag with require.js in it. - eachReverse(scripts(), function (script) { - //Set the 'head' where we can append children by - //using the script's parent. - if (!head) { - head = script.parentNode; - } - - //Look for a data-main attribute to set main script for the page - //to load. If it is there, the path to data main becomes the - //baseUrl, if it is not already set. - dataMain = script.getAttribute('data-main'); - if (dataMain) { - if (!cfg.baseUrl) { - //Pull off the directory of data-main for use as the - //baseUrl. - src = dataMain.split('/'); - mainScript = src.pop(); - subPath = src.length ? src.join('/') + '/' : './'; - - //Set final config. - cfg.baseUrl = subPath; - //Strip off any trailing .js since dataMain is now - //like a module name. - dataMain = mainScript.replace(jsSuffixRegExp, ''); - } - - //Put the data-main script in the files to load. - cfg.deps = cfg.deps ? cfg.deps.concat(dataMain) : [dataMain]; - - return true; - } - }); - } - - /** - * The function that handles definitions of modules. Differs from - * require() in that a string for the module should be the first argument, - * and the function to execute after dependencies are loaded should - * return a value to define the module corresponding to the first argument's - * name. - */ - define = function (name, deps, callback) { - var node, context; - - //Allow for anonymous functions - if (typeof name !== 'string') { - //Adjust args appropriately - callback = deps; - deps = name; - name = null; - } - - //This module may not have dependencies - if (!isArray(deps)) { - callback = deps; - deps = []; - } - - //If no name, and callback is a function, then figure out if it a - //CommonJS thing with dependencies. - if (!deps.length && isFunction(callback)) { - //Remove comments from the callback string, - //look for require calls, and pull them into the dependencies, - //but only if there are function args. - if (callback.length) { - callback - .toString() - .replace(commentRegExp, '') - .replace(cjsRequireRegExp, function (match, dep) { - deps.push(dep); - }); - - //May be a CommonJS thing even without require calls, but still - //could use exports, and module. Avoid doing exports and module - //work though if it just needs require. - //REQUIRES the function to expect the CommonJS variables in the - //order listed below. - deps = (callback.length === 1 ? ['require'] : ['require', 'exports', 'module']).concat(deps); - } - } - - //If in IE 6-8 and hit an anonymous define() call, do the interactive - //work. - if (useInteractive) { - node = currentlyAddingScript || getInteractiveScript(); - if (node) { - if (!name) { - name = node.getAttribute('data-requiremodule'); - } - context = contexts[node.getAttribute('data-requirecontext')]; - } - } - - //Always save off evaluating the def call until the script onload handler. - //This allows multiple modules to be in a file without prematurely - //tracing dependencies, and allows for anonymous module support, - //where the module name is not known until the script onload event - //occurs. If no context, use the global queue, and get it processed - //in the onscript load callback. - (context ? context.defQueue : globalDefQueue).push([name, deps, callback]); - }; - - define.amd = { - jQuery: true - }; - - - /** - * Executes the text. Normally just uses eval, but can be modified - * to use a better, environment-specific call. Only used for transpiling - * loader plugins, not for plain JS modules. - * @param {String} text the text to execute/evaluate. - */ - req.exec = function (text) { - /*jslint evil: true */ - return eval(text); - }; - - //Set up with config info. - req(cfg); -}(this)); diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/sundown.js b/lib/gollum/frontend/public/gollum/livepreview/js/sundown.js new file mode 100644 index 00000000..d084a6ea --- /dev/null +++ b/lib/gollum/frontend/public/gollum/livepreview/js/sundown.js @@ -0,0 +1 @@ +function c(b){throw b}var ba=void 0,m=!0,n=null,p=!1;try{this.Module=Module}catch(da){this.Module=Module={}}var ea="object"===typeof process,ga="object"===typeof window,ia="function"===typeof importScripts,ja=!ga&&!ea&&!ia;if(ea){Module.print=(function(b){process.stdout.write(b+"\n")});Module.printErr=(function(b){process.stderr.write(b+"\n")});var ma=require("fs"),na=require("path");Module.read=(function(b){var b=na.normalize(b),d=ma.readFileSync(b).toString();!d&&b!=na.resolve(b)&&(b=path.join(__dirname,"..","src",b),d=ma.readFileSync(b).toString());return d});Module.load=(function(b){oa(read(b))});Module.arguments||(Module.arguments=process.argv.slice(2))}else{ja?(Module.print=print,"undefined"!=typeof printErr&&(Module.printErr=printErr),Module.read="undefined"!=typeof read?read:(function(b){snarf(b)}),Module.arguments||("undefined"!=typeof scriptArgs?Module.arguments=scriptArgs:"undefined"!=typeof arguments&&(Module.arguments=arguments))):ga?(Module.print||(Module.print=(function(b){console.log(b)})),Module.printErr||(Module.printErr=(function(b){console.log(b)})),Module.read=(function(b){var d=new XMLHttpRequest;d.open("GET",b,p);d.send(n);return d.responseText}),Module.arguments||"undefined"!=typeof arguments&&(Module.arguments=arguments)):ia?Module.load=importScripts:c("Unknown runtime environment. Where are we?")}function oa(b){eval.call(n,b)}"undefined"==!Module.load&&Module.read&&(Module.load=(function(b){oa(Module.read(b))}));Module.print||(Module.print=(function(){}));Module.printErr||(Module.printErr=Module.print);Module.arguments||(Module.arguments=[]);Module.print=Module.print;Module.tc=Module.printErr;Module.preRun||(Module.preRun=[]);Module.postRun||(Module.postRun=[]);function ra(b){if(1==sa){return 1}var d={"%i1":1,"%i8":1,"%i16":2,"%i32":4,"%i64":8,"%float":4,"%double":8}["%"+b];d||("*"==b[b.length-1]?d=sa:"i"==b[0]&&(b=parseInt(b.substr(1)),wa(0==b%8),d=b/8));return d}function xa(){var b=[],d=0;this.R=(function(a){a&=255;d&&(b.push(a),d--);if(0==b.length){if(128>a){return String.fromCharCode(a)}b.push(a);d=191a?1:2;return""}if(0a?String.fromCharCode((a&31)<<6|e&63):String.fromCharCode((a&15)<<12|(e&63)<<6|f&63);b.length=0;return a});this.kc=(function(a){for(var a=unescape(encodeURIComponent(a)),b=[],d=0;d>2<<2;return d}function Da(b){var d=Ea;Ea+=b;Ea=Ea+3>>2<<2;if(Ea>=Fa){for(;Fa<=Ea;){Fa=2*Fa+4095>>12<<12}var b=u,a=new ArrayBuffer(Fa);u=new Int8Array(a);Ga=new Int16Array(a);v=new Int32Array(a);z=new Uint8Array(a);Pa=new Uint16Array(a);B=new Uint32Array(a);Ra=new Float32Array(a);Sa=new Float64Array(a);u.set(b)}return d}var sa=4,Za={},$a;function ab(b){Module.print(b+":\n"+Error().stack);c("Assertion: "+b)}function wa(b,d){b||ab("Assertion failed: "+d)}var bb=this;function cb(b,d,a,e){function f(a,b){if("string"==b){if(a===n||a===ba||0===a){return 0}g||(g=s);var d=Ca(a.length+1);db(a,d);return d}return"array"==b?(g||(g=s),d=Ca(a.length),fb(a,d),d):a}var g=0;try{var h=eval("_"+b)}catch(i){try{h=bb.Module["_"+b]}catch(j){}}wa(h,"Cannot call unknown function "+b+" (perhaps LLVM optimizations or closure removed it?)");var k=0,b=e?e.map((function(b){return f(b,a[k++])})):[],d=(function(a,b){if("string"==b){return gb(a)}wa("array"!=b);return a})(h.apply(n,b),d);g&&(s=g);return d}Module.ccall=cb;Module.cwrap=(function(b,d,a){return(function(){return cb(b,d,a,Array.prototype.slice.call(arguments))})});function nb(b,d,a){a=a||"i8";"*"===a[a.length-1]&&(a="i32");switch(a){case"i1":u[b]=d;break;case"i8":u[b]=d;break;case"i16":Ga[b>>1]=d;break;case"i32":v[b>>2]=d;break;case"i64":v[b>>2]=d;break;case"float":Ra[b>>2]=d;break;case"double":ob[0]=d;v[b>>2]=pb[0];v[b+4>>2]=pb[1];break;default:ab("invalid type for setValue: "+a)}}Module.setValue=nb;Module.getValue=(function(b,d){d=d||"i8";"*"===d[d.length-1]&&(d="i32");switch(d){case"i1":return u[b];case"i8":return u[b];case"i16":return Ga[b>>1];case"i32":return v[b>>2];case"i64":return v[b>>2];case"float":return Ra[b>>2];case"double":return pb[0]=v[b>>2],pb[1]=v[b+4>>2],ob[0];default:ab("invalid type for setValue: "+d)}return n});var C=2;Module.ALLOC_NORMAL=0;Module.ALLOC_STACK=1;Module.ALLOC_STATIC=C;function F(b,d,a){var e,f;"number"===typeof b?(e=m,f=b):(e=p,f=b.length);var g="string"===typeof d?d:n,a=[qb,Ca,Da][a===ba?C:a](Math.max(f,g?1:d.length));if(e){return rb(a,f),a}e=0;for(var h;e>2);Ra.subarray(Ob>>2);var ob=Sa.subarray(Ob>>3);Ib=Ob+8;Ea=Ib+4095>>12<<12;function Pb(b){for(;0=d?2*Math.abs(1<=b){return b}var a=32>=d?Math.abs(1<=a&&(32>=d||b>a)){b=-2*a+b}return b}var xc=0;function yc(){xc++;Module.monitorRunDependencies&&Module.monitorRunDependencies(xc)}Module.addRunDependency=yc;Module.removeRunDependency=(function(){xc--;Module.monitorRunDependencies&&Module.monitorRunDependencies(xc);0==xc&&zc()});Module._str_to_html=(function(b){var d=s;s+=124;var a=d+104,e=Ac(2048),f;f=a>>2;v[f]=0;v[f+1]=0;v[f+2]=0;v[f+3]=0;v[f+4]=0;v[a+12>>2]=0;f=Bc>>2;for(var g=d>>2,h=f+26;f>2]|0);a:do{if(!g){for(var h=b|0,i=0;;){if(Lc(v[v[h>>2]+(i<<2)>>2]),i=i+1|0,i>>>0>=B[f>>2]>>>0){break a}}}}while(0);f=a+396|0;g=a+404|0;h=0==(v[g>>2]|0);a:do{if(!h){for(var i=f|0,j=0;;){if(Lc(v[v[i>>2]+(j<<2)>>2]),j=j+1|0,j>>>0>=B[g>>2]>>>0){break a}}}}while(0);Mc(b);Mc(f);Nc(a);a=qb(v[e+4>>2]+1|0);h=0==(e|0)?4:0==(v[e+12>>2]|0)?4:5;4==h&&Oc(K.c|0,99,K.Z|0,K.b|0);b=e+4|0;f=B[b>>2];g=B[e+8>>2];if(f>>>0>>0){if(h=B[e>>2],0==u[h+f|0]<<24>>24){var k=h,h=11}else{h=7}}else{h=7}do{if(7==h){k=f+1|0;if(k>>>0>g>>>0){if(0!=(Pc(e,k)|0)){k=0;break}k=v[b>>2]}else{k=f}i=e|0;u[v[i>>2]+k|0]=0;k=v[i>>2]}}while(0);b=0;do{u[a+b]=u[k+b],b++}while(0!=u[k+(b-1)]);Lc(e);s=d;return a});function Cc(b,d,a,e){var f;0==(d|0)|0==(a|0)&&Oc(K.l|0,2400,K.ea|0,K.Ta|0);var g=qb(432);f=g>>2;if(0==(g|0)){b=0}else{for(var a=a>>2,h=f,i=a+26;a>2,i=s;s+=4;var j;g=i>>2;var k=Ac(64),l=0==(k|0);do{if(!l){Pc(k,a);var o=e+108|0;f=o>>2;v[f]=0;v[f+1]=0;v[f+2]=0;v[f+3]=0;v[f+4]=0;v[f+5]=0;v[f+6]=0;v[f+7]=0;f=2>>0?0==(Rc(d,K.fc|0,3)|0)?3:0:0;var t=f>>>0>>0;a:do{if(t){for(var q=o|0,r=f;;){var w=0==(Sc(d,r,a,i,q)|0);b:do{if(w){for(j=r;j>>>0>>0;){var x=u[d+j|0];if(13==x<<24>>24||10==x<<24>>24){break}j=j+1|0}v[g]=j;if(j>>>0>r>>>0){var x=k,D=d+r|0;j=j-r|0;for(var y=0,A=0;A>>>0>>0;){for(var E=A;;){if(E>>>0>=j>>>0){var G=0;break}if(9==u[D+E|0]<<24>>24){G=1;break}y=y+1|0;E=E+1|0}E>>>0>A>>>0&&L(x,D+A|0,E-A|0);if(!G){break}for(A=y;;){O(x,32);var N=A+1|0;if(0==(N&3|0)){break}A=N}y=N;A=E+1|0}x=v[g]}else{x=j}for(;;){if(x>>>0>=a>>>0){var I=x;break b}D=u[d+x|0];do{if(10==D<<24>>24){j=19}else{if(13==D<<24>>24){if(j=x+1|0,j>>>0>>0){10==u[d+j|0]<<24>>24?(M=x,j=20):j=19}else{var M=x;j=20}}else{I=x;break b}}}while(0);19==j&&(O(k,10),M=v[g]);x=M+1|0;v[g]=x}}else{I=v[g]}}while(0);if(I>>>0>=a>>>0){break a}r=I}}}while(0);f=(k+4|0)>>2;t=B[f];Pc(b,(t>>>1)+t|0);t=B[h+24];if(0!=(t|0)){H[t](b,v[h+26])}t=B[f];0!=(t|0)&&(q=k|0,r=v[q>>2],w=u[r+(t-1)|0],10==w<<24>>24||13==w<<24>>24?(q=r,f=t):(O(k,10),q=v[q>>2],f=v[f]),Tc(b,e,q,f));f=v[h+25];if(0!=(f|0)){H[f](b,v[h+26])}Lc(k);o|=0;f=ba;for(t=0;;){q=v[o+(t<<2)>>2];r=0==(q|0);a:do{if(!r){w=q;for(f=w>>2;;){x=v[f+3];Lc(v[f+1]);Lc(v[f+2]);Nc(w);if(0==(x|0)){break a}w=x;f=w>>2}}}while(0);f=t+1|0;if(8==(f|0)){break}t=f}0!=(v[h+103]|0)&&Oc(K.l|0,2522,K.r|0,K.Wa|0);0!=(v[h+100]|0)&&Oc(K.l|0,2523,K.r|0,K.Ya|0)}}while(0);s=i}Dc.X=1;function Sc(b,d,a,e,f){var g,h=d+3|0,i=h>>>0>>0;a:do{if(i){var j=32==u[b+d|0]<<24>>24;do{if(j){if(32!=u[d+(b+1)|0]<<24>>24){var k=1}else{if(32!=u[d+(b+2)|0]<<24>>24){k=2}else{if(32==u[b+h|0]<<24>>24){j=0;break a}k=3}}}else{k=0}}while(0);j=k+d|0;if(91!=u[b+j|0]<<24>>24){j=0}else{for(var l=k=j+1|0;;){if(l>>>0>=a>>>0){j=0;break a}j=u[b+l|0];if(93==j<<24>>24){break}else{if(10==j<<24>>24||13==j<<24>>24){j=0;break a}}l=l+1|0}j=l+1|0;if(j>>>0>>0){if(58!=u[b+j|0]<<24>>24){j=0}else{for(j=l+2|0;;){if(j>>>0>=a>>>0){var o=j;g=21;break}var t=z[b+j|0];if(32!=t<<24>>24){10==t<<24>>24||13==t<<24>>24?g=18:(o=j,g=21);break}j=j+1|0}18==g&&(o=j+1|0,o=o>>>0>>0?13!=u[b+o|0]<<24>>24?o:10==t<<24>>24?j+2|0:o:o);for(;;){if(o>>>0>=a>>>0){j=0;break a}var q=z[b+o|0];if(32!=q<<24>>24){break}o=o+1|0}for(var r=j=(60==q<<24>>24&1)+o|0;r>>>0>>0;){var w=u[b+r|0];if(32==w<<24>>24||10==w<<24>>24||13==w<<24>>24){break}r=r+1|0}w=r-1|0;for(w=62==u[b+w|0]<<24>>24?w:r;;){if(r>>>0>=a>>>0){var x=r;break}var D=u[b+r|0];if(32==D<<24>>24){r=r+1|0}else{if(13==D<<24>>24||10==D<<24>>24){x=r;break}else{if(34==D<<24>>24||39==D<<24>>24||40==D<<24>>24){x=0;break}else{j=0;break a}}}}var D=r+1|0,D=D>>>0>>0?10!=u[b+r|0]<<24>>24?x:13==u[b+D|0]<<24>>24?D:x:x,y=0==(D|0);b:do{if(y){var A=r}else{for(var E=D;;){E=E+1|0;if(E>>>0>=a>>>0){A=E;break b}if(32!=u[b+E|0]<<24>>24){A=E;break b}}}}while(0);var E=A+1|0,G=E>>>0>>0;b:do{if(G){if(r=u[b+A|0],39==r<<24>>24||34==r<<24>>24||40==r<<24>>24){for(r=E;;){if(r>>>0>=a>>>0){var N=r+1|0;break}g=u[b+r|0];y=r+1|0;if(13==g<<24>>24||10==g<<24>>24){N=y;break}r=y}if(N>>>0>>0){if(10!=u[b+r|0]<<24>>24){g=46}else{if(13==u[b+N|0]<<24>>24){var I=N;g=47}else{g=46}}}else{g=46}for(46==g&&(I=r);;){var M=r-1|0;if(M>>>0<=E>>>0){J=D;y=I;r=E;break b}r=u[b+M|0];if(32==r<<24>>24){r=M}else{if(39==r<<24>>24||34==r<<24>>24||41==r<<24>>24){break}else{J=D;y=I;r=E;break b}}}J=I;y=M;r=E}else{var J=D,r=y=0}}else{J=D,r=y=0}}while(0);0==(J|0)|(w|0)==(j|0)?j=0:(0!=(e|0)&&(v[e>>2]=J),0==(f|0))?j=1:(D=f,E=b+k|0,l=l-k|0,k=Uc(1,16),0==(k|0)?k=0:(l=Vc(E,l),v[k>>2]=l,l=((l&7)<<2)+D|0,v[k+12>>2]=v[l>>2],v[l>>2]=k),0==(k|0))?j=0:(l=w-j|0,w=Ac(l),v[k+4>>2]=w,L(w,b+j|0,l),y>>>0>r>>>0&&(j=y-r|0,l=Ac(j),v[k+8>>2]=l,L(l,b+r|0,j)),j=1)}}else{j=0}}}else{j=0}}while(0);return j}Sc.X=1;function Wc(b,d,a){var e=35==u[d]<<24>>24;a:do{if(e){var f=0==(v[b+420>>2]&64|0);b:do{if(!f){for(var g=0;;){var h=g>>>0>>0;if(!(h&6>g>>>0)){if(!h){break b}var i=u[d+g|0];break}h=z[d+g|0];if(35!=h<<24>>24){i=h;break}g=g+1|0}if(32!=i<<24>>24){f=0;break a}}}while(0);f=1}else{f=0}}while(0);return f}function Xc(b,d){var a=0;a:for(;;){var e=a>>>0>>0;do{if(e){var f=u[b+a|0];if(10!=f<<24>>24){if(32!=f<<24>>24){var g=0;break a}a=a+1|0;continue a}}}while(0);g=a+1|0;break}return g}function Yc(b,d){var a=3>d>>>0;a:do{if(a){var e=0}else{var f=32==u[b]<<24>>24?32!=u[b+1|0]<<24>>24?1:32==u[b+2|0]<<24>>24?3:2:0;if((f+2|0)>>>0>>0){if(e=z[b+f|0],42==e<<24>>24||45==e<<24>>24||95==e<<24>>24){for(var g=0;f>>>0>>0;){var h=z[b+f|0];if(10==h<<24>>24){break}if(h<<24>>24==e<<24>>24){g=g+1|0}else{if(32!=h<<24>>24){e=0;break a}}f=f+1|0}e=2>>0&1}else{e=0}}else{e=0}}}while(0);return e}function Tc(b,d,a,e){var f=(v[d+400>>2]+v[d+412>>2]|0)>>>0>B[d+424>>2]>>>0|0==(e|0);a:do{if(!f){for(var g=d+8|0,h=d+420|0,i=d+16|0,j=d+104|0,k=0;;){var l=a+k|0,o=e-k|0,t=0==(Wc(d,l,o)|0);b:do{if(t){var q=60==u[l]<<24>>24;do{if(q&&0!=(v[g>>2]|0)){var r=Zc(b,d,l,o,1);if(0!=(r|0)){q=r+k|0;break b}}}while(0);q=Xc(l,o);if(0==(q|0)){if(0==(Yc(l,o)|0)){q=B[h>>2];if(0!=(q&4|0)){q=$c(b,d,l,o);if(0!=(q|0)){q=q+k|0;break}q=v[h>>2]}q=0==(q&2|0);do{if(!q&&(r=ad(b,d,l,o),0!=(r|0))){q=r+k|0;break b}}while(0);q=0==(bd(l,o)|0)?0==(cd(l,o)|0)?0==(dd(l,o)|0)?0==(ed(l,o)|0)?fd(b,d,l,o)+k|0:gd(b,d,l,o,1)+k|0:gd(b,d,l,o,0)+k|0:hd(b,d,l,o)+k|0:id(b,d,l,o)+k|0}else{q=v[i>>2];if(0!=(q|0)){H[q](b,v[j>>2])}for(q=k;q>>>0>>0;){r=q+1|0;if(10==u[a+q|0]<<24>>24){q=r;break b}q=r}q=q+1|0}}else{q=q+k|0}}else{q=jd(b,d,l,o)+k|0}}while(0);if(q>>>0>=e>>>0){break a}k=q}}}while(0)}Tc.X=1;function jd(b,d,a,e){for(var f=0;;){if(!(f>>>0>>0&6>f>>>0)){var g=f;break}if(35!=u[a+f|0]<<24>>24){g=f;break}f=f+1|0}for(;;){if(g>>>0>=e>>>0){var h=g;break}if(32!=u[a+g|0]<<24>>24){h=g;break}g=g+1|0}for(;;){if(h>>>0>=e>>>0){var i=h;break}if(10==u[a+h|0]<<24>>24){i=h;break}h=h+1|0}for(;;){if(0==(i|0)){var j=0;break}e=i-1|0;if(35!=u[a+e|0]<<24>>24){j=i;break}i=e}for(;0!=(j|0);){i=j-1|0;if(32!=u[a+i|0]<<24>>24){break}j=i}if(j>>>0>g>>>0){i=P(d,1);kd(i,d,a+g|0,j-g|0);a=v[d+12>>2];if(0!=(a|0)){H[a](b,i,f,v[d+104>>2])}R(d,1)}return h}jd.X=1;function Zc(b,d,a,e,f){var g,h,d=d>>2,i=s;s+=16;h=i>>2;v[h]=a;g=(i+4|0)>>2;v[g]=0;v[h+2]=0;v[h+3]=0;h=2>e>>>0;a:do{if(h){var j=0}else{if(60!=u[a]<<24>>24){j=0}else{for(var k=1;k>>>0>>0;){j=u[a+k|0];if(62==j<<24>>24||32==j<<24>>24){var j=a+1|0,k=k-1|0,l=ba;if(11>k>>>0&0!=(k|0)){if(l=(z[K.H+(z[j]&255)|0]&255)+(1==(k|0)?1:(z[K.H+(z[j+1|0]&255)+1|0]&255)+k|0)|0,38>l>>>0){if(l=B[U+(l<<2)>>2],0!=((u[l]^u[j])&-33)<<24>>24){l=7}else{if(0!=(nd(j,l,k)|0)){l=7}else{if(0==u[l+k|0]<<24>>24){var o=l,l=8}else{l=7}}}}else{l=7}}else{l=7}7==l&&(o=0);j=o;if(0==(j|0)){break}o=od(j,a,e,1);if(0==(o|0)){if(0==(pd(j,K.z|0)|0)){j=0;break a}if(0==(pd(j,K.F|0)|0)){j=0;break a}a=od(j,a,e,0);if(0==(a|0)){j=0;break a}}else{a=o}v[g]=a;if(0==(f|0)){j=a;break a}f=v[d+2];if(0==(f|0)){j=a;break a}H[f](b,i,v[d+26]);j=a;break a}k=k+1|0}j=5>>0;do{if(j&&33==u[a+1|0]<<24>>24&&45==u[a+2|0]<<24>>24&&45==u[a+3|0]<<24>>24){k=5;b:for(;;){if(k>>>0>=e>>>0){var t=k+1|0;break}l=45==u[a+(k-2)|0]<<24>>24;do{if(l&&45==u[a+(k-1)|0]<<24>>24){l=k+1|0;if(62==u[a+k|0]<<24>>24){t=l;break b}k=l;continue b}}while(0);k=k+1|0}if(t>>>0>>0&&(k=Xc(a+t|0,e-t|0),0!=(k|0))){a=k+t|0;v[g]=a;if(0==(f|0)){j=a;break a}f=v[d+2];if(0==(f|0)){j=a;break a}H[f](b,i,v[d+26]);j=v[g];break a}}}while(0);if(4>>0){if(j=u[a+1|0],104==j<<24>>24||72==j<<24>>24){if(j=u[a+2|0],114==j<<24>>24||82==j<<24>>24){for(j=3;;){if(j>>>0>=e>>>0){var q=j+1|0;break}k=j+1|0;if(62==u[a+j|0]<<24>>24){q=k;break}j=k}q>>>0>>0?(j=Xc(a+q|0,e-q|0),0==(j|0)?j=0:(j=j+q|0,v[g]=j,0!=(f|0)&&(k=v[d+2],0!=(k|0)&&(H[k](b,i,v[d+26]),j=v[g])))):j=0}else{j=0}}else{j=0}}else{j=0}}}}while(0);s=i;return j}Zc.X=1;function $c(b,d,a,e){var f,g,h=s;s+=32;var i=h+16;g=h>>2;v[g]=0;v[g+1]=0;v[g+2]=0;v[g+3]=0;var j=qd(a,e,h);if(0==(j|0)){b=0}else{g=P(d,0);f=i>>2;var k=i+4|0,l=j;a:for(;;){if(l>>>0>=e>>>0){var o=l;break}v[f]=0;v[f+1]=0;v[f+2]=0;v[f+3]=0;var j=a+l|0,t=qd(j,e-l|0,i),q=0==(t|0);do{if(!q){if(0!=(v[k>>2]|0)){var r=l;break}o=t+l|0;break a}r=l}while(0);for(;;){var w=r+1|0;if(w>>>0>=e>>>0){break}if(10==u[a+r|0]<<24>>24){break}r=w}l>>>0>>0&&(l=w-l|0,0==(Xc(j,l)|0)?L(g,j,l):O(g,10));l=w}a=v[g+4>>2];0!=(a|0)&&10!=u[v[g>>2]+(a-1)|0]<<24>>24&&O(g,10);a=v[d>>2];if(0!=(a|0)){H[a](b,g,0!=(v[h+4>>2]|0)?h:0,v[d+104>>2])}R(d,0);b=o}s=h;return b}$c.X=1;function ad(b,d,a,e){var f,g=s;s+=8;var h=g+4;f=h>>2;v[f]=0;var i=P(d,1),j=P(d,0),h=rd(i,d,a,e,g,h),k=0==(h|0);do{if(k){var l=0,o=v[f]}else{for(var t=v[g>>2],o=v[f],l=h;l>>>0>>0;){for(var q=0,r=l;r>>>0>>0;){var w=z[a+r|0];if(10==w<<24>>24){break}q=(124==w<<24>>24&1)+q|0;r=r+1|0}if(0==(q|0)|(r|0)==(e|0)){break}sd(j,d,a+l|0,r-l|0,t,o,0);l=r+1|0}t=v[d+32>>2];if(0!=(t|0)){H[t](b,i,j,v[d+104>>2])}}}while(0);Nc(o);R(d,1);R(d,0);s=g;return l}ad.X=1;function bd(b,d){var a=0==(d|0)?0:32==u[b]<<24>>24&1,a=a>>>0>>0?(32==u[b+a|0]<<24>>24&1)+a|0:a,a=a>>>0>>0?(32==u[b+a|0]<<24>>24&1)+a|0:a;if(a>>>0>>0){if(62!=u[b+a|0]<<24>>24){a=0}else{var e=a+1|0;if(e>>>0>>0){return 32==u[b+e|0]<<24>>24?a+2|0:e}a=e}}else{a=0}return a}function cd(b,d){var a;if(3>>0){if(32!=u[b]<<24>>24){a=7}else{if(32!=u[b+1|0]<<24>>24){a=7}else{if(32!=u[b+2|0]<<24>>24){a=7}else{if(32==u[b+3|0]<<24>>24){var e=4;a=8}else{a=7}}}}}else{a=7}7==a&&(e=0);return e}function td(b,d){var a=u[b];a:do{if(61==a<<24>>24){for(var e=1;;){if(e>>>0>=d>>>0){var f=e;break}if(61!=u[b+e|0]<<24>>24){f=e;break}e=e+1|0}for(;;){if(f>>>0>=d>>>0){var g=1;break}e=z[b+f|0];if(32==e<<24>>24){f=f+1|0}else{g=10==e<<24>>24;break}}e=g&1}else{if(45==a<<24>>24){for(e=1;;){if(e>>>0>=d>>>0){var h=e;break}if(45!=u[b+e|0]<<24>>24){h=e;break}e=e+1|0}for(;;){if(h>>>0>=d>>>0){e=2;break a}var i=z[b+h|0];if(32!=i<<24>>24){break}h=h+1|0}e=10==i<<24>>24?2:0}else{e=0}}}while(0);return e}function id(b,d,a,e){var f=P(d,0),g=0,h=0,i=0;a:for(;;){for(;;){if(i>>>0>=e>>>0){var j=i;break a}for(var k=i;;){var l=k+1|0;if(l>>>0>=e>>>0){var o=0;break}if(10==u[a+k|0]<<24>>24){o=1;break}k=l}var t=a+i|0,q=l-i|0,r=bd(t,q),w=0==(r|0);do{if(w){if(0!=(Xc(t,q)|0)){if(!o){j=l;break a}var k=a+l|0,x=e-l|0;if(0==(bd(k,x)|0)&&0==(Xc(k,x)|0)){j=l;break a}}k=i}else{k=r+i|0}}while(0);if(k>>>0>>0){break}i=l}t=a+k|0;if(0==(g|0)){g=t}else{if(i=g+h|0,(t|0)!=(i|0)){if(q=l-k|0,t>2];if(0!=(a|0)){H[a](b,f,v[d+104>>2])}R(d,0);return j}id.X=1;function hd(b,d,a,e){for(var f=P(d,0),g=0;g>>>0>>0;){for(var h=g;;){var i=h+1|0;if(i>>>0>=e>>>0){break}if(10==u[a+h|0]<<24>>24){break}h=i}var h=a+g|0,j=i-g|0,k=cd(h,j);if(0==(k|0)){if(0==(Xc(h,j)|0)){break}h=g}else{h=k+g|0}h>>>0>>0&&(g=a+h|0,h=i-h|0,0==(Xc(g,h)|0)?L(f,g,h):O(f,10));g=i}a=f+4|0;e=f|0;for(i=v[a>>2];0!=(i|0);){i=i-1|0;if(10!=u[v[e>>2]+i|0]<<24>>24){break}v[a>>2]=i}O(f,10);a=v[d>>2];if(0!=(a|0)){H[a](b,f,0,v[d+104>>2])}R(d,0);return g}hd.X=1;function dd(b,d){var a=0==(d|0)?0:32==u[b]<<24>>24&1,a=a>>>0>>0?(32==u[b+a|0]<<24>>24&1)+a|0:a,a=a>>>0>>0?(32==u[b+a|0]<<24>>24&1)+a|0:a,e=a+1|0;if(e>>>0>>0){var f=b+a|0,g=u[f];if((42==g<<24>>24||43==g<<24>>24||45==g<<24>>24)&&32==u[b+e|0]<<24>>24){return 0==(vd(f,d-a|0)|0)?a+2|0:0}}return 0}function gd(b,d,a,e,f){var g,h=s;s+=4;g=h>>2;v[g]=f;for(var f=P(d,0),i=0;;){if(i>>>0>=e>>>0){var j=i;break}var k=wd(f,d,a+i|0,e-i|0,h),i=k+i|0;if(0==(k|0)){j=i;break}if(0!=(v[g]&8|0)){j=i;break}}a=v[d+20>>2];if(0!=(a|0)){H[a](b,f,v[g],v[d+104>>2])}R(d,0);s=h;return j}function ed(b,d){var a=0==(d|0)?0:32==u[b]<<24>>24&1,a=a>>>0>>0?(32==u[b+a|0]<<24>>24&1)+a|0:a,a=a>>>0>>0?(32==u[b+a|0]<<24>>24&1)+a|0:a,e=a>>>0>>0;do{if(e&&9>=(u[b+a|0]-48&255)){for(var f=a;;){if(f>>>0>=d>>>0){var g=f+1|0;break}var h=f+1|0;if(10<=(u[b+f|0]-48&255)){g=h;break}f=h}if(g>>>0>>0&&(h=b+f|0,46==u[h]<<24>>24&&32==u[b+g|0]<<24>>24)){return 0==(vd(h,d-f|0)|0)?f+2|0:0}}}while(0);return 0}ed.X=1;function fd(b,d,a,e){var f=d>>2,g=d+420|0,h=d+8|0,i=0;a:for(;;){if(i>>>0>=e>>>0){var j=0,k=i;break}for(var l=i;;){var o=l+1|0;if(o>>>0>=e>>>0){break}if(10==u[a+l|0]<<24>>24){break}l=o}var l=a+i|0,t=e-i|0;if(0!=(Xc(l,t)|0)){j=0;k=o;break}var q=td(l,t);if(0!=(q|0)){j=q;k=o;break}if(0!=(Wc(d,l,t)|0)){j=0;k=i;break}if(0!=(Yc(l,t)|0)){j=0;k=i;break}if(0!=(bd(l,t)|0)){j=0;k=i;break}if(0!=(v[g>>2]&256|0)&&0==(xd(z[l]&255)|0)){if(0!=(ed(l,t)|0)){j=0;k=i;break}if(0!=(dd(l,t)|0)){j=0;k=i;break}q=60==u[l]<<24>>24;do{if(q&&0!=(v[h>>2]|0)&&0!=(Zc(b,d,l,t,0)|0)){j=0;k=i;break a}}while(0);if(0!=(v[g>>2]&4|0)&&0!=(qd(l,t,0)|0)){j=0;k=i;break}}i=o}for(e=i;;){if(0==(e|0)){var r=0;break}g=e-1|0;if(10!=u[a+g|0]<<24>>24){r=1;break}e=g}if(0==(j|0)){j=P(d,0);kd(j,d,a,e);a=v[f+7];if(0!=(a|0)){H[a](b,j,v[f+26])}R(d,0)}else{a:do{if(r){for(g=e;;){h=g-1|0;if(0==(h|0)){var w=0;break}if(10==u[a+h|0]<<24>>24){w=h;break}g=h}for(;;){if(0==(w|0)){h=a;g=e;break a}h=w-1|0;if(10!=u[a+h|0]<<24>>24){break}w=h}h=P(d,0);kd(h,d,a,w);i=v[f+7];if(0!=(i|0)){H[i](b,h,v[f+26])}R(d,0);h=a+g|0;g=e-g|0}else{h=a,g=0}}while(0);a=P(d,1);kd(a,d,h,g);r=v[f+3];if(0!=(r|0)){H[r](b,a,j,v[f+26])}R(d,1)}return k}fd.X=1;function qd(b,d,a){var e,f;f=3>d>>>0;if(f){var g=0}else{var h=32==u[b]<<24>>24?32!=u[b+1|0]<<24>>24?1:32==u[b+2|0]<<24>>24?3:2:0;if((h+2|0)>>>0>>0){if(g=z[b+h|0],126==g<<24>>24||96==g<<24>>24){for(var i=0;h>>>0>>0&&u[b+h|0]<<24>>24==g<<24>>24;){i=i+1|0,h=h+1|0}g=3>i>>>0?0:h}else{g=0}}else{g=0}}f=g;g=0==(f|0);a:do{if(g){i=0}else{for(i=f;;){var j=b+i|0;if(i>>>0>=d>>>0){var k=0,l=i;e=17;break}var h=u[j],o=i+1|0;if(32==h<<24>>24){i=o}else{123==h<<24>>24?e=5:(k=0,l=i,e=17);break}}b:do{if(5==e){for(var t=b+o|0,q=0,r=i;;){var w=r+1|0;if(w>>>0>=d>>>0){break}h=u[b+w|0];if(125==h<<24>>24||10==h<<24>>24){break}q=q+1|0;r=w}if((w|0)==(d|0)){i=0;break a}if(125!=u[b+w|0]<<24>>24){i=0;break a}for(;;){if(0==(q|0)){var x=0;break}if(0==(V(z[t]&255)|0)){x=q;break}t=t+1|0;q=q-1|0}for(;0!=(x|0);){q=x-1|0;if(0==(V(z[t+q|0]&255)|0)){break}x=q}q=t;t=x;r=r+2|0}else{if(17==e){for(;;){if(l>>>0>=d>>>0){q=j;t=k;r=l;break b}if(0!=(V(z[b+l|0]&255)|0)){q=j;t=k;r=l;break b}k=k+1|0;l=l+1|0}}}}while(0);0==(a|0)?(i=r,e=22):(v[a>>2]=q,v[a+4>>2]=t,i=r);for(;i>>>0>>0;){h=z[b+i|0];if(10==h<<24>>24){break}if(0==(V(h&255)|0)){i=0;break a}i=i+1|0}i=i+1|0}}while(0);return i}qd.X=1;function P(b,d){var a,e=b+12*d+396|0;a=b+12*d+400|0;var f=B[a>>2];if(f>>>0>2)+(3*d|0)]>>>0){var g=(f<<2)+v[e>>2]|0;if(0==(v[g>>2]|0)){a=5}else{v[a>>2]=f+1|0;var h=v[g>>2];v[(h+4|0)>>2]=0;a=6}}else{a=5}5==a&&(h=Ac(v[yd+(d<<2)>>2]),a=(e+4|0)>>2,0>(zd(e,v[a]<<1)|0)||(f=v[a],v[a]=f+1|0,v[((f<<2)+v[e>>2]|0)>>2]=h));return h}function R(b,d){var a=b+12*d+400|0;v[a>>2]=v[a>>2]-1|0}function kd(b,d,a,e){var f,g=s;s+=16;f=g>>2;v[f]=0;v[f+1]=0;v[f+2]=0;v[f+3]=0;f=(v[d+400>>2]+v[d+412>>2]|0)>>>0>B[d+424>>2]>>>0;a:do{if(!f){for(var h=d+92|0,i=g|0,j=g+4|0,k=d+104|0,l=0,o=0,t=0;;){if(t>>>0>=e>>>0){break a}for(var q=o;;){if(q>>>0>=e>>>0){var r=l,w=0;break}o=z[d+(z[a+q|0]&255)+140|0];if(0!=o<<24>>24){r=o;w=1;break}l=0;q=q+1|0}o=B[h>>2];l=a+t|0;0==(o|0)?L(b,l,q-t|0):(v[i>>2]=l,v[j>>2]=q-t|0,H[o](b,g,v[k>>2]));if(!w){break a}t=H[v[Ad+((r&255)<<2)>>2]](b,d,a+q|0,q,e-q|0);0==(t|0)?(l=r,o=q+1|0):(q=t+q|0,l=r,o=q);t=q}}}while(0);s=g}kd.X=1;function Bd(b,d,a,e,f){e=z[a];if(2>>0){var g=a+1|0,h=z[g],i=h&255;if(h<<24>>24==e<<24>>24){3>>0?(g=a+2|0,h=z[g],h<<24>>24==e<<24>>24?4>>0?(a=a+3|0,g=z[a],g<<24>>24==e<<24>>24|126==e<<24>>24?b=0:0!=(V(g&255)|0)?b=0:(b=Cd(b,d,a,f-3|0,e),b=0==(b|0)?0:b+3|0)):b=0:0!=(V(h&255)|0)?b=0:(b=Dd(b,d,g,f-2|0,e),b=0==(b|0)?0:b+2|0)):b=0}else{if(126==e<<24>>24){b=0}else{if(0!=(V(i)|0)){b=0}else{return b=Ed(b,d,g,f-1|0,e),0==(b|0)?0:b+1|0}}}}else{b=0}return b}Bd.X=1;function Fd(b,d,a,e,f){var g,e=s;s+=16;var h;g=e>>2;for(var i=0;;){if(i>>>0>=f>>>0){var j=i,k=0,l=0;h=8;break}var o=z[a+i|0];if(96!=o<<24>>24){h=5;break}i=i+1|0}a:do{if(5==h){if(0==(i|0)){var t=i;h=9}else{for(var q=i,r=1,w=o;;){r=96==w<<24>>24?r:0;q=q+1|0;w=q>>>0>>0;if(!(w&r>>>0>>0)){j=q;k=r;l=w;h=8;break a}w=u[a+q|0];r=r+1|0}}}}while(0);if(8==h){if(k>>>0>=i>>>0|l){t=j,h=9}else{var x=0;h=18}}if(9==h){for(f=i;f>>>0>>0&&32==u[a+f|0]<<24>>24;){f=f+1|0}for(h=t-i|0;h>>>0>i>>>0;){j=h-1|0;if(32!=u[a+j|0]<<24>>24){break}h=j}if(f>>>0>>0){v[g]=a+f|0,v[g+1]=h-f|0,v[g+2]=0,v[g+3]=0,x=0==(H[v[d+48>>2]](b,e,v[d+104>>2])|0)?0:t}else{return b=0==(H[v[d+48>>2]](b,0,v[d+104>>2])|0)?0:t,s=e,b}}s=e;return x}Fd.X=1;function Gd(b,d,a,e,f){var g=d>>2;if(0==(e|0)){var h=e=d+412|0,i=v[e>>2],e=6}else{var e=d+412|0,j=B[e>>2];if(33!=u[a-1|0]<<24>>24){h=e,i=j,e=6}else{if(0==(v[g+15]|0)){var k=0,l=1,o=e,t=j,e=92}else{var q=1,r=e,w=j,e=7}}}6==e&&(0==(v[g+17]|0)?(k=0,l=1,o=h,t=i,e=92):(q=0,r=h,w=i,e=7));a:do{if(7==e){o=0;h=l=1;b:for(;;){if(h>>>0>=f>>>0){k=0;l=h;o=r;t=w;break a}k=z[a+h|0];t=10==k<<24>>24;do{if(t){i=1,j=l}else{var x=h-1|0;if(92==u[a+x|0]<<24>>24){i=o,j=l}else{if(91==k<<24>>24){i=o,j=l+1|0}else{if(93==k<<24>>24){j=l-1|0;if(1>(j|0)){break b}i=o}else{i=o,j=l}}}}}while(0);o=i;l=j;h=h+1|0}for(l=k=h+1|0;;){if(l>>>0>=f>>>0){e=69;break}var D=z[a+l|0],y=l+1|0;if(0==(V(D&255)|0)){e=18;break}l=y}do{if(18==e){if(40==D<<24>>24){for(var A=l;;){var E=A+1|0;if(E>>>0>=f>>>0){var G=E;break}if(0==(V(z[a+E|0]&255)|0)){G=E;break}A=E}b:for(;;){if(G>>>0>=f>>>0){k=0;l=G;o=r;t=w;break a}var N=z[a+G|0];if(92==N<<24>>24){G=G+2|0}else{if(41==N<<24>>24){var I=G,M=G,J=0,S=0,e=46;break}else{var Q=0==(G|0);do{if(!Q&&0!=(V(z[a+(G-1)|0]&255)|0)&&(39==N<<24>>24||34==N<<24>>24)){e=28;break b}}while(0);G=G+1|0}}}do{if(28==e){J=G+1|0;I=0;M=J;b:for(;;){c:do{if(I){for(var $=M;;){if($>>>0>=f>>>0){k=0;l=$;o=r;t=w;break a}S=z[a+$|0];if(92==S<<24>>24){$=$+2|0}else{if(S<<24>>24==N<<24>>24){var Ha=$;break c}if(41==S<<24>>24){var Qa=$;break b}$=$+1|0}}}else{for(S=M;;){if(S>>>0>=f>>>0){k=0;l=S;o=r;t=w;break a}Q=z[a+S|0];if(92==Q<<24>>24){S=S+2|0}else{if(Q<<24>>24==N<<24>>24){Ha=S;break c}S=S+1|0}}}}while(0);I=1;M=Ha+1|0}for(;;){var pa=Qa-1|0,ka=z[a+pa|0];if(pa>>>0<=J>>>0){break}if(0==(V(ka&255)|0)){break}Qa=pa}39==ka<<24>>24||34==ka<<24>>24?(I=$,M=G,S=pa):(M=I=$,S=J=0)}}while(0);for(e=M;;){var qa=e-1|0,Q=z[a+qa|0];if(e>>>0<=E>>>0){var eb=Q;break}if(0==(V(Q&255)|0)){eb=Q;break}e=qa}A=60==u[a+E|0]<<24>>24?A+2|0:E;e=62==eb<<24>>24?qa:e;e>>>0>A>>>0?(Q=P(d,1),L(Q,a+A|0,e-A|0),e=Q):e=0;if(S>>>0>J>>>0){A=P(d,1);L(A,a+J|0,S-J|0);var Y=A}else{Y=0}A=I+1|0;Q=e;e=80}else{if(91==D<<24>>24){for(e=y;;){if(e>>>0>=f>>>0){k=0;l=e;o=r;t=w;break a}var Ia=e+1|0;if(93==u[a+e|0]<<24>>24){break}e=Ia}if((y|0)==(e|0)){if(0==(o|0)){Q=a+1|0,A=x}else{A=P(d,1);Q=1>>0;b:do{if(Q){for(Y=1;;){if(t=z[a+Y|0],10==t<<24>>24?32!=u[a+(Y-1)|0]<<24>>24&&O(A,32):O(A,t&255),Y=Y+1|0,(Y|0)==(h|0)){break b}}}}while(0);Q=v[A>>2];A=v[A+4>>2]}}else{Q=a+y|0,A=e-y|0}Y=Hd(d+108|0,Q,A);if(0==(Y|0)){k=0;l=e;o=r;t=w;break a}A=Ia;Q=v[Y+4>>2];Y=v[Y+8>>2];e=80}else{e=69}}}}while(0);if(69==e){if(0==(o|0)){A=x,o=a+1|0}else{o=P(d,1);A=1>>0;b:do{if(A){for(Q=1;;){if(Y=z[a+Q|0],10==Y<<24>>24?32!=u[a+(Q-1)|0]<<24>>24&&O(o,32):O(o,Y&255),Q=Q+1|0,(Q|0)==(h|0)){break b}}}}while(0);A=v[o+4>>2];o=v[o>>2]}o=Hd(d+108|0,o,A);if(0==(o|0)){k=0;o=r;t=w;break}A=k;Q=v[o+4>>2];Y=v[o+8>>2]}1>>0?(h=P(d,1),q?L(h,a+1|0,x):(l=d+428|0,v[l>>2]=1,kd(h,d,a+1|0,x),v[l>>2]=0)):h=0;0==(Q|0)?l=0:(l=P(d,1),Id(l,Q));q?(k=b+4|0,o=v[k>>2],0!=(o|0)&&(o=o-1|0,33==u[v[b>>2]+o|0]<<24>>24&&(v[k>>2]=o)),k=H[v[g+15]](b,l,Y,h,v[g+26])):k=H[v[g+17]](b,l,Y,h,v[g+26]);l=A;o=r;t=w}}while(0);v[o>>2]=t;return 0!=(k|0)?l:0}Gd.X=1;function V(b){return(32==(b|0)|10==(b|0))&1}function Jd(b,d,a,e,f){var g,h=s;s+=4;g=(d+68|0)>>2;if(0==(v[g]|0)){b=0}else{if(0!=(v[d+428>>2]|0)){b=0}else{var i=P(d,1);if(0==(e|0)){e=5}else{if(e=a-1|0,0!=(Kd(z[e]&255)|0)){e=5}else{if(0==(Ld(z[e]&255)|0)|4>f>>>0){var j=0,e=12}else{e=6}}}5==e&&(4>f>>>0?(j=0,e=12):e=6);if(6==e){if(0!=(Rc(a,K.Nb|0,4)|0)){j=0}else{if(j=Md(a,f,0),0==(j|0)){j=0}else{for(;j>>>0>>0&&0==(Ld(z[a+j|0]&255)|0);){j=j+1|0}j=Nd(a,j);0==(j|0)?j=0:(L(i,a,j),v[h>>2]=0)}}}a=j;if(0!=(a|0)){f=P(d,1);L(f,K.u|0,7);L(f,v[i>>2],v[i+4>>2]);e=b+4|0;v[e>>2]=v[e>>2]-v[h>>2]|0;e=d+92|0;if(0==(v[e>>2]|0)){H[v[g]](b,f,0,i,v[d+104>>2])}else{var j=P(d,1),k=d+104|0;H[v[e>>2]](j,i,v[k>>2]);H[v[g]](b,f,0,j,v[k>>2]);R(d,1)}R(d,1)}R(d,1);b=a}}s=h;return b}Jd.X=1;function Od(b,d,a,e,f){var e=d+84|0,g=0==(v[e>>2]|0)|2>f>>>0;a:do{if(g){var h=0}else{h=40==u[a+1|0]<<24>>24;b:do{if(h){for(var i=2;i>>>0>>0&&41!=u[a+i|0]<<24>>24&&92!=u[a+(i-1)|0]<<24>>24;){i=i+1|0}if((i|0)==(f|0)){h=0;break a}var j=2}else{for(var k=1;;){if(k>>>0>=f>>>0){i=k;j=1;break b}if(0!=(V(z[a+k|0]&255)|0)){i=k;j=1;break b}k=k+1|0}}}while(0);(i|0)==(j|0)?h=2==(j|0)?3:0:(h=i-j|0,k=P(d,1),kd(k,d,a+j|0,h),H[v[e>>2]](b,k,v[d+104>>2]),R(d,1),h=(2==(j|0)&1)+i|0)}}while(0);return h}Od.X=1;function Pd(b,d,a){var a=a>>2,e=3>d>>>0;a:do{if(e){var f=0}else{if(60!=u[b]<<24>>24){f=0}else{var g=47==u[b+1|0]<<24>>24?2:1;if(0==(xd(z[b+g|0]&255)|0)){f=0}else{for(v[a]=0;g>>>0>>0;){var h=b+g|0;if(0==(xd(z[h]&255)|0)&&(h=u[h],!(46==h<<24>>24||43==h<<24>>24||45==h<<24>>24))){break}g=g+1|0}h=1>>0;do{if(h){var i=b+g|0,j=64==u[i]<<24>>24;do{if(j){var k,l=k=0;b:for(;;){if(l>>>0>=(d-g|0)>>>0){var o=0;break}var t=i+l|0,q=0==(xd(z[t]&255)|0);do{if(q){var r=z[t]&255;if(64==(r|0)){r=k+1|0}else{if(45==(r|0)||46==(r|0)||95==(r|0)){r=k}else{o=62==(r|0)?1==(k|0)?l+1|0:0:0;break b}}}else{r=k}}while(0);k=r;l=l+1|0}k=o;if(0!=(k|0)){v[a]=2;f=k+g|0;break a}}}while(0);2>>0?58!=u[i]<<24>>24?i=g:(v[a]=1,i=g+1|0):i=g}else{i=g}}while(0);g=i>>>0>>0;do{if(g){if(0==(v[a]|0)){h=i}else{for(h=i;;){if(h>>>0>=d>>>0){f=0;break a}var w=z[b+h|0];if(92==w<<24>>24){h=h+2|0}else{if(62==w<<24>>24||39==w<<24>>24||34==w<<24>>24||32==w<<24>>24||10==w<<24>>24){break}else{h=h+1|0}}}if(h>>>0>i>>>0&62==w<<24>>24){f=h+1|0;break a}v[a]=0}}else{v[a]=0,h=i}}while(0);for(;;){if(h>>>0>=d>>>0){f=0;break a}g=h+1|0;if(62==u[b+h|0]<<24>>24){f=g;break a}h=g}}}}}while(0);return f}Pd.X=1;function Id(b,d){var a,e=d+4|0;a=(d|0)>>2;for(var f=0;;){var g=B[e>>2];if(f>>>0>=g>>>0){break}for(var h=f;h>>>0>>0&&92!=u[v[a]+h|0]<<24>>24;){h=h+1|0}h>>>0>f>>>0?(L(b,v[a]+f|0,h-f|0),f=v[e>>2]):f=g;g=h+1|0;if(g>>>0>=f>>>0){break}O(b,z[v[a]+g|0]&255);f=h+2|0}}function Hd(b,d,a){d=Vc(d,a);for(b=((d&7)<<2)+b|0;;){b=v[b>>2];if(0==(b|0)){var e=0;break}if((v[b>>2]|0)==(d|0)){e=b;break}b=b+12|0}return e}function Vc(b,d){var a=0==(d|0);a:do{if(a){var e=0}else{for(var f=0,g=0;;){if(g=Qd(z[b+f|0]&255)-g+65600*g|0,f=f+1|0,(f|0)==(d|0)){e=g;break a}}}}while(0);return e}function Ed(b,d,a,e,f){var g=d+56|0,h=0==(v[g>>2]|0);a:do{if(h){var i=0}else{for(var i=d+420|0,j=1>>0?u[a]<<24>>24!=f<<24>>24?0:u[a+1|0]<<24>>24==f<<24>>24&1:0;;){if(j>>>0>=e>>>0){i=0;break a}var k=Rd(a+j|0,e-j|0,f);if(0==(k|0)){i=0;break a}k=k+j|0;if(k>>>0>=e>>>0){i=0;break a}if(u[a+k|0]<<24>>24==f<<24>>24&&0==(V(z[a+(k-1)|0]&255)|0)){var l=k+1|0;if(0==(v[i>>2]&1|0)|(l|0)==(e|0)){break}j=z[a+l|0]&255;if(0!=(V(j)|0)){break}if(0!=(Kd(j)|0)){break}}j=k}i=P(d,1);kd(i,d,a,k);i=H[v[g>>2]](b,i,v[d+104>>2]);R(d,1);i=0==(i|0)?0:l}}while(0);return i}Ed.X=1;function Dd(b,d,a,e,f){var g=B[(126==f<<24>>24?d+80|0:d+52|0)>>2],h=0==(g|0);a:do{if(h){var i=0}else{for(i=0;;){if(i>>>0>=e>>>0){i=0;break a}var j=Rd(a+i|0,e-i|0,f);if(0==(j|0)){i=0;break a}j=j+i|0;i=j+1|0;if(i>>>0>>0&&u[a+j|0]<<24>>24==f<<24>>24&&!(u[a+i|0]<<24>>24!=f<<24>>24|0==(j|0))&&0==(V(z[a+(j-1)|0]&255)|0)){break}}i=P(d,1);kd(i,d,a,j);i=H[g](b,i,v[d+104>>2]);R(d,1);i=0==(i|0)?0:j+2|0}}while(0);return i}function Cd(b,d,a,e,f){var g=0;a:for(;;){if(g>>>0>=e>>>0){var h=0;break}var i=Rd(a+g|0,e-g|0,f);if(0==(i|0)){h=0;break}g=i+g|0;if(u[a+g|0]<<24>>24==f<<24>>24&&0==(V(z[a+(g-1)|0]&255)|0)){var i=g+2|0,j=i>>>0>>0,k=g+1|0;do{if(j&&u[a+k|0]<<24>>24==f<<24>>24&&u[a+i|0]<<24>>24==f<<24>>24&&(h=d+76|0,0!=(v[h>>2]|0))){e=P(d,1);kd(e,d,a,g);b=H[v[h>>2]](b,e,v[d+104>>2]);R(d,1);h=0==(b|0)?0:g+3|0;break a}}while(0);if(k>>>0>>0&&u[a+k|0]<<24>>24==f<<24>>24){return d=Ed(b,d,a-2|0,e+2|0,f),0==(d|0)?0:d-2|0}d=Dd(b,d,a-1|0,e+1|0,f);h=0==(d|0)?0:d-1|0;break}}return h}Cd.X=1;function Rd(b,d,a){var e=1;a:for(;;){if(e>>>0>=d>>>0){var f=0;break}for(var g=e;g>>>0>>0;){e=z[b+g|0];if(e<<24>>24==a<<24>>24){break}if(96==e<<24>>24||91==e<<24>>24){break}g=g+1|0}if((g|0)==(d|0)){f=0;break}e=z[b+g|0];if(e<<24>>24==a<<24>>24){f=g;break}var h=0==(g|0);do{if(!h&&92==u[b+(g-1)|0]<<24>>24){e=g+1|0;continue a}}while(0);if(96==e<<24>>24){h=g;for(e=0;;){if(h>>>0>=d>>>0){f=0;break a}var i=z[b+h|0];if(96!=i<<24>>24){break}h=h+1|0;e=e+1|0}if(0==(e|0)){e=h}else{for(var g=1,j=0,k=i;;){var l=0==(j|0)?k<<24>>24==a<<24>>24?h:0:j,g=96==k<<24>>24?g:0,o=h+1|0,t=o>>>0>>0;if(!(t&g>>>0>>0)){break}k=u[b+o|0];g=g+1|0;h=o;j=l}if(!t){f=l;break}e=o}}else{if(91==e<<24>>24){for(e=0;;){h=g+1|0;if(h>>>0>=d>>>0){break}j=z[b+h|0];if(93==j<<24>>24){break}e=0==(e|0)&j<<24>>24==a<<24>>24?h:e;g=h}for(h=g+2|0;;){if(h>>>0>=d>>>0){f=e;break a}var q=z[b+h|0];if(!(32==q<<24>>24||10==q<<24>>24)){break}h=h+1|0}g=q&255;if(91==(g|0)){g=93}else{if(40==(g|0)){g=41}else{if(0==(e|0)){e=h;continue}f=e;break}}for(;;){j=h+1|0;if(j>>>0>=d>>>0){f=e;break a}k=z[b+j|0];if((k&255|0)==(g|0)){break}e=0==(e|0)&k<<24>>24==a<<24>>24?j:e;h=j}e=h+2|0}else{e=g}}}return f}Rd.X=1;function vd(b,d){for(var a=0;;){if(a>>>0>=d>>>0){var e=a+1|0;break}var f=a+1|0;if(10==u[b+a|0]<<24>>24){e=f;break}a=f}return e>>>0>>0?td(b+e|0,d-e|0):0}function wd(b,d,a,e,f){for(var g,h,f=f>>2,i,j=0;3>j>>>0&j>>>0>>0&&32==u[a+j|0]<<24>>24;){j=j+1|0}g=dd(a,e);if(0==(g|0)){if(g=ed(a,e),0==(g|0)){var k=0;i=51}else{h=g,i=7}}else{h=g,i=7}if(7==i){for(var l=h;l>>>0>>0&&10!=u[a+(l-1)|0]<<24>>24;){l=l+1|0}g=P(d,1);k=P(d,1);L(g,a+h|0,l-h|0);var o=d+420|0;h=(g+4|0)>>2;var t=0,q=0;i=l;l=0;a:for(;;){for(var r=0,w=i;;){if(w>>>0>=e>>>0){var x=q;break a}for(var D=w;;){var y=D+1|0;if(y>>>0>=e>>>0){break}if(10==u[a+D|0]<<24>>24){break}D=y}D=y-w|0;if(0==(Xc(a+w|0,D)|0)){var A=0;break}r=1;w=y}for(;4>A>>>0;){i=A+w|0;if(i>>>0>=y>>>0){break}if(32!=u[a+i|0]<<24>>24){break}A=A+1|0}t=0==(v[o>>2]&4|0)?t:0==(qd(a+A+w|0,D-A|0,0)|0)?t:0==(t|0)&1;if(0==(t|0)){var E=a+A+w|0,G=D-A|0;i=ed(E,G);E=dd(E,G)}else{E=i=0}r=0!=(r|0);do{if(r){var G=v[f],N=G&1;if(!(0==(N|0)|0==(E|0)&&0!=(N|0)|0==(i|0))){v[f]=G|8;x=q;break a}}}while(0);i=0==(E|0)?0==(i|0)?34:31:0!=(Yc(a+A+w|0,D-A|0)|0)&0==(i|0)?34:31;do{if(31==i){var I=r?1:q;if((A|0)==(j|0)){x=I;break a}var M=0!=(l|0)?l:v[h]}else{if(34==i){if(r&0==(A|0)){v[f]|=8;x=q;break a}r?(O(g,10),I=1):I=q;M=l}}}while(0);L(g,a+A+w|0,D-A|0);q=I;i=y;l=M}a=v[f];0==(x|0)?x=a:(x=a|2,v[f]=x);a=B[h];e=0!=(l|0)&l>>>0>>0;g=(g|0)>>2;y=v[g];0==(x&2|0)?e?(kd(k,d,y,l),Tc(k,d,v[g]+l|0,v[h]-l|0)):kd(k,d,y,a):e?(Tc(k,d,y,l),Tc(k,d,v[g]+l|0,v[h]-l|0)):Tc(k,d,y,a);h=v[d+24>>2];if(0!=(h|0)){H[h](b,k,v[f],v[d+104>>2])}R(d,1);R(d,1);k=w}return k}wd.X=1;function rd(b,d,a,e,f,g){for(var h,i=0,j=0;i>>>0>>0;){var k=z[a+i|0];if(10==k<<24>>24){break}j=(124==k<<24>>24&1)+j|0;i=i+1|0}k=(i|0)==(e|0)|0==(j|0);do{if(k){var l=0}else{for(l=i;;){if(0==(l|0)){var o=((124==u[a]<<24>>24)<<31>>31)+j|0,t=0;break}var q=l-1|0,r=z[a+q|0];if(0!=(V(r&255)|0)){l=q}else{o=((124==u[a]<<24>>24)<<31>>31)+((124==r<<24>>24)<<31>>31)+j|0;t=l;break}}l=o+1|0;v[f>>2]=l;l=Uc(l,4);v[g>>2]=l;l=i+1|0;for(l=q=l>>>0>>0?124==u[a+l|0]<<24>>24?i+2|0:l:l;;){if(l>>>0>=e>>>0){var w=0,x=q;break}if(10==u[a+l|0]<<24>>24){w=0;x=q;break}l=l+1|0}a:for(;w>>>0>2]>>>0&x>>>0>>0;){for(q=x;;){var D=u[a+q|0];if(q>>>0>=l>>>0){h=19;break}if(32==D<<24>>24){q=q+1|0}else{if(58==D<<24>>24){h=20}else{var y=0,A=q;h=21}break}}19==h&&(58==D<<24>>24?h=20:(y=0,A=q,h=21));20==h&&(y=(w<<2)+v[g>>2]|0,v[y>>2]|=1,y=1,A=q+1|0);for(;;){if(A>>>0>=l>>>0){var E=y,G=A;break}q=u[a+A|0];if(45==q<<24>>24){y=y+1|0,A=A+1|0}else{58==q<<24>>24?(E=(w<<2)+v[g>>2]|0,v[E>>2]|=2,E=y+1|0,G=A+1|0):(E=y,G=A);break}}for(r=G;;){if(r>>>0>=l>>>0){if(3>E>>>0){break a}var N=r+1|0;break}q=z[a+r|0];r=r+1|0;if(32!=q<<24>>24){if(124!=q<<24>>24|3>E>>>0){break a}N=r;break}}w=w+1|0;x=N}q=B[f>>2];w>>>0>>0?l=0:(sd(b,d,a,t,q,v[g>>2],4),l=l+1|0)}}while(0);return l}rd.X=1;function sd(b,d,a,e,f,g,h){var i,j,k=s;s+=16;j=(d+40|0)>>2;var l=0==(v[j]|0);do{if(!l){var o=d+36|0;if(0!=(v[o>>2]|0)){var t=P(d,1);i=0==(e|0)?0:124==u[a]<<24>>24&1;var q=0!=(f|0)&i>>>0>>0;a:do{if(q){for(var r=d+104|0,w=i,x=0;;){for(var D=P(d,1);;){if(w>>>0>=e>>>0){var y=w;break}if(0==(V(z[a+w|0]&255)|0)){y=w;break}w=w+1|0}for(;;){if(y>>>0>=e>>>0){var A=y;break}if(124==u[a+y|0]<<24>>24){A=y;break}y=y+1|0}for(;;){var E=A-1|0;if(E>>>0<=w>>>0){break}if(0==(V(z[a+E|0]&255)|0)){break}A=E}kd(D,d,a+w|0,A-w|0);H[v[j]](t,D,v[g+(x<<2)>>2]|h,v[r>>2]);R(d,1);D=y+1|0;x=x+1|0;if(!(x>>>0>>0&D>>>0>>0)){var G=x;break a}w=D}}else{G=0}}while(0);q=G>>>0>>0;a:do{if(q){i=k>>2;r=d+104|0;for(x=G;;){if(v[i]=0,v[i+1]=0,v[i+2]=0,v[i+3]=0,H[v[j]](t,k,v[g+(x<<2)>>2]|h,v[r>>2]),x=x+1|0,(x|0)==(f|0)){var N=r;break a}}}else{N=d+104|0}}while(0);H[v[o>>2]](b,t,v[N>>2]);R(d,1)}}}while(0);s=k}sd.X=1;function od(b,d,a,e){var f,g=uc(b),e=0==(e|0),h=g+3|0,i=a+1|0;a:do{if(e){for(var j=1;;){if(j>>>0>=a>>>0){var k=0;f=18;break a}for(;;){var l=j+1|0;if(l>>>0>=a>>>0){break}if(60==u[d+j|0]<<24>>24&&47==u[d+l|0]<<24>>24){break}j=l}if((h+j|0)>>>0>=a>>>0){k=0;f=18;break a}var o=Sd(b,g,d+j|0,i+(j^-1)|0);if(0!=(o|0)){var t=o,q=j;f=17;break a}j=l}}else{j=0;for(o=1;;){if(o>>>0>=a>>>0){k=0;f=18;break a}for(;;){var r=o+1|0;if(r>>>0>=a>>>0){break}var w=z[d+r|0];if(60==u[d+o|0]<<24>>24&47==w<<24>>24){break}j=(10==w<<24>>24&1)+j|0;o=r}if(!(0<(j|0)&&10!=u[d+(o-1)|0]<<24>>24)){if((h+o|0)>>>0>=a>>>0){k=0;f=18;break a}w=Sd(b,g,d+o|0,i+(o^-1)|0);if(0!=(w|0)){t=w;q=o;f=17;break a}}o=r}}}while(0);17==f&&(k=t+q|0);return k}od.X=1;function Sd(b,d,a,e){var f=d+3|0;f>>>0>>0?0!=(nd(a+2|0,b,d)|0)?a=0:62!=u[d+(a+2)|0]<<24>>24?a=0:(b=Xc(a+f|0,e-f|0),0==(b|0)?a=0:(f=b+f|0,a=(f>>>0>>0?Xc(a+f|0,e-f|0):0)+f|0)):a=0;return a}function zd(b,d){var a;a=(b+8|0)>>2;if(B[a]>>>0>>0){var e=b|0,f=Td(v[e>>2],d<<2);if(0==(f|0)){a=-1}else{var g=v[a];rb((g<<2)+f|0,d-g<<2);v[e>>2]=f;v[a]=d;a=b+4|0;B[a>>2]>>>0>d>>>0&&(v[a>>2]=d);a=0}}else{a=0}return a}function Mc(b){if(0!=(b|0)){var d=b|0;Nc(v[d>>2]);v[d>>2]=0;v[b+4>>2]=0;v[b+8>>2]=0}}function Qc(b,d){v[b>>2]=0;v[b+4>>2]=0;v[b+8>>2]=0;zd(b,0==(d|0)?8:d)}function Pc(b,d){4==(0==(b|0)?4:0==(v[b+12>>2]|0)?4:5)&&Oc(K.c|0,58,K.$|0,K.b|0);var a=16777216>>0;do{if(a){var e=-1}else{var e=b+8|0,f=B[e>>2];if(f>>>0>>0){var g=B[b+12>>2],f=g+f|0,h=f>>>0>>0;a:do{if(h){for(var i=f;;){if(i=g+i|0,i>>>0>=d>>>0){var j=i;break a}}}else{j=f}}while(0);g=b|0;f=Td(v[g>>2],j);0==(f|0)?e=-1:(v[g>>2]=f,v[e>>2]=j,e=0)}else{e=0}}}while(0);return e}function Ac(b){var d,a=qb(16);d=a>>2;0!=(a|0)&&(v[d]=0,v[d+2]=0,v[d+1]=0,v[d+3]=b);return a}function Ud(b,d){var a,e,f=s;s+=4;var g;g=0==(b|0)?4:0==(v[b+12>>2]|0)?4:5;4==g&&Oc(K.c|0,119,K.ba|0,K.b|0);e=(b+4|0)>>2;g=B[e];a=(b+8|0)>>2;g=g>>>0>>0?7:0>(Pc(b,g+1|0)|0)?13:7;do{if(7==g){var h=f;v[h>>2]=arguments[Ud.length];var i=b|0,j=v[e],k=Vd(v[i>>2]+j|0,v[a]-j|0,d,v[f>>2]);if(0<=(k|0)){j=B[e];if(k>>>0<(v[a]-j|0)>>>0){i=k,h=j}else{if(0>(Pc(b,j+(k+1)|0)|0)){break}v[h>>2]=arguments[Ud.length];h=v[e];i=Vd(v[i>>2]+h|0,v[a]-h|0,d,v[f>>2]);if(0>(i|0)){break}h=v[e]}v[e]=h+i|0}}}while(0);s=f}Ud.X=1;function L(b,d,a){var e,f;f=0==(b|0)?4:0==(v[b+12>>2]|0)?4:5;4==f&&Oc(K.c|0,157,K.ca|0,K.b|0);e=(b+4|0)>>2;f=B[e];var g=f+a|0;if(g>>>0>B[b+8>>2]>>>0){if(0>(Pc(b,g)|0)){f=9}else{var h=v[e];f=8}}else{h=f,f=8}8==f&&(ud(v[b>>2]+h|0,d,a),v[e]=v[e]+a|0)}function Wd(b,d){L(b,d,uc(d))}function O(b,d){var a,e;e=0==(b|0)?4:0==(v[b+12>>2]|0)?4:5;4==e&&Oc(K.c|0,178,K.da|0,K.b|0);a=(b+4|0)>>2;e=B[a];var f=e+1|0;if(f>>>0>B[b+8>>2]>>>0){if(0>(Pc(b,f)|0)){e=9}else{var g=v[a];e=8}}else{g=e,e=8}8==e&&(u[v[b>>2]+g|0]=d&255,v[a]=v[a]+1|0)}function Lc(b){0!=(b|0)&&(Nc(v[b>>2]),Nc(b))}function Xd(b,d){var a=0;a:for(;;){if(5<=a>>>0){var e=0;break}var f=B[Yd+(a<<2)>>2],g=uc(f),h=g>>>0>>0;do{if(h&&0==(nd(b,f,g)|0)&&0!=(xd(z[b+g|0]&255)|0)){e=1;break a}}while(0);a=a+1|0}return e}function Md(b,d,a){var e=0==(xd(z[b]&255)|0);do{if(e){var f=0}else{var f=d-1|0,g=0,h=1;a:for(;h>>>0>>0;){var i=b+h|0,j=z[i],k=46==j<<24>>24;do{if(k){var l=g+1|0}else{if(0==(xd(j&255)|0)&&45!=u[i]<<24>>24){break a}l=g}}while(0);g=l;h=h+1|0}f=0!=(a|0)?h:0!=(g|0)?h:0}}while(0);return f}function Nd(b,d){for(var a,e=0;;){if(e>>>0>=d>>>0){var f=d;break}if(60==u[b+e|0]<<24>>24){f=e;break}e=e+1|0}for(;;){if(0==(f|0)){var g=0;a=24;break}var h=f-1|0,i=z[b+h|0],j=i&255;if(0==(Zd(K.Yb|0,j,5)|0)){if(59!=i<<24>>24){a=14;break}for(e=f=f-2|0;0!=(e|0)&&0!=((97<=(z[b+e|0]&255)&&122>=(z[b+e|0]&255)||65<=(z[b+e|0]&255)&&90>=(z[b+e|0]&255))|0);){e=e-1|0}if(e>>>0>>0&&38==u[b+e|0]<<24>>24){f=e;continue}}f=h}do{if(14==a){if(34==(j|0)||39==(j|0)){a=j}else{if(41==(j|0)){a=40}else{if(93==(j|0)){a=91}else{if(125==(j|0)){a=123}else{g=f;break}}}}for(e=j=g=0;;){var k=z[b+e|0];if((k&255|0)==(a|0)){var l=j+1|0,k=g}else{l=j,k=(k<<24>>24==i<<24>>24&1)+g|0}e=e+1|0;if((e|0)==(f|0)){break}g=k;j=l}return(k|0)==(l|0)?f:h}}while(0);return g}Nd.X=1;function $d(b,d,a,e,f){for(var g=0;g>>>0>>0;){var h=z[a+(g^-1)|0]&255;if(0==(xd(h)|0)&&0==(Zd(K.Xb|0,h,5)|0)){break}g=g+1|0}e=0==(g|0);do{if(e){h=0}else{var h=f-1|0,i=0,j=0,k=0;a:for(;k>>>0>>0;){var l=z[a+k|0],o=0==(xd(l&255)|0);do{if(o){if(64==l<<24>>24){var t=i,q=j+1|0}else{if(46==l<<24>>24){if(k>>>0>=h>>>0){break a}t=i+1|0;q=j}else{if(45==l<<24>>24||95==l<<24>>24){t=i,q=j}else{break a}}}}else{t=i,q=j}}while(0);i=t;j=q;k=k+1|0}1!=(j|0)|2>k>>>0|0==(i|0)?h=0:(h=Nd(a,k),0==(h|0)?h=0:(L(d,a+ -g|0,h+g|0),v[b>>2]=g))}}while(0);return h}$d.X=1;function ae(b,d,a,e,f,g){var h=4>f>>>0;if(h){var i=0}else{if(47!=u[a+1|0]<<24>>24){i=0}else{if(47!=u[a+2|0]<<24>>24){i=0}else{for(i=0;i>>>0>>0&&0!=((97<=(z[a+(i^-1)|0]&255)&&122>=(z[a+(i^-1)|0]&255)||65<=(z[a+(i^-1)|0]&255)&&90>=(z[a+(i^-1)|0]&255))|0);){i=i+1|0}var j=a+ -i|0;if(0==(Xd(j,i+f|0)|0)){i=0}else{var k=Md(a+3|0,f-3|0,g&1);if(0==(k|0)){i=0}else{for(k=k+3|0;k>>>0>>0&&0==(Ld(z[a+k|0]&255)|0);){k=k+1|0}k=Nd(a,k);0==(k|0)?i=0:(L(d,j,k+i|0),v[b>>2]=i,i=k)}}}}}return i}ae.X=1;function be(b,d,a){var e=3>d>>>0;a:do{if(e){var f=0}else{if(60!=u[b]<<24>>24){f=0}else{for(var g=f=47==u[b+1|0]<<24>>24?2:1,h=a;g>>>0>>0;){var i=z[h];if(0==i<<24>>24){break}if((z[b+g|0]&255|0)!=(i<<24>>24|0)){f=0;break a}g=g+1|0;h=h+1|0}(g|0)==(d|0)?f=0:(g=b+g|0,f=0==(Ld(z[g]&255)|0)&&62!=u[g]<<24>>24?0:f)}}}while(0);return f}function ce(b,d,a,e){var f;f=(e+4|0)>>2;var g=v[f];if(0==(g|0)){var h=a-1|0;v[e+8>>2]=h}else{h=v[e+8>>2]}a=a-h|0;h=(a|0)>(g|0);a:do{if(h){for(;;){L(b,K.Pb|0,10);var i=v[f]+1|0;v[f]=i;if((a|0)<=(i|0)){break a}}}else{if((a|0)<(g|0)){L(b,K.A|0,6);i=(a|0)<(v[f]|0);b:do{if(i){for(;;){L(b,K.Qb|0,12);var j=v[f]-1|0;v[f]=j;if((a|0)>=(j|0)){break b}}}}while(0);L(b,K.Rb|0,5)}else{L(b,K.Tb|0,11)}}}while(0);f=v[e>>2];v[e>>2]=f+1|0;Ud(b,K.Ub|0,($a=s,s+=4,v[$a>>2]=f,$a));0!=(d|0)&&de(b,v[d>>2],v[d+4>>2],0);L(b,K.Wb|0,5)}ce.X=1;function ee(b,d,a){var e,f;0!=(v[b+4>>2]|0)&&O(b,10);var g=0==(a|0);do{if(g){e=22}else{if(f=(a+4|0)>>2,0==(v[f]|0)){e=22}else{L(b,K.sb|0,18);var h=v[f],i=0==(h|0);a:do{if(!i){e=(a|0)>>2;for(var j=0,k=0,l=h;;){for(var o=j,j=l;;){if(o>>>0>=j>>>0){var t=j;break}if(0==(Ld(z[v[e]+o|0]&255)|0)){t=v[f];break}o=o+1|0;j=v[f]}if(o>>>0>>0){j=o;for(l=t;j>>>0>>0&&0==(Ld(z[v[e]+j|0]&255)|0);){j=j+1|0,l=v[f]}l=B[e];o=(46==u[l+o|0]<<24>>24&1)+o|0;0!=(k|0)&&(O(b,32),l=v[e]);de(b,l+o|0,j-o|0,0);o=v[f]}else{j=o,o=t}j=j+1|0;if(j>>>0>=o>>>0){break a}k=k+1|0;l=o}}}while(0);L(b,K.g|0,2);e=23}}}while(0);22==e&&L(b,K.ub|0,11);0!=(d|0)&&de(b,v[d>>2],v[d+4>>2],0);L(b,K.vb|0,14)}ee.X=1;function fe(b,d,a){var e,f;0!=(v[b+4>>2]|0)&&O(b,10);var g=0==(d|0);do{if(!g){f=(d+4|0)>>2;var h=v[f];if(0!=(h|0)){e=(d|0)>>2;for(var i=0;;){if(i>>>0>=h>>>0){var j=h;break}if(0==(Ld(z[v[e]+i|0]&255)|0)){j=v[f];break}i=i+1|0;h=v[f]}if((i|0)!=(j|0)){L(b,K.Va|0,3);h=0==(v[a+12>>2]&128|0);a:do{if(h){L(b,v[e]+i|0,v[f]-i|0)}else{for(var k=i;;){var l=B[f];if(k>>>0>=l>>>0){break a}for(var o=k;o>>>0>>0&&10!=u[v[e]+o|0]<<24>>24;){o=o+1|0}o>>>0>k>>>0?(L(b,v[e]+k|0,o-k|0),k=v[f]):k=l;if(o>>>0>=(k-1|0)>>>0){break a}ge(b,a);k=o+1|0}}}while(0);L(b,K.Xa|0,5)}}}}while(0)}fe.X=1;function he(b,d,a,e){var f;if(0==(d|0)){b=0}else{f=(d+4|0)>>2;var g=v[f];if(0==(g|0)){b=0}else{if(0!=(v[e+12>>2]&32|0)&&!(0!=(Xd(v[d>>2],g)|0)|2==(a|0))){b=0}else{L(b,K.f|0,9);2==(a|0)&&L(b,K.k|0,7);a=d|0;ie(b,v[a>>2],v[f]);g=e+16|0;0==(v[g>>2]|0)?L(b,K.g|0,2):(O(b,34),H[v[g>>2]](b,d,e),O(b,62));e=K.k|0;4==(0==(d|0)?4:0==(v[d+12>>2]|0)?4:5)&&Oc(K.c|0,38,K.aa|0,K.b|0);for(var g=B[d+4>>2],d=d|0,h=0;;){if(h>>>0>=g>>>0){var i=0;break}var j=u[e+h|0],k=j<<24>>24;if(0==j<<24>>24){i=0;break}j=z[v[d>>2]+h|0]&255;if((j|0)==(k|0)){h=h+1|0}else{i=j-k|0;break}}a=v[a>>2];0==(i|0)?de(b,a+7|0,v[f]-7|0,0):de(b,a,v[f],0);L(b,K.D|0,4);b=1}}}return b}he.X=1;function ge(b,d){Wd(b,0!=(v[d+12>>2]&256|0)?K.Zb|0:K.ac|0);return 1}function je(b,d,a,e,f){var g,h=0==(d|0);do{if(h){L(b,K.f|0,9)}else{if(0==(v[f+12>>2]&32|0)){L(b,K.f|0,9),g=d+4|0}else{g=d+4|0;if(0==(Xd(v[d>>2],v[g>>2])|0)){var i=0;g=20;break}L(b,K.f|0,9)}g=v[g>>2];0!=(g|0)&&ie(b,v[d>>2],g)}g=10}while(0);10==g&&(0!=(a|0)&&(h=a+4|0,0!=(v[h>>2]|0)&&(L(b,K.B|0,9),de(b,v[a>>2],v[h>>2],0))),a=f+16|0,0==(v[a>>2]|0)?L(b,K.g|0,2):(O(b,34),H[v[a>>2]](b,d,f),O(b,62)),0!=(e|0)&&(d=v[e+4>>2],0!=(d|0)&&L(b,v[e>>2],d)),L(b,K.D|0,4),i=1);return i}je.X=1;function ke(b,d,a){var e=d>>2,a=(a+12|0)>>2,f=v[a],g=0==(f&512|0);do{if(g){if(0==(f&1|0)){if(0==(f&2|0)){var h=f}else{if(0!=(be(v[e],v[e+1],K.m|0)|0)){break}h=v[a]}var i=d|0;if(0!=(h&8|0)){if(0!=(be(v[i>>2],v[e+1],K.va|0)|0)){break}h=v[a]}if(0==(h&4|0)){h=d+4|0}else{if(h=d+4|0,0!=(be(v[i>>2],v[h>>2],K.Ua|0)|0)){break}}L(b,v[i>>2],v[h>>2])}}else{de(b,v[e],v[e+1],0)}}while(0);return 1}ke.X=1;function le(b,d,a,e,f){var g,h=1>>0;a:do{if(h){g=Qd(z[e+1|0]&255)&255;do{if(39==(g|0)){if(0!=(me(b,a,2>>0?u[e+2|0]:0,100,d+4|0)|0)){var i=1;g=22;break a}}else{if((115==(g|0)||116==(g|0)||109==(g|0)||100==(g|0))&&!(3!=(f|0)&&0==(ne(u[e+2|0])|0))){L(b,K.v|0,7);i=0;g=22;break a}}}while(0);if(2>>0){var j=Qd(z[e+2|0]&255);if(114==(g|0)){if(101!=(j&255|0)){g=18;break}}else{if(108==(g|0)){if(108!=(j&255|0)){g=18;break}}else{if(118==(g|0)){if(101!=(j&255|0)){g=18;break}}else{g=18;break}}}4!=(f|0)&&0==(ne(u[e+3|0])|0)?g=18:(L(b,K.v|0,7),i=0,g=22)}else{g=18}}else{g=18}}while(0);18==g&&(0==(me(b,a,0==(f|0)?0:u[e+1|0],115,d|0)|0)&&O(b,z[e]&255),i=0);return i}le.X=1;function oe(b,d,a,e,f){d=0!=(ne(a)|0)&2>>0;a:do{if(d){var g=49==u[e]<<24>>24;b:do{if(g){a=e+1|0;if(47!=u[a]<<24>>24){a=19;break}var g=e+2|0,h=z[g],i=50==h<<24>>24;c:do{if(i){h=3==(f|0);do{if(!h&&0==(ne(u[e+3|0])|0)){h=z[e];if(49!=h<<24>>24){var j=h,a=20;break b}if(47!=u[a]<<24>>24){a=19;break b}var k=u[g];break c}}while(0);L(b,K.cc|0,8);var l=2,a=31;break a}k=h}while(0);if(52!=k<<24>>24){a=19;break}a=3==(f|0);do{if(!a&&(g=e+3|0,0==(ne(u[g])|0))){if(4>=f>>>0){a=19;break b}if(116!=(Qd(z[g]&255)|0)){a=19;break b}if(104!=(Qd(z[e+4|0]&255)|0)){a=19;break b}}}while(0);L(b,K.ha|0,8);l=2;a=31;break a}a=19}while(0);19==a&&(j=u[e]);if(51!=j<<24>>24){a=30}else{if(47!=u[e+1|0]<<24>>24){a=30}else{if(52!=u[e+2|0]<<24>>24){a=30}else{a=3==(f|0);do{if(!a&&(g=e+3|0,0==(ne(u[g])|0))){if(5>=f>>>0){a=30;break a}if(116!=(Qd(z[g]&255)|0)){a=30;break a}if(104!=(Qd(z[e+4|0]&255)|0)){a=30;break a}if(115!=(Qd(z[e+5|0]&255)|0)){a=30;break a}}}while(0);L(b,K.ka|0,8);l=2;a=31}}}}else{a=30}}while(0);30==a&&(O(b,z[e]&255),l=0);return l}oe.X=1;function me(b,d,a,e,f){var f=f>>2,g=s;s+=8;if(0==(v[f]|0)){a=5}else{if(0==(ne(a)|0)){var h=0,a=8}else{if(a=v[f],0==(a|0)){a=5}else{var i=a,a=7}}}5==a&&(0==(ne(d)|0)?(h=0,a=8):(i=v[f],a=7));7==a&&(d=g|0,pe(d,8,K.dc|0,($a=s,s+=8,v[$a>>2]=0!=(i|0)?114:108,v[$a+4>>2]=e&255,$a)),v[f]=0==(v[f]|0)&1,Wd(b,d),h=1);s=g;return h}function ne(b){var d=b&255;return(0==b<<24>>24?1:0!=(Ld(d)|0)?1:0!=(Kd(d)|0))&1}function de(b,d,a,e){Pc(b,Math.floor(((12*a|0)>>>0)/10));e=0==(e|0);a:do{if(e){for(var f=0,g=0;;){if(g>>>0>=a>>>0){break a}for(var h=g;;){if(h>>>0>=a>>>0){var i=f,j=0;break}var f=z[K.q+(z[d+h|0]&255)|0],k=f<<24>>24;if(0!=f<<24>>24){i=k;j=1;break}f=k;h=h+1|0}h>>>0>g>>>0&&L(b,d+g|0,h-g|0);if(!j){break a}47==u[d+h|0]<<24>>24?O(b,47):Wd(b,v[qe+(i<<2)>>2]);f=i;g=h+1|0}}else{for(g=f=0;;){if(g>>>0>=a>>>0){break a}for(h=g;;){if(h>>>0>=a>>>0){var l=f,o=0;break}f=z[K.q+(z[d+h|0]&255)|0];k=f<<24>>24;if(0!=f<<24>>24){l=k;o=1;break}f=k;h=h+1|0}h>>>0>g>>>0&&L(b,d+g|0,h-g|0);if(!o){break a}Wd(b,v[qe+(l<<2)>>2]);f=l;g=h+1|0}}}while(0)}de.X=1;function ie(b,d,a){var e=s;s+=4;Pc(b,Math.floor(((12*a|0)>>>0)/10));var f=e|0;u[f]=37;for(var g=e+1|0,h=e+2|0,i=0;i>>>0>>0;){for(var j=i;;){if(j>>>0>=a>>>0){var k=0;break}if(0==u[K.V+(z[d+j|0]&255)|0]<<24>>24){k=1;break}j=j+1|0}j>>>0>i>>>0&&L(b,d+i|0,j-i|0);if(!k){break}i=z[d+j|0]&255;38==(i|0)?L(b,K.t|0,5):39==(i|0)?L(b,K.la|0,6):(u[g]=u[K.I+(i>>>4)|0],u[h]=u[K.I+(i&15)|0],L(b,f,3));i=j+1|0}s=e}ie.X=1;function qb(b){if(245>b>>>0){var d=11>b>>>0?16:b+11&-8,a=d>>>3,b=B[X>>2],e=b>>>(a>>>0);if(0!=(e&3|0)){var f=(e&1^1)+a|0,d=f<<1,a=(d<<2)+X+40|0,g=(d+2<<2)+X+40|0,e=B[g>>2],d=e+8|0,h=B[d>>2];(a|0)==(h|0)?v[X>>2]=b&(1<>>0>2]>>>0&&(Z(),c("Reached an unreachable!")),v[g>>2]=h,v[h+12>>2]=a);b=f<<3;v[e+4>>2]=b|3;b=e+(b|4)|0;v[b>>2]|=1;f=d;b=39}else{if(d>>>0>B[X+8>>2]>>>0){if(0!=(e|0)){var f=2<>>12&16,e=a>>>(f>>>0),a=e>>>5&8,g=e>>>(a>>>0),e=g>>>2&4,h=g>>>(e>>>0),g=h>>>1&2,h=h>>>(g>>>0),i=h>>>1&1,a=(a|f|e|g|i)+(h>>>(i>>>0))|0,f=a<<1,g=(f<<2)+X+40|0,h=(f+2<<2)+X+40|0,e=B[h>>2],f=e+8|0,i=B[f>>2];(g|0)==(i|0)?v[X>>2]=b&(1<>>0>2]>>>0&&(Z(),c("Reached an unreachable!")),v[h>>2]=i,v[i+12>>2]=g);g=a<<3;b=g-d|0;v[e+4>>2]=d|3;a=e+d|0;v[e+(d|4)>>2]=b|1;v[e+g>>2]=b;i=B[X+8>>2];0!=(i|0)&&(d=v[X+20>>2],g=i>>>2&1073741822,e=(g<<2)+X+40|0,h=B[X>>2],i=1<<(i>>>3),0==(h&i|0)?(v[X>>2]=h|i,h=e,g=(g+2<<2)+X+40|0):(g=(g+2<<2)+X+40|0,h=B[g>>2],h>>>0>2]>>>0&&(Z(),c("Reached an unreachable!"))),v[g>>2]=d,v[h+12>>2]=d,v[(d+8|0)>>2]=h,v[(d+12|0)>>2]=e);v[X+8>>2]=b;v[X+20>>2]=a;b=39}else{0==(v[X+4>>2]|0)?(j=d,b=31):(b=re(d),0==(b|0)?(j=d,b=31):(f=b,b=39))}}else{var j=d,b=31}}}else{4294967231>>0?(j=-1,b=31):(b=b+11&-8,0==(v[X+4>>2]|0)?(j=b,b=31):(d=se(b),0==(d|0)?(j=b,b=31):(f=d,b=39)))}31==b&&(d=B[X+8>>2],j>>>0>d>>>0?(b=B[X+12>>2],j>>>0>>0?(b=b-j|0,v[X+12>>2]=b,d=B[X+24>>2],v[X+24>>2]=d+j|0,v[j+(d+4)>>2]=b|1,v[d+4>>2]=j|3,f=d+8|0):f=te(j)):(f=d-j|0,b=B[X+20>>2],15>>0?(v[X+20>>2]=b+j|0,v[X+8>>2]=f,v[j+(b+4)>>2]=f|1,v[b+d>>2]=f,v[b+4>>2]=j|3):(v[X+8>>2]=0,v[X+20>>2]=0,v[b+4>>2]=d|3,j=d+(b+4)|0,v[j>>2]|=1),f=b+8|0));return f}Module._malloc=qb;qb.X=1;function re(b){var d,a,e=v[X+4>>2],f=(e&-e)-1|0,e=f>>>12&16,g=f>>>(e>>>0),f=g>>>5&8;a=g>>>(f>>>0);var g=a>>>2&4,h=a>>>(g>>>0);a=h>>>1&2;var h=h>>>(a>>>0),i=h>>>1&1,e=g=f=B[X+((f|e|g|a|i)+(h>>>(i>>>0))<<2)+304>>2];a=e>>2;for(f=(v[f+4>>2]&-8)-b|0;;){h=v[g+16>>2];if(0==(h|0)){if(g=v[g+20>>2],0==(g|0)){break}}else{g=h}h=(v[g+4>>2]&-8)-b|0;f=(a=h>>>0>>0)?h:f;e=a?g:e;a=e>>2}var h=e,j=B[X+16>>2],i=h>>>0>>0;do{if(!i){var k=h+b|0,g=k;if(h>>>0>>0){var i=B[a+6],k=B[a+3],l=(k|0)==(e|0);do{if(l){d=e+20|0;var o=v[d>>2];if(0==(o|0)&&(d=e+16|0,o=v[d>>2],0==(o|0))){o=0;d=o>>2;break}for(;;){var t=o+20|0,q=v[t>>2];if(0==(q|0)&&(t=o+16|0,q=B[t>>2],0==(q|0))){break}d=t;o=q}d>>>0>>0&&(Z(),c("Reached an unreachable!"));v[d>>2]=0}else{d=B[a+2],d>>>0>>0&&(Z(),c("Reached an unreachable!")),v[d+12>>2]=k,v[k+8>>2]=d,o=k}d=o>>2}while(0);j=0==(i|0);a:do{if(!j){k=e+28|0;l=(v[k>>2]<<2)+X+304|0;t=(e|0)==(v[l>>2]|0);do{if(t){v[l>>2]=o;if(0!=(o|0)){break}v[X+4>>2]&=1<>2]^-1;break a}i>>>0>2]>>>0&&(Z(),c("Reached an unreachable!"));q=i+16|0;(v[q>>2]|0)==(e|0)?v[q>>2]=o:v[i+20>>2]=o;if(0==(o|0)){break a}}while(0);o>>>0>2]>>>0&&(Z(),c("Reached an unreachable!"));v[d+6]=i;k=B[a+4];0!=(k|0)&&(k>>>0>2]>>>0&&(Z(),c("Reached an unreachable!")),v[d+4]=k,v[k+24>>2]=o);k=B[a+5];0!=(k|0)&&(k>>>0>2]>>>0&&(Z(),c("Reached an unreachable!")),v[d+5]=k,v[k+24>>2]=o)}}while(0);16>f>>>0?(b=f+b|0,v[a+1]=b|3,b=b+(h+4)|0,v[b>>2]|=1):(v[a+1]=b|3,v[b+(h+4)>>2]=f|1,v[h+f+b>>2]=f,j=B[X+8>>2],0!=(j|0)&&(b=B[X+20>>2],h=j>>>2&1073741822,a=(h<<2)+X+40|0,i=B[X>>2],j=1<<(j>>>3),0==(i&j|0)?(v[X>>2]=i|j,i=a,h=(h+2<<2)+X+40|0):(h=(h+2<<2)+X+40|0,i=B[h>>2],i>>>0>2]>>>0&&(Z(),c("Reached an unreachable!"))),v[h>>2]=b,v[i+12>>2]=b,v[b+8>>2]=i,v[b+12>>2]=a),v[X+8>>2]=f,v[X+20>>2]=g);return e+8|0}}}while(0);Z();c("Reached an unreachable!")}re.X=1;function se(b){var d,a,e,f,g,h=b>>2,i,j=-b|0,k=b>>>8;if(0==(k|0)){var l=0}else{if(16777215>>0){l=31}else{var o=(k+1048320|0)>>>16&8,t=k<>>16&4,r=t<>>16&2,x=14-(q|o|w)+(r<>>15)|0,l=b>>>((x+7|0)>>>0)&1|x<<1}}var D=B[X+(l<<2)+304>>2],y=0==(D|0);a:do{if(y){var A=0,E=j,G=0}else{var N=31==(l|0)?0:25-(l>>>1)|0,I=0,M=j,J=D;g=J>>2;for(var S=b<>>0>>0){if(($|0)==(b|0)){A=J;E=Ha;G=J;break a}var Qa=J,pa=Ha}else{Qa=I,pa=M}var ka=B[g+5],qa=B[((S>>>31<<2)+16>>2)+g],eb=0==(ka|0)|(ka|0)==(qa|0)?Q:ka;if(0==(qa|0)){A=Qa;E=pa;G=eb;break a}I=Qa;M=pa;J=qa;g=J>>2;S<<=1;Q=eb}}}while(0);if(0==(G|0)&0==(A|0)){var Y=2<>2]&(Y|-Y);if(0==(Ia|0)){var tb=0;i=80}else{var Qb=(Ia&-Ia)-1|0,fa=Qb>>>12&16,Ta=Qb>>>(fa>>>0),Ja=Ta>>>5&8,Rb=Ta>>>(Ja>>>0),Sb=Rb>>>2&4,Tb=Rb>>>(Sb>>>0),Ub=Tb>>>1&2,ub=Tb>>>(Ub>>>0),Vb=ub>>>1&1,vb=v[X+((Ja|fa|Sb|Ub|Vb)+(ub>>>(Vb>>>0))<<2)+304>>2];i=15}}else{vb=G,i=15}a:do{if(15==i){var ld=0==(vb|0);b:do{if(ld){var ca=E,aa=A;f=aa>>2}else{var ya=vb;e=ya>>2;for(var Ua=E,Wb=A;;){var za=(v[e+1]&-8)-b|0,Ec=za>>>0>>0,wb=Ec?za:Ua,hb=Ec?ya:Wb,Va=B[e+4];if(0!=(Va|0)){ya=Va}else{var Fc=B[e+5];if(0==(Fc|0)){ca=wb;aa=hb;f=aa>>2;break b}ya=Fc}e=ya>>2;Ua=wb;Wb=hb}}}while(0);if(0!=(aa|0)&&ca>>>0<(v[X+8>>2]-b|0)>>>0){var Wa=aa;a=Wa>>2;var Ka=B[X+16>>2],ib=Wa>>>0>>0;do{if(!ib){var xb=Wa+b|0,yb=xb;if(Wa>>>0>>0){var ta=B[f+6],La=B[f+3],md=(La|0)==(aa|0);do{if(md){var Xb=aa+20|0,Yb=v[Xb>>2];if(0==(Yb|0)){var Zb=aa+16|0,$b=v[Zb>>2];if(0==($b|0)){var W=0;d=W>>2;break}var ua=Zb,la=$b}else{ua=Xb,la=Yb,i=28}for(;;){var ac=la+20|0,bc=v[ac>>2];if(0!=(bc|0)){ua=ac,la=bc}else{var cc=la+16|0,dc=B[cc>>2];if(0==(dc|0)){break}ua=cc;la=dc}}ua>>>0>>0&&(Z(),c("Reached an unreachable!"));v[ua>>2]=0;W=la}else{var jb=B[f+2];jb>>>0>>0&&(Z(),c("Reached an unreachable!"));v[jb+12>>2]=La;v[La+8>>2]=jb;W=La}d=W>>2}while(0);var Gc=0==(ta|0);b:do{if(Gc){var Ma=aa}else{var Hc=aa+28|0,ec=(v[Hc>>2]<<2)+X+304|0,zb=(aa|0)==(v[ec>>2]|0);do{if(zb){v[ec>>2]=W;if(0!=(W|0)){break}v[X+4>>2]&=1<>2]^-1;Ma=aa;break b}ta>>>0>2]>>>0&&(Z(),c("Reached an unreachable!"));var kb=ta+16|0;(v[kb>>2]|0)==(aa|0)?v[kb>>2]=W:v[ta+20>>2]=W;if(0==(W|0)){Ma=aa;break b}}while(0);W>>>0>2]>>>0&&(Z(),c("Reached an unreachable!"));v[d+6]=ta;var ha=B[f+4];0!=(ha|0)&&(ha>>>0>2]>>>0&&(Z(),c("Reached an unreachable!")),v[d+4]=ha,v[ha+24>>2]=W);var Xa=B[f+5];0!=(Xa|0)&&(Xa>>>0>2]>>>0&&(Z(),c("Reached an unreachable!")),v[d+5]=Xa,v[Xa+24>>2]=W);Ma=aa}}while(0);var Ic=16>ca>>>0;b:do{if(Ic){var fc=ca+b|0;v[Ma+4>>2]=fc|3;var gc=fc+(Wa+4)|0;v[gc>>2]|=1}else{if(v[Ma+4>>2]=b|3,v[h+(a+1)]=ca|1,v[(ca>>2)+a+h]=ca,256>ca>>>0){var lb=ca>>>2&1073741822,hc=(lb<<2)+X+40|0,ic=B[X>>2],jc=1<<(ca>>>3);if(0==(ic&jc|0)){v[X>>2]=ic|jc;var Ya=hc,Ab=(lb+2<<2)+X+40|0}else{var Aa=(lb+2<<2)+X+40|0,kc=B[Aa>>2];kc>>>0>2]>>>0&&(Z(),c("Reached an unreachable!"));Ya=kc;Ab=Aa}v[Ab>>2]=yb;v[Ya+12>>2]=yb;v[h+(a+2)]=Ya;v[h+(a+3)]=hc}else{var va=xb,Bb=ca>>>8;if(0==(Bb|0)){var Ba=0}else{if(16777215>>0){Ba=31}else{var lc=(Bb+1048320|0)>>>16&8,mc=Bb<>>16&4,nc=mc<>>16&2,Jc=14-(Cb|lc|oc)+(nc<>>15)|0,Ba=ca>>>((Jc+7|0)>>>0)&1|Jc<<1}}var mb=(Ba<<2)+X+304|0;v[h+(a+7)]=Ba;var Na=b+(Wa+16)|0;v[h+(a+5)]=0;v[Na>>2]=0;var pc=v[X+4>>2],Db=1<>2]=pc|Db,v[mb>>2]=va,v[h+(a+6)]=mb,v[h+(a+3)]=va,v[h+(a+2)]=va}else{for(var Eb=ca<<(31==(Ba|0)?0:25-(Ba>>>1)|0),Oa=v[mb>>2];;){if((v[Oa+4>>2]&-8|0)==(ca|0)){var Fb=Oa+8|0,Gb=B[Fb>>2],qc=B[X+16>>2],Kc=Oa>>>0>>0;do{if(!Kc&&Gb>>>0>=qc>>>0){v[Gb+12>>2]=va;v[Fb>>2]=va;v[h+(a+2)]=Gb;v[h+(a+3)]=Oa;v[h+(a+6)]=0;break b}}while(0);Z();c("Reached an unreachable!")}var Hb=(Eb>>>31<<2)+Oa+16|0,Me=B[Hb>>2];if(0!=(Me|0)){Eb<<=1,Oa=Me}else{if(Hb>>>0>=B[X+16>>2]>>>0){v[Hb>>2]=va;v[h+(a+6)]=Oa;v[h+(a+3)]=va;v[h+(a+2)]=va;break b}Z();c("Reached an unreachable!")}}}}}}while(0);tb=Ma+8|0;break a}}}while(0);Z();c("Reached an unreachable!")}tb=0}}while(0);return tb}se.X=1;function te(b){var d,a;0==(v[ue>>2]|0)&&ve();var e=0==(v[X+440>>2]&4|0);a:do{if(e){a=v[X+24>>2];if(0==(a|0)){a=7}else{if(a=we(a),0==(a|0)){a=7}else{var f=v[ue+8>>2],f=b+47-v[X+12>>2]+f&-f;if(2147483647>f>>>0){var g=xe(f),h=(d=(g|0)==(v[a>>2]+v[a+4>>2]|0))?g:-1;d=d?f:0;var i=f;a=14}else{var j=0;a=22}}}if(7==a){if(a=xe(0),-1==(a|0)){j=0,a=22}else{var f=v[ue+8>>2],f=f+(b+47)&-f,k=a,l=v[ue+4>>2],o=l-1|0,f=0==(o&k|0)?f:f-k+(o+k&-l)|0;2147483647>f>>>0?(g=xe(f),d=(h=(g|0)==(a|0))?f:0,h=h?a:-1,i=f,a=14):(j=0,a=22)}}b:do{if(14==a){j=-i|0;if(-1!=(h|0)){var t=d,q=h;a=27;break a}a=-1!=(g|0)&2147483647>i>>>0;do{if(a){if(i>>>0<(b+48|0)>>>0){if(f=v[ue+8>>2],f=b+47-i+f&-f,2147483647>f>>>0){if(-1==(xe(f)|0)){xe(j);j=d;break b}f=f+i|0}else{f=i}}else{f=i}}else{f=i}}while(0);if(-1!=(g|0)){t=f;q=g;a=27;break a}v[X+440>>2]|=4;var r=d;a=24;break a}}while(0);v[X+440>>2]|=4;r=j}else{r=0}a=24}while(0);24==a&&(e=v[ue+8>>2],e=e+(b+47)&-e,2147483647>e>>>0?(e=xe(e),h=xe(0),-1!=(h|0)&-1!=(e|0)&e>>>0>>0?(d=h-e|0,r=(h=d>>>0>(b+40|0)>>>0)?d:r,e=h?e:-1,-1==(e|0)?a=50:(t=r,q=e,a=27)):a=50):a=50);a:do{if(27==a){r=v[X+432>>2]+t|0;v[X+432>>2]=r;r>>>0>B[X+436>>2]>>>0&&(v[X+436>>2]=r);r=B[X+24>>2];e=0==(r|0);b:do{if(e){h=B[X+16>>2];0==(h|0)|q>>>0>>0&&(v[X+16>>2]=q);v[X+444>>2]=q;v[X+448>>2]=t;v[X+456>>2]=0;v[X+36>>2]=v[ue>>2];v[X+32>>2]=-1;for(h=0;!(d=h<<1,i=(d<<2)+X+40|0,v[X+(d+3<<2)+40>>2]=i,v[X+(d+2<<2)+40>>2]=i,h=h+1|0,32==(h|0));){}ye(q,t-40|0)}else{i=X+444|0;for(d=i>>2;0!=(i|0);){h=B[d];i=i+4|0;g=B[i>>2];if((q|0)==(h+g|0)){if(0!=(v[d+3]&8|0)){break}d=r;if(!(d>>>0>=h>>>0&d>>>0>>0)){break}v[i>>2]=g+t|0;ye(v[X+24>>2],v[X+12>>2]+t|0);break b}i=v[d+2];d=i>>2}q>>>0>2]>>>0&&(v[X+16>>2]=q);h=q+t|0;for(d=X+444|0;0!=(d|0);){i=d|0;if((v[i>>2]|0)==(h|0)){if(0!=(v[d+12>>2]&8|0)){break}v[i>>2]=q;var w=d+4|0;v[w>>2]=v[w>>2]+t|0;w=ze(q,h,b);a=51;break a}d=v[d+8>>2]}Ae(q,t)}}while(0);r=B[X+12>>2];r>>>0>b>>>0?(w=r-b|0,v[X+12>>2]=w,e=r=B[X+24>>2],v[X+24>>2]=e+b|0,v[b+(e+4)>>2]=w|1,v[r+4>>2]=b|3,w=r+8|0,a=51):a=50}}while(0);50==a&&(v[Be>>2]=12,w=0);return w}te.X=1;function Ce(b){var d;0==(v[ue>>2]|0)&&ve();var a=4294967232>b>>>0;a:do{if(a){var e=B[X+24>>2];if(0!=(e|0)){var f=B[X+12>>2],g=f>>>0>(b+40|0)>>>0;do{if(g){var h=B[ue+8>>2],i=(Math.floor(((-40-b-1+f+h|0)>>>0)/(h>>>0))-1)*h|0,j=we(e);if(0==(v[j+12>>2]&8|0)){var k=xe(0);d=(j+4|0)>>2;if((k|0)==(v[j>>2]+v[d]|0)&&(i=xe(-(2147483646>>0?-2147483648-h|0:i)|0),h=xe(0),-1!=(i|0)&h>>>0>>0&&(i=k-h|0,(k|0)!=(h|0)))){v[d]=v[d]-i|0;v[X+432>>2]=v[X+432>>2]-i|0;ye(v[X+24>>2],v[X+12>>2]-i|0);d=1;break a}}}}while(0);B[X+12>>2]>>>0>B[X+28>>2]>>>0&&(v[X+28>>2]=-1)}}d=0}while(0);return d}Ce.X=1;function Nc(b){var d,a,e,f,g,h,i=b>>2,j,k=0==(b|0);a:do{if(!k){var l=b-8|0,o=l,t=B[X+16>>2],q=l>>>0>>0;b:do{if(!q){var r=B[b-4>>2],w=r&3;if(1!=(w|0)){var x=r&-8;h=x>>2;var D=b+(x-8)|0,y=D,A=0==(r&1|0);c:do{if(A){var E=B[l>>2];if(0==(w|0)){break a}var G=-8-E|0;g=G>>2;var N=b+G|0,I=N,M=E+x|0;if(N>>>0>>0){break b}if((I|0)==(v[X+20>>2]|0)){f=(b+(x-4)|0)>>2;if(3!=(v[f]&3|0)){var J=I;e=J>>2;var S=M;break}v[X+8>>2]=M;v[f]&=-2;v[g+(i+1)]=M|1;v[D>>2]=M;break a}if(256>E>>>0){var Q=B[g+(i+2)],$=B[g+(i+3)];if((Q|0)==($|0)){v[X>>2]&=1<<(E>>>3)^-1,J=I,e=J>>2,S=M}else{var Ha=((E>>>2&1073741822)<<2)+X+40|0,Qa=(Q|0)!=(Ha|0)&Q>>>0>>0;do{if(!Qa&&($|0)==(Ha|0)|$>>>0>=t>>>0){v[Q+12>>2]=$;v[$+8>>2]=Q;J=I;e=J>>2;S=M;break c}}while(0);Z();c("Reached an unreachable!")}}else{var pa=N,ka=B[g+(i+6)],qa=B[g+(i+3)],eb=(qa|0)==(pa|0);do{if(eb){var Y=G+(b+20)|0,Ia=v[Y>>2];if(0==(Ia|0)){var tb=G+(b+16)|0,Qb=v[tb>>2];if(0==(Qb|0)){var fa=0;a=fa>>2;break}var Ta=tb,Ja=Qb}else{Ta=Y,Ja=Ia,j=22}for(;;){var Rb=Ja+20|0,Sb=v[Rb>>2];if(0!=(Sb|0)){Ta=Rb,Ja=Sb}else{var Tb=Ja+16|0,Ub=B[Tb>>2];if(0==(Ub|0)){break}Ta=Tb;Ja=Ub}}Ta>>>0>>0&&(Z(),c("Reached an unreachable!"));v[Ta>>2]=0;fa=Ja}else{var ub=B[g+(i+2)];ub>>>0>>0&&(Z(),c("Reached an unreachable!"));v[ub+12>>2]=qa;v[qa+8>>2]=ub;fa=qa}a=fa>>2}while(0);if(0!=(ka|0)){var Vb=G+(b+28)|0,vb=(v[Vb>>2]<<2)+X+304|0,ld=(pa|0)==(v[vb>>2]|0);do{if(ld){v[vb>>2]=fa;if(0!=(fa|0)){break}v[X+4>>2]&=1<>2]^-1;J=I;e=J>>2;S=M;break c}ka>>>0>2]>>>0&&(Z(),c("Reached an unreachable!"));var ca=ka+16|0;(v[ca>>2]|0)==(pa|0)?v[ca>>2]=fa:v[ka+20>>2]=fa;if(0==(fa|0)){J=I;e=J>>2;S=M;break c}}while(0);fa>>>0>2]>>>0&&(Z(),c("Reached an unreachable!"));v[a+6]=ka;var aa=B[g+(i+4)];0!=(aa|0)&&(aa>>>0>2]>>>0&&(Z(),c("Reached an unreachable!")),v[a+4]=aa,v[aa+24>>2]=fa);var ya=B[g+(i+5)];0!=(ya|0)&&(ya>>>0>2]>>>0&&(Z(),c("Reached an unreachable!")),v[a+5]=ya,v[ya+24>>2]=fa)}J=I;e=J>>2;S=M}}else{J=o,e=J>>2,S=x}}while(0);var Ua=J;if(Ua>>>0>>0){var Wb=b+(x-4)|0,za=B[Wb>>2];if(0!=(za&1|0)){var Ec=0==(za&2|0);do{if(Ec){if((y|0)==(v[X+24>>2]|0)){var wb=v[X+12>>2]+S|0;v[X+12>>2]=wb;v[X+24>>2]=J;v[e+1]=wb|1;(J|0)==(v[X+20>>2]|0)&&(v[X+20>>2]=0,v[X+8>>2]=0);if(wb>>>0<=B[X+28>>2]>>>0){break a}Ce(0);break a}if((y|0)==(v[X+20>>2]|0)){var hb=v[X+8>>2]+S|0;v[X+8>>2]=hb;v[X+20>>2]=J;v[e+1]=hb|1;v[(Ua+hb|0)>>2]=hb;break a}var Va=(za&-8)+S|0,Fc=za>>>3,Wa=256>za>>>0;c:do{if(Wa){var Ka=B[i+h],ib=B[((x|4)>>2)+i];if((Ka|0)==(ib|0)){v[X>>2]&=1<>>2&1073741822)<<2)+X+40|0;j=(Ka|0)==(xb|0)?64:Ka>>>0>2]>>>0?67:64;do{if(64==j&&!((ib|0)!=(xb|0)&&ib>>>0>2]>>>0)){v[Ka+12>>2]=ib;v[ib+8>>2]=Ka;break c}}while(0);Z();c("Reached an unreachable!")}}else{var yb=D,ta=B[h+(i+4)],La=B[((x|4)>>2)+i],md=(La|0)==(yb|0);do{if(md){var Xb=x+(b+12)|0,Yb=v[Xb>>2];if(0==(Yb|0)){var Zb=x+(b+8)|0,$b=v[Zb>>2];if(0==($b|0)){var W=0;d=W>>2;break}var ua=Zb,la=$b}else{ua=Xb,la=Yb,j=74}for(;;){var ac=la+20|0,bc=v[ac>>2];if(0!=(bc|0)){ua=ac,la=bc}else{var cc=la+16|0,dc=B[cc>>2];if(0==(dc|0)){break}ua=cc;la=dc}}ua>>>0>2]>>>0&&(Z(),c("Reached an unreachable!"));v[ua>>2]=0;W=la}else{var jb=B[i+h];jb>>>0>2]>>>0&&(Z(),c("Reached an unreachable!"));v[jb+12>>2]=La;v[La+8>>2]=jb;W=La}d=W>>2}while(0);if(0!=(ta|0)){var Gc=x+(b+20)|0,Ma=(v[Gc>>2]<<2)+X+304|0,Hc=(yb|0)==(v[Ma>>2]|0);do{if(Hc){v[Ma>>2]=W;if(0!=(W|0)){break}v[X+4>>2]&=1<>2]^-1;break c}ta>>>0>2]>>>0&&(Z(),c("Reached an unreachable!"));var ec=ta+16|0;(v[ec>>2]|0)==(yb|0)?v[ec>>2]=W:v[ta+20>>2]=W;if(0==(W|0)){break c}}while(0);W>>>0>2]>>>0&&(Z(),c("Reached an unreachable!"));v[d+6]=ta;var zb=B[h+(i+2)];0!=(zb|0)&&(zb>>>0>2]>>>0&&(Z(),c("Reached an unreachable!")),v[d+4]=zb,v[zb+24>>2]=W);var kb=B[h+(i+3)];0!=(kb|0)&&(kb>>>0>2]>>>0&&(Z(),c("Reached an unreachable!")),v[d+5]=kb,v[kb+24>>2]=W)}}}while(0);v[e+1]=Va|1;v[Ua+Va>>2]=Va;if((J|0)!=(v[X+20>>2]|0)){var ha=Va}else{v[X+8>>2]=Va;break a}}else{v[Wb>>2]=za&-2,v[e+1]=S|1,ha=v[Ua+S>>2]=S}}while(0);if(256>ha>>>0){var Xa=ha>>>2&1073741822,Ic=(Xa<<2)+X+40|0,fc=B[X>>2],gc=1<<(ha>>>3);if(0==(fc&gc|0)){v[X>>2]=fc|gc;var lb=Ic,hc=(Xa+2<<2)+X+40|0}else{var ic=(Xa+2<<2)+X+40|0,jc=B[ic>>2];jc>>>0>2]>>>0&&(Z(),c("Reached an unreachable!"));lb=jc;hc=ic}v[hc>>2]=J;v[lb+12>>2]=J;v[e+2]=lb;v[e+3]=Ic;break a}var Ya=J,Ab=ha>>>8;if(0==(Ab|0)){var Aa=0}else{if(16777215>>0){Aa=31}else{var kc=(Ab+1048320|0)>>>16&8,va=Ab<>>16&4,Ba=va<>>16&2,mc=14-(Bb|kc|lc)+(Ba<>>15)|0,Aa=ha>>>((mc+7|0)>>>0)&1|mc<<1}}var Cb=(Aa<<2)+X+304|0;v[e+7]=Aa;v[e+5]=0;v[e+4]=0;var nc=v[X+4>>2],oc=1<>2]=nc|oc,v[Cb>>2]=Ya,v[e+6]=Cb,v[e+3]=J,v[e+2]=J}else{for(var mb=ha<<(31==(Aa|0)?0:25-(Aa>>>1)|0),Na=v[Cb>>2];;){if((v[Na+4>>2]&-8|0)==(ha|0)){var pc=Na+8|0,Db=B[pc>>2],Eb=B[X+16>>2],Oa=Na>>>0>>0;do{if(!Oa&&Db>>>0>=Eb>>>0){v[Db+12>>2]=Ya;v[pc>>2]=Ya;v[e+2]=Db;v[e+3]=Na;v[e+6]=0;break c}}while(0);Z();c("Reached an unreachable!")}var Fb=(mb>>>31<<2)+Na+16|0,Gb=B[Fb>>2];if(0!=(Gb|0)){mb<<=1,Na=Gb}else{if(Fb>>>0>=B[X+16>>2]>>>0){v[Fb>>2]=Ya;v[e+6]=Na;v[e+3]=J;v[e+2]=J;break c}Z();c("Reached an unreachable!")}}}}while(0);var qc=v[X+32>>2]-1|0;v[X+32>>2]=qc;if(0!=(qc|0)){break a}for(var Kc=X+452|0;;){var Hb=v[Kc>>2];if(0==(Hb|0)){break}Kc=Hb+8|0}v[X+32>>2]=-1;break a}}}}}while(0);Z();c("Reached an unreachable!")}}while(0)}Module._free=Nc;Nc.X=1;function Uc(b,d){if(0==(b|0)){var a=0}else{a=d*b|0,a=65535<(d|b)>>>0?(Math.floor((a>>>0)/(b>>>0))|0)==(d|0)?a:-1:a}var e=qb(a);0!=(e|0)&&0!=(v[e-4>>2]&3|0)&&rb(e,a);return e}function Td(b,d){return 0==(b|0)?qb(d):De(b,d)}Module._realloc=Td;function De(b,d){var a,e,f,g=4294967231>>0;a:do{if(g){v[Be>>2]=12;var h=0}else{f=a=b-8|0;e=(b-4|0)>>2;var i=B[e],j=i&-8,k=j-8|0,l=b+k|0,o=a>>>0>2]>>>0;do{if(!o){var t=i&3;if(1!=(t|0)&-8<(k|0)&&(a=(b+(j-4)|0)>>2,0!=(v[a]&1|0))){g=11>d>>>0?16:d+11&-8;if(0==(t|0)){var q=0,r,i=v[f+4>>2]&-8;r=256>g>>>0?0:i>>>0>=(g+4|0)>>>0&&(i-g|0)>>>0<=v[ue+8>>2]<<1>>>0?f:0;f=18}else{j>>>0>>0?(l|0)!=(v[X+24>>2]|0)?f=22:(a=v[X+12>>2]+j|0,a>>>0>g>>>0?(q=a-g|0,r=b+(g-8)|0,v[e]=g|i&1|2,v[b+(g-4)>>2]=q|1,v[X+24>>2]=r,v[X+12>>2]=q,q=0,r=f,f=18):f=22):(q=j-g|0,15>>0?(v[e]=g|i&1|2,v[b+(g-4)>>2]=q|3,v[a]|=1,q=b+g|0):q=0,r=f,f=18)}do{if(18==f&&0!=(r|0)){0!=(q|0)&&Nc(q);h=r+8|0;break a}}while(0);f=qb(d);if(0==(f|0)){h=0;break a}e=j-(0==(v[e]&3|0)?8:4)|0;ud(f,b,e>>>0>>0?e:d);Nc(b);h=f;break a}}}while(0);Z();c("Reached an unreachable!")}}while(0);return h}De.X=1;function ve(){if(0==(v[ue>>2]|0)){var b=Ee();0==(b-1&b|0)?(v[ue+8>>2]=b,v[ue+4>>2]=b,v[ue+12>>2]=-1,v[ue+16>>2]=2097152,v[ue+20>>2]=0,v[X+440>>2]=0,v[ue>>2]=Math.floor(Date.now()/1e3)&-16^1431655768):(Z(),c("Reached an unreachable!"))}}function we(b){var d,a=X+444|0;for(d=a>>2;;){var e=B[d];if(e>>>0<=b>>>0&&(e+v[d+1]|0)>>>0>b>>>0){var f=a;break}d=B[d+2];if(0==(d|0)){f=0;break}a=d;d=a>>2}return f}function ye(b,d){var a=b+8|0,a=0==(a&7|0)?0:-a&7,e=d-a|0;v[X+24>>2]=b+a|0;v[X+12>>2]=e;v[a+(b+4)>>2]=e|1;v[d+(b+4)>>2]=40;v[X+28>>2]=v[ue+16>>2]}function ze(b,d,a){var e,f,g,h=d>>2,i=b>>2,j,k=b+8|0,k=0==(k&7|0)?0:-k&7;f=d+8|0;var l=0==(f&7|0)?0:-f&7;g=l>>2;var o=d+l|0,t=k+a|0;f=t>>2;var q=b+t|0,r=o-(b+k)-a|0;v[(k+4>>2)+i]=a|3;a=(o|0)==(v[X+24>>2]|0);a:do{if(a){var w=v[X+12>>2]+r|0;v[X+12>>2]=w;v[X+24>>2]=q;v[f+(i+1)]=w|1}else{if((o|0)==(v[X+20>>2]|0)){w=v[X+8>>2]+r|0,v[X+8>>2]=w,v[X+20>>2]=q,v[f+(i+1)]=w|1,v[(b+w+t|0)>>2]=w}else{var x=B[g+(h+1)];if(1==(x&3|0)){var w=x&-8,D=x>>>3,y=256>x>>>0;b:do{if(y){var A=B[((l|8)>>2)+h],E=B[g+(h+3)];if((A|0)==(E|0)){v[X>>2]&=1<>>2&1073741822)<<2)+X+40|0;j=(A|0)==(G|0)?16:A>>>0>2]>>>0?19:16;do{if(16==j&&!((E|0)!=(G|0)&&E>>>0>2]>>>0)){v[A+12>>2]=E;v[E+8>>2]=A;break b}}while(0);Z();c("Reached an unreachable!")}}else{j=o;A=B[((l|24)>>2)+h];E=B[g+(h+3)];G=(E|0)==(j|0);do{if(G){e=l|16;var N=e+(d+4)|0,I=v[N>>2];if(0==(I|0)){if(e=d+e|0,I=v[e>>2],0==(I|0)){I=0;e=I>>2;break}}else{e=N}for(;;){var N=I+20|0,M=v[N>>2];if(0==(M|0)&&(N=I+16|0,M=B[N>>2],0==(M|0))){break}e=N;I=M}e>>>0>2]>>>0&&(Z(),c("Reached an unreachable!"));v[e>>2]=0}else{e=B[((l|8)>>2)+h],e>>>0>2]>>>0&&(Z(),c("Reached an unreachable!")),v[e+12>>2]=E,v[E+8>>2]=e,I=E}e=I>>2}while(0);if(0!=(A|0)){E=l+(d+28)|0;G=(v[E>>2]<<2)+X+304|0;N=(j|0)==(v[G>>2]|0);do{if(N){v[G>>2]=I;if(0!=(I|0)){break}v[X+4>>2]&=1<>2]^-1;break b}A>>>0>2]>>>0&&(Z(),c("Reached an unreachable!"));M=A+16|0;(v[M>>2]|0)==(j|0)?v[M>>2]=I:v[A+20>>2]=I;if(0==(I|0)){break b}}while(0);I>>>0>2]>>>0&&(Z(),c("Reached an unreachable!"));v[e+6]=A;j=l|16;A=B[(j>>2)+h];0!=(A|0)&&(A>>>0>2]>>>0&&(Z(),c("Reached an unreachable!")),v[e+4]=A,v[A+24>>2]=I);j=B[(j+4>>2)+h];0!=(j|0)&&(j>>>0>2]>>>0&&(Z(),c("Reached an unreachable!")),v[e+5]=j,v[j+24>>2]=I)}}}while(0);x=d+(w|l)|0;w=w+r|0}else{x=o,w=r}x=x+4|0;v[x>>2]&=-2;v[f+(i+1)]=w|1;v[(w>>2)+i+f]=w;if(256>w>>>0){D=w>>>2&1073741822,x=(D<<2)+X+40|0,y=B[X>>2],w=1<<(w>>>3),0==(y&w|0)?(v[X>>2]=y|w,w=x,D=(D+2<<2)+X+40|0):(D=(D+2<<2)+X+40|0,w=B[D>>2],w>>>0>2]>>>0&&(Z(),c("Reached an unreachable!"))),v[D>>2]=q,v[w+12>>2]=q,v[f+(i+2)]=w,v[f+(i+3)]=x}else{if(x=q,y=w>>>8,0==(y|0)?D=0:16777215>>0?D=31:(D=(y+1048320|0)>>>16&8,j=y<>>16&4,j<<=y,A=(j+245760|0)>>>16&2,D=14-(y|D|A)+(j<>>15)|0,D=w>>>((D+7|0)>>>0)&1|D<<1),y=(D<<2)+X+304|0,v[f+(i+7)]=D,j=t+(b+16)|0,v[f+(i+5)]=0,v[j>>2]=0,j=v[X+4>>2],A=1<>2]=j|A,v[y>>2]=x,v[f+(i+6)]=y,v[f+(i+3)]=x,v[f+(i+2)]=x}else{D=w<<(31==(D|0)?0:25-(D>>>1)|0);for(y=v[y>>2];;){if((v[y+4>>2]&-8|0)==(w|0)){j=y+8|0;A=B[j>>2];E=B[X+16>>2];G=y>>>0>>0;do{if(!G&&A>>>0>=E>>>0){v[A+12>>2]=x;v[j>>2]=x;v[f+(i+2)]=A;v[f+(i+3)]=y;v[f+(i+6)]=0;break a}}while(0);Z();c("Reached an unreachable!")}j=(D>>>31<<2)+y+16|0;A=B[j>>2];if(0!=(A|0)){D<<=1,y=A}else{if(j>>>0>=B[X+16>>2]>>>0){v[j>>2]=x;v[f+(i+6)]=y;v[f+(i+3)]=x;v[f+(i+2)]=x;break a}Z();c("Reached an unreachable!")}}}}}}}while(0);return b+(k|8)|0}ze.X=1;function Ae(b,d){var a,e,f=B[X+24>>2];e=f>>2;var g=we(f),h=v[g>>2];a=v[g+4>>2];var g=h+a|0,i=h+(a-39)|0,h=h+(a-47)+(0==(i&7|0)?0:-i&7)|0,h=h>>>0<(f+16|0)>>>0?f:h,i=h+8|0;a=i>>2;ye(b,d-40|0);v[(h+4|0)>>2]=27;v[a]=v[X+444>>2];v[a+1]=v[X+448>>2];v[a+2]=v[X+452>>2];v[a+3]=v[X+456>>2];v[X+444>>2]=b;v[X+448>>2]=d;v[X+456>>2]=0;v[X+452>>2]=i;a=h+28|0;v[a>>2]=7;i=(h+32|0)>>>0>>0;a:do{if(i){for(var j=a;;){var k=j+4|0;v[k>>2]=7;if((j+8|0)>>>0>=g>>>0){break a}j=k}}}while(0);g=(h|0)==(f|0);a:do{if(!g){if(a=h-f|0,i=f+a|0,j=a+(f+4)|0,v[j>>2]&=-2,v[e+1]=a|1,v[i>>2]=a,256>a>>>0){j=a>>>2&1073741822,i=(j<<2)+X+40|0,k=B[X>>2],a=1<<(a>>>3),0==(k&a|0)?(v[X>>2]=k|a,a=i,j=(j+2<<2)+X+40|0):(j=(j+2<<2)+X+40|0,a=B[j>>2],a>>>0>2]>>>0&&(Z(),c("Reached an unreachable!"))),v[j>>2]=f,v[a+12>>2]=f,v[e+2]=a,v[e+3]=i}else{i=f;k=a>>>8;if(0==(k|0)){j=0}else{if(16777215>>0){j=31}else{var j=(k+1048320|0)>>>16&8,l=k<>>16&4,l=l<>>16&2,j=14-(k|j|o)+(l<>>15)|0,j=a>>>((j+7|0)>>>0)&1|j<<1}}k=(j<<2)+X+304|0;v[e+7]=j;v[e+5]=0;v[e+4]=0;l=v[X+4>>2];o=1<>2]=l|o,v[k>>2]=i,v[e+6]=k,v[e+3]=f,v[e+2]=f}else{j=a<<(31==(j|0)?0:25-(j>>>1)|0);for(k=v[k>>2];;){if((v[k+4>>2]&-8|0)==(a|0)){var l=k+8|0,o=B[l>>2],t=B[X+16>>2],q=k>>>0>>0;do{if(!q&&o>>>0>=t>>>0){v[o+12>>2]=i;v[l>>2]=i;v[e+2]=o;v[e+3]=k;v[e+6]=0;break a}}while(0);Z();c("Reached an unreachable!")}l=(j>>>31<<2)+k+16|0;o=B[l>>2];if(0!=(o|0)){j<<=1,k=o}else{if(l>>>0>=B[X+16>>2]>>>0){v[l>>2]=i;v[e+6]=k;v[e+3]=f;v[e+2]=f;break a}Z();c("Reached an unreachable!")}}}}}}while(0)}Ae.X=1;function Fe(b){v[b>>2]=Ge+8|0}function He(b){Ie(b|0)}var Je=n;function Qd(b){return 65<=b&&90>=b?b-65+97:b}function nd(b,d,a){for(var e=0;eg?1:-1}}return 0}function Oc(b,d,a,e){c("Assertion failed: "+gb(e)+", at: "+[gb(b),d,gb(a)])}function ud(b,d,a){if(20<=a&&d%2==b%2){if(d%4==b%4){for(a=d+a;d%4;){u[b++]=u[d++]}for(var d=d>>2,b=b>>2,e=a>>2;d>=1;b>>=1;for(e=a>>1;da&&(a+=256);for(var f=b>>2,g=e>>2,h=a|a<<8|a<<16|a<<24;fg?1:-1}}return 0}function xd(b){return 48<=b&&57>=b||97<=b&&122>=b||65<=b&&90>=b}function Kd(b){return 33<=b&&47>=b||58<=b&&64>=b||91<=b&&96>=b||123<=b&&126>=b}function pd(b,d){for(var a=Fa,e=0;eg?1:-1}}return 0}function Ke(b,d){function a(a){var b;"double"===a?b=(pb[0]=v[d+f>>2],pb[1]=v[d+(f+4)>>2],ob[0]):"i64"==a?b=[v[d+f>>2],v[d+(f+4)>>2]]:(a="i32",b=v[d+f>>2]);f+=Math.max(ra(a),sa);return b}for(var e=b,f=0,g=[],h,i;;){var j=e;h=u[e];if(0===h){break}i=u[e+1];if(37==h){var k=p,l=p,o=p,t=p;a:for(;;){switch(i){case 43:k=m;break;case 45:l=m;break;case 35:o=m;break;case 48:if(t){break a}else{t=m;break};default:break a}e++;i=u[e+1]}var q=0;if(42==i){q=a("i32"),e++,i=u[e+1]}else{for(;48<=i&&57>=i;){q=10*q+(i-48),e++,i=u[e+1]}}var r=p;if(46==i){var w=0,r=m;e++;i=u[e+1];if(42==i){w=a("i32"),e++}else{for(;;){i=u[e+1];if(48>i||57>>0)+4294967296*(h[1]>>>0):(h[0]>>>0)+4294967296*(h[1]|0));4>=x&&(h=(j?wc:vc)(h&Math.pow(256,x)-1,8*x));var A=Math.abs(h),j="";if(100==i||105==i){y=8==x&&Je?Je.stringify(D[0],D[1]):wc(h,8*x).toString(10)}else{if(117==i){y=8==x&&Je?Je.stringify(D[0],D[1],m):vc(h,8*x).toString(10),h=Math.abs(h)}else{if(111==i){y=(o?"0":"")+A.toString(8)}else{if(120==i||88==i){j=o?"0x":"";if(0>h){h=-h;y=(A-1).toString(16);D=[];for(o=0;oh?"-"+j:"+"+j);j.length+y.lengthx&&-4<=x?(i=(103==i?"f":"F").charCodeAt(0),w-=x+1):(i=(103==i?"e":"E").charCodeAt(0),w--),x=Math.min(w,20)}if(101==i||69==i){y=h.toExponential(x),/[eE][-+]\d$/.test(y)&&(y=y.slice(0,-1)+"0"+y.slice(-1))}else{if(102==i||70==i){y=h.toFixed(x)}}j=y.split("e");if(r&&!o){for(;1x++;){j[0]+="0"}}y=j[0]+(1h?"-":"")+"inf",t=p}}for(;y.lengthi&&(y=y.toUpperCase());y.split("").forEach((function(a){g.push(a.charCodeAt(0))}))}else{if(115==i){k=a("i8*")||0;t=uc(k);r&&(t=Math.min(uc(k),w));if(!l){for(;t>2]=g.length}else{if(37==i){g.push(h)}else{for(o=j;o>2]=b}var Be,Oe=0,Pe=0,Qe=0,Re=2,Se=[n],Te=m;function Ue(b,d){if("string"!==typeof b){return n}d===ba&&(d="/");b&&"/"==b[0]&&(d="");for(var a=(d+"/"+b).split("/").reverse(),e=[""];a.length;){var f=a.pop();""==f||"."==f||(".."==f?1>12<<12,ff=m);var d=Ea;0!=b&&Da(b);return d}var ff,Ie;function Zd(b,d,a){for(var d=vc(d),e=0;ea;a++){e.push(0)}}var a=b.length+1,e=[F(Lb("/bin/this.program"),"i8",C)];d();for(var f=0;f>2]=kf|0;v[U+4>>2]=K.fa|0;v[U+8>>2]=K.Ga|0;v[U+12>>2]=K.ab|0;v[U+16>>2]=K.C|0;v[U+20>>2]=K.Eb|0;v[U+24>>2]=kf|0;v[U+28>>2]=K.Sb|0;v[U+32>>2]=K.F|0;v[U+36>>2]=K.$b|0;v[U+40>>2]=K.bc|0;v[U+44>>2]=K.ga|0;v[U+48>>2]=K.ja|0;v[U+52>>2]=K.na|0;v[U+56>>2]=kf|0;v[U+60>>2]=K.oa|0;v[U+64>>2]=kf|0;v[U+68>>2]=K.qa|0;v[U+72>>2]=K.w|0;v[U+76>>2]=kf|0;v[U+80>>2]=kf|0;v[U+84>>2]=K.G|0;v[U+88>>2]=K.ya|0;v[U+92>>2]=K.Ba|0;v[U+96>>2]=kf|0;v[U+100>>2]=K.m|0;v[U+104>>2]=K.Ha|0;v[U+108>>2]=K.Ka|0;v[U+112>>2]=K.z|0;v[U+116>>2]=kf|0;v[U+120>>2]=kf|0;v[U+124>>2]=kf|0;v[U+128>>2]=K.Na|0;v[U+132>>2]=kf|0;v[U+136>>2]=kf|0;v[U+140>>2]=kf|0;v[U+144>>2]=kf|0;v[U+148>>2]=K.Pa|0;v[Yd>>2]=K.xb|0;v[Yd+4>>2]=K.u|0;v[Yd+8>>2]=K.Qa|0;v[Yd+12>>2]=K.jb|0;v[Yd+16>>2]=K.k|0;v[jf>>2]=K.w|0;v[jf+4>>2]=K.$a|0;v[jf+8>>2]=K.qb|0;v[jf+12>>2]=K.Db|0;v[jf+16>>2]=K.Hb|0;v[jf+20>>2]=K.C|0;v[jf+24>>2]=K.G|0;v[jf+28>>2]=K.m|0;v[qe>>2]=kf|0;v[qe+4>>2]=K.j|0;v[qe+8>>2]=K.t|0;v[qe+12>>2]=K.eb|0;v[qe+16>>2]=K.tb|0;v[qe+20>>2]=K.Ib|0;v[qe+24>>2]=K.Vb|0;v[Ge+4>>2]=nf;v[lf+4>>2]=of;mf=F([2,0,0,0],["i8*",0,0,0],C);v[nf>>2]=mf+8|0;v[nf+4>>2]=K.Y|0;v[nf+8>>2]=ba;v[of>>2]=mf+8|0;v[of+4>>2]=K.W|0;v[of+8>>2]=nf;H=[0,0,He,0,Bd,0,Fd,0,(function(b,d,a,e){e=2>e>>>0;do{if(e){var f=0}else{if(32!=u[a-1|0]<<24>>24){f=0}else{if(32!=u[a-2|0]<<24>>24){f=0}else{for(var f=b+4|0,g=b|0,h=v[f>>2];0!=(h|0);){h=h-1|0;if(32!=u[v[g>>2]+h|0]<<24>>24){break}v[f>>2]=h}f=0!=(H[v[d+64>>2]](b,v[d+104>>2])|0)&1}}}}while(0);return f}),0,Gd,0,(function(b,d,a,e,f){e=s;s+=20;var g=e+4;v[e>>2]=0;var f=Pd(a,f,e),h=g|0;v[h>>2]=a;var i=g+4|0;v[i>>2]=f;v[g+8>>2]=0;v[g+12>>2]=0;var j=2>>0;a:do{if(j){var k=d+44|0,l=0==(v[k>>2]|0);do{if(!l){var o=B[e>>2];if(0!=(o|0)){j=P(d,1);v[h>>2]=a+1|0;v[i>>2]=f-2|0;Id(j,g);b=H[v[k>>2]](b,j,o,v[d+104>>2]);R(d,1);k=b;break a}}}while(0);k=v[d+72>>2];k=0==(k|0)?0:H[k](b,g,v[d+104>>2])}else{k=0}}while(0);s=e;return 0==(k|0)?0:f}),0,(function(b,d,a,e,f){var g,e=s;s+=16;g=e>>2;v[g]=0;v[g+1]=0;v[g+2]=0;v[g+3]=0;1>>0?(a=a+1|0,f=z[a]&255,0==(Zd(K.bb|0,f,23)|0)?b=0:(g=B[d+92>>2],0==(g|0)?O(b,f):(v[e>>2]=a,v[e+4>>2]=1,H[g](b,e,v[d+104>>2])),b=2)):(1==(f|0)&&O(b,z[a]&255),b=2);s=e;return b}),0,(function(b,d,a,e,f){var g,e=s;s+=16;g=e>>2;v[g]=0;v[g+1]=0;v[g+2]=0;v[g+3]=0;for(var h=1>>0?35==u[a+1|0]<<24>>24?2:1:1;;){if(h>>>0>=f>>>0){var i=0;break}g=a+h|0;h=h+1|0;if(0==(xd(z[g]&255)|0)){if(59!=u[g]<<24>>24){i=0;break}f=B[d+88>>2];if(0==(f|0)){L(b,a,h);i=h;break}v[e>>2]=a;v[e+4>>2]=h;H[f](b,e,v[d+104>>2]);i=h;break}}s=e;return i}),0,(function(b,d,a,e,f){var g=s;s+=4;var h=d+44|0;if(0==(v[h>>2]|0)){b=0}else{if(0!=(v[d+428>>2]|0)){b=0}else{var i=P(d,1),a=ae(g,i,a,e,f,0);0!=(a|0)&&(e=b+4|0,v[e>>2]=v[e>>2]-v[g>>2]|0,H[v[h>>2]](b,i,1,v[d+104>>2]));R(d,1);b=a}}s=g;return b}),0,(function(b,d,a,e,f){var g=s;s+=4;var h=d+44|0;if(0==(v[h>>2]|0)){b=0}else{if(0!=(v[d+428>>2]|0)){b=0}else{var i=P(d,1),a=$d(g,i,a,e,f);0!=(a|0)&&(e=b+4|0,v[e>>2]=v[e>>2]-v[g>>2]|0,H[v[h>>2]](b,i,2,v[d+104>>2]));R(d,1);b=a}}s=g;return b}),0,Jd,0,Od,0,ce,0,(function(b,d){L(b,K.Mb|0,6);0!=(d|0)&&de(b,v[d>>2],v[d+4>>2],0);L(b,K.Ob|0,7);return 1}),0,(function(b,d){if(0==(d|0)){var a=0}else{a=d+4|0,0==(v[a>>2]|0)?a=0:(L(b,K.Kb|0,8),L(b,v[d>>2],v[a>>2]),L(b,K.Lb|0,9),a=1)}return a}),0,(function(b,d){if(0==(d|0)){var a=0}else{a=d+4|0,0==(v[a>>2]|0)?a=0:(L(b,K.Gb|0,4),L(b,v[d>>2],v[a>>2]),L(b,K.Jb|0,5),a=1)}return a}),0,(function(b,d,a,e){0!=(e|0)&&(d=v[e+4>>2],0!=(d|0)&&L(b,v[e>>2],d));return 1}),0,(function(b,d){if(0==(d|0)){var a=0}else{a=d+4|0,0==(v[a>>2]|0)?a=0:(L(b,K.Cb|0,12),L(b,v[d>>2],v[a>>2]),L(b,K.Fb|0,14),a=1)}return a}),0,(function(b,d){if(0==(d|0)){var a=0}else{a=d+4|0,0==(v[a>>2]|0)?a=0:(L(b,K.Ab|0,5),L(b,v[d>>2],v[a>>2]),L(b,K.Bb|0,6),a=1)}return a}),0,(function(b,d){if(0==(d|0)){var a=0}else{a=d+4|0,0==(v[a>>2]|0)?a=0:(L(b,K.yb|0,5),L(b,v[d>>2],v[a>>2]),L(b,K.zb|0,6),a=1)}return a}),0,(function(b,d){var a;a=(d+4|0)>>2;var e=0<(v[a]|0);a:do{if(e){for(;;){L(b,K.wb|0,12);var f=v[a]-1|0;v[a]=f;if(0>=(f|0)){break a}}}}while(0)}),0,ee,0,(function(b,d){0!=(v[b+4>>2]|0)&&O(b,10);L(b,K.pb|0,13);0!=(d|0)&&L(b,v[d>>2],v[d+4>>2]);L(b,K.rb|0,14)}),0,(function(b,d){var a,e=0==(d|0);a:do{if(!e){a=(d|0)>>2;for(var f=v[d+4>>2];;){if(0==(f|0)){var g=0;break}var h=f-1|0;if(10!=u[v[a]+h|0]<<24>>24){g=0;break}f=h}for(;;){if(g>>>0>=f>>>0){break a}var i=B[a];if(10!=u[i+g|0]<<24>>24){break}g=g+1|0}0==(v[b+4>>2]|0)?a=i:(O(b,10),a=v[a]);L(b,a+g|0,f-g|0);O(b,10)}}while(0)}),0,(function(b,d,a,e){0!=(v[b+4>>2]|0)&&O(b,10);if(0==(v[e+12>>2]&64|0)){Ud(b,K.nb|0,($a=s,s+=4,v[$a>>2]=a,$a))}else{var f=v[e>>2];v[e>>2]=f+1|0;Ud(b,K.lb|0,($a=s,s+=8,v[$a>>2]=a,v[$a+4>>2]=f,$a))}0!=(d|0)&&L(b,v[d>>2],v[d+4>>2]);Ud(b,K.ob|0,($a=s,s+=4,v[$a>>2]=a,$a))}),0,(function(b,d){0!=(v[b+4>>2]|0)&&O(b,10);Wd(b,0!=(v[d+12>>2]&256|0)?K.ib|0:K.kb|0)}),0,(function(b,d,a){0!=(v[b+4>>2]|0)&&O(b,10);a=0!=(a&1|0);L(b,a?K.cb|0:K.fb|0,5);0!=(d|0)&&L(b,v[d>>2],v[d+4>>2]);L(b,a?K.gb|0:K.hb|0,6)}),0,(function(b,d){L(b,K.Za|0,4);if(0!=(d|0)){for(var a=d|0,e=v[d+4>>2];;){if(0==(e|0)){var f=v[a>>2];break}var g=e-1|0,h=v[a>>2];if(10!=u[h+g|0]<<24>>24){f=h;break}e=g}L(b,f,e)}L(b,K.A|0,6)}),0,fe,0,(function(b,d,a){0!=(v[b+4>>2]|0)&&O(b,10);L(b,K.Oa|0,15);0!=(d|0)&&L(b,v[d>>2],v[d+4>>2]);L(b,K.Ra|0,16);0!=(a|0)&&L(b,v[a>>2],v[a+4>>2]);L(b,K.Sa|0,17)}),0,(function(b,d){L(b,K.La|0,5);0!=(d|0)&&L(b,v[d>>2],v[d+4>>2]);L(b,K.Ma|0,6)}),0,(function(b,d,a){var e=0!=(a&4|0);e?L(b,K.pa|0,3):L(b,K.ta|0,3);a&=3;3==(a|0)?L(b,K.ua|0,16):1==(a|0)?L(b,K.xa|0,14):2==(a|0)?L(b,K.Aa|0,15):L(b,K.Da|0,1);0!=(d|0)&&L(b,v[d>>2],v[d+4>>2]);e?L(b,K.Fa|0,6):L(b,K.Ja|0,6)}),0,he,0,(function(b,d,a,e,f){if(0==(d|0)){b=0}else{var g=d+4|0;0==(v[g>>2]|0)?b=0:(L(b,K.ec|0,10),ie(b,v[d>>2],v[g>>2]),L(b,K.ia|0,7),0!=(e|0)&&(d=v[e+4>>2],0!=(d|0)&&de(b,v[e>>2],d,0)),0!=(a|0)&&(e=a+4|0,0!=(v[e>>2]|0)&&(L(b,K.B|0,9),de(b,v[a>>2],v[e>>2],0))),Wd(b,0!=(v[f+12>>2]&256|0)?K.ma|0:K.g|0),b=1)}return b}),0,ge,0,je,0,ke,0,(function(b,d){0!=(d|0)&&de(b,v[d>>2],v[d+4>>2],0)}),0,(function(b,d,a,e,f){if(2>>0){if(45!=u[e+1|0]<<24>>24){d=6}else{if(45!=u[e+2|0]<<24>>24){d=6}else{L(b,K.Ea|0,7);var g=2,d=10}}}else{d=6}a:do{if(6==d){g=1>>0;do{if(g&&45==u[e+1|0]<<24>>24){L(b,K.Ia|0,7);g=1;break a}}while(0);O(b,z[e]&255);g=0}}while(0);return g}),0,(function(b,d,a,e,f){if(2>>0){if(d=Qd(z[e+2|0]&255),a=Qd(z[e+1|0]&255)&255,99==(a|0)){if(41!=(d&255|0)){f=12}else{L(b,K.wa|0,6);var g=2,f=13}}else{114==(a|0)?41!=(d&255|0)?f=12:(L(b,K.za|0,5),g=2,f=13):3>>0&116==(a|0)?109!=(d&255|0)?f=12:41!=u[e+3|0]<<24>>24?f=12:(L(b,K.Ca|0,7),g=3,f=13):f=12}}else{f=12}12==f&&(O(b,z[e]&255),g=0);return g}),0,le,0,(function(b,d,a,e,f){0==(me(b,a,0==(f|0)?0:u[e+1|0],100,d+4|0)|0)&&L(b,K.j|0,6);return 0}),0,(function(b,d,a,e,f){if(5>>0){if(0!=(Rc(e,K.j|0,6)|0)){d=7}else{if(0==(me(b,a,6>>0?u[e+6|0]:0,100,d+4|0)|0)){d=7}else{var g=5,d=10}}}else{d=7}7==d&&(3>>0&&0==(Rc(e,K.ra|0,4)|0)?g=3:(O(b,38),g=0));return g}),0,(function(b,d,a,e,f){if(2>>0){if(d=z[e+1|0],46==d<<24>>24){if(46!=u[e+2|0]<<24>>24){f=11}else{L(b,K.s|0,8);var g=2,f=12}}else{4>>0&32==d<<24>>24?46!=u[e+2|0]<<24>>24?f=11:32!=u[e+3|0]<<24>>24?f=11:46!=u[e+4|0]<<24>>24?f=11:(L(b,K.s|0,8),g=4,f=12):f=11}}else{f=11}11==f&&(O(b,z[e]&255),g=0);return g}),0,oe,0,(function(b,d,a,e,f){for(var g,d=0;;){if(d>>>0>=f>>>0){var h=0;break}if(62==u[e+d|0]<<24>>24){h=0;break}d=d+1|0}for(;;){if(8<=h>>>0){var i=d;g=14;break}var j=B[jf+(h<<2)>>2];if(1==(be(e,f,j)|0)){var k=d;g=7;break}h=h+1|0}a:do{if(7==g){for(;;){g=k>>>0>>0?60==u[e+k|0]<<24>>24?10:9:10;if(10==g){if((k|0)==(f|0)){var l=k;break}if(2==(be(e+k|0,f-k|0,j)|0)){l=k;break}}k=k+1|0}for(;;){if(l>>>0>=f>>>0){i=l;break a}if(62==u[e+l|0]<<24>>24){i=l;break a}l=l+1|0}}}while(0);L(b,e,i+1|0);return i}),0,(function(b,d,a,e,f){if(1>>0){if(96!=u[e+1|0]<<24>>24){b=7}else{if(0==(me(b,a,2>>0?u[e+2|0]:0,100,d+4|0)|0)){b=7}else{var g=1,b=8}}}else{b=7}7==b&&(g=0);return g}),0,(function(b,d,a,e,f){2>f>>>0?b=0:(d=z[e+1|0]&255,92==(d|0)||34==(d|0)||39==(d|0)||46==(d|0)||45==(d|0)||96==(d|0)?(O(b,d),b=1):(O(b,92),b=0));return b}),0,(function(b){He(b);0!=(b|0)&&Nc(b)}),0,(function(){return K.mb|0}),0,(function(b){He(b|0);0!=(b|0)&&Nc(b)}),0,(function(){return K.sa|0}),0,Fe,0,(function(b){Fe(b|0);v[b>>2]=lf+8|0}),0];Module.FUNCTION_TABLE=H;function zc(b){function d(){var a=0;Module._main&&(Pb(sc),a=Module.hc(b),Module.noExitRuntime||Pb(tc));if(Module.postRun){for("function"==typeof Module.postRun&&(Module.postRun=[Module.postRun]);0 - - -Original Showdown code copyright (c) 2007 John Fraser - -Modifications and bugfixes (c) 2009 Dana Robinson -Modifications and bugfixes (c) 2009-2011 Stack Exchange Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - diff --git a/lib/gollum/frontend/public/gollum/livepreview/licenses/sundown/sundown.txt b/lib/gollum/frontend/public/gollum/livepreview/licenses/sundown/sundown.txt new file mode 100644 index 00000000..a53a750d --- /dev/null +++ b/lib/gollum/frontend/public/gollum/livepreview/licenses/sundown/sundown.txt @@ -0,0 +1,4 @@ +License +Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/lib/gollum/frontend/public/gollum/livepreview/readme.md b/lib/gollum/frontend/public/gollum/livepreview/readme.md index cc46108f..809a7fca 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/readme.md +++ b/lib/gollum/frontend/public/gollum/livepreview/readme.md @@ -1,6 +1,5 @@ -Client side live preview of Markdown for Gollum with syntax highlighting. - -[Click for demo.](http://bootstraponline.github.com/livepreview/public) +- [sundown + livepreview](http://bootstraponline.github.com/livepreview/public) +- [markdowndeep + livepreview](http://bootstraponline.github.com/livepreview/public/index_deep.html) Uses code/assets from: @@ -9,13 +8,25 @@ Uses code/assets from: 0. [jquery](https://github.com/jquery/jquery) 0. [sizzle](https://github.com/jquery/sizzle) 0. [notepages](https://github.com/fivesixty/notepages) -0. [pagedown](https://code.google.com/p/pagedown/) 0. [retina_display_icon_set](http://blog.twg.ca/2010/11/retina-display-icon-set/) 0. [debounce](https://github.com/cowboy/jquery-throttle-debounce) 0. [requirejs](https://github.com/jrburke/requirejs) +0. [emscripten](https://github.com/kripken/emscripten) +0. [sundown](https://github.com/bootstraponline/sundown) +0. [markdowndeep](https://github.com/toptensoftware/markdowndeep) See licenses folder for details. +# Updating gollum + + - /public/css/custom.css (not css/gollum/) + - /public/images/* + - /public/js/* + - /public/licenses/* + - /public/index.html + - readme.md + - replace template.css link in index.html + # Dependency Notes ## Ace @@ -31,21 +42,3 @@ All changes to Ace for livepreview have been upstreamed. Using jQuery v1.7.2. - Download latest production version from [jquery.com](http://www.jquery.com). - -## Pagedown -The [Pagedown code](https://code.google.com/p/pagedown/source/list) used is from revision `3151a581819f39123b0b5fd1ca9e26cebdcaa873`, May 31, 2012. Markdown.Converter.js has been enhanced to support Gollum style code highlighting. Markdown.Sanitizer.js has been fixed to not remove h4-6. - -https://code.google.com/p/pagedown/source/detail?r=3151a581819f39123b0b5fd1ca9e26cebdcaa873 - -- The h4-6 fix has been submitted for upstream inclusion. [#29](https://code.google.com/p/pagedown/issues/detail?id=29) -- livepreview has various additions to pagedown so it can't be replaced by upstream unpatched. - -# Updating gollum - - - /public/css/custom.css (not css/gollum/) - - /public/images/* - - /public/js/* - - /public/licenses/* - - /public/index.html - - readme.md - - replace template.css link in index.html diff --git a/lib/gollum/frontend/templates/editor.mustache b/lib/gollum/frontend/templates/editor.mustache index 4450c7e0..a84765b0 100644 --- a/lib/gollum/frontend/templates/editor.mustache +++ b/lib/gollum/frontend/templates/editor.mustache @@ -88,7 +88,7 @@
    9. + data-markup-lang="{{format}}" name="content" class="mousetrap">{{content}} {{#header}} diff --git a/lib/gollum/frontend/templates/layout.mustache b/lib/gollum/frontend/templates/layout.mustache index 04e4f6df..e3e6ad2e 100644 --- a/lib/gollum/frontend/templates/layout.mustache +++ b/lib/gollum/frontend/templates/layout.mustache @@ -6,19 +6,25 @@ - + - + + - - {{#mathjax}}{{/mathjax}} + {{#mathjax}}{{/mathjax}} + {{title}} diff --git a/lib/gollum/frontend/templates/page.mustache b/lib/gollum/frontend/templates/page.mustache index 953fb22d..e62021ee 100644 --- a/lib/gollum/frontend/templates/page.mustache +++ b/lib/gollum/frontend/templates/page.mustache @@ -6,17 +6,19 @@ {{>searchbar}}
    10. All Pages
    11. + class="action-all-pages">All
    12. File View
    13. + class="action-all-pages">Files
    14. - New Page
    15. + New +
    16. + Rename
    17. {{#editable}}
    18. Edit Page
    19. + class="action-edit-page">Edit {{/editable}}
    20. Page History
    21. + class="action-page-history">History
      @@ -57,5 +59,8 @@
      diff --git a/lib/gollum/frontend/views/history.rb b/lib/gollum/frontend/views/history.rb index 9dfa19e7..3c069e84 100644 --- a/lib/gollum/frontend/views/history.rb +++ b/lib/gollum/frontend/views/history.rb @@ -17,8 +17,8 @@ module Precious :id7 => v.id[0..6], :num => i, :selected => @page.version.id == v.id, - :author => v.author.name, - :message => v.message, + :author => v.author.name.respond_to?(:force_encoding) ? v.author.name.force_encoding('UTF-8') : v.author.name, + :message => v.message.respond_to?(:force_encoding) ? v.message.force_encoding('UTF-8') : v.message, :date => v.committed_date.strftime("%B %d, %Y"), :gravatar => Digest::MD5.hexdigest(v.author.email) } end diff --git a/lib/gollum/frontend/views/page.rb b/lib/gollum/frontend/views/page.rb index 101de52f..84246a9d 100644 --- a/lib/gollum/frontend/views/page.rb +++ b/lib/gollum/frontend/views/page.rb @@ -15,7 +15,7 @@ module Precious page_versions = @page.versions first = page_versions ? page_versions.first : false return DEFAULT_AUTHOR unless first - first.author.name + first.author.name.respond_to?(:force_encoding) ? first.author.name.force_encoding('UTF-8') : first.author.name end def date diff --git a/lib/gollum/markup.rb b/lib/gollum/markup.rb index 312d03da..170d95c4 100644 --- a/lib/gollum/markup.rb +++ b/lib/gollum/markup.rb @@ -124,30 +124,17 @@ module Gollum # # Returns the placeholder'd String data. def extract_tex(data) - # Random string to escape the `$` character (might be overkill) - esc = "/%%/" data.gsub(/\\\[\s*(.*?)\s*\\\]/m) do tag = CGI.escapeHTML($1) id = Digest::SHA1.hexdigest(tag) @texmap[id] = [:block, tag] id - end.gsub(/'\$/, esc). # Replace `'$` with the `esc` string in order to escape it - gsub(/\$\$\s*(.*?)\s*\$\$/m) do - tag = CGI.escapeHTML($1) - id = Digest::SHA1.hexdigest(tag) - @texmap[id] = [:block, tag] - id end.gsub(/\\\(\s*(.*?)\s*\\\)/m) do tag = CGI.escapeHTML($1) id = Digest::SHA1.hexdigest(tag) @texmap[id] = [:inline, tag] id - end.gsub(/\$\s*(.*?)\s*\$/m) do # match inline $$ - tag = CGI.escapeHTML($1) - id = Digest::SHA1.hexdigest(tag) - @texmap[id] = [:inline, tag] - id - end.gsub(/#{esc}/, '$') # replace the `esc` string back to `$` + end end # Process all TeX from the texmap and replace the placeholders with the @@ -472,11 +459,12 @@ module Gollum # Returns the placeholder'd String data. def extract_code(data) data.gsub!(/^([ \t]*)``` ?([^\r\n]+)?\r?\n(.+?)\r?\n\1```\r?$/m) do - id = Digest::SHA1.hexdigest("#{$2}.#{$3}") + lang = $2 ? $2.strip : nil + id = Digest::SHA1.hexdigest("#{lang}.#{$3}") cached = check_cache(:code, id) @codemap[id] = cached ? { :output => cached } : - { :lang => $2, :code => $3, :indent => $1 } + { :lang => lang, :code => $3, :indent => $1 } "#{$1}#{id}" # print the SHA1 ID with the proper indentation end data diff --git a/lib/gollum/page.rb b/lib/gollum/page.rb index 3ce8ef08..66822015 100644 --- a/lib/gollum/page.rb +++ b/lib/gollum/page.rb @@ -259,6 +259,13 @@ module Gollum end end + # Public: The first 7 characters of the current version. + # + # Returns the first 7 characters of the current version. + def version_short + version.to_s[0,7] + end + # Public: The header Page. # # Returns the header Page or nil if none exists. @@ -433,8 +440,10 @@ module Gollum false end - # Loads a sub page. Sub page nanes (footers) are prefixed with - # an underscore to distinguish them from other Pages. + # Loads a sub page. Sub page names (footers, headers, sidebars) are prefixed with + # an underscore to distinguish them from other Pages. If there is not one within + # the current directory, starts walking up the directory tree to try and find one + # within parent directories. # # name - String page name. # @@ -447,7 +456,7 @@ module Gollum dirs = self.path.split('/') dirs.pop - map = @wiki.tree_map_for(@wiki.ref) + map = @wiki.tree_map_for(@wiki.ref, true) while !dirs.empty? if page = find_page_in_tree(map, name, dirs.join('/')) page.parent_page = self diff --git a/lib/gollum/wiki.rb b/lib/gollum/wiki.rb index 089b25d5..c3967df9 100644 --- a/lib/gollum/wiki.rb +++ b/lib/gollum/wiki.rb @@ -682,10 +682,16 @@ module Gollum # listing is cached based on its actual commit SHA. # # ref - A String ref that is either a commit SHA or references one. + # ignore_page_file_dir - Boolean, if true, searches all files within the git repo, regardless of dir/subdir # # Returns an Array of BlobEntry instances. - def tree_map_for(ref) - @access.tree(ref) + def tree_map_for(ref, ignore_page_file_dir=false) + if ignore_page_file_dir && !@page_file_dir.nil? + @root_access ||= GitAccess.new(path, nil, @repo_is_bare) + @root_access.tree(ref) + else + @access.tree(ref) + end rescue Grit::GitRuby::Repository::NoSuchShaFound [] end diff --git a/test/examples/lotr.git/logs/HEAD b/test/examples/lotr.git/logs/HEAD index 6cba614a..31a4e256 100644 --- a/test/examples/lotr.git/logs/HEAD +++ b/test/examples/lotr.git/logs/HEAD @@ -3,3 +3,5 @@ a8ad3c09dd842a3517085bfadd37718856dee813 1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3 Arran Cudbard-Bell 1309107565 +0200 commit: Test out whitespace with Sam 1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3 b16b3d9fad9d78e5a669e7f33d94c96da374eccd kristi 1336983525 -0700 push b16b3d9fad9d78e5a669e7f33d94c96da374eccd b0de6e794dfdc7ef3400e894225bfe23308aae5c kristi 1336984025 -0700 push +b0de6e794dfdc7ef3400e894225bfe23308aae5c cfea406f5f77afc7fb673a43e97721234385b1bd Darren Oakley 1341830099 +0100 push +cfea406f5f77afc7fb673a43e97721234385b1bd 629aa678272b017a4d136d35e77ac94d80b08dc2 Darren Oakley 1341830833 +0100 push diff --git a/test/examples/lotr.git/logs/refs/heads/master b/test/examples/lotr.git/logs/refs/heads/master index 6cba614a..31a4e256 100644 --- a/test/examples/lotr.git/logs/refs/heads/master +++ b/test/examples/lotr.git/logs/refs/heads/master @@ -3,3 +3,5 @@ a8ad3c09dd842a3517085bfadd37718856dee813 1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3 Arran Cudbard-Bell 1309107565 +0200 commit: Test out whitespace with Sam 1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3 b16b3d9fad9d78e5a669e7f33d94c96da374eccd kristi 1336983525 -0700 push b16b3d9fad9d78e5a669e7f33d94c96da374eccd b0de6e794dfdc7ef3400e894225bfe23308aae5c kristi 1336984025 -0700 push +b0de6e794dfdc7ef3400e894225bfe23308aae5c cfea406f5f77afc7fb673a43e97721234385b1bd Darren Oakley 1341830099 +0100 push +cfea406f5f77afc7fb673a43e97721234385b1bd 629aa678272b017a4d136d35e77ac94d80b08dc2 Darren Oakley 1341830833 +0100 push diff --git a/test/examples/lotr.git/objects/1c/79ddc69707f7b164bc2ea58beb5d8965ff6bd0 b/test/examples/lotr.git/objects/1c/79ddc69707f7b164bc2ea58beb5d8965ff6bd0 new file mode 100644 index 00000000..415ae116 Binary files /dev/null and b/test/examples/lotr.git/objects/1c/79ddc69707f7b164bc2ea58beb5d8965ff6bd0 differ diff --git a/test/examples/lotr.git/objects/27/680b0fce1abfbc528e7aa53d92645852d52eb6 b/test/examples/lotr.git/objects/27/680b0fce1abfbc528e7aa53d92645852d52eb6 new file mode 100644 index 00000000..e0fb454f Binary files /dev/null and b/test/examples/lotr.git/objects/27/680b0fce1abfbc528e7aa53d92645852d52eb6 differ diff --git a/test/examples/lotr.git/objects/4e/023f460ce466e154ca09d8774c79ad5a53fc15 b/test/examples/lotr.git/objects/4e/023f460ce466e154ca09d8774c79ad5a53fc15 new file mode 100644 index 00000000..c2229ba7 Binary files /dev/null and b/test/examples/lotr.git/objects/4e/023f460ce466e154ca09d8774c79ad5a53fc15 differ diff --git a/test/examples/lotr.git/objects/62/9aa678272b017a4d136d35e77ac94d80b08dc2 b/test/examples/lotr.git/objects/62/9aa678272b017a4d136d35e77ac94d80b08dc2 new file mode 100644 index 00000000..4b894d58 --- /dev/null +++ b/test/examples/lotr.git/objects/62/9aa678272b017a4d136d35e77ac94d80b08dc2 @@ -0,0 +1 @@ +xMJ1F])j0S4(ZTe& 187pP55PNߴ*jzAFDV&cUli8SGIp0KQb>0ХJ'zwL}ǕRއè4p#^?<2k%sec8Q*|vipb;z{bT\ \ No newline at end of file diff --git a/test/examples/lotr.git/objects/cf/ea406f5f77afc7fb673a43e97721234385b1bd b/test/examples/lotr.git/objects/cf/ea406f5f77afc7fb673a43e97721234385b1bd new file mode 100644 index 00000000..92192562 --- /dev/null +++ b/test/examples/lotr.git/objects/cf/ea406f5f77afc7fb673a43e97721234385b1bd @@ -0,0 +1,2 @@ +xN0EY+fjǏHF&jWcvWW::g*P 1΁CY` &"[k<3" ZOгѫ|ѽ.*iy} wtˆko/=[XRt# +}vt(Ŝ]-=)&)]/ \ No newline at end of file diff --git a/test/examples/lotr.git/objects/fb/c5dd7d807707b4a0a97c1182fecfef1eced5df b/test/examples/lotr.git/objects/fb/c5dd7d807707b4a0a97c1182fecfef1eced5df new file mode 100644 index 00000000..e931c46b --- /dev/null +++ b/test/examples/lotr.git/objects/fb/c5dd7d807707b4a0a97c1182fecfef1eced5df @@ -0,0 +1 @@ +xEN@ D+FKR$h:8NbENgTI wW8hɖBT|QK. ylU;dM18ʢ\&fMmA3qXxwLŧ6C8I?dzT͍d Tjf̱ 9]<7[ b#t'Ǭga.BaH\d%ܬ[ŧRv/b \ No newline at end of file diff --git a/test/examples/lotr.git/objects/fc/3eee516ff72dc9099ba00d4611eb02e5c9e634 b/test/examples/lotr.git/objects/fc/3eee516ff72dc9099ba00d4611eb02e5c9e634 new file mode 100644 index 00000000..74cbd3c1 Binary files /dev/null and b/test/examples/lotr.git/objects/fc/3eee516ff72dc9099ba00d4611eb02e5c9e634 differ diff --git a/test/examples/lotr.git/objects/ff/6f7de62644369380ba73b4e4297c1a2d6f0b66 b/test/examples/lotr.git/objects/ff/6f7de62644369380ba73b4e4297c1a2d6f0b66 new file mode 100644 index 00000000..670f5931 Binary files /dev/null and b/test/examples/lotr.git/objects/ff/6f7de62644369380ba73b4e4297c1a2d6f0b66 differ diff --git a/test/examples/lotr.git/refs/heads/master b/test/examples/lotr.git/refs/heads/master index bd1b8af0..a19ee561 100644 --- a/test/examples/lotr.git/refs/heads/master +++ b/test/examples/lotr.git/refs/heads/master @@ -1 +1 @@ -b0de6e794dfdc7ef3400e894225bfe23308aae5c +629aa678272b017a4d136d35e77ac94d80b08dc2 diff --git a/test/file_view/2_files_2_folders.txt b/test/file_view/2_files_2_folders.txt index 11da79d0..a481bb0e 100644 --- a/test/file_view/2_files_2_folders.txt +++ b/test/file_view/2_files_2_folders.txt @@ -2,11 +2,11 @@
      1. -
      2. 0
      3. +
      4. 0
      1. -
      2. 1
      3. +
      4. 1
      \ No newline at end of file diff --git a/test/file_view/2_files_2_folders_1_root.txt b/test/file_view/2_files_2_folders_1_root.txt index 7c1e4a96..95ba363b 100644 --- a/test/file_view/2_files_2_folders_1_root.txt +++ b/test/file_view/2_files_2_folders_1_root.txt @@ -3,11 +3,11 @@
      1. -
      2. 0
      3. +
      4. 0
      1. -
      2. 1
      3. +
      4. 1
      \ No newline at end of file diff --git a/test/file_view/nested_folders.txt b/test/file_view/nested_folders.txt index 5daae668..d026e8be 100644 --- a/test/file_view/nested_folders.txt +++ b/test/file_view/nested_folders.txt @@ -1,12 +1,22 @@
      1. - +
          -
        1. 0
        2. +
        3. + +
            +
          1. + +
              +
            1. 0
            2. +
            +
            1. -
            2. 1
            3. +
            4. 1
            5. +
            +
        @@ -14,5 +24,5 @@
        1. -
        2. 2
        3. +
        4. 2
        \ No newline at end of file diff --git a/test/test_app.rb b/test/test_app.rb index 5ae94cf7..d76eab1e 100644 --- a/test/test_app.rb +++ b/test/test_app.rb @@ -88,7 +88,7 @@ context "Frontend" do :rename => "C", :page => 'B', :format => page_1.format, :message => 'def' follow_redirect! - assert_equal "/C", last_request.fullpath + assert_equal '/c', last_request.fullpath assert last_response.ok? @wiki.clear_cache @@ -113,15 +113,9 @@ context "Frontend" do test "creates pages with escaped characters in title" do post "/create", :content => 'abc', :page => 'Title with spaces', :format => 'markdown', :message => 'foo' - assert_equal 'http://example.org/Title-with-spaces', last_response.headers['Location'] + assert_equal 'http://example.org/title-with-spaces', last_response.headers['Location'] get "/Title-with-spaces" assert_match /abc/, last_response.body - - post "/create", :content => 'ghi', :page => 'Title/with/slashes', - :format => 'markdown', :message => 'bar' - assert_equal 'http://example.org/Title-with-slashes', last_response.headers['Location'] - get "/Title-with-slashes" - assert_match /ghi/, last_response.body end test "redirects to create on non-existant page" do @@ -138,7 +132,7 @@ context "Frontend" do follow_redirect! assert_equal "/create/#{name}", last_request.fullpath assert last_response.ok? - end + end test "create redirects to page if already exists" do name = "A" @@ -147,7 +141,7 @@ context "Frontend" do assert_equal "/#{name}", last_request.fullpath assert last_response.ok? end - + test "guards against creation of existing page" do name = "A" post "/create", :content => 'abc', :page => name, @@ -159,6 +153,20 @@ context "Frontend" do assert_not_equal 'abc', page.raw_data end + test "delete a page" do + name = "deleteme" + post "/create", :content => 'abc', :page => name, + :format => 'markdown', :message => 'foo' + page = @wiki.page(name) + assert_equal 'abc', page.raw_data + + get '/delete/' + name + + @wiki.clear_cache + page = @wiki.page(name) + assert_equal nil, page + end + test "previews content" do post "/preview", :content => 'abc', :format => 'markdown' assert last_response.ok? @@ -216,41 +224,6 @@ context "Frontend" do end end -# WTF? Surely this test is wrong... -# In this test repo there is already a file called 'bar.md'. -# This SHOULD raise a Duplicate Page error, no? -# context "Frontend with page-file-dir" do -# include Rack::Test::Methods - -# setup do -# @path = cloned_testpath("examples/page_file_dir.git") -# @wiki = Gollum::Wiki.new(@path, { :page_file_dir => "docs" }) -# Precious::App.set(:gollum_path, @path) -# Precious::App.set(:wiki_options, { :page_file_dir => "docs" }) -# end - -# teardown do -# FileUtils.rm_rf(@path) -# end - -# test "open existing parent" do -# get "/" -# assert last_response.ok? - -# post "/create", :content => "asdf", :page => "bar", -# :format => 'markdown' -# follow_redirect! -# assert last_response.ok? - -# # Assert not match. -# assert_equal true, /Duplicate page/.match(last_response.body) == nil -# end - -# def app -# Precious::App -# end -# end - context "Frontend with lotr" do include Rack::Test::Methods @@ -316,25 +289,25 @@ context "Frontend with lotr" do test "create pages within sub-directories" do post "/create", :content => 'big smelly creatures', :page => 'Orc', :path => 'Mordor', :format => 'markdown', :message => 'oooh, scary' - assert_equal 'http://example.org/Mordor/Orc', last_response.headers['Location'] + assert_equal 'http://example.org/Mordor/orc', last_response.headers['Location'] get "/Mordor/Orc" assert_match /big smelly creatures/, last_response.body - post "/create", :content => 'really big smelly creatures', :page => 'Orc/Uruk-hai', + post "/create", :content => 'really big smelly creatures', :page => 'Uruk Hai', :path => 'Mordor', :format => 'markdown', :message => 'oooh, very scary' - assert_equal 'http://example.org/Mordor/Orc-Uruk-hai', last_response.headers['Location'] - get "/Mordor/Orc-Uruk-hai" + assert_equal 'http://example.org/Mordor/uruk-hai', last_response.headers['Location'] + get "/Mordor/Uruk-Hai" assert_match /really big smelly creatures/, last_response.body end test "edit pages within sub-directories" do post "/create", :content => 'big smelly creatures', :page => 'Orc', :path => 'Mordor', :format => 'markdown', :message => 'oooh, scary' - assert_equal 'http://example.org/Mordor/Orc', last_response.headers['Location'] + assert_equal 'http://example.org/Mordor/orc', last_response.headers['Location'] post "/edit/Mordor/Orc", :content => 'not so big smelly creatures', :page => 'Orc', :path => 'Mordor', :message => 'minor edit' - assert_equal 'http://example.org/Mordor/Orc', last_response.headers['Location'] + assert_equal 'http://example.org/Mordor/orc', last_response.headers['Location'] get "/Mordor/Orc" assert_match /not so big smelly creatures/, last_response.body diff --git a/test/test_committer.rb b/test/test_committer.rb index 494b12f5..57d8c2b8 100644 --- a/test/test_committer.rb +++ b/test/test_committer.rb @@ -50,7 +50,7 @@ context "Wiki" do end test "parents with default master ref" do - ref = 'b0de6e794dfdc7ef3400e894225bfe23308aae5c' + ref = '629aa678272b017a4d136d35e77ac94d80b08dc2' committer = Gollum::Committer.new(@wiki) assert_equal ref, committer.parents.first.sha end diff --git a/test/test_file_view.rb b/test/test_file_view.rb index 12e89852..744e479e 100644 --- a/test/test_file_view.rb +++ b/test/test_file_view.rb @@ -7,6 +7,11 @@ class FakePage @filepath = filepath end + # From page.rb + def filename_stripped + ::File.basename(@filepath, ::File.extname(@filepath)) + end + def path return @filepath end diff --git a/test/test_git_access.rb b/test/test_git_access.rb index 3cd8d0ac..df49b17d 100644 --- a/test/test_git_access.rb +++ b/test/test_git_access.rb @@ -18,7 +18,7 @@ context "GitAccess" do assert @access.ref_map.empty? assert @access.tree_map.empty? @access.tree 'master' - assert_equal({"master"=>"b0de6e794dfdc7ef3400e894225bfe23308aae5c"}, @access.ref_map) + assert_equal({"master"=>"629aa678272b017a4d136d35e77ac94d80b08dc2"}, @access.ref_map) @access.tree '1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3' map = @access.tree_map['1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3'] diff --git a/test/test_markup.rb b/test/test_markup.rb index 6a406cd9..cfd78fd2 100644 --- a/test/test_markup.rb +++ b/test/test_markup.rb @@ -478,6 +478,20 @@ np.array([[2,2],[1,3]],np.float) assert_markup_highlights_code Gollum::Markup, rendered end + test "code with trailing whitespace" do + content = <<-END +shoop da woop + +``` python +np.array([[2,2],[1,3]],np.float) +``` + END + + # rendered with Gollum::Markup + page, rendered = render_page(content) + assert_markup_highlights_code Gollum::Markup, rendered + end + def assert_markup_highlights_code(markup_class, rendered) assert_match /div class="highlight"/, rendered, "#{markup_class} doesn't highlight code\n #{rendered}" assert_match /span class="n"/, rendered, "#{markup_class} doesn't highlight code\n #{rendered}" diff --git a/test/test_page.rb b/test/test_page.rb index b10d4c1d..fb41a792 100644 --- a/test/test_page.rb +++ b/test/test_page.rb @@ -195,3 +195,36 @@ context "Page" do assert_equal "/foo", Gollum::BlobEntry.normalize_dir("/foo") end end + +context "within a sub-directory" do + setup do + @wiki = Gollum::Wiki.new(testpath("examples/lotr.git"), { :page_file_dir => 'Rivendell' }) + end + + test "get existing page" do + page = @wiki.page('Elrond') + assert_equal Gollum::Page, page.class + assert page.raw_data =~ /^# Elrond\n\nElrond/ + assert_equal 'Rivendell/Elrond.md', page.path + assert_equal :markdown, page.format + assert_equal @wiki.repo.commits.first.id, page.version.id + end + + test "should not get page from parent dir" do + page = @wiki.page('Bilbo Baggins') + assert_equal nil, page + end + + test "should inherit header/footer/sidebar pages from parent directories" do + page = @wiki.page('Elrond') + + assert_equal Gollum::Page, page.sidebar.class + assert_equal Gollum::Page, page.header.class + assert_equal Gollum::Page, page.footer.class + + assert page.sidebar.raw_data =~ /^Lord of the Rings/ + assert page.header.raw_data =~ /^Hobbits/ + assert page.footer.raw_data =~ /^Lord of the Rings/ + end +end + diff --git a/test/test_page_revert.rb b/test/test_page_revert.rb index a36df6e6..ccebb117 100644 --- a/test/test_page_revert.rb +++ b/test/test_page_revert.rb @@ -11,6 +11,8 @@ context "Page Reverting" do FileUtils.rm_rf(@path) end +=begin + # Grit is broken and this test fails often. See #363. test "reverts single commit" do page1 = @wiki.page("B") sha = @wiki.revert_commit('7c45b5f16ff3bae2a0063191ef832701214d4df5') @@ -20,8 +22,6 @@ context "Page Reverting" do assert_equal body, File.read(File.join(@path, "B.md")).strip end -=begin - # Grit is broken and this test fails often. See #363. test "reverts single commit for a page" do page1 = nil while (page1 == nil) diff --git a/test/test_unicode.rb b/test/test_unicode.rb index 35c6a3bb..0ffed378 100644 --- a/test/test_unicode.rb +++ b/test/test_unicode.rb @@ -16,16 +16,16 @@ context "Unicode Support" do end test "create and read non-latin page" do - @wiki.write_page("한글 test", :markdown, "# 한글") + @wiki.write_page("test", :markdown, "# 한글") - page = @wiki.page("한글 test") + page = @wiki.page("test") assert_equal Gollum::Page, page.class assert_equal "# 한글", utf8(page.raw_data) end test "unicode with existing format rules" do - @wiki.write_page("한글 test", :markdown, "# 한글") - assert_equal @wiki.page("한글 test").path, @wiki.page("한글-test").path + @wiki.write_page("test", :markdown, "# 한글") + assert_equal @wiki.page("test").path, @wiki.page("test").path end end @@ -43,24 +43,13 @@ context "Frontend Unicode support" do FileUtils.rm_rf(@path) end - test "creates korean page" do - post "/create", :content => 'english text', :page => "한글", - :format => 'markdown', :message => 'def' - follow_redirect! - assert last_response.ok? - - page = @wiki.page('한글') - assert_equal 'english text', page.raw_data - assert_equal 'def', page.version.message - end - test "creates korean page which contains korean content" do - post "/create", :content => '한글 text', :page => "한글", + post "/create", :content => '한글 text', :page => "k", :format => 'markdown', :message => 'def' follow_redirect! assert last_response.ok? - page = @wiki.page('한글') + page = @wiki.page('k') assert_equal '한글 text', utf8(page.raw_data) assert_equal 'def', page.version.message end @@ -86,27 +75,34 @@ context "Frontend Unicode support" do end test "heavy use 2" do - post "/create", :content => '한글 text', :page => "한글", + post "/create", :content => '한글 text', :page => "k", :format => 'markdown', :message => 'def' follow_redirect! assert last_response.ok? - @wiki.update_page(@wiki.page('한글'), nil, nil, '다른 text', {}) + @wiki.update_page(@wiki.page('k'), nil, nil, '다른 text', {}) @wiki = Gollum::Wiki.new(@path) - page = @wiki.page('한글') + page = @wiki.page('k') assert_equal '다른 text', utf8(page.raw_data) - post '/edit/' + CGI.escape('한글'), :page => '한글', :content => '바뀐 text', + post '/edit/' + CGI.escape('한글'), :page => 'k', :content => '바뀐 text', :format => 'markdown', :message => 'ghi' follow_redirect! assert last_response.ok? @wiki = Gollum::Wiki.new(@path) - page = @wiki.page('한글') + page = @wiki.page('k') assert_equal '바뀐 text', utf8(page.raw_data) assert_equal 'ghi', page.version.message end + test 'transliteration' do + # TODO: Remove to_url once write_page changes are merged. + @wiki.write_page('ééééé'.to_url, :markdown, '한글 text', { :name => '', :email => '' } ) + page = @wiki.page('eeeee') + assert_equal '한글 text', utf8(page.raw_data) + end + def app Precious::App end diff --git a/test/test_wiki.rb b/test/test_wiki.rb index 63303f67..5fa7c0f6 100644 --- a/test/test_wiki.rb +++ b/test/test_wiki.rb @@ -54,7 +54,7 @@ context "Wiki" do test "list pages" do pages = @wiki.pages assert_equal \ - ['Bilbo-Baggins.md', 'Boromir.md', 'Eye-Of-Sauron.md', 'Home.textile', 'My-Precious.md', 'Samwise Gamgee.mediawiki'], + ['Bilbo-Baggins.md', 'Boromir.md', 'Elrond.md', 'Eye-Of-Sauron.md', 'Home.textile', 'My-Precious.md', 'Samwise Gamgee.mediawiki'], pages.map { |p| p.filename }.sort end @@ -66,7 +66,7 @@ context "Wiki" do end test "counts pages" do - assert_equal 6, @wiki.size + assert_equal 7, @wiki.size end test "text_data" do