-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtoSQLInController.js
60 lines (51 loc) · 1.45 KB
/
toSQLInController.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
app.controller("toSQLInController", function ($scope) {
$scope.types = [
{typeConcat : "new line", symbol : "\n"},
{typeConcat : "tab", symbol : "\t"},
{typeConcat : "semicolon", symbol : ";"},
{typeConcat : "dash", symbol : "-"},
{typeConcat : "underscore", symbol : "_"},
];
$scope.checks = {
double : false,
simple : true,
}
$scope.UpdateCheckBox = function(name){
if(name == "toSimple" && $scope.checks.double == true){
$scope.checks.double = false;
}
if(name == "toDouble" && $scope.checks.simple == true){
$scope.checks.simple = false;
}
}
$scope.stringToReplace = "";
$scope.stringOut = undefined;
$scope.msgError = undefined;
$scope.replaceString = function(){
$scope.msgError = undefined;
$scope.stringOut = undefined;
try{
if($scope.stringToReplace.trim() != ""){
var array;
for(var i=0; i < $scope.types.length; i++){
if($scope.types[i].typeConcat == $scope.selectedType.typeConcat){
array = $scope.stringToReplace.split($scope.types[i].symbol);
break;
}
}
var cleanString = "";
if($scope.checks.simple == true){
cleanString = "('"+array.join("','")+"')";
}
else{
cleanString = '("'+array.join('","')+'")';
}
$scope.stringOut=cleanString;
}else{
$scope.msgError = "Please insert elements in the textarea box";
}
}catch(err){
$scope.msgError = err.toString();
}
}
});