TagSpaces is an offline, open source, document manager with tagging support
Added utility module
Borislav Sapundzhiev122d1091c4b1
diff --git a/data/js/core.api.js b/data/js/core.api.jsindex a2229e735..8a2a9209f 100644--- a/data/js/core.api.js+++ b/data/js/core.api.js@@ -16,7 +16,7 @@ define(function(require, exports, module) {var tsCoreUI = require('tscoreui');var tsSearch = require('tssearch');var tsPro = require('tspro');-+ var tsUtils = require('tsutils');var currentPath;var currentLocationObject;var currentPerspectiveID;@@ -553,7 +553,7 @@ define(function(require, exports, module) {exports.TagUtils = tsTagUtils;exports.FileOpener = tsFileOpener;exports.Search = tsSearch;-+ exports.Utils = tsUtils;if (tsPro.available) {exports.PRO = tsPro;}diff --git a/data/js/utils.js b/data/js/utils.jsnew file mode 100644index 000000000..c95111f85--- /dev/null+++ b/data/js/utils.js@@ -0,0 +1,34 @@+/* Copyright (c) 2012-2015 The Tagspaces Authors. All rights reserved.+ * Use of this source code is governed by a AGPL3 license that+ * can be found in the LICENSE file. */+/* global define */+define(function(require, exports, module) {+ 'use strict';+ console.log('Loading utils.js ...');++ //Conversion utility+ function arrayBufferToDataURL(arrayBuffer, mime) {+ var blob = new Blob([ arrayBuffer ], { type: mime});+ var url = window.URL || window.webkitURL;+ return url.createObjectURL(blob);+ }++ function base64ToArrayBuffer(base64) {+ var bstr = window.atob(base64);+ var bytes = new Uint8Array( bstr.length );+ for (var i = 0; i < bstr.length; i++) {+ bytes[i] = bstr.charCodeAt(i);+ }+ return bytes.buffer;+ }++ function dataURLtoBlob(dataURI) {+ var arr = dataURI.split(','), mime = arr[0].match(/:(.*?);/)[1];+ var arrBuff = base64ToArrayBuffer(arr[1]);+ return new window.Blob([arrBuff], {type:mime});+ }++ exports.arrayBufferToDataURL = arrayBufferToDataURL;+ exports.base64ToArrayBuffer = base64ToArrayBuffer;+ exports.dataURLtoBlob = dataURLtoBlob;+});diff --git a/data/loader.js b/data/loader.jsindex 24d027b49..687a1fab5 100644--- a/data/loader.js+++ b/data/loader.js@@ -5,7 +5,7 @@// the value of this var is replaced to "true" by the build scriptvar PRODUCTION = "@@PRODUCTION";-var PRO = "@@PROVERSION";+var PRO = "@@PRO";// Disabling all output to console in production modeif (PRODUCTION == "true") {@@ -111,6 +111,7 @@ requirejs.config({tscoreui: 'js/core.ui',tspostioapi: 'js/postioapi',tsdirectorybrowser: 'js/directorybrowser',+ tsutils: 'js/utils',tsioapi: IO_JS,tspro: PRO_JS},