diff --git a/.gitignore b/.gitignore index b291294d..4af3878b 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,4 @@ tahrir.ini .coverage coverage.xml htmlcov/ -.vagrant \ No newline at end of file +.vagrant diff --git a/Vagrantfile b/Vagrantfile index 69adfca1..4a66318c 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -27,4 +27,4 @@ Vagrant.configure(2) do |config| end end -end \ No newline at end of file +end diff --git a/devel/ansible/ansible.cfg b/devel/ansible/ansible.cfg index 546d11d7..1da76fd1 100644 --- a/devel/ansible/ansible.cfg +++ b/devel/ansible/ansible.cfg @@ -2,4 +2,4 @@ interpreter_python = auto allow_world_readable_tmpfiles = True # Human-readable output -stdout_callback = yaml \ No newline at end of file +stdout_callback = yaml diff --git a/docs/conf.py b/docs/conf.py index ff3524b7..b11d5fff 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -# # Tahrir documentation build configuration file, created by # sphinx-quickstart on Thu Jul 25 11:39:50 2013. # @@ -11,217 +9,214 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys, os - # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) +# sys.path.insert(0, os.path.abspath('.')) # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' +# needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.coverage'] +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.intersphinx", + "sphinx.ext.todo", + "sphinx.ext.coverage", +] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix of source filenames. -source_suffix = '.rst' +source_suffix = ".rst" # The encoding of source files. -#source_encoding = 'utf-8-sig' +# source_encoding = 'utf-8-sig' # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = u'Tahrir' -copyright = u'2013, David Gay, Ralph Bean' +project = "Tahrir" +copyright = "2013, David Gay, Ralph Bean" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = '0.2.5' +version = "0.2.5" # The full version, including alpha/beta/rc tags. -release = '0.2.5' +release = "0.2.5" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -#language = None +# language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -#today = '' +# today = '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +# today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = ['_build'] +exclude_patterns = ["_build"] # The reST default role (used for this markup: `text`) to use for all documents. -#default_role = None +# default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True +# add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -#add_module_names = True +# add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -#show_authors = False +# show_authors = False # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] +# modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. -#keep_warnings = False +# keep_warnings = False # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = 'default' +html_theme = "default" # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. -#html_theme_options = {} +# html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] +# html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -#html_title = None +# html_title = None # A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None +# html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. -#html_logo = None +# html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -#html_favicon = None +# html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = ["_static"] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' +# html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -#html_use_smartypants = True +# html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -#html_sidebars = {} +# html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. -#html_additional_pages = {} +# html_additional_pages = {} # If false, no module index is generated. -#html_domain_indices = True +# html_domain_indices = True # If false, no index is generated. -#html_use_index = True +# html_use_index = True # If true, the index is split into individual pages for each letter. -#html_split_index = False +# html_split_index = False # If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True +# html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True +# html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True +# html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -#html_use_opensearch = '' +# html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None +# html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = 'Tahrirdoc' +htmlhelp_basename = "Tahrirdoc" # -- Options for LaTeX output -------------------------------------------------- latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', - -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', - -# Additional stuff for the LaTeX preamble. -#'preamble': '', + # The paper size ('letterpaper' or 'a4paper'). + #'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + #'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + #'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('index', 'Tahrir.tex', u'Tahrir Documentation', - u'David Gay, Ralph Bean', 'manual'), + ("index", "Tahrir.tex", "Tahrir Documentation", "David Gay, Ralph Bean", "manual"), ] # The name of an image file (relative to this directory) to place at the top of # the title page. -#latex_logo = None +# latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. -#latex_use_parts = False +# latex_use_parts = False # If true, show page references after internal links. -#latex_show_pagerefs = False +# latex_show_pagerefs = False # If true, show URL addresses after external links. -#latex_show_urls = False +# latex_show_urls = False # Documents to append as an appendix to all manuals. -#latex_appendices = [] +# latex_appendices = [] # If false, no module index is generated. -#latex_domain_indices = True +# latex_domain_indices = True # -- Options for manual page output -------------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [ - ('index', 'tahrir', u'Tahrir Documentation', - [u'David Gay, Ralph Bean'], 1) -] +man_pages = [("index", "tahrir", "Tahrir Documentation", ["David Gay, Ralph Bean"], 1)] # If true, show URL addresses after external links. -#man_show_urls = False +# man_show_urls = False # -- Options for Texinfo output ------------------------------------------------ @@ -230,23 +225,29 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'Tahrir', u'Tahrir Documentation', - u'David Gay, Ralph Bean', 'Tahrir', 'One line description of project.', - 'Miscellaneous'), + ( + "index", + "Tahrir", + "Tahrir Documentation", + "David Gay, Ralph Bean", + "Tahrir", + "One line description of project.", + "Miscellaneous", + ), ] # Documents to append as an appendix to all manuals. -#texinfo_appendices = [] +# texinfo_appendices = [] # If false, no module index is generated. -#texinfo_domain_indices = True +# texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' +# texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. -#texinfo_no_detailmenu = False +# texinfo_no_detailmenu = False # Example configuration for intersphinx: refer to the Python standard library. -#intersphinx_mapping = {'http://docs.python.org/': None} +# intersphinx_mapping = {'http://docs.python.org/': None} diff --git a/tahrir/static/js/builder.js b/tahrir/static/js/builder.js index aa1a88dc..5b923eda 100644 --- a/tahrir/static/js/builder.js +++ b/tahrir/static/js/builder.js @@ -59,7 +59,7 @@ $(document).ready(function() { badgeDescription = $(this).val(); updateTextarea(); }); - + $('input[name=badge-creator]').keyup(function() { badgeCreator = $(this).val(); updateTextarea(); @@ -95,7 +95,7 @@ $(document).ready(function() { if ($(this).is(':checked')) { $('textarea#preview').prop('readonly', 'readonly'); } - else { + else { $('textarea#preview').prop('readonly', ''); } }); @@ -104,7 +104,7 @@ $(document).ready(function() { if ($('input[name=read-only]').is(':checked')) { $('textarea#preview').prop('readonly', 'readonly'); } - else { + else { $('textarea#preview').prop('readonly', ''); } }); diff --git a/tahrir/static/js/favico-0.3.4.min.js b/tahrir/static/js/favico-0.3.4.min.js index 7e7a0c7a..79cfd566 100644 --- a/tahrir/static/js/favico-0.3.4.min.js +++ b/tahrir/static/js/favico-0.3.4.min.js @@ -4,4 +4,4 @@ * @author Miroslav Magda, http://blog.ejci.net * @version 0.3.4 */ -!function(){var e=function(e){"use strict";function t(e){if(e.paused||e.ended||w)return!1;try{d.clearRect(0,0,h,s),d.drawImage(e,0,0,h,s)}catch(o){}setTimeout(t,U.duration,e),L.setIcon(c)}function o(e){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;e=e.replace(t,function(e,t,o,n){return t+t+o+o+n+n});var o=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return o?{r:parseInt(o[1],16),g:parseInt(o[2],16),b:parseInt(o[3],16)}:!1}function n(e,t){var o,n={};for(o in e)n[o]=e[o];for(o in t)n[o]=t[o];return n}function r(){return document.hidden||document.msHidden||document.webkitHidden||document.mozHidden}e=e?e:{};var i,a,s,h,c,d,f,l,u,g,y,w,x,m={bgColor:"#d00",textColor:"#fff",fontFamily:"sans-serif",fontStyle:"bold",type:"circle",position:"down",animation:"slide",elementId:!1};x={},x.ff=/firefox/i.test(navigator.userAgent.toLowerCase()),x.chrome=/chrome/i.test(navigator.userAgent.toLowerCase()),x.opera=/opera/i.test(navigator.userAgent.toLowerCase()),x.ie=/msie/i.test(navigator.userAgent.toLowerCase())||/trident/i.test(navigator.userAgent.toLowerCase()),x.supported=x.chrome||x.ff||x.opera;var p=[];y=function(){},l=w=!1;var v=function(){i=n(m,e),i.bgColor=o(i.bgColor),i.textColor=o(i.textColor),i.position=i.position.toLowerCase(),i.animation=U.types[""+i.animation]?i.animation:m.animation;var t=i.position.indexOf("up")>-1,r=i.position.indexOf("left")>-1;if(t||r)for(var l=0;l0?f.height:32,h=f.width>0?f.width:32,c.height=s,c.width=h,d=c.getContext("2d"),b.ready()}):(f.setAttribute("src",""),s=32,h=32,f.height=s,f.width=h,c.height=s,c.width=h,d=c.getContext("2d"),b.ready())}catch(g){throw"Error initializing favico. Message: "+g.message}},b={};b.ready=function(){l=!0,b.reset(),y()},b.reset=function(){p=[],u=!1,d.clearRect(0,0,h,s),d.drawImage(f,0,0,h,s),L.setIcon(c)},b.start=function(){if(l&&!g){var e=function(){u=p[0],g=!1,p.length>0&&(p.shift(),b.start())};p.length>0&&(g=!0,u?U.run(u.options,function(){U.run(p[0].options,function(){e()},!1)},!0):U.run(p[0].options,function(){e()},!1))}};var C={},M=function(e){return e.n=Math.abs(e.n),e.x=h*e.x,e.y=s*e.y,e.w=h*e.w,e.h=s*e.h,e};C.circle=function(e){e=M(e);var t=!1;e.n>9&&e.n<100?(e.x=e.x-.4*e.w,e.w=1.4*e.w,t=!0):e.n>=100&&(e.x=e.x-.65*e.w,e.w=1.65*e.w,t=!0),d.clearRect(0,0,h,s),d.drawImage(f,0,0,h,s),d.beginPath(),d.font=i.fontStyle+" "+Math.floor(e.h*(e.n>99?.85:1))+"px "+i.fontFamily,d.textAlign="center",t?(d.moveTo(e.x+e.w/2,e.y),d.lineTo(e.x+e.w-e.h/2,e.y),d.quadraticCurveTo(e.x+e.w,e.y,e.x+e.w,e.y+e.h/2),d.lineTo(e.x+e.w,e.y+e.h-e.h/2),d.quadraticCurveTo(e.x+e.w,e.y+e.h,e.x+e.w-e.h/2,e.y+e.h),d.lineTo(e.x+e.h/2,e.y+e.h),d.quadraticCurveTo(e.x,e.y+e.h,e.x,e.y+e.h-e.h/2),d.lineTo(e.x,e.y+e.h/2),d.quadraticCurveTo(e.x,e.y,e.x+e.h/2,e.y)):d.arc(e.x+e.w/2,e.y+e.h/2,e.h/2,0,2*Math.PI),d.fillStyle="rgba("+i.bgColor.r+","+i.bgColor.g+","+i.bgColor.b+","+e.o+")",d.fill(),d.closePath(),d.beginPath(),d.stroke(),d.fillStyle="rgba("+i.textColor.r+","+i.textColor.g+","+i.textColor.b+","+e.o+")",e.n>999?d.fillText((e.n>9999?9:Math.floor(e.n/1e3))+"k+",Math.floor(e.x+e.w/2),Math.floor(e.y+e.h-.2*e.h)):d.fillText(e.n,Math.floor(e.x+e.w/2),Math.floor(e.y+e.h-.15*e.h)),d.closePath()},C.rectangle=function(e){e=M(e);var t=!1;e.n>9&&e.n<100?(e.x=e.x-.4*e.w,e.w=1.4*e.w,t=!0):e.n>=100&&(e.x=e.x-.65*e.w,e.w=1.65*e.w,t=!0),d.clearRect(0,0,h,s),d.drawImage(f,0,0,h,s),d.beginPath(),d.font="bold "+Math.floor(e.h*(e.n>99?.9:1))+"px sans-serif",d.textAlign="center",d.fillStyle="rgba("+i.bgColor.r+","+i.bgColor.g+","+i.bgColor.b+","+e.o+")",d.fillRect(e.x,e.y,e.w,e.h),d.fillStyle="rgba("+i.textColor.r+","+i.textColor.g+","+i.textColor.b+","+e.o+")",e.n>999?d.fillText((e.n>9999?9:Math.floor(e.n/1e3))+"k+",Math.floor(e.x+e.w/2),Math.floor(e.y+e.h-.2*e.h)):d.fillText(e.n,Math.floor(e.x+e.w/2),Math.floor(e.y+e.h-.15*e.h)),d.closePath()};var I=function(e,t){y=function(){try{if(e>0){if(U.types[""+t]&&(i.animation=t),p.push({type:"badge",options:{n:e}}),p.length>100)throw"Too many badges requests in queue.";b.start()}else b.reset()}catch(o){throw"Error setting badge. Message: "+o.message}},l&&y()},A=function(e){y=function(){try{var t=e.width,o=e.height,n=document.createElement("img"),r=o/s>t/h?t/h:o/s;n.setAttribute("src",e.getAttribute("src")),n.height=o/r,n.width=t/r,d.clearRect(0,0,h,s),d.drawImage(n,0,0,h,s),L.setIcon(c)}catch(i){throw"Error setting image. Message: "+i.message}},l&&y()},E=function(e){y=function(){try{if("stop"===e)return w=!0,b.reset(),w=!1,void 0;e.addEventListener("play",function(){t(this)},!1)}catch(o){throw"Error setting video. Message: "+o.message}},l&&y()},T=function(e){if(window.URL&&window.URL.createObjectURL||(window.URL=window.URL||{},window.URL.createObjectURL=function(e){return e}),x.supported){var o=!1;navigator.getUserMedia=navigator.getUserMedia||navigator.oGetUserMedia||navigator.msGetUserMedia||navigator.mozGetUserMedia||navigator.webkitGetUserMedia,y=function(){try{if("stop"===e)return w=!0,b.reset(),w=!1,void 0;o=document.createElement("video"),o.width=h,o.height=s,navigator.getUserMedia({video:!0,audio:!1},function(e){o.src=URL.createObjectURL(e),o.play(),t(o)},function(){})}catch(n){throw"Error setting webcam. Message: "+n.message}},l&&y()}},L={};L.getIcon=function(){var e=!1,t="",o=function(){for(var e=document.getElementsByTagName("head")[0].getElementsByTagName("link"),t=e.length,o=t-1;o>=0;o--)if(/icon/i.test(e[o].getAttribute("rel")))return e[o];return!1};if(i.elementId?(e=document.getElementById(i.elementId),e.setAttribute("href",e.getAttribute("src"))):(e=o(),e===!1&&(e=document.createElement("link"),e.setAttribute("rel","icon"),document.getElementsByTagName("head")[0].appendChild(e))),t=i.elementId?e.src:e.href,-1===t.indexOf(document.location.hostname))throw new Error("Error setting favicon. Favicon image is on different domain (Icon: "+t+", Domain: "+document.location.hostname+")");return e.setAttribute("type","image/png"),e},L.setIcon=function(e){var t=e.toDataURL("image/png");if(i.elementId)document.getElementById(i.elementId).setAttribute("src",t);else if(x.ff||x.opera){var o=a;a=document.createElement("link"),x.opera&&a.setAttribute("rel","icon"),a.setAttribute("rel","icon"),a.setAttribute("type","image/png"),document.getElementsByTagName("head")[0].appendChild(a),a.setAttribute("href",t),o.parentNode&&o.parentNode.removeChild(o)}else a.setAttribute("href",t)};var U={};return U.duration=40,U.types={},U.types.fade=[{x:.4,y:.4,w:.6,h:.6,o:0},{x:.4,y:.4,w:.6,h:.6,o:.1},{x:.4,y:.4,w:.6,h:.6,o:.2},{x:.4,y:.4,w:.6,h:.6,o:.3},{x:.4,y:.4,w:.6,h:.6,o:.4},{x:.4,y:.4,w:.6,h:.6,o:.5},{x:.4,y:.4,w:.6,h:.6,o:.6},{x:.4,y:.4,w:.6,h:.6,o:.7},{x:.4,y:.4,w:.6,h:.6,o:.8},{x:.4,y:.4,w:.6,h:.6,o:.9},{x:.4,y:.4,w:.6,h:.6,o:1}],U.types.none=[{x:.4,y:.4,w:.6,h:.6,o:1}],U.types.pop=[{x:1,y:1,w:0,h:0,o:1},{x:.9,y:.9,w:.1,h:.1,o:1},{x:.8,y:.8,w:.2,h:.2,o:1},{x:.7,y:.7,w:.3,h:.3,o:1},{x:.6,y:.6,w:.4,h:.4,o:1},{x:.5,y:.5,w:.5,h:.5,o:1},{x:.4,y:.4,w:.6,h:.6,o:1}],U.types.popFade=[{x:.75,y:.75,w:0,h:0,o:0},{x:.65,y:.65,w:.1,h:.1,o:.2},{x:.6,y:.6,w:.2,h:.2,o:.4},{x:.55,y:.55,w:.3,h:.3,o:.6},{x:.5,y:.5,w:.4,h:.4,o:.8},{x:.45,y:.45,w:.5,h:.5,o:.9},{x:.4,y:.4,w:.6,h:.6,o:1}],U.types.slide=[{x:.4,y:1,w:.6,h:.6,o:1},{x:.4,y:.9,w:.6,h:.6,o:1},{x:.4,y:.9,w:.6,h:.6,o:1},{x:.4,y:.8,w:.6,h:.6,o:1},{x:.4,y:.7,w:.6,h:.6,o:1},{x:.4,y:.6,w:.6,h:.6,o:1},{x:.4,y:.5,w:.6,h:.6,o:1},{x:.4,y:.4,w:.6,h:.6,o:1}],U.run=function(e,t,o,a){var s=U.types[r()?"none":i.animation];return a=o===!0?"undefined"!=typeof a?a:s.length-1:"undefined"!=typeof a?a:0,t=t?t:function(){},a=0?(C[i.type](n(e,s[a])),setTimeout(function(){o?a-=1:a+=1,U.run(e,t,o,a)},U.duration),L.setIcon(c),void 0):(t(),void 0)},v(),{badge:I,video:E,image:A,webcam:T,reset:b.reset}};"undefined"!=typeof define&&define.amd?define([],function(){return e}):"undefined"!=typeof module&&module.exports?module.exports=e:this.Favico=e}(); \ No newline at end of file +!function(){var e=function(e){"use strict";function t(e){if(e.paused||e.ended||w)return!1;try{d.clearRect(0,0,h,s),d.drawImage(e,0,0,h,s)}catch(o){}setTimeout(t,U.duration,e),L.setIcon(c)}function o(e){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;e=e.replace(t,function(e,t,o,n){return t+t+o+o+n+n});var o=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return o?{r:parseInt(o[1],16),g:parseInt(o[2],16),b:parseInt(o[3],16)}:!1}function n(e,t){var o,n={};for(o in e)n[o]=e[o];for(o in t)n[o]=t[o];return n}function r(){return document.hidden||document.msHidden||document.webkitHidden||document.mozHidden}e=e?e:{};var i,a,s,h,c,d,f,l,u,g,y,w,x,m={bgColor:"#d00",textColor:"#fff",fontFamily:"sans-serif",fontStyle:"bold",type:"circle",position:"down",animation:"slide",elementId:!1};x={},x.ff=/firefox/i.test(navigator.userAgent.toLowerCase()),x.chrome=/chrome/i.test(navigator.userAgent.toLowerCase()),x.opera=/opera/i.test(navigator.userAgent.toLowerCase()),x.ie=/msie/i.test(navigator.userAgent.toLowerCase())||/trident/i.test(navigator.userAgent.toLowerCase()),x.supported=x.chrome||x.ff||x.opera;var p=[];y=function(){},l=w=!1;var v=function(){i=n(m,e),i.bgColor=o(i.bgColor),i.textColor=o(i.textColor),i.position=i.position.toLowerCase(),i.animation=U.types[""+i.animation]?i.animation:m.animation;var t=i.position.indexOf("up")>-1,r=i.position.indexOf("left")>-1;if(t||r)for(var l=0;l0?f.height:32,h=f.width>0?f.width:32,c.height=s,c.width=h,d=c.getContext("2d"),b.ready()}):(f.setAttribute("src",""),s=32,h=32,f.height=s,f.width=h,c.height=s,c.width=h,d=c.getContext("2d"),b.ready())}catch(g){throw"Error initializing favico. Message: "+g.message}},b={};b.ready=function(){l=!0,b.reset(),y()},b.reset=function(){p=[],u=!1,d.clearRect(0,0,h,s),d.drawImage(f,0,0,h,s),L.setIcon(c)},b.start=function(){if(l&&!g){var e=function(){u=p[0],g=!1,p.length>0&&(p.shift(),b.start())};p.length>0&&(g=!0,u?U.run(u.options,function(){U.run(p[0].options,function(){e()},!1)},!0):U.run(p[0].options,function(){e()},!1))}};var C={},M=function(e){return e.n=Math.abs(e.n),e.x=h*e.x,e.y=s*e.y,e.w=h*e.w,e.h=s*e.h,e};C.circle=function(e){e=M(e);var t=!1;e.n>9&&e.n<100?(e.x=e.x-.4*e.w,e.w=1.4*e.w,t=!0):e.n>=100&&(e.x=e.x-.65*e.w,e.w=1.65*e.w,t=!0),d.clearRect(0,0,h,s),d.drawImage(f,0,0,h,s),d.beginPath(),d.font=i.fontStyle+" "+Math.floor(e.h*(e.n>99?.85:1))+"px "+i.fontFamily,d.textAlign="center",t?(d.moveTo(e.x+e.w/2,e.y),d.lineTo(e.x+e.w-e.h/2,e.y),d.quadraticCurveTo(e.x+e.w,e.y,e.x+e.w,e.y+e.h/2),d.lineTo(e.x+e.w,e.y+e.h-e.h/2),d.quadraticCurveTo(e.x+e.w,e.y+e.h,e.x+e.w-e.h/2,e.y+e.h),d.lineTo(e.x+e.h/2,e.y+e.h),d.quadraticCurveTo(e.x,e.y+e.h,e.x,e.y+e.h-e.h/2),d.lineTo(e.x,e.y+e.h/2),d.quadraticCurveTo(e.x,e.y,e.x+e.h/2,e.y)):d.arc(e.x+e.w/2,e.y+e.h/2,e.h/2,0,2*Math.PI),d.fillStyle="rgba("+i.bgColor.r+","+i.bgColor.g+","+i.bgColor.b+","+e.o+")",d.fill(),d.closePath(),d.beginPath(),d.stroke(),d.fillStyle="rgba("+i.textColor.r+","+i.textColor.g+","+i.textColor.b+","+e.o+")",e.n>999?d.fillText((e.n>9999?9:Math.floor(e.n/1e3))+"k+",Math.floor(e.x+e.w/2),Math.floor(e.y+e.h-.2*e.h)):d.fillText(e.n,Math.floor(e.x+e.w/2),Math.floor(e.y+e.h-.15*e.h)),d.closePath()},C.rectangle=function(e){e=M(e);var t=!1;e.n>9&&e.n<100?(e.x=e.x-.4*e.w,e.w=1.4*e.w,t=!0):e.n>=100&&(e.x=e.x-.65*e.w,e.w=1.65*e.w,t=!0),d.clearRect(0,0,h,s),d.drawImage(f,0,0,h,s),d.beginPath(),d.font="bold "+Math.floor(e.h*(e.n>99?.9:1))+"px sans-serif",d.textAlign="center",d.fillStyle="rgba("+i.bgColor.r+","+i.bgColor.g+","+i.bgColor.b+","+e.o+")",d.fillRect(e.x,e.y,e.w,e.h),d.fillStyle="rgba("+i.textColor.r+","+i.textColor.g+","+i.textColor.b+","+e.o+")",e.n>999?d.fillText((e.n>9999?9:Math.floor(e.n/1e3))+"k+",Math.floor(e.x+e.w/2),Math.floor(e.y+e.h-.2*e.h)):d.fillText(e.n,Math.floor(e.x+e.w/2),Math.floor(e.y+e.h-.15*e.h)),d.closePath()};var I=function(e,t){y=function(){try{if(e>0){if(U.types[""+t]&&(i.animation=t),p.push({type:"badge",options:{n:e}}),p.length>100)throw"Too many badges requests in queue.";b.start()}else b.reset()}catch(o){throw"Error setting badge. Message: "+o.message}},l&&y()},A=function(e){y=function(){try{var t=e.width,o=e.height,n=document.createElement("img"),r=o/s>t/h?t/h:o/s;n.setAttribute("src",e.getAttribute("src")),n.height=o/r,n.width=t/r,d.clearRect(0,0,h,s),d.drawImage(n,0,0,h,s),L.setIcon(c)}catch(i){throw"Error setting image. Message: "+i.message}},l&&y()},E=function(e){y=function(){try{if("stop"===e)return w=!0,b.reset(),w=!1,void 0;e.addEventListener("play",function(){t(this)},!1)}catch(o){throw"Error setting video. Message: "+o.message}},l&&y()},T=function(e){if(window.URL&&window.URL.createObjectURL||(window.URL=window.URL||{},window.URL.createObjectURL=function(e){return e}),x.supported){var o=!1;navigator.getUserMedia=navigator.getUserMedia||navigator.oGetUserMedia||navigator.msGetUserMedia||navigator.mozGetUserMedia||navigator.webkitGetUserMedia,y=function(){try{if("stop"===e)return w=!0,b.reset(),w=!1,void 0;o=document.createElement("video"),o.width=h,o.height=s,navigator.getUserMedia({video:!0,audio:!1},function(e){o.src=URL.createObjectURL(e),o.play(),t(o)},function(){})}catch(n){throw"Error setting webcam. Message: "+n.message}},l&&y()}},L={};L.getIcon=function(){var e=!1,t="",o=function(){for(var e=document.getElementsByTagName("head")[0].getElementsByTagName("link"),t=e.length,o=t-1;o>=0;o--)if(/icon/i.test(e[o].getAttribute("rel")))return e[o];return!1};if(i.elementId?(e=document.getElementById(i.elementId),e.setAttribute("href",e.getAttribute("src"))):(e=o(),e===!1&&(e=document.createElement("link"),e.setAttribute("rel","icon"),document.getElementsByTagName("head")[0].appendChild(e))),t=i.elementId?e.src:e.href,-1===t.indexOf(document.location.hostname))throw new Error("Error setting favicon. Favicon image is on different domain (Icon: "+t+", Domain: "+document.location.hostname+")");return e.setAttribute("type","image/png"),e},L.setIcon=function(e){var t=e.toDataURL("image/png");if(i.elementId)document.getElementById(i.elementId).setAttribute("src",t);else if(x.ff||x.opera){var o=a;a=document.createElement("link"),x.opera&&a.setAttribute("rel","icon"),a.setAttribute("rel","icon"),a.setAttribute("type","image/png"),document.getElementsByTagName("head")[0].appendChild(a),a.setAttribute("href",t),o.parentNode&&o.parentNode.removeChild(o)}else a.setAttribute("href",t)};var U={};return U.duration=40,U.types={},U.types.fade=[{x:.4,y:.4,w:.6,h:.6,o:0},{x:.4,y:.4,w:.6,h:.6,o:.1},{x:.4,y:.4,w:.6,h:.6,o:.2},{x:.4,y:.4,w:.6,h:.6,o:.3},{x:.4,y:.4,w:.6,h:.6,o:.4},{x:.4,y:.4,w:.6,h:.6,o:.5},{x:.4,y:.4,w:.6,h:.6,o:.6},{x:.4,y:.4,w:.6,h:.6,o:.7},{x:.4,y:.4,w:.6,h:.6,o:.8},{x:.4,y:.4,w:.6,h:.6,o:.9},{x:.4,y:.4,w:.6,h:.6,o:1}],U.types.none=[{x:.4,y:.4,w:.6,h:.6,o:1}],U.types.pop=[{x:1,y:1,w:0,h:0,o:1},{x:.9,y:.9,w:.1,h:.1,o:1},{x:.8,y:.8,w:.2,h:.2,o:1},{x:.7,y:.7,w:.3,h:.3,o:1},{x:.6,y:.6,w:.4,h:.4,o:1},{x:.5,y:.5,w:.5,h:.5,o:1},{x:.4,y:.4,w:.6,h:.6,o:1}],U.types.popFade=[{x:.75,y:.75,w:0,h:0,o:0},{x:.65,y:.65,w:.1,h:.1,o:.2},{x:.6,y:.6,w:.2,h:.2,o:.4},{x:.55,y:.55,w:.3,h:.3,o:.6},{x:.5,y:.5,w:.4,h:.4,o:.8},{x:.45,y:.45,w:.5,h:.5,o:.9},{x:.4,y:.4,w:.6,h:.6,o:1}],U.types.slide=[{x:.4,y:1,w:.6,h:.6,o:1},{x:.4,y:.9,w:.6,h:.6,o:1},{x:.4,y:.9,w:.6,h:.6,o:1},{x:.4,y:.8,w:.6,h:.6,o:1},{x:.4,y:.7,w:.6,h:.6,o:1},{x:.4,y:.6,w:.6,h:.6,o:1},{x:.4,y:.5,w:.6,h:.6,o:1},{x:.4,y:.4,w:.6,h:.6,o:1}],U.run=function(e,t,o,a){var s=U.types[r()?"none":i.animation];return a=o===!0?"undefined"!=typeof a?a:s.length-1:"undefined"!=typeof a?a:0,t=t?t:function(){},a=0?(C[i.type](n(e,s[a])),setTimeout(function(){o?a-=1:a+=1,U.run(e,t,o,a)},U.duration),L.setIcon(c),void 0):(t(),void 0)},v(),{badge:I,video:E,image:A,webcam:T,reset:b.reset}};"undefined"!=typeof define&&define.amd?define([],function(){return e}):"undefined"!=typeof module&&module.exports?module.exports=e:this.Favico=e}(); diff --git a/tahrir/static/js/thingiview/binaryReader.js b/tahrir/static/js/thingiview/binaryReader.js index f99a2379..76ea1161 100644 --- a/tahrir/static/js/thingiview/binaryReader.js +++ b/tahrir/static/js/thingiview/binaryReader.js @@ -24,7 +24,7 @@ BinaryReader.prototype = { readFloat: function (){ return this._decodeFloat(23, 8); }, readDouble: function (){ return this._decodeFloat(52, 11); }, - + readChar: function () { return this.readString(1); }, readString: function (length) { this._checkSize(length * 8); @@ -37,18 +37,18 @@ BinaryReader.prototype = { this._pos = pos; this._checkSize(0); }, - + getPosition: function () { return this._pos; }, - + getSize: function () { return this._buffer.length; }, /* Private */ - + _decodeFloat: function(precisionBits, exponentBits){ var length = precisionBits + exponentBits + 1; var size = length >> 3; @@ -93,7 +93,7 @@ BinaryReader.prototype = { for (++b; --b; a = ((a %= 0x7fffffff + 1) & 0x40000000) == 0x40000000 ? a * 2 : (a - 0x40000000) * 2 + 0x7fffffff + 1); return a; }, - + _readByte: function (i, size) { return this._buffer.charCodeAt(this._pos + size - i - 1) & 0xff; }, @@ -108,7 +108,7 @@ BinaryReader.prototype = { var sum = (this._readByte(curByte, size) >> offsetRight) & ((1 << (diff ? 8 - offsetRight : length)) - 1); if (diff && offsetLeft) { - sum += (this._readByte(lastByte++, size) & ((1 << offsetLeft) - 1)) << (diff-- << 3) - offsetRight; + sum += (this._readByte(lastByte++, size) & ((1 << offsetLeft) - 1)) << (diff-- << 3) - offsetRight; } while (diff) { @@ -123,4 +123,4 @@ BinaryReader.prototype = { throw new Error("Index out of bound"); } } -}; \ No newline at end of file +}; diff --git a/tahrir/static/js/thingiview/thingiloader.js b/tahrir/static/js/thingiview/thingiloader.js index 3791a49c..12986a17 100644 --- a/tahrir/static/js/thingiview/thingiloader.js +++ b/tahrir/static/js/thingiview/thingiloader.js @@ -29,7 +29,7 @@ Thingiloader = function(event) { return reader.getSize() == predictedSize; }; - workerFacadeMessage({'status':'message', 'content':'Downloading ' + url}); + workerFacadeMessage({'status':'message', 'content':'Downloading ' + url}); var file = this.load_binary_resource(url); var reader = new BinaryReader(file); @@ -41,7 +41,7 @@ Thingiloader = function(event) { }; this.loadOBJ = function(url) { - workerFacadeMessage({'status':'message', 'content':'Downloading ' + url}); + workerFacadeMessage({'status':'message', 'content':'Downloading ' + url}); var file = this.load_binary_resource(url); this.loadOBJString(file); }; @@ -51,12 +51,12 @@ Thingiloader = function(event) { var file = this.load_binary_resource(url); this.loadJSONString(file); }; - + this.loadPLY = function(url) { - workerFacadeMessage({'status':'message', 'content':'Downloading ' + url}); - + workerFacadeMessage({'status':'message', 'content':'Downloading ' + url}); + var file = this.load_binary_resource(url); - + if (file.match(/format ascii/i)) { this.loadPLYString(file); } else { @@ -65,7 +65,7 @@ Thingiloader = function(event) { }; this.loadSTLString = function(STLString) { - workerFacadeMessage({'status':'message', 'content':'Parsing STL String...'}); + workerFacadeMessage({'status':'message', 'content':'Parsing STL String...'}); workerFacadeMessage({'status':'complete', 'content':this.ParseSTLString(STLString)}); }; @@ -83,14 +83,14 @@ Thingiloader = function(event) { workerFacadeMessage({'status':'message', 'content':'Parsing JSON String...'}); workerFacadeMessage({'status':'complete', 'content':eval(JSONString)}); }; - + this.loadPLYString = function(PLYString) { - workerFacadeMessage({'status':'message', 'content':'Parsing PLY String...'}); + workerFacadeMessage({'status':'message', 'content':'Parsing PLY String...'}); workerFacadeMessage({'status':'complete_points', 'content':this.ParsePLYString(PLYString)}); }; this.loadPLYBinary = function(PLYBinary) { - workerFacadeMessage({'status':'message', 'content':'Parsing PLY Binary...'}); + workerFacadeMessage({'status':'message', 'content':'Parsing PLY Binary...'}); workerFacadeMessage({'status':'complete_points', 'content':this.ParsePLYBinary(PLYBinary)}); }; @@ -100,15 +100,15 @@ Thingiloader = function(event) { var colors = []; var vertex_count = 0; - + var header = /ply\n([\s\S]+)\nend_header/ig.exec(input)[1]; var data = /end_header\n([\s\S]+)$/ig.exec(input)[1]; - - // workerFacadeMessage({'status':'message', 'content':'header:\n' + header}); - // workerFacadeMessage({'status':'message', 'content':'data:\n' + data}); + + // workerFacadeMessage({'status':'message', 'content':'header:\n' + header}); + // workerFacadeMessage({'status':'message', 'content':'data:\n' + data}); header_parts = header.split("\n"); - + for (i in header_parts) { if (/element vertex/i.test(header_parts[i])) { vertex_count = /element vertex (\d+)/i.exec(header_parts[i])[1]; @@ -116,25 +116,25 @@ Thingiloader = function(event) { properties.push(/property (.*) (.*)/i.exec(header_parts[i])[2]); } } - + // workerFacadeMessage({'status':'message', 'content':'properties: ' + properties}); data_parts = data.split("\n"); - + for (i in data_parts) { data_line = data_parts[i]; data_line_parts = data_line.split(" "); - + vertices.push([ - parseFloat(data_line_parts[properties.indexOf("x")]), - parseFloat(data_line_parts[properties.indexOf("y")]), - parseFloat(data_line_parts[properties.indexOf("z")]) + parseFloat(data_line_parts[properties.indexOf("x")]), + parseFloat(data_line_parts[properties.indexOf("y")]), + parseFloat(data_line_parts[properties.indexOf("z")]) ]); - - colors.push([ - parseInt(data_line_parts[properties.indexOf("red")]), - parseInt(data_line_parts[properties.indexOf("green")]), - parseInt(data_line_parts[properties.indexOf("blue")]) + + colors.push([ + parseInt(data_line_parts[properties.indexOf("red")]), + parseInt(data_line_parts[properties.indexOf("green")]), + parseInt(data_line_parts[properties.indexOf("blue")]) ]); } @@ -171,14 +171,14 @@ Thingiloader = function(event) { 'content':parseInt(i / count * 100) + '%' }); } - + // Skip the normal (3 single-precision floats) input.seek(input.getPosition() + 12); var face_indices = []; for (var x = 0; x < 3; x++) { var vertex = [input.readFloat(), input.readFloat(), input.readFloat()]; - + var vertexIndex = vert_hash[vertex]; if (vertexIndex == null) { vertexIndex = vertices.length; @@ -189,7 +189,7 @@ Thingiloader = function(event) { face_indices.push(vertexIndex); } faces.push(face_indices); - + // Skip the "attribute" field (unused in common models) input.readUInt16(); } @@ -201,7 +201,7 @@ Thingiloader = function(event) { this.ParseSTLString = function(STLString) { var vertexes = []; var faces = []; - + var face_vertexes = []; var vert_hash = {} @@ -212,7 +212,7 @@ Thingiloader = function(event) { STLString = STLString.replace(/^solid[^\n]*/, ""); STLString = STLString.replace(/\n/g, " "); STLString = STLString.replace(/facet normal /g,""); - STLString = STLString.replace(/outer loop/g,""); + STLString = STLString.replace(/outer loop/g,""); STLString = STLString.replace(/vertex /g,""); STLString = STLString.replace(/endloop/g,""); STLString = STLString.replace(/endfacet/g,""); @@ -232,7 +232,7 @@ Thingiloader = function(event) { if ((i % 100) == 0) { workerFacadeMessage({'status':'progress', 'content':parseInt(i / (points.length/12-1) * 100) + '%'}); } - + var face_indices = []; for (var x=0; x<3; x++) { var vertex = [parseFloat(points[block_start+x*3+3]), parseFloat(points[block_start+x*3+4]), parseFloat(points[block_start+x*3+5])]; @@ -247,7 +247,7 @@ Thingiloader = function(event) { face_indices.push(vertexIndex); } faces.push(face_indices); - + block_start = block_start + 12; } @@ -259,21 +259,21 @@ Thingiloader = function(event) { var faces = []; var lines = OBJString.split("\n"); - + // var normal_position = 0; - + for (var i=0; i 0) { factor = 0; @@ -488,7 +488,7 @@ Thingiview = function(containerId) { factor = 0; } } - + if (cameraView == 'top') { camera.position.z -= factor; } else if (cameraView == 'bottom') { @@ -516,7 +516,7 @@ Thingiview = function(containerId) { this.setBackgroundColor = function(color) { backgroundColor = color - + if (renderer) { renderer.domElement.style.backgroundColor = color; } @@ -524,7 +524,7 @@ Thingiview = function(containerId) { this.setObjectColor = function(color) { objectColor = parseInt(color.replace(/\#/g, ''), 16); - + loadObjectGeometry(); } @@ -535,15 +535,15 @@ Thingiview = function(containerId) { this.loadOBJ = function(url) { scope.newWorker('loadOBJ', url); } - + this.loadSTLString = function(STLString) { scope.newWorker('loadSTLString', STLString); } - + this.loadSTLBinary = function(STLBinary) { scope.newWorker('loadSTLBinary', STLBinary); } - + this.loadOBJString = function(OBJString) { scope.newWorker('loadOBJString', OBJString); } @@ -555,7 +555,7 @@ Thingiview = function(containerId) { this.loadPLY = function(url) { scope.newWorker('loadPLY', url); } - + this.loadPLYString = function(PLYString) { scope.newWorker('loadPLYString', PLYString); } @@ -614,9 +614,9 @@ Thingiview = function(containerId) { this.newWorker = function(cmd, param) { scope.setRotation(false); - + var worker = new WorkerFacade(thingiurlbase + '/thingiloader.js'); - + worker.onmessage = function(event) { if (event.data.status == "complete") { progressBar.innerHTML = 'Initializing geometry...'; @@ -639,7 +639,7 @@ Thingiview = function(containerId) { // material = new THREE.ParticleBasicMaterial( { size: 35, sizeAttenuation: false} ); // material.color.setHSV( 1.0, 0.2, 0.8 ); - + for (i in event.data.content[0]) { // for (var i=0; i<10; i++) { vector = new THREE.Vector3( event.data.content[0][i][0], event.data.content[0][i][1], event.data.content[0][i][2] ); @@ -650,10 +650,10 @@ Thingiview = function(containerId) { particles.sortParticles = true; particles.updateMatrix(); scene.addObject( particles ); - + camera.updateMatrix(); renderer.render(scene, camera); - + progressBar.innerHTML = ''; progressBar.style.display = 'none'; @@ -687,10 +687,10 @@ Thingiview = function(containerId) { this.displayAlert = function(msg) { msg = msg + "

" - + alertBox.innerHTML = msg; alertBox.style.display = 'block'; - + // log(msg); } @@ -717,12 +717,12 @@ Thingiview = function(containerId) { } } - // scene.removeObject(object); + // scene.removeObject(object); if (object) { // shouldn't be needed, but this fixes a bug with webgl not removing previous object when loading a new one dynamically object.materials = [new THREE.MeshBasicMaterial({color:0xffffff, opacity:0})]; - scene.removeObject(object); + scene.removeObject(object); // object.geometry = geometry; // object.materials = [material]; } @@ -734,9 +734,9 @@ Thingiview = function(containerId) { object.overdraw = true; object.doubleSided = true; } - + object.updateMatrix(); - + targetXRotation = 0; targetYRotation = 0; @@ -757,7 +757,7 @@ var STLGeometry = function(stlArray) { // var normals = stlArray[1]; // var faces = stlArray[2]; - for (var i=0; i