Browse Source

general changes

bmallred 12 years ago
parent
commit
b7e8ab6e63
6 changed files with 133 additions and 178 deletions
  1. 23 77
      hexmeh.sublime-workspace
  2. 3 2
      index.html
  3. 6 2
      partials/dump.html
  4. 1 25
      scripts/app.js
  5. 24 0
      scripts/components.js
  6. 76 72
      scripts/controllers.js

+ 23 - 77
hexmeh.sublime-workspace

@ -3,26 +3,18 @@
3 3
	{
4 4
		"selected_items":
5 5
		[
6
			[
7
				"binary",
8
				"binaryLength"
9
			],
10
			[
11
				"generate",
12
				"generateBinary"
13
			]
6 14
		]
7 15
	},
8 16
	"buffers":
9 17
	[
10
		{
11
			"file": "index.html",
12
			"settings":
13
			{
14
				"buffer_size": 1070,
15
				"line_ending": "Unix"
16
			}
17
		},
18
		{
19
			"file": "scripts/controllers.js",
20
			"settings":
21
			{
22
				"buffer_size": 4893,
23
				"line_ending": "Unix"
24
			}
25
		}
26 18
	],
27 19
	"build_system": "",
28 20
	"command_palette":
@ -48,6 +40,16 @@
48 40
	},
49 41
	"file_history":
50 42
	[
43
		"/home/bryan/Projects/hexmeh/scripts/utilities.js",
44
		"/home/bryan/Projects/hexmeh/styles/hexmeh.css",
45
		"/home/bryan/Projects/hexmeh/index.html",
46
		"/home/bryan/Projects/hexmeh/scripts/controllers.js",
47
		"/home/bryan/Projects/hexmeh/partials/intro.html",
48
		"/home/bryan/Projects/hexmeh/scripts/services.js",
49
		"/home/bryan/Projects/hexmeh/crossdomain.xml",
50
		"/home/bryan/Projects/hexmeh/scripts/app.js",
51
		"/home/bryan/Projects/hexmeh/.gitignore",
52
		"/home/bryan/Projects/hexmeh/README.md",
51 53
		"/home/bryan/Projects/whistle/scripts/app.js",
52 54
		"/home/bryan/Projects/whistle/scripts/utilities.js",
53 55
		"/home/bryan/Projects/whistle/index.html",
@ -55,7 +57,7 @@
55 57
	],
56 58
	"find":
57 59
	{
58
		"height": 0.0
60
		"height": 35.0
59 61
	},
60 62
	"find_in_files":
61 63
	{
@ -69,6 +71,7 @@
69 71
		"case_sensitive": false,
70 72
		"find_history":
71 73
		[
74
			"whistler"
72 75
		],
73 76
		"highlight": true,
74 77
		"in_selection": false,
@ -86,65 +89,8 @@
86 89
	"groups":
87 90
	[
88 91
		{
89
			"selected": 1,
90 92
			"sheets":
91 93
			[
92
				{
93
					"buffer": 0,
94
					"file": "index.html",
95
					"settings":
96
					{
97
						"buffer_size": 1070,
98
						"regions":
99
						{
100
						},
101
						"selection":
102
						[
103
							[
104
								243,
105
								243
106
							]
107
						],
108
						"settings":
109
						{
110
							"syntax": "Packages/HTML/HTML.tmLanguage",
111
							"tab_size": 4,
112
							"translate_tabs_to_spaces": true
113
						},
114
						"translation.x": 0.0,
115
						"translation.y": 0.0,
116
						"zoom_level": 1.0
117
					},
118
					"type": "text"
119
				},
120
				{
121
					"buffer": 1,
122
					"file": "scripts/controllers.js",
123
					"settings":
124
					{
125
						"buffer_size": 4893,
126
						"regions":
127
						{
128
						},
129
						"selection":
130
						[
131
							[
132
								4893,
133
								4893
134
							]
135
						],
136
						"settings":
137
						{
138
							"syntax": "Packages/JavaScript/JavaScript.tmLanguage",
139
							"tab_size": 4,
140
							"translate_tabs_to_spaces": true
141
						},
142
						"translation.x": 0.0,
143
						"translation.y": 0.0,
144
						"zoom_level": 1.0
145
					},
146
					"type": "text"
147
				}
148 94
			]
149 95
		}
150 96
	],
@ -154,7 +100,7 @@
154 100
	},
155 101
	"input":
156 102
	{
157
		"height": 0.0
103
		"height": 33.0
158 104
	},
159 105
	"layout":
160 106
	{
@ -199,13 +145,13 @@
199 145
		[
200 146
			[
201 147
				"",
202
				"/home/bryan/Projects/azucar-fitness/azucar-fitness.sublime-project"
148
				"/home/bryan/Projects/mcnaughty/mcnaughty.sublime-project"
203 149
			]
204 150
		],
205 151
		"width": 380.0
206 152
	},
207 153
	"show_minimap": true,
208
	"show_open_files": true,
154
	"show_open_files": false,
209 155
	"show_tabs": true,
210 156
	"side_bar_visible": true,
211 157
	"side_bar_width": 243.0,

+ 3 - 2
index.html

@ -7,6 +7,7 @@
7 7
    <body>
8 8
        <header>
9 9
            <a href="/" title="Hex Intro">Hex Inro</a>
10
            &nbsp;|&nbsp;
10 11
            <a href="#/dump" title="Hex Dump">Hex Dump</a>
11 12
            <a href="https://github.com/bmallred/hexmeh"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>
12 13
        </header>
@ -15,8 +16,8 @@
15 16
            <span>For demonstration purposes.</span>
16 17
        </footer>
17 18
        
18
        <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
19
        <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js"></script>
19
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
20
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js"></script>
20 21
        <script type="text/javascript" src="http://code.angularjs.org/1.0.1/angular-resource-1.0.1.min.js"></script>
21 22
        <script type="text/javascript" src="scripts/utilities.js"></script>
22 23
        <script type="text/javascript" src="scripts/components.js"></script>

+ 6 - 2
partials/dump.html

@ -1,5 +1,9 @@
1
<div id="drop-zone" style="height: 5em; width: 80%; border: 1px dashed #000; background-color: #fff;">Drop a file here!</div>
1
<!--<div id="drop-zone" style="height: 5em; width: 80%; border: 1px dashed #000; background-color: #fff;">Drop a file here!</div>-->
2 2
3 3
<tabs>
4
    <pane ng:repeat="file in files" title="{{file.name}}"></pane>
4
    <pane ng-repeat="file in files" title="{{file.name}}">
5
    	<div class="lineNumber" style="display: inline-block;">Line Numbers</div>
6
    	<div class="lineHex" style="display: inline-block;">Line Hex</div>
7
    	<div class="lineCharacters" style="display: inline-block;">Line Characters</div>
8
    </pane>
5 9
</tabs>

+ 1 - 25
scripts/app.js

@ -17,28 +17,4 @@ angular.module("hexmeh", [])
17 17
            templateUrl: "partials/intro.html"
18 18
        });
19 19
        //.otherwise({ redirectTo: "/" });
20
    }])
21
    .directive('fadey', function() {
22
        return {
23
            restrict: 'A',
24
            link: function(scope, elm, attrs) {
25
                var duration = parseInt(attrs.fadey);
26
                
27
                if (isNaN(duration)) {
28
                    duration = 500;
29
                }
30
                
31
                elm = jQuery(elm);
32
                elm.hide();
33
                elm.fadeIn(duration)
34
                
35
                scope.destroy = function(complete) {
36
                    elm.fadeOut(duration, function() {
37
                        if (complete) {
38
                            complete.apply(scope);
39
                        }
40
                    });
41
                };
42
            }
43
        };
44
    });;
20
    }]);

+ 24 - 0
scripts/components.js

@ -1,4 +1,28 @@
1 1
angular.module('hexmeh', [])
2
    .directive('fadey', function() {
3
        return {
4
            restrict: 'A',
5
            link: function(scope, elm, attrs) {
6
                var duration = parseInt(attrs.fadey);
7
                
8
                if (isNaN(duration)) {
9
                    duration = 500;
10
                }
11
                
12
                elm = jQuery(elm);
13
                elm.hide();
14
                elm.fadeIn(duration)
15
                
16
                scope.destroy = function(complete) {
17
                    elm.fadeOut(duration, function() {
18
                        if (complete) {
19
                            complete.apply(scope);
20
                        }
21
                    });
22
                };
23
            }
24
        };
25
    });
2 26
    .directive('tabs', function () {
3 27
        return {
4 28
            restrict: 'E',

+ 76 - 72
scripts/controllers.js

@ -8,91 +8,95 @@ function MainController($scope, $routeParams) {
8 8
  $scope.hex = "";
9 9
  
10 10
  $scope.displayResults = function () {
11
      return $scope.hex.length > 0;
11
    return $scope.hex.length > 0;
12 12
  };
13 13
  
14 14
  $scope.generate = function () {
15
      $scope.binary = generateBinary($scope.binaryLength);
16
      $scope.parts = [];
17
      $scope.hex = "";
18
      
19
      return false;
15
    $scope.binary = generateBinary($scope.binaryLength);
16
    $scope.parts = [];
17
    $scope.hex = "";
18
    
19
    return false;
20 20
  };
21 21
  
22 22
  $scope.solve = function () {
23
      $scope.parts = [];
24
      $scope.hex = "";
25
      
26
      var original = $scope.binary;
23
    $scope.parts = [];
24
    $scope.hex = "";
25
    
26
    var original = $scope.binary;
27
    
28
    while (original.length > 0) {
29
      // Find the 16 bytes we need.
30
      var part = original.substr(-4);
31
      var character = binaryToHex(part);
27 32
      
28
      while (original.length > 0) {
29
          // Find the 16 bytes we need.
30
          var part = original.substr(-4);
31
          var character = binaryToHex(part);
32
          
33
          // Divvy this stuff up.
34
          $scope.parts.push({ "binary": part, "hex": character });
35
          $scope.hex = character + $scope.hex;
36
          
37
          // Remove the last four.
38
          original = original.substr(0, original.length - 4);
39
      }
33
      // Divvy this stuff up.
34
      $scope.parts.push({ "binary": part, "hex": character });
35
      $scope.hex = character + $scope.hex;
40 36
      
41
      return false;
37
      // Remove the last four.
38
      original = original.substr(0, original.length - 4);
39
    }
40
    
41
    return false;
42 42
  };
43 43
}
44 44
45 45
function DumpController($scope, $routeParams) {
46
    $scope.columns = 16;
47
    $scope.fileApi = false;
48
    $scope.files = [];
49
    
50
    $scope.showFiles = function () {
51
        return $scope.files;
52
    };
46
  $scope.columns = 16;
47
  $scope.fileApi = false;
48
  $scope.files = [];
49
  
50
  $scope.showFiles = function () {
51
    return $scope.files;
52
  };
53
  
54
  // Check for the various File API support.
55
  if (window.File && window.FileReader && window.FileList && window.Blob) {
56
    // Great success! All the File APIs are supported.
57
    $(window).bind("dragover", function (e) {
58
      e.stopPropagation();
59
      e.preventDefault();
60
      e.originalEvent.dataTransfer.dropEffect = 'copy';
61
    });
53 62
    
54
    // Check for the various File API support.
55
    if (window.File && window.FileReader && window.FileList && window.Blob) {
56
        // Great success! All the File APIs are supported.
57
        $("#drop-zone").bind("dragover", function (e) {
58
            e.stopPropagation();
59
            e.preventDefault();
60
            e.originalEvent.dataTransfer.dropEffect = 'copy';
61
        });
63
    $(window).bind("drop", function(e) {
64
      e.stopPropagation();
65
      e.preventDefault();
66
      
67
      var files = e.originalEvent.dataTransfer.files;
68
      
69
      for (var i = 0, f; f = files[i]; i++) {
70
        var reader = new FileReader();
62 71
        
63
        $("#drop-zone").bind("drop", function(e) {
64
            e.stopPropagation();
65
            e.preventDefault();
66
            
67
            var files = e.originalEvent.dataTransfer.files;
72
        // Closure to capture the file information.
73
        reader.onload = (function(theFile) {
74
          return function(e) {
75
            var bytes = new Uint8Array(e.target.result);
68 76
            
69
            for (var i = 0, f; f = files[i]; i++) {
70
                /*var reader = new FileReader();
71
                
72
                // Closure to capture the file information.
73
                reader.onload = (function(theFile) {
74
                    return function(e) {
75
                        var bytes = new Uint8Array(e.target.result);
76
                        var c = 0;
77
                        for (var i = 0; i < bytes.length; i++) {
78
                            if (c++ >= 16) {
79
                                $("#tabFile1").append("<br>");
80
                                c = 0;
81
                            }
82
                            
83
                            $("#tabFile1").append(bytes[i].toString(16) + " ");
84
                        }
85
                };
86
                })(f);
87
                
88
                // Read in the image file as a data URL.
89
                reader.readAsArrayBuffer(f);*/
90
          
91
                $scope.files.push(f);
92
            }
93
        });
94
    } else {
95
        $scope.fileApi = false;
96
        alert('The File APIs are not fully supported in this browser.');
97
    }
77
            $scope.files.push({
78
              "name": theFile.name,
79
              "bytes": bytes
80
            });
81
82
            /*var c = 0;
83
            for (var i = 0; i < bytes.length; i++) {
84
              if (c++ >= 16) {
85
                $("#tabFile1").append("<br>");
86
                c = 0;
87
              }
88
              
89
              $("#tabFile1").append(bytes[i].toString(16) + " ");
90
            }*/
91
          };
92
        })(f);
93
        
94
        // Read in the image file as a data URL.
95
        reader.readAsArrayBuffer(f);
96
      }
97
    });
98
  } else {
99
    $scope.fileApi = false;
100
    alert('The File APIs are not fully supported in this browser.');
101
  }
98 102
}