Skip to content

TagSpaces is an offline, open source, document manager with tagging support

audio recorder - update 0.1.1

kristiyandd4ec2c9dedd42
diff --git a/data/index.html b/data/index.html
index 92780d0ff..9bd23e78e 100644
--- a/data/index.html
+++ b/data/index.html
@@ -478,9 +478,30 @@
</div>
</div>
<hr>
- <div id="recordingList"></div>
+ <div id="recordingList">
+ <form role="form" data-toggle="validator" id="formFileCreateAudioRecorder">
+ <div class="form-group">
+ <p id="recordingUrl" recording=''><audio id="audioRecordingUrl" controls src=''></audio></p>
+ </div>
+ <div class="form-group">
+ <label class="control-label" for="newFileNameAudioRecorder" data-i18n="ns.dialogs:newFileTitle"></label>
+ <input type="text" id="newFileNameAudioRecorder" class="form-control" placeholder="Title of the file"
+ pattern='^([^#/\\:*?<>|"]){1,}$' data-i18n="[data-error]ns.dialogs:fileNameHelp"/>
+ <p class="help-block with-errors"></p>
+ </div>
+ <div class="form-group">
+ <label class="control-label" for="newFileNameTags" data-i18n="ns.dialogs:newFileTags"></label>
+ <input type="text" id="newFileNameTagsAudioRecorder" name="newFileNameTags" autocomplete="off" class="form-control"
+ placeholder="List of tags">
+ <p class="help-block" data-i18n="ns.dialogs:editTagNamesRestrictionsHelp"></p>
+ </div>
+ </form>
+ <button id="audioRecordingConfirmButton" class='btn btn-primary' data-i18n="ns.dialogs:save" data-dismiss="modal" aria-hidden="true"></button>
+ <button id="deleteAudioRecording" class='btn btn-default' recording='' data-i18n="ns.dialogs:delete"></button>
+ </div>
</div>
<div class="modal-footer">
+ <button class="btn btn-primary" data-dismiss="modal" aria-hidden="true"><i class="fa fa-check fa-lg"></i>
</div>
</div>
</div>
diff --git a/data/js/audiorecorder.ui.js b/data/js/audiorecorder.ui.js
index 43975a674..c1b43ad98 100644
--- a/data/js/audiorecorder.ui.js
+++ b/data/js/audiorecorder.ui.js
@@ -7,12 +7,49 @@ define(function(require, exports, module) {
'use strict';
console.log('Loading audiorecorder.ui.js ...');
var TSCORE = require('tscore');
- var TSAUDIORECORDER = require("webaudiorecording");
+
+ var fileContent;
+ var fileType;
var initUI = function() {
+ $('#audioRecordingConfirmButton').click(function() {
+ saveAudioVideoFile();
+ });
+
};
+ function saveAudioVideoFile(event, blob) {
+ var fileTags = '';
+ var rawTags = $('#newFileNameTagsAudioRecorder').val().split(',');
+ rawTags.forEach(function(value, index) {
+ if (index === 0) {
+ fileTags = value;
+ } else {
+ fileTags = fileTags + TSCORE.Config.getTagDelimiter() + value;
+ }
+ });
+ //if ($('#tagWithCurrentDate').prop('checked')) {
+ // if (fileTags.length < 1) {
+ // fileTags = TSCORE.TagUtils.formatDateTime4Tag(new Date());
+ // } else {
+ // fileTags = fileTags + TSCORE.Config.getTagDelimiter() + TSCORE.TagUtils.formatDateTime4Tag(new Date());
+ // }
+ //}
+ if (fileTags.length > 0) {
+ fileTags = TSCORE.TagUtils.beginTagContainer + fileTags + TSCORE.TagUtils.endTagContainer;
+ }
+ var filePath = TSCORE.currentPath + TSCORE.dirSeparator + $('#newFileNameAudioRecorder').val() + fileTags + '.' + fileType;
+ TSCORE.IO.saveBinaryFilePromise(filePath, content, false).then(function() {
+ TSCORE.showSuccessDialog("File saved successfully.");
+
+ }, function(error) {
+ TSCORE.hideLoadingAnimation();
+ TSCORE.showAlertDialog("Saving " + filePath + " failed.");
+ console.error("Save to file " + filePath + " failed " + error);
+ });
+ }
+
// Navigator.getUserMedia shim
navigator.getUserMedia =
navigator.getUserMedia ||
@@ -241,26 +278,61 @@ define(function(require, exports, module) {
// Save/Delete recording
function saveRecording(blob, encoding) {
- var time = new Date(),
- url = URL.createObjectURL(blob),
- html = "<p recording='" + url + "'>" +
- "<audio controls src='" + url + "'></audio> " +
- //" (" + encoding.toUpperCase() + ") " +
- //time +
- " <a class='btn btn-default' style='margin-top:-15px' href='" + url +
- "' download='recording." +
- encoding +
- "'>Save</a> " +
- "<button class='btn btn-danger' style='margin-top:-15px' recording='" +
- url +
- "'>Delete</button>" +
- "</p>";
- if ($recordingList.empty()) {
- $recordingList.append($(html));
- } else {
- $recordingList.removeAttribute(html);
- }
-
+ var time = new Date();
+ var url = URL.createObjectURL(blob);
+ //var html = "<p recording='"+url+"'>"+
+ // "<audio controls src='" + url + "'></audio> " +//" ("+encoding.toUpperCase()+")"+time
+ // " <a class='btn btn-default' style='margin-top:-15px'>Save</a> " +
+ // "<button class='btn btn-danger' style='margin-top:-15px' recording='" + url + "'>Delete</button>"+"</p>";
+ //
+ //if ($recordingList.empty()) {
+ // $recordingList.append($(html));
+ //} else {
+ // $recordingList.removeAttribute(html);
+ //}
+
+ $('#recordingUrl').prop('recording', url);
+ $('#formFileCreateAudioRecorder').prop('recording', url);
+ $('#audioRecordingUrl').attr('src', url);
+ $('#deleteAudioRecording').prop('recording', url);
+
+ fileContent = TSCORE.Config.getNewTextFileContent();
+ // Default new file in text file
+ fileType = 'wav' || 'ogg';
+ $('#newFileNameTagsAudioRecorder').select2('data', null);
+ $('#newFileNameTagsAudioRecorder').select2({
+ multiple: true,
+ tags: TSCORE.Config.getAllTags(),
+ tokenSeparators: [
+ ',',
+ ' '
+ ],
+ minimumInputLength: 1,
+ selectOnBlur: true
+ });
+ $('#newFileNameAudioRecorder').val('');
+ //$('#tagWithCurrentDate').prop('checked', false);
+ $('#txtFileTypeButtonAudioRecorder').button('toggle');
+ $('#formFileCreateAudioRecorder').validator();
+ $('#formFileCreateAudioRecorder').submit(function(e) {
+ e.preventDefault();
+ });
+ $('#formFileCreateAudioRecorder').on('invalid.bs.validator', function() {
+ $('#audioRecordingConfirmButton').prop('disabled', true);
+ });
+ $('#formFileCreateAudioRecorder').on('valid.bs.validator', function() {
+ $('#audioRecordingConfirmButton').prop('disabled', false);
+ });
+ $('#audioRecordingDialog').on('shown.bs.modal', function() {
+ $('#newFileNameAudioRecorder').select2().focus();
+ });
+ $('#audioRecordingDialog').modal({
+ backdrop: 'static',
+ show: true
+ });
+ $('#audioRecordingDialog').draggable({
+ handle: ".modal-header"
+ });
}
$recordingList.on('click', 'button', function(event) {
diff --git a/data/locales/en_US/ns.dialogs.json b/data/locales/en_US/ns.dialogs.json
index a5af0aa92..3e689eae3 100644
--- a/data/locales/en_US/ns.dialogs.json
+++ b/data/locales/en_US/ns.dialogs.json
@@ -180,5 +180,7 @@
"encodeBackground": "Encode background",
"wav": ".wav",
"ogg": ".ogg",
+ "save":"Save",
+ "delete":"Delete",
"-": "-"
}