diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/CurrBuildController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/CurrBuildController.js index ff09667..b3a35a7 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/CurrBuildController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/CurrBuildController.js @@ -1,7 +1,6 @@ AIA.controller("CurrBuildController", ["$scope", "$rootScope", "pages", "$log", "Modules", "$http", "$compile", "$location", "$timeout", "ModuleService", "$interval","$window", function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $timeout, ModuleService, $interval, $window) { - // $rootScope.currentActiveModuleTitle = pages[6].name; $scope.showTabButton = false; $scope.listCurriculumBuilder = null; $scope.dataPopup = null; @@ -13,7 +12,6 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $rootScope.contentNotesForSaveCB = []; $rootScope.dynamicUpdatedJsonForSaveCB = ""; $scope.isChangeFromDropDown=false; - //$rootScope.updateSaveDraftCB = []; $scope.IsVisible = function () { $scope.scroll(); } @@ -23,10 +21,6 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ //alert("scroll"); } - //$scope.showDeleteEditorModel = function () { - // document.getElementById('cbModelDeleteBackground').style.display = "block"; - // document.getElementById('cbModelDeleteEditorId').style.display = "block"; - //} $rootScope.closeEditorModel = function () { document.getElementById('cbModelDeleteBackground').style.display = "none"; document.getElementById('cbModelDeleteEditorId').style.display = "none"; @@ -52,8 +46,6 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ tinymce.execCommand('mceRemoveEditor', true, 'CBTextArea'); tinymce.execCommand('mceAddEditor', true, 'CBTextArea'); - //$rootScope.structureObjForSaveCB = []; - //$rootScope.contentNotesForSaveCB = []; if ($('#' + id).html() != undefined) { $('#' + id).remove(); @@ -72,9 +64,6 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ }); - - - $scope.CBDisableUI = function () { $rootScope.isLoading = true; @@ -318,7 +307,8 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $scope.CBEnableUI(); var jsonData = JSON.parse(e.target.result); localStorage.setItem("cbJsonDataObject", JSON.stringify(jsonData)); - $rootScope.cbJsonData = ""; $rootScope.cbDynamicJsonData = ""; + $rootScope.cbJsonData = ""; + $rootScope.cbDynamicJsonData = ""; $rootScope.cbJsonData = JSON.parse(e.target.result); $rootScope.cbDynamicJsonData = JSON.parse(e.target.result); $rootScope.cbTreeFirstLabel = $rootScope.cbJsonData.slideshow.presentation.structure._label; @@ -332,7 +322,6 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $timeout(function () { $('#modal-CurBuilder').css("display", "block"); $("#CurBuilderbackground").css("display", "block"); - //$scope.openCurriculumDetail(); }, 200); } @@ -382,19 +371,33 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ "_isLocked": "false" }); $rootScope.stru = $scope.selectedNodeSingle[0]; - //$scope.nodeid = $scope.selectedNodeSingle[0].structure.structure[0]._label; - //traverseTreeSelectedSingleObj($rootScope.stru, $scope.nodeid); - //$scope.structure = $scope.selectedNodeSingle[0].structure.structure[0]._label; $rootScope.cbTreeFirstLabel = $scope.selectedNodeSingle[0]._label; $rootScope.structure = $scope.selectedNodeSingle[0].structure.structure; - //$rootScope.structureObjForSaveCB = $rootScope.stru.slideshow.presentation.structure.structure; $rootScope.cbTreeFirstID = $scope.selectedNodeSingle[0]._id; $location.url("/curriculum-builder-detail"); } - $scope.openCBJsPanel = function () { $scope.CBDisableUI(); + + $('#jstree').empty(); + var $e1 = $('').appendTo('#jstree'); + $compile($e1)($scope); + + $timeout(function () { + $scope.openCBEditorPanel(); + }, 500); + + } + + $scope.openCBEditorPanel = function () { + var jsContentURL = 'app/views/CBuild/curriculum-builder-TinyMCEjspanel.html'; $.jsPanel({ id: 'CBTinyMCEPanel', @@ -417,9 +420,8 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ }); $timeout(function () { - $rootScope.resetMenuOptionOnClick("CBTinyMCEPanel"); - - }, 200); + $rootScope.resetMenuOptionOnClick("CBTinyMCEPanel"); + }, 200); } @@ -460,14 +462,14 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ var nodeid = document.getElementById('cbSelect').value; $('#jstree').jstree('select_node', nodeid); - traverseTreeForSetIcons($rootScope.stru, nodeid); + // traverseTreeForSetIcons($rootScope.stru, nodeid); }, 200); } - $scope.openTinyMCE = function (nodeid) { - $scope.CBDisableUI(); + $scope.openTinyMCE = function (nodeid) { if ($scope.Currentselectednodeid == undefined || $scope.Currentselectednodeid != nodeid) { + $scope.CBDisableUI(); console.log("instance create for id : " + nodeid); $scope.Currentselectednodeid = nodeid; @@ -546,9 +548,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ } } - else { - $scope.CBEnableUI(); - } + } $rootScope.cbSelectOnChange = function (obj,prevValue) { @@ -568,7 +568,6 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ } } - var isActive = false; //Start Code by Sandeep for TicketNo: 49226(3) $scope.DropDownSelectNodeClick = function (nodeid) { @@ -720,7 +719,6 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ } } - $rootScope.cbPasswordModelShow = function () { //var current_id = document.getElementById('cbSelect').value; //traverseTreeSelectedSingleObj($rootScope.stru, current_id); @@ -772,7 +770,6 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ } } if ($scope.selectedNodeSingleObj._isBranch == "true") { - //traverseTreeSelectedSingleObj($rootScope.Auther, current_id); traverseTreeSelectedSingleObj($rootScope.contentNotesForSaveCB, current_id); //document.getElementById('cbRenameDate').value = $scope.selectedNodeSingleObj.modified; $scope.setProperties(); @@ -950,6 +947,143 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ document.getElementById('cbModelDeleteBackground').style.display = "block"; document.getElementById('cbModelDeleteConfirmBoxId').style.display = "block"; } + + $rootScope.ImportSection = function () { + var fileupload = document.getElementById("openCBJsonFile"); + $timeout(function () { + $(fileupload).trigger('click'); + }, 300); + + $(fileupload).val('');//old file path + fileupload.onchange = function () { + + var fileId, file, objFileRead; + if (typeof window.FileReader !== 'function') { + alert("The file API isn't supported on this browser yet."); + return; + } + fileId = document.getElementById('openCBJsonFile'); + if (!fileId) { + alert("File couldn't find the element."); + } + else if (!fileId.files) { + alert("This browser doesn't seem to support the `files` property of file inputs."); + } + else if (!fileId.files[0]) { + alert("Please select a file before clicking 'Load'"); + } + else { + file = fileId.files[0]; + var extension = file.name.split(".")[1]; + if (file.type == "application/json" && extension == "json") { + $timeout(function () { + objFileRead = new FileReader(); + objFileRead.onload = CbFileData; + objFileRead.readAsText(file); + }, 300); + } else { + alert("Please select only Export Curriculum Builder Json file!"); + } + + } + + function CbFileData(e) { + //$scope.CBEnableUI(); + var importdata = JSON.parse(e.target.result); + $rootScope.ImportCurriculum(importdata); + + } + }; + + } + + $rootScope.ImportCurriculum = function (importdata) { + var cbCurrentId = document.getElementById('cbSelect').value; + if ($rootScope.structureObjForSaveCB.length == 0) { + $rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure; + } + if ($rootScope.contentNotesForSaveCB.length == 0) { + $rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents;//Assign Dnamic Contents + } + $rootScope.updatedContentFromEditor(cbCurrentId); + + $scope.updateWindowsContentForSaveCB(cbCurrentId,false); + + $scope.newstructure = importdata.slideshow.presentation.structure; + $scope.newcontent = importdata.slideshow.content.element; + + //set false for root for import + $scope.newstructure._isRoot="false"; + + // modidy with new slide resolve conflict of id while import on same curriculum + var date = new Date(); + var newId =date.getTime().toString();//timestamp is the number of milliseconds that have passed since January 1, 1970 + $scope.newstructure._id+="-"+newId; + + var newData=[]; + var parentid = $('#jstree').jstree('get_selected')[0]; + newData.push({ "id" : $scope.newstructure._id,"chid":$scope.newstructure._id+'_imp', "isBranch":$scope.newstructure._isBranch , "parent" : parentid, "label" : $scope.newstructure._label}) + + function traverseTreeforImportContent(o,pid) { + for (var i in o) { + if (o[i] !== null && typeof (o[i]) == "object") { + var selectedNode = o[i]; + var childId = selectedNode._id; + if(childId!=undefined) + { + for (var k = 0; k < $scope.newcontent.length; k++) { + if (($scope.newcontent[k]._id == childId)) { + childId=childId +'-'+newId; + o[i]._id= childId; + $scope.newcontent[k]._id=childId; + newData.push({ "id" : childId, "chid":childId+'_imp' ,"isBranch":selectedNode._isBranch, "parent" : pid+'_imp', "label" : selectedNode._label}) + break; + } + } + } + var newpid= i=="structure"?pid: childId; + + traverseTreeforImportContent(o[i],newpid); + } + } + } + traverseTreeforImportContent($scope.newstructure,$scope.newstructure._id); + + //expend parent if collapse + $("#jstree").jstree("open_node", $('#'+parentid)); + + traverseTreeSelectedSingleObj($rootScope.stru, cbCurrentId); + + + $scope.selectedNodeSingleObj['structure'].push($scope.newstructure); + + $.merge($rootScope.contentNotesForSaveCB,$scope.newcontent); + + $rootScope.cbDynamicContents=$rootScope.contentNotesForSaveCB; + $rootScope.cbDynamicJsonData.slideshow.content.element=$rootScope.cbDynamicContents; + $rootScope.structure = $rootScope.cbDynamicJsonData.slideshow.presentation.structure.structure + + // add new node to tree + for (var i = 0 ; i < newData.length; i++) { + $('#jstree').jstree().create_node(newData[i].parent, { + "id": newData[i].chid, + "text":''+newData[i].label+'' + }, "last"); + } + $timeout(function(){ + for (var i = 0 ; i < newData.length; i++) { + $("#jstree").jstree("open_node", $('#'+newData[i].chid)); + var span_Id = newData[i].id; + var isbranch = newData[i].isBranch; + if (isbranch == "false") { + $("#jstree").jstree(true).set_icon(span_Id, "../../../content/images/CB/file.png"); + } + } + },500); + + + } + $rootScope.ExportSection = function () { var currentid = document.getElementById('cbSelect').value; @@ -981,10 +1115,10 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ alert("Curriculum name is empty!"); return; } - + var strFromParent=$scope.selectedNodeSingleObj['structure']; var parentLevel=$scope.selectedNodeSingleObj._label; - var parentId=$scope.selectedNodeSingleObj._id; + var parentId=$scope.selectedNodeSingleObj._id ; var rootNoteSummary = new jinqJs() .from($rootScope.contentNotesForSaveCB) @@ -1012,7 +1146,8 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ { for (var k = 0; k < $rootScope.contentNotesForSaveCB.length; k++) { if (($rootScope.contentNotesForSaveCB[k]._id == childId)) { - $scope.SectionContentForExportCB.push($rootScope.contentNotesForSaveCB[k]); + $scope.SectionContentForExportCB.push($rootScope.contentNotesForSaveCB[k]); + break; } } } @@ -1022,9 +1157,9 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ } } - + traverseTreeforExportContent(strFromParent); - + $rootScope.dynamicUpdatedJsonForExportCB = { "slideshow": { @@ -1071,7 +1206,6 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ } - $rootScope.DeleteSlideSection = function () { var cbCurrentSelectedId = document.getElementById('cbSelect').value; var CurrentSelectedLiId = $('#' + cbCurrentSelectedId).closest('li').attr('id'); @@ -1093,7 +1227,6 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ else { $rootScope.cbBack(); } - //$scope.deleteSectionForCB(cbCurrentSelectedId, CurrentSelectedParentSpanId); $scope.DeleteSlide(cbCurrentSelectedId, CurrentSelectedParentSpanId); var CurrentId = document.getElementById('cbSelect').value; $scope.DropDownSelectNodeClick(CurrentId); @@ -1105,7 +1238,6 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ document.getElementById('cbModelDeleteConfirmBoxId').style.display = "none"; } - $rootScope.CBAddSlide = function () { var current_id if (($rootScope.getLocalStorageValue("cbSelectId")) != '') { @@ -1115,7 +1247,6 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ current_id = document.getElementById('cbSelect').value; } - traverseTreeSelectedSingleObj($rootScope.stru, current_id); var parentid = $('#' + current_id).parent().parent().parent().parent().find('span').attr('id'); var createNodeId; @@ -1128,31 +1259,68 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ createNodeId = parentid; } - var AddSlideId = ""; - var AddSlideLiId = ""; - var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + var date = new Date(); + var newSlideId = 'sd'+date.getTime();//timestamp is the number of milliseconds that have passed since January 1, 1970 + + var treeliId=newSlideId+'li'; + + //expend parent if collapse + $("#jstree").jstree("open_node", $('#'+createNodeId)); - for (var i = 0; i < 5; i++) { - AddSlideId += possible.charAt(Math.floor(Math.random() * possible.length)); - AddSlideLiId += possible.charAt(Math.floor(Math.random() * (possible.length) + 1)); - } - // var AddSlideId = 'abcd'; - //var AddSlideId = Math.random().toString(); $('#jstree').jstree().create_node(createNodeId, { - li_attr: { "name": "isBranchFalse" }, - "id": AddSlideLiId, - "text": 'New Slide' + "id": treeliId, + "text": 'New Slide' }, "last", function () { - // //$scope.addCBSlide(current_id, AddSlideId); - $scope.addSlide(createNodeId, AddSlideId); - //$scope.DropDownSelectNodeClick(current_id); + $scope.addSlide(createNodeId, newSlideId); $('#jstree').jstree(true).deselect_all(); - $('#jstree').jstree('select_node', AddSlideLiId); - //$('#jstree').jstree('select_node', AddSlideId); - //$scope.openTinyMCE(AddSlideId); + $('#jstree').jstree('select_node', newSlideId); + }); + } + + $scope.addSlide = function (currentid, AddSlideId) { + if ($rootScope.structureObjForSaveCB.length == 0) { + $rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure; + } + + traverseTreeSelectedSingleObj($rootScope.stru, currentid); + + if (currentid == "-225638207") { + $rootScope.selectedNodeSingle.push( + { + "_label": "NEW Slide1", + "_id": AddSlideId, + "_isRoot": "false", + "_isBranch": "false", + "_isLocked": "false" + }); + $rootScope.structureObjForSaveCB.push({ + "_label": "NEW Slide1", + "_id": AddSlideId, + "_isRoot": "false", + "_isBranch": "false", + "_isLocked": "false" + }); + } + else { + $scope.selectedNodeSingleObj['structure'].push({ + "_label": "New Slide", + "_id": AddSlideId, + "_isRoot": "false", + "_isBranch": "false", + "_isLocked": "false" + }); - }); + for (var i = 0; i < $rootScope.structureObjForSaveCB.length; i++) { + if ($rootScope.structureObjForSaveCB[i]._id == currentid) { + $rootScope.structureObjForSaveCB[i]['structure'] = $scope.selectedNodeSingleObj['structure']; + } + } + } + + setTimeout(function () { + $("#jstree").jstree(true).set_icon(AddSlideId, "../../../content/images/CB/file.png"); + }, 500); } $rootScope.CBAddSection = function () { @@ -1174,88 +1342,100 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ createNodeId = parentid; } + var date = new Date(); + var newSectionId = 'sn'+date.getTime();//timestamp is the number of milliseconds that have passed since January 1, 1970 + + var treeliId=newSectionId+'li'; + //expend parent if collapse + $("#jstree").jstree("open_node", $('#'+createNodeId)); - var AddSectionId = ""; - var AddSectionLiId = ""; - var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; - - for (var i = 0; i < 5; i++) { - AddSectionId += possible.charAt(Math.floor(Math.random() * possible.length)); - AddSectionLiId += possible.charAt(Math.floor(Math.random() * (possible.length) + 1)); - } - - // var AddSlideId = 'abcd'; - //var AddSlideId = Math.random().toString(); $('#jstree').jstree().create_node(createNodeId, { - li_attr: { "name": "isBranchFalse" }, - "id": AddSectionLiId, - "text": 'New Section' + "id": treeliId, + "text": 'New Section' }, "last", function () { - //$scope.addCBSlide(current_id, AddSlideId); - $scope.addSection(createNodeId, AddSectionId); - //$scope.DropDownSelectNodeClick(current_id); + $scope.addSection(createNodeId, newSectionId); $('#jstree').jstree(true).deselect_all(); - //$('#jstree').jstree('select_node', AddSectionId); - $('#jstree').jstree('select_node', AddSectionLiId); - - + $('#jstree').jstree('select_node', newSectionId); }); } + $scope.addSection = function (currentid, AddSecionId) { - function traverseForLoadDropDown(o) { - - for (var i = 0; i < o.structure.structure.length; i++) { - $('#cbSelect').append(''); + if ($rootScope.structureObjForSaveCB.length == 0) { + $rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure; + } + if ($rootScope.contentNotesForSaveCB.length == 0) { + $rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents; } - } + traverseTreeSelectedSingleObj($rootScope.stru, currentid); + traverse($rootScope.stru, currentid); + if (currentid == "-225638207") { + $rootScope.selectedNodeSingle.push( + { + "structure": { + "structure": [ + ], + "_label": "New Section", + "_id": AddSecionId, + "_isRoot": "false", + "_isBranch": "true", + "_isLocked": "false" + } + }); + $rootScope.structureObjForSaveCB.push( + { + "structure": [ + ], + "_label": "New Section", + "_id": AddSecionId, + "_isRoot": "false", + "_isBranch": "true", + "_isLocked": "false" - $scope.deleteSectionForCB = function (currentid, CurrentSelectedParentSpanId) { + }); + } + else { + $scope.selectedNodeSingleObj['structure'].push( + { + "structure": [ + ], + "_label": "New Section", + "_id": AddSecionId, + "_isRoot": "false", + "_isBranch": "true", + "_isLocked": "false" + }); - if ($rootScope.structureObjForSaveCB.length == 0) { + $rootScope.contentNotesForSaveCB.push( + { + "summary": "", + "author": "", + "modified": "", + "password": "", + "version": "", + "windows": "", + "_id": AddSecionId + }); - $rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure; - } - if ($rootScope.contentNotesForSaveCB.length == 0) { - //$rootScope.contentNotesForSaveCB = $rootScope.cbJsonData.slideshow.content.element; - $rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents;//Assign Dnamic Contents - } - traverseTreeSelectedSingleObj($rootScope.structureObjForSaveCB, currentid); - if ($scope.selectedNodeSingleObj._isBranch == "true") { - for (var j = 0; j < $scope.selectedNodeSingleObj['structure'].length; j++) { - if ($scope.selectedNodeSingleObj._id == currentid) { - var childNodesForSelectedSection = $scope.selectedNodeSingleObj['structure']; - - if (childNodesForSelectedSection.length > 0) { - - for (var l = 0; l < childNodesForSelectedSection.length; l++) { - var childId = childNodesForSelectedSection[l]._id; // Get Child ID for selected Section node - for (var k = 0; k < $rootScope.contentNotesForSaveCB.length; k++) { - if (($rootScope.contentNotesForSaveCB[k]._id == childId)) { - $rootScope.contentNotesForSaveCB.splice(k, 1); - } - } - } - } + + for (var i = 0; i < $rootScope.structureObjForSaveCB.length; i++) { + if ($rootScope.structureObjForSaveCB[i]._id == currentid) { + $rootScope.structureObjForSaveCB[i]['structure'] = $scope.selectedNodeSingleObj['structure']; } - $scope.selectedNodeSingleObj['structure'].splice(j, 1); - //$rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure; } + } + + } + function traverseForLoadDropDown(o) { - //Delete notes for SavedraftCB as per Selected Section from tree - var deleteNotes = $rootScope.contentNotesForSaveCB - var remaingNotesForCB = new jinqJs() - .from(deleteNotes) - .delete().at("_id == " + currentid).select(); - $rootScope.contentNotesForSaveCB = remaingNotesForCB; - - //$rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents; - + for (var i = 0; i < o.structure.structure.length; i++) { + $('#cbSelect').append(''); + } } function getLoadNodeId(o) { @@ -1276,7 +1456,6 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure; } if ($rootScope.contentNotesForSaveCB.length == 0) { - //$rootScope.contentNotesForSaveCB = $rootScope.cbJsonData.slideshow.content.element; $rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents;//Assign Dnamic Contents } @@ -1409,7 +1588,6 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $("#filename").val(""); } - $rootScope.updatedContentFromEditor = function (cbCurrentId) { if ($rootScope.contentNotesForSaveCB.length == 0) { @@ -1427,8 +1605,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ if (notesForSelectedSlide == "" || notesForSelectedSlide == undefined) { notesForSelectedSlide = selectedSlideContent[0].notes; } - //Calling method for update Windows Data for selected slide - //$scope.windowsContentForSelectedSlide(windowsInSelectedSlide); + } else { windowsInSelectedSlide = ""; @@ -1454,7 +1631,6 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ } else if ($scope.selectedNodeSingleObj._isBranch == "true" && $scope.selectedNodeSingleObj._isRoot == "true") { - //traverseTreeSelectedSingleObj($rootScope.Auther, cbCurrentId); traverseTreeSelectedSingleObj($rootScope.cbDynamicContents, cbCurrentId); $rootScope.contentNotesForSaveCB.push( { @@ -1471,7 +1647,6 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ }); } else if ($scope.selectedNodeSingleObj._isBranch == "true") { - //traverseTreeSelectedSingleObj($rootScope.Auther, cbCurrentId); traverseTreeSelectedSingleObj($rootScope.cbDynamicContents, cbCurrentId); $rootScope.contentNotesForSaveCB.push( { @@ -1494,241 +1669,6 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ } - - $rootScope.exportToFile = function () { - - var cbCurrentId = document.getElementById('cbSelect').value; - if ($rootScope.structureObjForSaveCB.length == 0) { - //$rootScope.structureObjForSaveCB = $rootScope.structure;// only Tree Array - //$rootScope.structureObjForSaveCB = $rootScope.stru.slideshow.presentation.structure.structure; - $rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure; - } - if ($rootScope.contentNotesForSaveCB.length == 0) { - //$rootScope.contentNotesForSaveCB = $rootScope.cbJsonData.slideshow.content.element; - $rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents;//Assign Dnamic Contents - } - $rootScope.updatedContentFromEditor(cbCurrentId); - - $rootScope.dynamicUpdatedJsonForSaveCB = - { - "slideshow": { - "presentation": { - "structure": { - "structure": //[ - - $rootScope.structureObjForSaveCB, - //], - "_label": $rootScope.cbTreeFirstLabel, - "_id": $rootScope.cbTreeFirstID, - "_isRoot": "true", - "_isBranch": "true", - "_isLocked": "false" - }, - "_anchor": "true", - "_window_position": "6,10", - "_window_size": "828,453" // Apply Dynamic - }, - "content": { - "element": //[ - - $rootScope.contentNotesForSaveCB, - //] - } - } - - }; - - $scope.slideshow = $rootScope.dynamicUpdatedJsonForSaveCB; - $scope.filename = "SandySaveCB.json"; - var filename = $scope.filename; - var blob = new Blob([angular.toJson($rootScope.dynamicUpdatedJsonForSaveCB, true)], { type: 'text/text' }); - if (window.navigator && window.navigator.msSaveOrOpenBlob) { - window.navigator.msSaveOrOpenBlob(blob, filename); - } - else { - - $(document).execCommand("SaveAs", true, filename); - document.execCommand("SaveAs", true, filename); - angular.element(document.execCommand("SaveAs", false, filename)).scope(); - - //var e = document.createEvent('MouseEvents'), - //a = document.createElement('a'); - // a.download = filename; - //a.href = window.URL.createObjectURL(blob); - //a.dataset.downloadurl = ['text/json', a.download, a.href].join(':'); - //e.initEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); - //a.dispatchEvent(e); - //window.URL.revokeObjectURL(url); // clean the url.createObjectURL resource - } - $rootScope.dynamicUpdatedJsonForSaveCB = ""; - //$rootScope.contentNotesForSaveCB = []; - //$rootScope.structureObjForSaveCB = []; - - // $http({ method: 'Post', url: $scope.fileName }).success(function (data) { - // localStorage.setItem("cbJsonDataObject", JSON.stringify(data)); - // $rootScope.cbJsonData = JSON.parse(localStorage.getItem("cbJsonDataObject")); - // $rootScope.cbDynamicJsonData = data; - // //$scope.getCBsummary(); - // $rootScope.cbJsonData.slideshow.content.element = "Eement data"; - // $rootScope.cbDynamicJsonData.slideshow.content.element = "slideshow element data"; - // $rootScope.note = "save data" - // //$scope.openCurriculumDetail(); - // }) - //.error(function (data, status, headers, config) { - // console.log(data); - //}); - }; - - $scope.addSection = function (currentid, AddSecionId) { - - if ($rootScope.structureObjForSaveCB.length == 0) { - $rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure; - } - if ($rootScope.contentNotesForSaveCB.length == 0) { - $rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents; - } - - traverseTreeSelectedSingleObj($rootScope.stru, currentid); - traverse($rootScope.stru, currentid); - if (currentid == "-225638207") { - $rootScope.selectedNodeSingle.push( - { - "structure": { - "structure": [ - ], - "_label": "New Section", - "_id": AddSecionId, - "_isRoot": "false", - "_isBranch": "true", - "_isLocked": "false" - } - - }); - $rootScope.structureObjForSaveCB.push( - { - "structure": [ - ], - "_label": "New Section", - "_id": AddSecionId, - "_isRoot": "false", - "_isBranch": "true", - "_isLocked": "false" - - }); - } - else { - $scope.selectedNodeSingleObj['structure'].push( - { - "structure": [ - ], - "_label": "New Section", - "_id": AddSecionId, - "_isRoot": "false", - "_isBranch": "true", - "_isLocked": "false" - }); - - $rootScope.contentNotesForSaveCB.push( - { - "summary": "", - "author": "", - "modified": "", - "password": "", - "version": "", - "windows": "", - "_id": AddSecionId - //"notes": notesForSelectedSlide, - //"windows": windowsInSelectedSlide, - //"_id": cbCurrentId - }); - - //if (currentid == $rootScope.cbTreeFirstID) { - // $rootScope.structureObjForSaveCB.push( - // { - // "structure": [ - // ], - // "_label": "New Section", - // "_id": AddSecionId, - // "_isRoot": "false", - // "_isBranch": "true", - // "_isLocked": "false" - // }); - //} - //else { - for (var i = 0; i < $rootScope.structureObjForSaveCB.length; i++) { - if ($rootScope.structureObjForSaveCB[i]._id == currentid) { - $rootScope.structureObjForSaveCB[i]['structure'] = $scope.selectedNodeSingleObj['structure']; - } - } - //} - } - // setTimeout(function () { traverseTreeForSetIcons($rootScope.stru, currentid); }, 1500); - } - - $scope.addSlide = function (currentid, AddSlideId) { - if ($rootScope.structureObjForSaveCB.length == 0) { - $rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure; - } - //if ($rootScope.contentNotesForSaveCB.length == 0) { - // $rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents; - //} - traverseTreeSelectedSingleObj($rootScope.stru, currentid); - // traverse($rootScope.stru, currentid); - //console.log(JSON.stringify($scope.upDateJsonObj)) - if (currentid == "-225638207") { - $rootScope.selectedNodeSingle.push( - { - "_label": "NEW Slide1", - "_id": AddSlideId, - "_isRoot": "false", - "_isBranch": "false", - "_isLocked": "false" - }); - $rootScope.structureObjForSaveCB.push({ - "_label": "NEW Slide1", - "_id": AddSlideId, - "_isRoot": "false", - "_isBranch": "false", - "_isLocked": "false" - }); - } - else { - $scope.selectedNodeSingleObj['structure'].push({ - "_label": "New Slide", - "_id": AddSlideId, - "_isRoot": "false", - "_isBranch": "false", - "_isLocked": "false" - }); - - //$rootScope.contentNotesForSaveCB.push({ - // "notes": tinyMCE.activeEditor.getContent(), - // "windows": "", - // "_id": AddSlideId - //}); - - //if (currentid == $rootScope.cbTreeFirstID) { - // $rootScope.structureObjForSaveCB.push({ - // "_label": "New Slide", - // "_id": AddSlideId, - // "_isRoot": "false", - // "_isBranch": "false", - // "_isLocked": "false" - // }); - //} - //else { - for (var i = 0; i < $rootScope.structureObjForSaveCB.length; i++) { - if ($rootScope.structureObjForSaveCB[i]._id == currentid) { - $rootScope.structureObjForSaveCB[i]['structure'] = $scope.selectedNodeSingleObj['structure']; - } - } - //} - } - // setTimeout(function () { traverseTreeForSetIcons($rootScope.stru, currentid); }, 3000); - setTimeout(function () { $("#jstree").jstree(true).set_icon(AddSlideId, "../../../content/images/CB/file.png"); }, 100); - } - - $scope.moveDown = function (currentid) { traverse($rootScope.stru, currentid); @@ -1747,8 +1687,6 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ $scope.moveUP = function (currentid) { traverse($rootScope.stru, currentid); - //console.log("cbJsonData Before" + JSON.stringify($rootScope.stru)); - //console.log("upDateJsonObj Before" + JSON.stringify($scope.selectedNodeSiblingObjs)); for (var j = 0; j < $scope.selectedNodeSiblingObjs.length; j++) { if (($scope.selectedNodeSiblingObjs[j]._id == currentid) && ($scope.selectedNodeSiblingObjs[j - 1] != undefined)) { @@ -1758,9 +1696,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ } } $rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure; - //console.log("upDateJsonObjenew after" + JSON.stringify($scope.selectedNodeSiblingObjs)); - //console.log("stru after" + JSON.stringify($rootScope.stru)); - //console.log("structure after" + JSON.stringify($rootScope.structure)); + } function traverseTreeSelectedSingleObj(o, current_id) { @@ -2157,128 +2093,8 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ } } - //Start Code for Update Windows Content for DA, CA, CI, AA, 3D Module to Save CB - $scope.windowsContentForSelectedSlide = function (currentId) { - var contentWindowsdata = $rootScope.contentNotesForSaveCB; - $scope.setWinDataToArray = []; - var selectedSlideContent = new jinqJs() - .from(contentWindowsdata) - .where("_id == " + currentId) - .select(); - if (selectedSlideContent[0].windows != "") { - if (selectedSlideContent != undefined && Array.isArray(selectedSlideContent[0].windows.window)) { - for (var i = 0 ; i < selectedSlideContent[0].windows.window.length; i++) { - $scope.windowDataforCB = JSON.parse(selectedSlideContent[0].windows.window[i]) - $scope.setWinDataToArray.push($scope.windowDataforCB); - } - } - else { - $scope.windowDataforCB = JSON.parse(selectedSlideContent[0].windows.window) - $scope.setWinDataToArray.push($scope.windowDataforCB); - } - $rootScope.updateWindowsContentForSaveCB_Old(currentId); - } - } - $scope.updatedWindowListForSaveCB = []; - $rootScope.updateWindowsContentForSaveCB_Old = function (currentId) { - var isAA = true; var isCI = true; var isDA = true; - for (var j = 0; j < $scope.setWinDataToArray.length; j++) { - - switch ($scope.setWinDataToArray[j].mType) { - case "MY_PICTURES": - $scope.savePicWindowActivity($scope.windowDataforCB); - break; - case "DISSECTIBLE_ANATOMY": - $scope.saveDAWindowActivity(); - break; - case "ATLAS_ANATOMY": - if (isAA) { - $scope.saveAAWindowActivity(); - isAA = false; - } - break; - case "CLINICAL_ILLUSTRATIONS": - if (isCI) { - $scope.saveCIWindowActivity(); - isCI = false; - } - break; - case "CLINICAL_ANIMATIONS": - $scope.saveCAWindowActivity(); - break; - case "THREE_D_ANATOMY": - $scope.save3DWindowActivity(); - break; - default: - - } - } - findKeyForChange($rootScope.contentNotesForSaveCB, currentId); - $scope.selectedKey.windows.window = []; - - for (var s = 0; s < $scope.updatedWindowListForSaveCB.length; s++) { - var arrToStrWinObj = JSON.stringify($scope.updatedWindowListForSaveCB[s]); - $scope.selectedKey.windows.window.push(arrToStrWinObj); - } - $scope.updatedWindowListForSaveCB = []; - console.log($scope.selectedKey.windows.window); - } - - $scope.saveCIWindowActivity_Old = function (keyName, value) { - for (var i = 0; i < $scope.setWinDataToArray.length; i++) { - $scope.setWinDataToArray[i][keyName] = value; - var current_id; - if (($rootScope.getLocalStorageValue("cbSelectId")) != '') { - current_id = $rootScope.getLocalStorageValue("cbSelectId"); - } - else { - current_id = document.getElementById('cbSelect').value; - } - findKeyForChange($rootScope.contentNotesForSaveCB, current_id); - //var modifiedWindowObj = JSON.parse($scope.selectedKey.windows.window); - //modifiedWindowObj.textVisible = value; - //$scope.selectedKey.windows.window = modifiedWindowObj; - $scope.selectedKey.windows.window = ""; - if (keyName != "") { - $scope.selectedKey.windows.window = JSON.stringify($scope.setWinDataToArray[i]); - } - } - console.log($rootScope.contentNotesForSaveCB); - - //$scope.windowDataforCB = { - //slideId: currentId,//SlideNo, - //currentWindowId: windowId, - //mType: windowData.mType, - //containsCapturedContent: windowData.containsCapturedContent, - - //textVisible: checkVisiblity//windowData.textVisible, - //anatomyTitle: windowData.currentViewTitle, - //horizontalScroll: windowData.scrollPosition.horizontal + 'px', - //verticalScroll: windowData.scrollPosition.vertical + 'px', - //imageId: windowData.imageId,//N - //maximised: windowData.maximised,//Not Found - //minimised: windowData.minimised,//Not Found - //id: windowData.id, - //size: windowData.size, - //position: windowData.position, - //position: { - // top: $rootScope.jsPanelTop, - // left: $rootScope.jsPanelLeft, - //}, - - //size: { - // width: $rootScope.jsPanelWidth, - // height: $rootScope.jsPanelHeight - //}, - //contextMenu: windowData.contextMenu, - //annotationData: windowData.annotationData - - //}; - - } - function findKeyForChange(o, keyname) { var i; for (i in o) { @@ -2289,11 +2105,7 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $ } findKeyForChange(o[i], keyname); } - //else { - // if (i == keyname) { - // $scope.selectedKey = i; - // } - //} + } } diff --git a/400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/CBuild-view.html b/400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/CBuild-view.html index 6b4450c..7aed8f8 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/CBuild-view.html +++ b/400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/CBuild-view.html @@ -2,7 +2,7 @@
-
+
    @@ -25,7 +25,7 @@