From d1c4a1a2d6724a457e44254715705e34386c158e Mon Sep 17 00:00:00 2001 From: Joshua Smith Date: Sat, 20 Sep 2014 17:56:30 -0400 Subject: [PATCH 01/84] 0.3.3 -> 0.4, update Bugsense --- index.html | 2 +- locales/en-US/app.properties | 1 + manifest.webapp | 2 +- scripts/cloud/cloud.js | 31 - scripts/firetext.js | 91 +- scripts/io.js | 2 +- scripts/lib/bugsense.js | 1524 ---------------------------------- scripts/lib/bugsense.min.js | 1 + scripts/settings.js | 11 +- 9 files changed, 58 insertions(+), 1607 deletions(-) delete mode 100644 scripts/lib/bugsense.js create mode 100644 scripts/lib/bugsense.min.js diff --git a/index.html b/index.html index ab3d7c1..7c29881 100755 --- a/index.html +++ b/index.html @@ -36,7 +36,7 @@ - + diff --git a/locales/en-US/app.properties b/locales/en-US/app.properties index a9f75ed..f5e1424 100644 --- a/locales/en-US/app.properties +++ b/locales/en-US/app.properties @@ -58,6 +58,7 @@ list=List load-last-file.innerHTML=Load last file on startup load-unsuccessful=Load unsuccessful.\n\nError details:\n menu=Menu +needs-restart=This setting will be applied after Firetext restarts. Restart now? network-error=Your network appears to be unavailable.\n\nPlease check your connection and try again. no=No no-dropbox-documents-found=No Dropbox documents found diff --git a/manifest.webapp b/manifest.webapp index 3ac2646..1c6b0bd 100644 --- a/manifest.webapp +++ b/manifest.webapp @@ -1,7 +1,7 @@ { "name": "Firetext", "description": "The word processor for Firefox OS", - "version": "0.3.3", + "version": "0.4", "type": "privileged", "launch_path": "/index.html", "developer": { diff --git a/scripts/cloud/cloud.js b/scripts/cloud/cloud.js index 4ad5442..f2efec8 100644 --- a/scripts/cloud/cloud.js +++ b/scripts/cloud/cloud.js @@ -89,37 +89,6 @@ cloud.init = function () { } } - /* 0.4 - // Google Drive - if (firetext.settings.get('gdrive.enabled') == 'true') { - // Code to get Google Drive files - updateDocLists(); - - // Show UI Elements - welcomeGoogleArea.style.display = 'block'; - openDialogGoogleArea.style.display = 'block'; - locationGoogle = document.createElement('option'); - locationGoogle.textContent = 'Google Drive'; - locationSelect.appendChild(locationGoogle); - } else { - // Hide/Remove UI elements - welcomeGoogleArea.style.display = 'none'; - openDialogGoogleArea.style.display = 'none'; - if (locationGoogle) { - locationSelect.removeChild(locationGoogle); - locationGoogle = undefined; - } - - // Remove Google recents - var driveRecents = firetext.recents.get(); - for (var i = 0; i < driveRecents.length; i++) { - if (driveRecents[i][4] == 'gdrive') { - firetext.recents.remove([driveRecents[i][0], driveRecents[i][1], driveRecents[i][2]], driveRecents[i][3], driveRecents[i][4]); - } - } - } - */ - updateAddDialog(); }; diff --git a/scripts/firetext.js b/scripts/firetext.js index be5ed4e..28fc760 100644 --- a/scripts/firetext.js +++ b/scripts/firetext.js @@ -22,11 +22,11 @@ firetext.isInitialized = false; var html = document.getElementsByTagName('html')[0], head = document.getElementsByTagName("head")[0]; var themeColor = document.getElementById("theme-color"); var loadSpinner, editor, toolbar, toolbarInterval, editWindow, editState, rawEditor, tabRaw, tabDesign; -var deviceType, fileChanged, saveTimeout, saving, tempAutozen, urls={}, version = '0.3.3'; +var deviceType, fileChanged, saveTimeout, saving, tempAutozen, urls={}, version = '0.4'; var bold, boldCheckbox, italic, italicCheckbox, justifySelect, strikethrough, strikethroughCheckbox; var underline, underlineCheckbox; var locationLegend, locationSelect, locationDevice, locationDropbox; -var bugsense, bugsenseKey = ''; +var bugsenseInitialized = false, bugsenseKey = ''; var editorMessageProxy; // Lists @@ -47,11 +47,6 @@ firetext.init = function () { // Initialize l10n navigator.mozL10n.once(function () { - - // Initialize urls - getURLs(function(){ - fixMenu(); - }); // Initialize Settings firetext.settings.init(); @@ -136,53 +131,59 @@ firetext.init = function () { editDocs(); } ); - - // Initialize IO - firetext.io.init(null, function() { - // Update Doc Lists - updateDocLists(); + + + // Initialize urls + getURLs(function(){ + fixMenu(); + + // Initialize IO + firetext.io.init(null, function() { + // Update Doc Lists + updateDocLists(); - // Initialize sharing - cloud.init(); + // Initialize sharing + cloud.init(); - // Check for recent file, and if found, load it. - if (firetext.settings.get('autoload') == 'true') { - var lastDoc = [firetext.settings.get('autoload.dir'), firetext.settings.get('autoload.name'), firetext.settings.get('autoload.ext'), firetext.settings.get('autoload.loc')]; - var wasEditing = firetext.settings.get('autoload.wasEditing'); + // Check for recent file, and if found, load it. + if (firetext.settings.get('autoload') == 'true') { + var lastDoc = [firetext.settings.get('autoload.dir'), firetext.settings.get('autoload.name'), firetext.settings.get('autoload.ext'), firetext.settings.get('autoload.loc')]; + var wasEditing = firetext.settings.get('autoload.wasEditing'); - // Navigate to welcome region - regions.nav('welcome'); + // Navigate to welcome region + regions.nav('welcome'); - // Load file - if (wasEditing == 'true') { - // Wait until Dropbox is authenticated - if (lastDoc[3] == 'dropbox') { - if (firetext.settings.get('dropbox.enabled') == 'true') { - window.addEventListener('cloud.dropbox.authed', function() { + // Load file + if (wasEditing == 'true') { + // Wait until Dropbox is authenticated + if (lastDoc[3] == 'dropbox') { + if (firetext.settings.get('dropbox.enabled') == 'true') { + window.addEventListener('cloud.dropbox.authed', function() { + spinner('hide'); + loadToEditor(lastDoc[0], lastDoc[1], lastDoc[2], lastDoc[3]); + }); + } else { spinner('hide'); - loadToEditor(lastDoc[0], lastDoc[1], lastDoc[2], lastDoc[3]); - }); + } } else { spinner('hide'); + loadToEditor(lastDoc[0], lastDoc[1], lastDoc[2], lastDoc[3]); } } else { spinner('hide'); - loadToEditor(lastDoc[0], lastDoc[1], lastDoc[2], lastDoc[3]); } } else { - spinner('hide'); + spinner('hide'); + regions.nav('welcome'); } - } else { - spinner('hide'); - regions.nav('welcome'); - } - // Night - night(); + // Night + night(); - // Dispatch init event - window.dispatchEvent(firetext.initialized); - firetext.isInitialized = true; + // Dispatch init event + window.dispatchEvent(firetext.initialized); + firetext.isInitialized = true; + }); }); }); @@ -278,14 +279,10 @@ function updateAddDialog() { ------------------------*/ function bugsenseInit() { if (bugsenseKey) { - if (firetext.settings.get('stats.enabled') != 'false') { - bugsense = new Bugsense({ appversion: version, apiKey: bugsenseKey }); - } else { - bugsense = null; - } - } else { - if (firetext.settings.get('stats.enabled') != 'false') { - firetext.settings.save('stats.enabled','false'); + if (firetext.settings.get('stats.enabled') != 'false' && + !bugsenseInitialized) { + Bugsense.initAndStartSession({ appname: 'Firetext', appVersion: version, apiKey: bugsenseKey }); + bugsenseInitialized = true; } } } diff --git a/scripts/io.js b/scripts/io.js index 1f26504..862b0c5 100644 --- a/scripts/io.js +++ b/scripts/io.js @@ -480,7 +480,7 @@ firetext.io.save = function (directory, filename, filetype, contentBlob, showBan // Save file if (deviceAPI == 'deviceStorage') { - var req = storage.addNamed(contentBlob, filePath); + var req = storage.addNamed(contentBlob, filePath); req.onsuccess = function () { // Show banner or hide spinner if (showBanner) { diff --git a/scripts/lib/bugsense.js b/scripts/lib/bugsense.js deleted file mode 100644 index be2cbdb..0000000 --- a/scripts/lib/bugsense.js +++ /dev/null @@ -1,1524 +0,0 @@ -/*! - * Bowser - a browser detector - * https://github.com/ded/bowser - * MIT License | (c) Dustin Diaz 2013 - */ - -!function (name, definition) { - if (typeof define == 'function') define(definition) - else if (typeof module != 'undefined' && module.exports) module.exports['browser'] = definition() - else this[name] = definition() -}('bowser', function () { - /** - * navigator.userAgent => - * Chrome: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.57 Safari/534.24" - * Opera: "Opera/9.80 (Macintosh; Intel Mac OS X 10.6.7; U; en) Presto/2.7.62 Version/11.01" - * Safari: "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-us) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1" - * IE: "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)" - * IE>=11: "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; Media Center PC 6.0; rv:11.0) like Gecko" - * Firefox: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0) Gecko/20100101 Firefox/4.0" - * iPhone: "Mozilla/5.0 (iPhone Simulator; U; CPU iPhone OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5" - * iPad: "Mozilla/5.0 (iPad; U; CPU OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5", - * Android: "Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; T-Mobile G2 Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1" - * Touchpad: "Mozilla/5.0 (hp-tabled;Linux;hpwOS/3.0.5; U; en-US)) AppleWebKit/534.6 (KHTML, like Gecko) wOSBrowser/234.83 Safari/534.6 TouchPad/1.0" - * PhantomJS: "Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.5.0 Safari/534.34" - */ - - var ua = navigator.userAgent - , t = true - , ie = /(msie|trident)/i.test(ua) - , chrome = /chrome|crios/i.test(ua) - , phantom = /phantom/i.test(ua) - , safari = /safari/i.test(ua) && !chrome && !phantom - , iphone = /iphone/i.test(ua) - , ipad = /ipad/i.test(ua) - , touchpad = /touchpad/i.test(ua) - , android = /android/i.test(ua) - , opera = /opera/i.test(ua) || /opr/i.test(ua) - , firefox = /firefox/i.test(ua) - , gecko = /gecko\//i.test(ua) - , seamonkey = /seamonkey\//i.test(ua) - , webkitVersion = /version\/(\d+(\.\d+)?)/i - , firefoxVersion = /firefox\/(\d+(\.\d+)?)/i - , o - - function detect() { - - if (ie) return { - name: 'Internet Explorer' - , msie: t - , version: ua.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2] - } - if (opera) return { - name: 'Opera' - , opera: t - , version: ua.match(webkitVersion) ? ua.match(webkitVersion)[1] : ua.match(/opr\/(\d+(\.\d+)?)/i)[1] - } - if (chrome) return { - name: 'Chrome' - , webkit: t - , chrome: t - , version: ua.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i)[1] - } - if (phantom) return { - name: 'PhantomJS' - , webkit: t - , phantom: t - , version: ua.match(/phantomjs\/(\d+(\.\d+)+)/i)[1] - } - if (touchpad) return { - name: 'TouchPad' - , webkit: t - , touchpad: t - , version : ua.match(/touchpad\/(\d+(\.\d+)?)/i)[1] - } - if (iphone || ipad) { - o = { - name : iphone ? 'iPhone' : 'iPad' - , webkit: t - , mobile: t - , ios: t - , iphone: iphone - , ipad: ipad - } - // WTF: version is not part of user agent in web apps - if (webkitVersion.test(ua)) { - o.version = ua.match(webkitVersion)[1] - } - return o - } - if (android) return { - name: 'Android' - , webkit: t - , android: t - , mobile: t - , version: (ua.match(webkitVersion) || ua.match(firefoxVersion))[1] - } - if (safari) return { - name: 'Safari' - , webkit: t - , safari: t - , version: ua.match(webkitVersion)[1] - } - if (gecko) { - o = { - name: 'Gecko' - , gecko: t - , mozilla: t - , version: ua.match(firefoxVersion)[1] - } - if (firefox) { - o.name = 'Firefox'; - o.firefox = t; - } - return o - } - if (seamonkey) return { - name: 'SeaMonkey' - , seamonkey: t - , version: ua.match(/seamonkey\/(\d+(\.\d+)?)/i)[1] - } - return {} - } - - var bowser = detect() - - // Graded Browser Support - // http://developer.yahoo.com/yui/articles/gbs - if ((bowser.msie && bowser.version >= 8) || - (bowser.chrome && bowser.version >= 10) || - (bowser.firefox && bowser.version >= 4.0) || - (bowser.safari && bowser.version >= 5) || - (bowser.opera && bowser.version >= 10.0)) { - bowser.a = t; - } - - else if ((bowser.msie && bowser.version < 8) || - (bowser.chrome && bowser.version < 10) || - (bowser.firefox && bowser.version < 4.0) || - (bowser.safari && bowser.version < 5) || - (bowser.opera && bowser.version < 10.0)) { - bowser.c = t - } else bowser.x = t - - return bowser -}); - -"use strict"; -/* - * Bugsense JavaScript SDK v1.1.1 - * http://bugsense.com/ - * - * Copyright 2013 Splunk Inc. - * - */ - -var extend = function(obj) { - each(slice.call(arguments, 1), function(source) { - if (source) { - for (var prop in source) { - obj[prop] = source[prop]; - } - } - }); - return obj; -} -var _has = function(object, key) { - return Object.prototype.hasOwnProperty.call(object, key); -} - -// BEGIN - Extracted from Zepto -var escape = encodeURIComponent; - -Object.keys = Object.keys || function(o) { - var result = []; - for(var name in o) { - if (o.hasOwnProperty(name)) - result.push(name); - } - return result; -}; - -var isObject = function isObject ( instance ) { - return instance instanceof Object; -}; -var array = [] - -var slice = array.slice; - -var isArray = function isArray ( instance ) { - return instance instanceof Array; -}; - -var isValidKeyValue = function isValidKeyValue ( instance ) { - return ( typeof(instance) == 'string' || typeof(instance) == 'number' || typeof(instance) == 'boolean' ); -}; - -/** - * Simple forEach, implements jQuery/Zepto api, sort of, and most likely breaks with arrays: LOL - * @param {Object} obj To be iterated - * @param {Object} iterator Iterator function - */ -var forEach = function forEach ( obj, iterator ) { - Array.prototype.forEach.call( Object.keys( obj ), function ( key ) { - iterator( key, obj[ key ] ); - } ); -}; - -var each = function(obj, iterator, context) { - if (obj == null) return; - var nativeForEach = Array.prototype.forEach; - if (nativeForEach && obj.forEach === nativeForEach) { - obj.forEach(iterator, context); - } else if (obj.length === +obj.length) { - for (var i = 0, length = obj.length; i < length; i++) { - if (iterator.call(context, obj[i], i, obj) === breaker) return; - } - } else { - var keys = _.keys(obj); - for (var i = 0, length = keys.length; i < length; i++) { - if (iterator.call(context, obj[keys[i]], keys[i], obj) === breaker) return; - } - } -}; - -var serialize = function serialize ( params, obj, traditional, scope ) { - var array = isArray( obj ); - - forEach( obj, function ( key, value ) { - if ( scope ) { key = traditional ? scope : scope + '[' + (array ? '' : key) + ']'; } - - // handle data in serializeArray() format - if ( !scope && array ) { - params.add( value.name, value.value ); - // recurse into nested objects - } else if ( traditional ? isArray( value ) : isObject( value ) ) { - serialize( params, value, traditional, key ); - } else { - params.add( key, value ); - } - }); -}; - -var param = function param ( obj, traditional ) { - var params = []; - params.add = function( k, v ){ this.push( escape( k ) + '=' + escape( v ) ); }; - serialize( params, obj, traditional ); - // return params.join( '&' ).replace( /%20/g, '+' ); - return params.join( '&' ); -}; - // END - Extracted from Zepto - -var guid_generator = function GUIDGenerator() { - var S4 = function () { - return Math.floor( - Math.random() * 0x10000 /* 65536 */ - ).toString(16); - }; - return ( - S4() + S4() + "-" + - S4() + "-" + - S4() + "-" + - S4() + "-" + - S4() + S4() + S4() - ); -} - -// Extracted from Backbone; -// Regular expression used to split event strings. -var eventSplitter = /\s+/; - -// Implement fancy features of the Events API such as multiple event -// names `"change blur"` and jQuery-style event maps `{change: action}` -// in terms of the existing API. -var eventsApi = function(obj, action, name, rest) { - if (!name) return true; - - // Handle event maps. - if (typeof name === 'object') { - for (var key in name) { - obj[action].apply(obj, [key, name[key]].concat(rest)); - } - return false; - } - - // Handle space separated event names. - if (eventSplitter.test(name)) { - var names = name.split(eventSplitter); - for (var i = 0, l = names.length; i < l; i++) { - obj[action].apply(obj, [names[i]].concat(rest)); - } - return false; - } - - return true; -}; - -// A difficult-to-believe, but optimized internal dispatch function for -// triggering events. Tries to keep the usual cases speedy (most internal -// Backbone events have 3 arguments). -var triggerEvents = function(events, args) { - var ev, i = -1, l = events.length, a1 = args[0], a2 = args[1], a3 = args[2]; - switch (args.length) { - case 0: while (++i < l) (ev = events[i]).callback.call(ev.ctx); return; - case 1: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1); return; - case 2: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2); return; - case 3: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3); return; - default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args); - } -}; -var _once = function(func) { - var ran = false, memo; - return function() { - if (ran) return memo; - ran = true; - memo = func.apply(this, arguments); - func = null; - return memo; - }; -}; - -var TraceKit = { - linesOfContext: 11 -}; -var UNKNOWN_FUNCTION = ''; -TraceKit.computeStackTrace = (function computeStackTraceWrapper() { - var debug = false, - sourceCache = {}; - function loadSource(url) { - try { - var getXHR = function() { - try { - return new window.XMLHttpRequest(); - } catch (e) { - // explicitly bubble up the exception if not found - return new window.ActiveXObject('Microsoft.XMLHTTP'); - } - }; - - var request = getXHR(); - request.open('GET', url, false); - request.send(''); - return request.responseText; - } catch (e) { - return ''; - } - } - - function getSource(url) { - if (!_has(sourceCache, url)) { - // URL needs to be able to fetched within the acceptable domain. Otherwise, - // cross-domain errors will be triggered. - var source = ''; - if (url.indexOf(document.domain) !== -1) { - source = loadSource(url); - } - sourceCache[url] = source ? source.split('\n') : []; - } - - return sourceCache[url]; - } - function guessFunctionName(url, lineNo) { - var reFunctionArgNames = /function ([^(]*)\(([^)]*)\)/, - reGuessFunction = /['"]?([0-9A-Za-z$_]+)['"]?\s*[:=]\s*(function|eval|new Function)/, - line = '', - maxLines = 10, - source = getSource(url), - m; - - if (!source.length) { - return UNKNOWN_FUNCTION; - } - - // Walk backwards from the first line in the function until we find the line which - // matches the pattern above, which is the function definition - for (var i = 0; i < maxLines; ++i) { - line = source[lineNo - i] + line; - - if (line) { - if ((m = reGuessFunction.exec(line))) { - return m[1]; - } else if ((m = reFunctionArgNames.exec(line))) { - return m[1]; - } - } - } - - return UNKNOWN_FUNCTION; - } - function gatherContext(url, line) { - var source = getSource(url); - - if (!source.length) { - return null; - } - - var context = [], - // linesBefore & linesAfter are inclusive with the offending line. - // if linesOfContext is even, there will be one extra line - // *before* the offending line. - linesBefore = Math.floor(TraceKit.linesOfContext / 2), - // Add one extra line if linesOfContext is odd - linesAfter = linesBefore + (TraceKit.linesOfContext % 2), - start = Math.max(0, line - linesBefore - 1), - end = Math.min(source.length, line + linesAfter - 1); - - line -= 1; // convert to 0-based index - - for (var i = start; i < end; ++i) { - if (source[i]) { - context.push(source[i]); - } - } - - return context.length > 0 ? context : null; - } - - function escapeRegExp(text) { - return text.replace(/[\-\[\]{}()*+?.,\\\^$|#]/g, '\\$&'); - } - function escapeCodeAsRegExpForMatchingInsideHTML(body) { - return escapeRegExp(body).replace('<', '(?:<|<)').replace('>', '(?:>|>)').replace('&', '(?:&|&)').replace('"', '(?:"|")').replace(/\s+/g, '\\s+'); - } - function findSourceInUrls(re, urls) { - var source, m; - for (var i = 0, j = urls.length; i < j; ++i) { - // console.log('searching', urls[i]); - if ((source = getSource(urls[i])).length) { - source = source.join('\n'); - if ((m = re.exec(source))) { - // console.log('Found function in ' + urls[i]); - - return { - 'url': urls[i], - 'line': source.substring(0, m.index).split('\n').length, - 'column': m.index - source.lastIndexOf('\n', m.index) - 1 - }; - } - } - } - - // console.log('no match'); - - return null; - } - function findSourceInLine(fragment, url, line) { - var source = getSource(url), - re = new RegExp('\\b' + escapeRegExp(fragment) + '\\b'), - m; - - line -= 1; - - if (source && source.length > line && (m = re.exec(source[line]))) { - return m.index; - } - - return null; - } - function findSourceByFunctionBody(func) { - var urls = [window.location.href], - scripts = document.getElementsByTagName('script'), - body, - code = '' + func, - codeRE = /^function(?:\s+([\w$]+))?\s*\(([\w\s,]*)\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/, - eventRE = /^function on([\w$]+)\s*\(event\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/, - re, - parts, - result; - - for (var i = 0; i < scripts.length; ++i) { - var script = scripts[i]; - if (script.src) { - urls.push(script.src); - } - } - - if (!(parts = codeRE.exec(code))) { - re = new RegExp(escapeRegExp(code).replace(/\s+/g, '\\s+')); - } - - else { - var name = parts[1] ? '\\s+' + parts[1] : '', - args = parts[2].split(',').join('\\s*,\\s*'); - - body = escapeRegExp(parts[3]).replace(/;$/, ';?'); // semicolon is inserted if the function ends with a comment.replace(/\s+/g, '\\s+'); - re = new RegExp('function' + name + '\\s*\\(\\s*' + args + '\\s*\\)\\s*{\\s*' + body + '\\s*}'); - } - - if ((result = findSourceInUrls(re, urls))) { - return result; - } - if ((parts = eventRE.exec(code))) { - var event = parts[1]; - body = escapeCodeAsRegExpForMatchingInsideHTML(parts[2]); - - // look for a function defined in HTML as an onXXX handler - re = new RegExp('on' + event + '=[\\\'"]\\s*' + body + '\\s*[\\\'"]', 'i'); - - if ((result = findSourceInUrls(re, urls[0]))) { - return result; - } - - // look for ??? - re = new RegExp(body); - - if ((result = findSourceInUrls(re, urls))) { - return result; - } - } - - return null; - } - - function computeStackTraceFromStackProp(ex) { - if (!ex.stack) { - return null; - } - - var chrome = /^\s*at (?:((?:\[object object\])?\S+(?: \[as \S+\])?) )?\(?((?:file|http|https):.*?):(\d+)(?::(\d+))?\)?\s*$/i, - gecko = /^\s*(\S*)(?:\((.*?)\))?@((?:file|http|https).*?):(\d+)(?::(\d+))?\s*$/i, - lines = ex.stack.split('\n'), - stack = [], - parts, - element, - reference = /^(.*) is undefined$/.exec(ex.message); - - for (var i = 0, j = lines.length; i < j; ++i) { - if ((parts = gecko.exec(lines[i]))) { - element = { - 'url': parts[3], - 'func': parts[1] || UNKNOWN_FUNCTION, - 'args': parts[2] ? parts[2].split(',') : '', - 'line': +parts[4], - 'column': parts[5] ? +parts[5] : null - }; - } else if ((parts = chrome.exec(lines[i]))) { - element = { - 'url': parts[2], - 'func': parts[1] || UNKNOWN_FUNCTION, - 'line': +parts[3], - 'column': parts[4] ? +parts[4] : null - }; - } else { - continue; - } - - if (!element.func && element.line) { - element.func = guessFunctionName(element.url, element.line); - } - - if (element.line) { - element.context = gatherContext(element.url, element.line); - } - - stack.push(element); - } - - if (stack[0] && stack[0].line && !stack[0].column && reference) { - stack[0].column = findSourceInLine(reference[1], stack[0].url, stack[0].line); - } - - if (!stack.length) { - return null; - } - - return { - 'mode': 'stack', - 'name': ex.name, - 'message': ex.message, - 'url': document.location.href, - 'stack': stack, - 'useragent': navigator.userAgent - }; - } - function computeStackTraceFromStacktraceProp(ex) { - // Access and store the stacktrace property before doing ANYTHING - // else to it because Opera is not very good at providing it - // reliably in other circumstances. - var stacktrace = ex.stacktrace; - - var testRE = / line (\d+), column (\d+) in (?:]+)>|([^\)]+))\((.*)\) in (.*):\s*$/i, - lines = stacktrace.split('\n'), - stack = [], - parts; - - for (var i = 0, j = lines.length; i < j; i += 2) { - if ((parts = testRE.exec(lines[i]))) { - var element = { - 'line': +parts[1], - 'column': +parts[2], - 'func': parts[3] || parts[4], - 'args': parts[5] ? parts[5].split(',') : [], - 'url': parts[6] - }; - - if (!element.func && element.line) { - element.func = guessFunctionName(element.url, element.line); - } - if (element.line) { - try { - element.context = gatherContext(element.url, element.line); - } catch (exc) {} - } - - if (!element.context) { - element.context = [lines[i + 1]]; - } - - stack.push(element); - } - } - - if (!stack.length) { - return null; - } - - return { - 'mode': 'stacktrace', - 'name': ex.name, - 'message': ex.message, - 'url': document.location.href, - 'stack': stack, - 'useragent': navigator.userAgent - }; - } - function computeStackTraceFromOperaMultiLineMessage(ex) { - var lines = ex.message.split('\n'); - if (lines.length < 4) { - return null; - } - - var lineRE1 = /^\s*Line (\d+) of linked script ((?:file|http|https)\S+)(?:: in function (\S+))?\s*$/i, - lineRE2 = /^\s*Line (\d+) of inline#(\d+) script in ((?:file|http|https)\S+)(?:: in function (\S+))?\s*$/i, - lineRE3 = /^\s*Line (\d+) of function script\s*$/i, - stack = [], - scripts = document.getElementsByTagName('script'), - inlineScriptBlocks = [], - parts, - i, - len, - source; - - for (i in scripts) { - if (_has(scripts, i) && !scripts[i].src) { - inlineScriptBlocks.push(scripts[i]); - } - } - - for (i = 2, len = lines.length; i < len; i += 2) { - var item = null; - if ((parts = lineRE1.exec(lines[i]))) { - item = { - 'url': parts[2], - 'func': parts[3], - 'line': +parts[1] - }; - } else if ((parts = lineRE2.exec(lines[i]))) { - item = { - 'url': parts[3], - 'func': parts[4] - }; - var relativeLine = (+parts[1]); // relative to the start of the - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/index.html b/index.html index 279bb62..e4d711d 100755 --- a/index.html +++ b/index.html @@ -39,7 +39,7 @@ - + diff --git a/modules/editor/editor.html b/modules/editor/editor.html new file mode 100644 index 0000000..0b46f21 --- /dev/null +++ b/modules/editor/editor.html @@ -0,0 +1,46 @@ + + + + + + + Firetext Editor + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/editor/scripts/docIO.js b/modules/editor/scripts/docIO.js similarity index 100% rename from editor/scripts/docIO.js rename to modules/editor/scripts/docIO.js diff --git a/editor/scripts/editorProxy.js b/modules/editor/scripts/editorProxy.js similarity index 100% rename from editor/scripts/editorProxy.js rename to modules/editor/scripts/editorProxy.js diff --git a/editor/scripts/nightEditor.js b/modules/editor/scripts/nightEditor.js similarity index 100% rename from editor/scripts/nightEditor.js rename to modules/editor/scripts/nightEditor.js diff --git a/scripts/editorLoader.js b/scripts/editorLoader.js deleted file mode 100644 index c6b668e..0000000 --- a/scripts/editorLoader.js +++ /dev/null @@ -1,63 +0,0 @@ -var loadEditor = (function () { - var editorURL; - var loadEditor = function loadEditor(callback) { - if(editorURL) { - callback(editorURL); - return; - } - var editorDoc; - - var editorReq = new XMLHttpRequest(); - editorReq.open("GET", "editor/editor.html", true); - editorReq.responseType = "document"; - editorReq.overrideMimeType("text/html"); - editorReq.addEventListener("load", function(e) { - if(this.status === 200) { - editorDoc = this.response; - var scriptTags = editorDoc.querySelectorAll("script"); - var scripts = {}; - for (var i = 0; i < scriptTags.length; i++) { - if(scriptTags[i].src) { - (function() { - var scriptURL = new URI(scriptTags[i].src, new URI("editor", location.href)).toString(); - if(!scripts[scriptURL]) { - scripts[scriptURL] = []; - var scriptReq = new XMLHttpRequest(); - scriptReq.open("GET", scriptURL, true); - scriptReq.responseType = "text"; - scriptReq.addEventListener("load", function(e) { - var done = true; - if(this.status === 200) { - var inlineScript = editorDoc.createElement("script"); - var scriptText = this.response; - scriptText = scriptText.replace(/\[ORIGIN_OF_MAIN_DOCUMENT\]/g, window.location.origin ? window.location.origin : window.location.protocol + "//" + window.location.host); - inlineScript.type = "text/javascript"; - inlineScript.src = "data:text/javascript;base64," + btoa(scriptText); - scripts[scriptURL][0].parentNode.replaceChild(inlineScript, scripts[scriptURL][0]); - for (var i = 1; i < scripts[scriptURL].length; i++) { - scripts[scriptURL][i].parentNode.removeChild(scripts[scriptURL][i]); - } - delete scripts[scriptURL]; - for(var x in scripts) { - done = false; - break; - } - if (done) { - var editorBlob = new Blob([editorDoc.documentElement.outerHTML], {type: "text/html"}) - editorURL = URL.createObjectURL ? URL.createObjectURL(editorBlob) : URL.webkitCreateObjectURL ? URL.webkitCreateObjectURL(editorBlob) : null; - callback(editorURL); - } - } - }, false); - scriptReq.send(); - } - scripts[scriptURL].push(scriptTags[i]); - })(); - } - } - } - }, false); - editorReq.send(); - } - return loadEditor; -})(); \ No newline at end of file diff --git a/scripts/firetext.js b/scripts/firetext.js index 702ff36..0b3c36f 100644 --- a/scripts/firetext.js +++ b/scripts/firetext.js @@ -101,7 +101,7 @@ firetext.init = function () { firetext.recents.init(); // Initialize the editor - initEditor(function() { + initEditor(function() { // Init extIcon extIcon(); @@ -131,8 +131,7 @@ firetext.init = function () { editDocs(); } ); - - + // Initialize urls getURLs(function(){ fixMenu(); @@ -668,9 +667,8 @@ function extIcon() { /* Editor ------------------------*/ function initEditor(callback) { - loadEditor(function(editorURL) { + app.modules.load('modules/editor/editor.html', editor, function() { editor.onload = null; - editor.src = editorURL; editor.onload = function() { var editorMessageChannel = new MessageChannel(); // See: scripts/messages.js @@ -713,7 +711,7 @@ function initEditor(callback) { Window.postMessage(editor.contentWindow, {command: "init"}, "*", [editorMessageChannel.port2]); editorMessageProxy.getPort().start(); } - }) + }, true); } function watchDocument(filetype) { @@ -742,7 +740,7 @@ function forceAutosave() { function autosave(force) { if (firetext.settings.get('autosave') != 'false') { - if (!saveTimeout | force == true) { + if (!saveTimeout || force == true) { if (saving != true) { // Add timeout for saving saveTimeout = window.setTimeout(saveFromEditor, 1000); @@ -1347,3 +1345,7 @@ function editFullScreen(enter) { html.classList.remove('fullscreen'); } } + +firetext.alert = function(message) { + alert(message); +}; diff --git a/scripts/modules.js b/scripts/modules.js new file mode 100644 index 0000000..80c4e74 --- /dev/null +++ b/scripts/modules.js @@ -0,0 +1,121 @@ +/* +* Modules +* Copyright (C) Codexa Organization. +*/ + +if (!app) { + var app = {}; +} + +(function(window, undefined) { + 'use strict'; + + function loadModule(url, callback, deep) { + // Validate params + if (!url) { + callback('bad-params'); + } + + // Get module + var request = new XMLHttpRequest(); + request.open("GET", url, true); + request.responseType = "document"; + request.overrideMimeType("text/html"); + request.addEventListener("load", function(e) { + if(this.status === 200) { + var response = this.response; + if (deep) { + var scriptTags = response.querySelectorAll("script"); + var scripts = {}; + for (var i = 0; i < scriptTags.length; i++) { + if(scriptTags[i].src) { + (function() { + var scriptURL = new URI(scriptTags[i].src, new URI(location.href)).toString(); + if(!scripts[scriptURL]) { + scripts[scriptURL] = []; + var scriptReq = new XMLHttpRequest(); + scriptReq.open("GET", scriptURL, true); + scriptReq.responseType = "text"; + scriptReq.addEventListener("load", function(e) { + var done = true; + if(this.status === 200) { + var inlineScript = response.createElement("script"); + var scriptText = this.response; + scriptText = scriptText.replace(/\[ORIGIN_OF_MAIN_DOCUMENT\]/g, window.location.origin ? window.location.origin : window.location.protocol + "//" + window.location.host); + inlineScript.type = "text/javascript"; + inlineScript.src = "data:text/javascript;base64," + btoa(scriptText); + scripts[scriptURL][0].parentNode.replaceChild(inlineScript, scripts[scriptURL][0]); + for (var i = 1; i < scripts[scriptURL].length; i++) { + scripts[scriptURL][i].parentNode.removeChild(scripts[scriptURL][i]); + } + delete scripts[scriptURL]; + for(var x in scripts) { + done = false; + break; + } + if (done) { + callback(null, createBlob(response)); + } + } + }, false); + scriptReq.send(); + } + scripts[scriptURL].push(scriptTags[i]); + })(); + } + } + } else { + callback(null, createBlob(response)); + } + } else { + callback(this.status); + } + }, false); + request.send(); + } + + function fillFrame(blobURL, destinations, callback) { + // Validate params + if (!blobURL || !destinations) { + callback('bad-params'); + } + + if (!Array.isArray(destinations)) { + destinations = [destinations]; + } + + // Fill frames + destinations.forEach(function(t){ + t.src = blobURL; + }); + + // Done! + callback(); + } + + function createBlob(response) { + var moduleBlob = new Blob([response.documentElement.outerHTML], {type: "text/html"}); + var moduleURL = URL.createObjectURL ? URL.createObjectURL(moduleBlob) : URL.webkitCreateObjectURL ? URL.webkitCreateObjectURL(moduleBlob) : null; + return moduleURL; + } + + app.modules = { + load: function (url, destinations, callback, deep) { + console.log('Loading '+url); + loadModule(url, function(e,b){ + if (e) { + console.log(e); + } else { + fillFrame(b, destinations, function(e){ + if (e) { + console.log(e); + } else { + console.log('Finished loading '+url); + callback(); + } + }); + } + }, deep); + } + }; +})(this); From adbb820f4b39cf35d8984f66f0b9d567f84872f1 Mon Sep 17 00:00:00 2001 From: Joshua Smith Date: Tue, 22 Jul 2014 11:23:21 -0400 Subject: [PATCH 11/84] Better init function, rename editor scripts --- modules/editor/editor.html | 4 +- .../scripts/{editorProxy.js => editor.js} | 0 .../{nightEditor.js => editor_night.js} | 0 scripts/firetext.js | 212 +++++++++--------- style/main.css | 3 + 5 files changed, 114 insertions(+), 105 deletions(-) rename modules/editor/scripts/{editorProxy.js => editor.js} (100%) rename modules/editor/scripts/{nightEditor.js => editor_night.js} (100%) diff --git a/modules/editor/editor.html b/modules/editor/editor.html index 0b46f21..c4b0959 100644 --- a/modules/editor/editor.html +++ b/modules/editor/editor.html @@ -11,7 +11,7 @@ - + @@ -38,7 +38,7 @@ - + diff --git a/modules/editor/scripts/editorProxy.js b/modules/editor/scripts/editor.js similarity index 100% rename from modules/editor/scripts/editorProxy.js rename to modules/editor/scripts/editor.js diff --git a/modules/editor/scripts/nightEditor.js b/modules/editor/scripts/editor_night.js similarity index 100% rename from modules/editor/scripts/nightEditor.js rename to modules/editor/scripts/editor_night.js diff --git a/scripts/firetext.js b/scripts/firetext.js index 0b3c36f..218ce20 100644 --- a/scripts/firetext.js +++ b/scripts/firetext.js @@ -41,26 +41,96 @@ var appCache = window.applicationCache; ------------------------*/ window.addEventListener('DOMContentLoaded', function() {firetext.init();}, false); -firetext.init = function () { +firetext.init = function () { + // l10n catch + navigator.mozL10n.once(function () { + // Select elements + initElements(); + + // Load modules + initModules(function() { + // Update Doc Lists + updateDocLists(); + + // Navigate to welcome + regions.nav('welcome'); + + // Check for recent file, and if found, load it. + if (firetext.settings.get('autoload') == 'true') { + var lastDoc = [firetext.settings.get('autoload.dir'), firetext.settings.get('autoload.name'), firetext.settings.get('autoload.ext'), firetext.settings.get('autoload.loc')]; + if (firetext.settings.get('autoload.wasEditing') == 'true') { + // Wait until Dropbox is authenticated + if (lastDoc[3] == 'dropbox') { + if (firetext.settings.get('dropbox.enabled') == 'true') { + window.addEventListener('cloud.dropbox.authed', function() { + loadToEditor(lastDoc[0], lastDoc[1], lastDoc[2], lastDoc[3]); + spinner('hide'); + }); + } else { + spinner('hide'); + } + } else { + loadToEditor(lastDoc[0], lastDoc[1], lastDoc[2], lastDoc[3]); + spinner('hide'); + } + } else { + spinner('hide'); + } + } else { + spinner('hide'); + } + + // Create listeners + initListeners(); + + // Dispatch init event + window.dispatchEvent(firetext.initialized); + firetext.isInitialized = true; + }); + }); +}; + +function initModules(callback) { // Initialize Bugsense bugsenseInit(); - // Initialize l10n - navigator.mozL10n.once(function () { + // Initialize urls + initURLs(function(){}); + + // Find device type + checkDevice(); // Initialize Settings firetext.settings.init(); - // Initialize language handler + // Initialize Language firetext.language(firetext.settings.get('language')); - // Find device type - checkDevice(); - - // Initialize gestures + // Initialize Gestures initGestures(); + + // Initialize extIcon + extIcon(); + + // Initiate UID + firetext.user.id.init(); + + // Initialize sharing + cloud.init(); + + // Initalize recent docs + firetext.recents.init(); + + // Initialize IO + firetext.io.init(null, function() { + // Initialize editor + initEditor(function() { + callback(); + }); + }); +} - /* Select important elements for later */ +function initElements() { // Misc loadSpinner = document.getElementById('loadSpinner'); spinner(); @@ -71,7 +141,7 @@ firetext.init = function () { toolbar = document.getElementById('edit-zone'); editWindow = document.getElementById('edit'); locationLegend = document.getElementById('locationLegend'); - locationSelect = document.getElementById('createDialogFileLocation'); + locationSelect = document.getElementById('createDialogFileLocation'); // Lists welcomeDocsList = document.getElementById('welcome-docs-list'); @@ -85,7 +155,7 @@ firetext.init = function () { welcomeDropboxList = document.getElementById('welcome-dropbox-list'); openDialogDropboxArea = document.getElementById('open-dialog-dropbox-area'); openDialogDropboxList = document.getElementById('open-dialog-dropbox-list'); - + // Formatting bold = document.getElementById('bold'); boldCheckbox = document.getElementById('boldCheckbox'); @@ -96,100 +166,36 @@ firetext.init = function () { strikethroughCheckbox = document.getElementById('strikethroughCheckbox'); underline = document.getElementById('underline'); underlineCheckbox = document.getElementById('underlineCheckbox'); - - // Initalize recent docs - firetext.recents.init(); - - // Initialize the editor - initEditor(function() { - // Init extIcon - extIcon(); - - // Add event listeners - toolbar.addEventListener( - 'mousedown', function mouseDown(event) { - event.preventDefault(); - event.target.classList.toggle('active'); - } - ); - toolbar.addEventListener( - 'mouseup', function mouseDown(event) { - if (event.target.classList.contains('sticky') != true) { - event.target.classList.remove('active'); - } - } - ); - editWindow.addEventListener( - 'mouseenter', function mouseDown(event) { - editor.focus(); - } - ); - - document.getElementById('welcome-main-area').addEventListener( - 'contextmenu', function contextmenu(event) { - event.preventDefault(); - editDocs(); +} + +function initListeners() { + // Add event listeners + toolbar.addEventListener( + 'mousedown', function mouseDown(event) { + event.preventDefault(); + event.target.classList.toggle('active'); + } + ); + toolbar.addEventListener( + 'mouseup', function mouseDown(event) { + if (event.target.classList.contains('sticky') != true) { + event.target.classList.remove('active'); } - ); - - // Initialize urls - getURLs(function(){ - fixMenu(); - - // Initialize IO - firetext.io.init(null, function() { - // Update Doc Lists - updateDocLists(); - - // Initialize sharing - cloud.init(); - - // Check for recent file, and if found, load it. - if (firetext.settings.get('autoload') == 'true') { - var lastDoc = [firetext.settings.get('autoload.dir'), firetext.settings.get('autoload.name'), firetext.settings.get('autoload.ext'), firetext.settings.get('autoload.loc')]; - var wasEditing = firetext.settings.get('autoload.wasEditing'); - - // Navigate to welcome region - regions.nav('welcome'); - - // Load file - if (wasEditing == 'true') { - // Wait until Dropbox is authenticated - if (lastDoc[3] == 'dropbox') { - if (firetext.settings.get('dropbox.enabled') == 'true') { - window.addEventListener('cloud.dropbox.authed', function() { - spinner('hide'); - loadToEditor(lastDoc[0], lastDoc[1], lastDoc[2], lastDoc[3]); - }); - } else { - spinner('hide'); - } - } else { - spinner('hide'); - loadToEditor(lastDoc[0], lastDoc[1], lastDoc[2], lastDoc[3]); - } - } else { - spinner('hide'); - } - } else { - spinner('hide'); - regions.nav('welcome'); - } - - // Night - night(); - - // Dispatch init event - window.dispatchEvent(firetext.initialized); - firetext.isInitialized = true; - }); - }); - }); - - }); -}; + } + ); + editWindow.addEventListener( + 'mouseenter', function mouseDown(event) { + editor.focus(); + } + ); + welcomeDocsList.addEventListener( + 'contextmenu', function contextmenu(event) { + editDocs(); + } + ); +} -function getURLs(callback) { +function initURLs(callback) { var xhr = new XMLHttpRequest(); xhr.open('post','http://firetext.codexa.bugs3.com/',true); xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); diff --git a/style/main.css b/style/main.css index dd642e6..94b483a 100755 --- a/style/main.css +++ b/style/main.css @@ -21,6 +21,9 @@ html, body { height: -webkit-calc(100% - 5.2rem); height: calc(100% - 5.2rem); overflow: scroll; + width: 100%; + border: none; + outline: none; } .redAlert { From 1be7709e2b18c1853341d419a8690170f91949a9 Mon Sep 17 00:00:00 2001 From: Joshua Smith Date: Tue, 22 Jul 2014 11:38:47 -0400 Subject: [PATCH 12/84] Remove redundant editor load --- scripts/firetext.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/firetext.js b/scripts/firetext.js index 218ce20..d910799 100644 --- a/scripts/firetext.js +++ b/scripts/firetext.js @@ -123,10 +123,7 @@ function initModules(callback) { // Initialize IO firetext.io.init(null, function() { - // Initialize editor - initEditor(function() { - callback(); - }); + callback(); }); } From 69673ee7fe917d76bf7b871274c08c40c4e50528 Mon Sep 17 00:00:00 2001 From: Joshua Smith Date: Thu, 24 Jul 2014 08:33:14 -0400 Subject: [PATCH 13/84] Allow non-blob module URLs, save editor URL --- scripts/firetext.js | 97 +++++++++++++++++++++++++-------------------- scripts/modules.js | 57 +++++++++++++++++--------- 2 files changed, 92 insertions(+), 62 deletions(-) diff --git a/scripts/firetext.js b/scripts/firetext.js index d910799..40ebd1d 100644 --- a/scripts/firetext.js +++ b/scripts/firetext.js @@ -27,7 +27,7 @@ var bold, boldCheckbox, italic, italicCheckbox, justifySelect, strikethrough, st var underline, underlineCheckbox; var locationLegend, locationSelect, locationDevice, locationDropbox; var bugsenseInitialized = false, bugsenseKey = ''; -var editorMessageProxy; +var editorMessageProxy, editorURL; // Lists var welcomeDocsList, welcomeDeviceArea, welcomeDeviceList, openDialogDeviceArea, openDialogDeviceList; @@ -670,51 +670,60 @@ function extIcon() { /* Editor ------------------------*/ function initEditor(callback) { - app.modules.load('modules/editor/editor.html', editor, function() { - editor.onload = null; - editor.onload = function() { - var editorMessageChannel = new MessageChannel(); - // See: scripts/messages.js - editorMessageProxy = new MessageProxy(editorMessageChannel.port1); - // Successful initialization - editorMessageProxy.registerMessageHandler(function(e) { - // Initialize Raw Editor - rawEditor.setAttribute('contentEditable', 'true'); - rawEditor.addEventListener('focus',function(){ - processActions('data-focus', rawEditor); - }); - rawEditor.addEventListener('blur',function(){ - processActions('data-blur', rawEditor); - }); - - // Nav to the design tab - regions.tab(document.querySelector('#editTabs'), 'design'); + if (editorURL) { + app.modules.fill(editorURL, editor, function() { + editorCommunication(function(){ callback(); - - // Initialize Night Mode - night(); - }, "init-success", true); - - editorMessageProxy.registerMessageHandler(function(e) { - fileChanged = true; - if(e.data.filetype === ".html") { - rawEditor.textContent = e.data.html; - } - autosave(); - }, "doc-changed"); + }); + }); + } else { + app.modules.load('modules/editor/editor.html', editor, function(u) { + editorURL = u; + editorCommunication(function(){ + callback(); + }); + }, true); + } +} - // editor focus and blur - editorMessageProxy.registerMessageHandler(function(e) { - if(e.data.focus) { - processActions('data-focus', editor); - } else { - processActions('data-blur', editor); - } - }, "focus"); - Window.postMessage(editor.contentWindow, {command: "init"}, "*", [editorMessageChannel.port2]); - editorMessageProxy.getPort().start(); - } - }, true); +function editorCommunication(callback) { + editor.onload = null; + editor.onload = function() { + var editorMessageChannel = new MessageChannel(); + // See: scripts/messages.js + editorMessageProxy = new MessageProxy(editorMessageChannel.port1); + // Successful initialization + editorMessageProxy.registerMessageHandler(function(e) { + // Initialize Raw Editor + rawEditor.setAttribute('contentEditable', 'true'); + + // Nav to the design tab + regions.tab(document.querySelector('#editTabs'), 'design'); + callback(); + + // Initialize Night Mode + night(); + }, "init-success", true); + + editorMessageProxy.registerMessageHandler(function(e) { + fileChanged = true; + if(e.data.filetype === ".html") { + rawEditor.textContent = e.data.html; + } + autosave(); + }, "doc-changed"); + + // editor focus and blur + editorMessageProxy.registerMessageHandler(function(e) { + if(e.data.focus) { + processActions('data-focus', editor); + } else { + processActions('data-blur', editor); + } + }, "focus"); + Window.postMessage(editor.contentWindow, {command: "init"}, "*", [editorMessageChannel.port2]); + editorMessageProxy.getPort().start(); + } } function watchDocument(filetype) { diff --git a/scripts/modules.js b/scripts/modules.js index 80c4e74..cf9fff9 100644 --- a/scripts/modules.js +++ b/scripts/modules.js @@ -74,9 +74,9 @@ if (!app) { request.send(); } - function fillFrame(blobURL, destinations, callback) { + function fillFrame(url, destinations, callback) { // Validate params - if (!blobURL || !destinations) { + if (!url || !destinations) { callback('bad-params'); } @@ -86,7 +86,7 @@ if (!app) { // Fill frames destinations.forEach(function(t){ - t.src = blobURL; + t.src = url; }); // Done! @@ -100,22 +100,43 @@ if (!app) { } app.modules = { - load: function (url, destinations, callback, deep) { + fill: function (url, destinations, callback) { + fillFrame(url, destinations, function(e){ + if (e) { + console.log(e); + } else { + callback(); + } + }); + }, + load: function (url, destinations, callback, store) { console.log('Loading '+url); - loadModule(url, function(e,b){ - if (e) { - console.log(e); - } else { - fillFrame(b, destinations, function(e){ - if (e) { - console.log(e); - } else { - console.log('Finished loading '+url); - callback(); - } - }); - } - }, deep); + + if (store) { + loadModule(url, function(e,b){ + if (e) { + console.log(e); + } else { + fillFrame(b, destinations, function(e){ + if (e) { + console.log(e); + } else { + console.log('Finished loading '+url); + callback(b); + } + }); + } + }); + } else { + fillFrame(url, destinations, function(e){ + if (e) { + console.log(e); + } else { + console.log('Finished loading '+url); + callback(); + } + }); + } } }; })(this); From 85d849bac70df9763d435796a6373e2025421dbf Mon Sep 17 00:00:00 2001 From: joshua-s Date: Fri, 21 Nov 2014 05:15:56 +0000 Subject: [PATCH 14/84] Remove user ID initialization, Fix loading issue --- scripts/firetext.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/firetext.js b/scripts/firetext.js index 40ebd1d..2231cf3 100644 --- a/scripts/firetext.js +++ b/scripts/firetext.js @@ -110,17 +110,14 @@ function initModules(callback) { initGestures(); // Initialize extIcon - extIcon(); - - // Initiate UID - firetext.user.id.init(); - + extIcon(); + + // Initalize recent docs + firetext.recents.init(); + // Initialize sharing cloud.init(); - // Initalize recent docs - firetext.recents.init(); - // Initialize IO firetext.io.init(null, function() { callback(); @@ -1361,3 +1358,6 @@ function editFullScreen(enter) { firetext.alert = function(message) { alert(message); }; +etext.alert = function(message) { + alert(message); +}; From 1404a69584e4c0adf49cc5df244d5e6cdc6c58b3 Mon Sep 17 00:00:00 2001 From: Daniel Huigens Date: Sun, 23 Nov 2014 17:19:53 +0100 Subject: [PATCH 15/84] Remove trailing garbage in firetext.js --- scripts/firetext.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/firetext.js b/scripts/firetext.js index 2231cf3..775820b 100644 --- a/scripts/firetext.js +++ b/scripts/firetext.js @@ -1358,6 +1358,3 @@ function editFullScreen(enter) { firetext.alert = function(message) { alert(message); }; -etext.alert = function(message) { - alert(message); -}; From 8005d26842206cb2ee4cd724002611e5ffad5c35 Mon Sep 17 00:00:00 2001 From: joshua-s Date: Sun, 23 Nov 2014 19:08:18 +0000 Subject: [PATCH 16/84] Fix indentation --- scripts/modules.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/modules.js b/scripts/modules.js index cf9fff9..7522940 100644 --- a/scripts/modules.js +++ b/scripts/modules.js @@ -109,10 +109,10 @@ if (!app) { } }); }, - load: function (url, destinations, callback, store) { - console.log('Loading '+url); - - if (store) { + load: function (url, destinations, callback, store) { + console.log('Loading '+url); + + if (store) { loadModule(url, function(e,b){ if (e) { console.log(e); @@ -127,7 +127,7 @@ if (!app) { }); } }); - } else { + } else { fillFrame(url, destinations, function(e){ if (e) { console.log(e); @@ -136,7 +136,7 @@ if (!app) { callback(); } }); - } - } - }; + } + } + }; })(this); From a004fa1286d6e69acf346323ba85095f14d50530 Mon Sep 17 00:00:00 2001 From: Daniel Huigens Date: Thu, 27 Nov 2014 15:11:19 +0100 Subject: [PATCH 17/84] Fix editor loading --- scripts/firetext.js | 2 +- scripts/modules.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/firetext.js b/scripts/firetext.js index 775820b..b55f349 100644 --- a/scripts/firetext.js +++ b/scripts/firetext.js @@ -679,7 +679,7 @@ function initEditor(callback) { editorCommunication(function(){ callback(); }); - }, true); + }, true, true); } } diff --git a/scripts/modules.js b/scripts/modules.js index 7522940..6b1234a 100644 --- a/scripts/modules.js +++ b/scripts/modules.js @@ -109,7 +109,7 @@ if (!app) { } }); }, - load: function (url, destinations, callback, store) { + load: function (url, destinations, callback, store, deep) { console.log('Loading '+url); if (store) { @@ -126,7 +126,7 @@ if (!app) { } }); } - }); + }, deep); } else { fillFrame(url, destinations, function(e){ if (e) { From 4a07a5dce317cedd17ab61b90dd889826d2b9c61 Mon Sep 17 00:00:00 2001 From: joshua-s Date: Thu, 27 Nov 2014 15:09:51 +0000 Subject: [PATCH 18/84] Fix menus on init --- scripts/firetext.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/firetext.js b/scripts/firetext.js index b55f349..e9a5e69 100644 --- a/scripts/firetext.js +++ b/scripts/firetext.js @@ -95,7 +95,7 @@ function initModules(callback) { bugsenseInit(); // Initialize urls - initURLs(function(){}); + initURLs(function(){fixMenu();}); // Find device type checkDevice(); @@ -112,8 +112,8 @@ function initModules(callback) { // Initialize extIcon extIcon(); - // Initalize recent docs - firetext.recents.init(); + // Initalize recent docs + firetext.recents.init(); // Initialize sharing cloud.init(); From 316a92cc53687571db7c41d8887411163e6532d7 Mon Sep 17 00:00:00 2001 From: Daniel Huigens Date: Thu, 27 Nov 2014 18:10:45 +0100 Subject: [PATCH 19/84] [desktop] Chrome-style menu --- index.html | 34 ++++++++++++++++++---------------- style/desktop.css | 39 +++++++++++++++++++++------------------ style/main.css | 4 ++++ 3 files changed, 43 insertions(+), 34 deletions(-) diff --git a/index.html b/index.html index e4d711d..44d4b68 100755 --- a/index.html +++ b/index.html @@ -87,13 +87,6 @@

Menu

-
-
    -
  • -
-
    -
-
+
+
    +
  • +
+
    +
+
+ data-swipe-right="sidebar" data-swipe-right-id="welcome" data-swipe-right-state="close" data-swipe-right-only="current" + data-click="sidebar" data-click-id="welcome" data-click-state="close" data-click-only="current">
@@ -215,13 +216,6 @@

Documents on your Dropbox

Menu

-
-
    -
  • -
-
    -
-
+
+
    +
  • +
+
    +
+
+ data-swipe-right="sidebar" data-swipe-right-id="main" data-swipe-right-state="close" + data-click="sidebar" data-click-id="main" data-click-state="close">
diff --git a/style/desktop.css b/style/desktop.css index 5bc9312..17b8d75 100644 --- a/style/desktop.css +++ b/style/desktop.css @@ -58,26 +58,29 @@ } /* Drawer/Sidebar */ - section[data-type="sidebar"], section[data-type="sidebar"] [role="toolbar"] { + section[data-type="sidebar"] { width: 250px; + position: absolute; + top: 5rem; + z-index: 1000; + height: auto; + transition: none; + } + .fullscreen section[data-type="sidebar"] { + top: 4rem; + } + section[data-type="sidebar"] [role="toolbar"] { + width: 250px; + position: static; } - section[data-type="sidebar"] > nav { - height: calc(100% - 5rem - 4rem); + section[data-type="sidebar"] [role="toolbar"] button { + margin: 0; } - [data-state="drawer"].current, - [dir="rtl"] [data-state="drawer"][data-position="right"].current { - -moz-transform: translateX(250px) !important; - -webkit-transform: translateX(250px) !important; - -o-transform: translateX(250px) !important; - -ms-transform: translateX(250px) !important; - transform: translateX(250px) !important; + [data-state="drawer"].current, [data-state="drawer"][data-position="right"].current { + -moz-transform: translateX(0) !important; + -webkit-transform: translateX(0) !important; + -o-transform: translateX(0) !important; + -ms-transform: translateX(0) !important; + transform: translateX(0) !important; } - [data-state="drawer"][data-position="right"].current, - [dir="rtl"] [data-state="drawer"].current { - -moz-transform: translateX(-250px) !important; - -webkit-transform: translateX(-250px) !important; - -o-transform: translateX(-250px) !important; - -ms-transform: translateX(-250px) !important; - transform: translateX(-250px) !important; - } } diff --git a/style/main.css b/style/main.css index 94b483a..114ba75 100755 --- a/style/main.css +++ b/style/main.css @@ -69,6 +69,10 @@ html, body { background-color: #444; } +section[data-type="sidebar"] > nav { + height: calc(100% - 5rem - 4rem); +} + section[data-type="sidebar"] [role="toolbar"] .icon-setting { padding-top: .3rem; font-size: 2.5rem; From b00c63a125cbb813e4f8eac51167c7ea2fdffdc1 Mon Sep 17 00:00:00 2001 From: joshua-s Date: Thu, 27 Nov 2014 18:54:39 +0000 Subject: [PATCH 20/84] Fix document creation issue --- scripts/firetext.js | 1 + scripts/io.js | 1 + 2 files changed, 2 insertions(+) diff --git a/scripts/firetext.js b/scripts/firetext.js index e9a5e69..92e0450 100644 --- a/scripts/firetext.js +++ b/scripts/firetext.js @@ -184,6 +184,7 @@ function initListeners() { ); welcomeDocsList.addEventListener( 'contextmenu', function contextmenu(event) { + event.preventDefault(); editDocs(); } ); diff --git a/scripts/io.js b/scripts/io.js index 862b0c5..9fc2e82 100644 --- a/scripts/io.js +++ b/scripts/io.js @@ -101,6 +101,7 @@ firetext.io.init = function (api, callback) { locationDevice.setAttribute('data-l10n-id','internal-storage'); locationDevice.textContent = navigator.mozL10n.get('internal-storage'); locationSelect.appendChild(locationDevice); + updateAddDialog(); } function disableInternalStorage() { From fefc1802ec24524033fcb9e1c10cbeb14e818288 Mon Sep 17 00:00:00 2001 From: Daniel Huigens Date: Thu, 27 Nov 2014 22:20:43 +0100 Subject: [PATCH 21/84] Detect fullscreen denies and manual fullscreen changes --- scripts/firetext.js | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/scripts/firetext.js b/scripts/firetext.js index 92e0450..ab44eb3 100644 --- a/scripts/firetext.js +++ b/scripts/firetext.js @@ -1330,13 +1330,6 @@ function editFullScreen(enter) { } else if (document.documentElement.webkitRequestFullscreen) { document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); } - - // Special editor UI - document.querySelector('#edit header:first-child').style.display = 'none'; - document.getElementById('editTabs').setAttribute('data-items', '4.1'); - document.querySelector('#editTabs #tabToolbarLeft').classList.add('visible'); - document.querySelector('#editTabs #tabToolbarRight').classList.add('visible'); - html.classList.add('fullscreen'); } else { // Exit fullscreen if (document.cancelFullScreen) { @@ -1346,7 +1339,22 @@ function editFullScreen(enter) { } else if (document.webkitCancelFullScreen) { document.webkitCancelFullScreen(); } - + } +} + +function onFullScreenChange() { + if ( + document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement + ) { + // Special editor UI + document.querySelector('#edit header:first-child').style.display = 'none'; + document.getElementById('editTabs').setAttribute('data-items', '4.1'); + document.querySelector('#editTabs #tabToolbarLeft').classList.add('visible'); + document.querySelector('#editTabs #tabToolbarRight').classList.add('visible'); + html.classList.add('fullscreen'); + } else { // Regular editor UI document.querySelector('#edit header:first-child').style.display = 'block'; document.getElementById('editTabs').setAttribute('data-items', '2'); @@ -1356,6 +1364,10 @@ function editFullScreen(enter) { } } +document.addEventListener('fullscreenchange', onFullScreenChange); +document.addEventListener('mozfullscreenchange', onFullScreenChange); +document.addEventListener('webkitfullscreenchange', onFullScreenChange); + firetext.alert = function(message) { alert(message); }; From 87b2127b49f5a1034287fd39f39802b0707b2887 Mon Sep 17 00:00:00 2001 From: Daniel Huigens Date: Thu, 27 Nov 2014 22:41:20 +0100 Subject: [PATCH 22/84] Never automatically switch to zen mode on the desktop --- scripts/regions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/regions.js b/scripts/regions.js index 88f0319..265c39b 100644 --- a/scripts/regions.js +++ b/scripts/regions.js @@ -54,7 +54,7 @@ function nav2() { /* Remove this section when porting to other projects */ if (tempLoc == 'edit') { - if (tempAutozen !== false) { + if (tempAutozen !== false && deviceType === 'mobile') { // Start Zen Mode if autozen == true if (firetext.settings.get('autozen') == 'true' || tempAutozen === true) { From 2ca28e46f593edfe42f722481ee74b7200c8a100 Mon Sep 17 00:00:00 2001 From: joshua-s Date: Fri, 28 Nov 2014 14:29:44 +0000 Subject: [PATCH 23/84] Update documentation --- CONTRIBUTING.md | 3 ++- README.md | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1497966..fe737d8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,8 @@ Firetext delivers office capabilities to many Firefox OS users. We could really use your help! ### Hack -Is the open web is your passion? Do you dream in code? Well, head on over to our [Get Coding](https://github.com/codexa/firetext/wiki/Get-Coding) page, and help us bring more productivity power to Firefox OS users! +Is the open web is your passion? Do you dream in code? Well, head on over to our [Get Coding](https://github.com/codexa/firetext/wiki/Get-Coding) page, +and learn how to bring more productivity power to Firefox OS users! ### Localize Do you bridge the gap between cultures? Localize Firetext on [Transifex](https://www.transifex.com/projects/p/firetext/), and expand our global impact. diff --git a/README.md b/README.md index b8eeec5..b1c40a8 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,15 @@ ## About Firetext is an open-source word processor for Firefox OS, and is [available on the Firefox Marketplace](https://marketplace.firefox.com/app/firetext). -You can run Firetext on a Firefox OS device, on a [Firefox OS simulator](https://ftp.mozilla.org/pub/mozilla.org/labs/fxos-simulator/), or on the Firefox [App Manager](https://developer.mozilla.org/Firefox_OS/Using_the_App_Manager)/[WebIDE](https://developer.mozilla.org/docs/Tools/WebIDE). +You can run Firetext on a Firefox OS device, on a [Firefox OS simulator](https://ftp.mozilla.org/pub/mozilla.org/labs/fxos-simulator/), +or in Firefox/Chrome with a web server. Please see [our documentation](https://github.com/codexa/firetext/wiki/Get-Coding#set-up-a-development-environment) for instructions. ## Contribute Firetext is kept alive by contributions from the community. Please donate skills, time, or money to make this project better. ### Hack -Is the open web is your passion? Do you dream in code? Well, head on over to our [Get Coding](https://github.com/codexa/firetext/wiki/Get-Coding) page, and help us bring more productivity power to Firefox OS users! +Is the open web is your passion? Do you dream in code? Well, head on over to our [Get Coding](https://github.com/codexa/firetext/wiki/Get-Coding) page, +and learn how to bring more productivity power to Firefox OS users! ### Localize Do you bridge the gap between cultures? Localize Firetext on [Transifex](https://www.transifex.com/projects/p/firetext/), and expand our global impact. From 290913b8fb6194558e62b3b2d2e996adfc20b1b3 Mon Sep 17 00:00:00 2001 From: Daniel Huigens Date: Fri, 28 Nov 2014 15:31:37 +0100 Subject: [PATCH 24/84] Hide autozen setting on the desktop --- index.html | 2 +- style/desktop.css | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 44d4b68..81bc2b5 100755 --- a/index.html +++ b/index.html @@ -590,7 +590,7 @@

Privacy

Visual

    -

Help

diff --git a/modules/editor/scripts/docIO.js b/modules/editor/scripts/docIO.js index d3bcf4e..97fe2c7 100644 --- a/modules/editor/scripts/docIO.js +++ b/modules/editor/scripts/docIO.js @@ -83,6 +83,13 @@ function initDocIO(document, messageProxy, loadCallback) { }); }, "get-content-blob"); + messageProxy.registerMessageHandler(function(e) { + messageProxy.postMessage({ + command: e.data.key, + content: getHTML() + }); + }, "get-content-html"); + messageProxy.registerMessageHandler(function(e) { load(e.data.content, e.data.filetype); if(e.data.key) { diff --git a/modules/printButton/printButton.html b/modules/printButton/printButton.html new file mode 100644 index 0000000..75c5061 --- /dev/null +++ b/modules/printButton/printButton.html @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/printButton/scripts/printButton.js b/modules/printButton/scripts/printButton.js new file mode 100644 index 0000000..35a0746 --- /dev/null +++ b/modules/printButton/scripts/printButton.js @@ -0,0 +1,96 @@ +window.addEventListener('DOMContentLoaded', function() { + // Proxy for communication with parent page + var parentMessageProxy = new MessageProxy(); + parentMessageProxy.setSend(parent); + parentMessageProxy.setRecv(window); + + window.addEventListener('click', function() { + var win = window.open(URL.createObjectURL(new Blob([ + "", + ], {type: 'text/html'}))); + var key = parentMessageProxy.registerMessageHandler(function(e){ + win.postMessage({ + content: + e.data.content + .replace('', [ + '', + ' ', // Default to utf-8 + ' ' + e.data.filename.replace(/</g, '<') + e.data.filetype + '', + ' ', + '', + ].join('\n')) + .replace('', [ + "", + "", + "", + ].join('\n')) + }, '*'); + }, null, true); + parentMessageProxy.postMessage({ + command: "print-button-pressed", + key: key + }); + }); +}); \ No newline at end of file diff --git a/modules/printButton/style/printButton.css b/modules/printButton/style/printButton.css new file mode 100644 index 0000000..ae93f8e --- /dev/null +++ b/modules/printButton/style/printButton.css @@ -0,0 +1,4 @@ +html { + height: 100%; + cursor: pointer; +} \ No newline at end of file diff --git a/scripts/firetext.js b/scripts/firetext.js index 84a8b61..313d6d4 100644 --- a/scripts/firetext.js +++ b/scripts/firetext.js @@ -21,7 +21,7 @@ firetext.initialized = new CustomEvent('firetext.initialized'); firetext.isInitialized = false; var html = document.getElementsByTagName('html')[0], head = document.getElementsByTagName("head")[0]; var themeColor = document.getElementById("theme-color"); -var loadSpinner, editor, toolbar, toolbarInterval, editWindow, editState, rawEditor, tabRaw, tabDesign; +var loadSpinner, editor, toolbar, toolbarInterval, editWindow, editState, rawEditor, tabRaw, tabDesign, printButton; var deviceType, fileChanged, saveTimeout, saving, urls={}, version = '0.4'; var bold, boldCheckbox, italic, italicCheckbox, justifySelect, strikethrough, strikethroughCheckbox; var underline, underlineCheckbox; @@ -128,6 +128,11 @@ function initModules(callback) { firetext.io.init(null, function() { callback(); }); + + // Initialize print button + initPrintButton(function() { + + }); } function initElements() { @@ -142,6 +147,7 @@ function initElements() { editWindow = document.getElementById('edit'); locationLegend = document.getElementById('locationLegend'); locationSelect = document.getElementById('createDialogFileLocation'); + printButton = document.getElementById('printButton'); // Lists welcomeDocsList = document.getElementById('welcome-docs-list'); @@ -1388,3 +1394,43 @@ document.addEventListener('webkitfullscreenerror', onFullScreenError); firetext.alert = function(message) { alert(message); }; + +/* Print button +------------------------*/ +function initPrintButton(callback) { + app.modules.load('modules/printButton/printButton.html', printButton, function() { + printButtonCommunication(function(){ + callback(); + }); + }, true, true); +} + +function printButtonCommunication(callback) { + printButton.onload = null; + printButton.onload = function() { + // See: scripts/messages.js + var printButtonMessageProxy = new MessageProxy(); + printButtonMessageProxy.setSend(printButton.contentWindow); + printButtonMessageProxy.setRecv(window); + + printButtonMessageProxy.registerMessageHandler(function(printEvt) { + var key = editorMessageProxy.registerMessageHandler(function(editorEvt){ + var filename = document.getElementById('currentFileName').textContent; + var filetype = document.getElementById('currentFileType').textContent; + + printButtonMessageProxy.postMessage({ + command: printEvt.data.key, + filename: filename, + filetype: filetype, + content: editorEvt.data.content, + 'automatic-printing-failed': navigator.mozL10n.get('automatic-printing-failed') + }); + }, null, true); + editorMessageProxy.postMessage({ + command: "get-content-html", + key: key + }); + regions.nav('edit'); + }, "print-button-pressed"); + } +} diff --git a/style/main.css b/style/main.css index 3789173..5e774e9 100755 --- a/style/main.css +++ b/style/main.css @@ -108,6 +108,17 @@ section > header:first-child .icon.icon-close { overflow: hidden; } +section[data-type="sidebar"] > nav > ul > li { + position: relative; +} +section[data-type="sidebar"] > nav > ul > li > iframe { + border: 0; + position: absolute; + top: 0; + width: 100%; + height: 100%; +} + /* action_menu.css */ form[role=dialog] { From 164b20f868cfdad9701b6054380ae85fdb8a6c27 Mon Sep 17 00:00:00 2001 From: joshua-s Date: Sun, 8 Feb 2015 01:10:01 +0000 Subject: [PATCH 56/84] Don't add descriptions to preview-disabled lists --- scripts/firetext.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/firetext.js b/scripts/firetext.js index 84a8b61..03b51a6 100644 --- a/scripts/firetext.js +++ b/scripts/firetext.js @@ -512,7 +512,7 @@ function buildDocListItems(DOCS, listElms, description, output, location, previe description = ''; } - if (firetext.settings.get('previews.enabled') != 'false') { + if (preview && firetext.settings.get('previews.enabled') != 'false') { switch (DOCS[0][2]) { case ".txt": description = firetext.parsers.plain.parse(cleanForPreview(description, DOCS[0][2]), "HTML"); From 16a970015ae65042520106e8ef0302e210d0e54e Mon Sep 17 00:00:00 2001 From: Daniel Huigens Date: Fri, 6 Feb 2015 16:11:17 +0100 Subject: [PATCH 57/84] Add upload button --- index.html | 30 +++++++++++-- scripts/firetext.js | 59 ++++++++++++++------------ scripts/io.js | 100 ++++++++++++++++++++++++++++++++++++++++++++ scripts/regions.js | 5 +++ style/main.css | 11 +++-- 5 files changed, 173 insertions(+), 32 deletions(-) diff --git a/index.html b/index.html index 27ae6be..db0dedb 100755 --- a/index.html +++ b/index.html @@ -91,6 +91,7 @@

Menu

Document actions

Help

@@ -157,15 +158,15 @@

Edit docs

-