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
	{
3
	{
4
		"selected_items":
4
		"selected_items":
5
		[
5
		[
6
			[
7
				"binary",
8
				"binaryLength"
9
			],
10
			[
11
				"generate",
12
				"generateBinary"
13
			]
6
		]
14
		]
7
	},
15
	},
8
	"buffers":
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
	"build_system": "",
19
	"build_system": "",
28
	"command_palette":
20
	"command_palette":
48
	},
40
	},
49
	"file_history":
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
		"/home/bryan/Projects/whistle/scripts/app.js",
53
		"/home/bryan/Projects/whistle/scripts/app.js",
52
		"/home/bryan/Projects/whistle/scripts/utilities.js",
54
		"/home/bryan/Projects/whistle/scripts/utilities.js",
53
		"/home/bryan/Projects/whistle/index.html",
55
		"/home/bryan/Projects/whistle/index.html",
55
	],
57
	],
56
	"find":
58
	"find":
57
	{
59
	{
58
		"height": 0.0
60
		"height": 35.0
59
	},
61
	},
60
	"find_in_files":
62
	"find_in_files":
61
	{
63
	{
69
		"case_sensitive": false,
71
		"case_sensitive": false,
70
		"find_history":
72
		"find_history":
71
		[
73
		[
74
			"whistler"
72
		],
75
		],
73
		"highlight": true,
76
		"highlight": true,
74
		"in_selection": false,
77
		"in_selection": false,
86
	"groups":
89
	"groups":
87
	[
90
	[
88
		{
91
		{
89
			"selected": 1,
90
			"sheets":
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
	},
100
	},
155
	"input":
101
	"input":
156
	{
102
	{
157
		"height": 0.0
103
		"height": 33.0
158
	},
104
	},
159
	"layout":
105
	"layout":
160
	{
106
	{
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
		"width": 380.0
151
		"width": 380.0
206
	},
152
	},
207
	"show_minimap": true,
153
	"show_minimap": true,
208
	"show_open_files": true,
154
	"show_open_files": false,
209
	"show_tabs": true,
155
	"show_tabs": true,
210
	"side_bar_visible": true,
156
	"side_bar_visible": true,
211
	"side_bar_width": 243.0,
157
	"side_bar_width": 243.0,

+ 3 - 2
index.html

7
    <body>
7
    <body>
8
        <header>
8
        <header>
9
            <a href="/" title="Hex Intro">Hex Inro</a>
9
            <a href="/" title="Hex Intro">Hex Inro</a>
10
            &nbsp;|&nbsp;
10
            <a href="#/dump" title="Hex Dump">Hex Dump</a>
11
            <a href="#/dump" title="Hex Dump">Hex Dump</a>
11
            <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
            <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
        </header>
13
        </header>
15
            <span>For demonstration purposes.</span>
16
            <span>For demonstration purposes.</span>
16
        </footer>
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="http://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>
20
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js"></script>
20
        <script type="text/javascript" src="http://code.angularjs.org/1.0.1/angular-resource-1.0.1.min.js"></script>
21
        <script type="text/javascript" src="http://code.angularjs.org/1.0.1/angular-resource-1.0.1.min.js"></script>
21
        <script type="text/javascript" src="scripts/utilities.js"></script>
22
        <script type="text/javascript" src="scripts/utilities.js"></script>
22
        <script type="text/javascript" src="scripts/components.js"></script>
23
        <script type="text/javascript" src="scripts/components.js"></script>

+ 6 - 2
partials/dump.html

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
<tabs>
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
</tabs>
9
</tabs>

+ 1 - 25
scripts/app.js

17
            templateUrl: "partials/intro.html"
17
            templateUrl: "partials/intro.html"
18
        });
18
        });
19
        //.otherwise({ redirectTo: "/" });
19
        //.otherwise({ redirectTo: "/" });
20
    }])
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
    });;

+ 24 - 0
scripts/components.js

1
angular.module('hexmeh', [])
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
    .directive('tabs', function () {
26
    .directive('tabs', function () {
3
        return {
27
        return {
4
            restrict: 'E',
28
            restrict: 'E',

+ 76 - 72
scripts/controllers.js

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