{"id":21540321,"url":"https://github.com/lostsource/jshexgrid","last_synced_at":"2025-04-10T03:33:08.045Z","repository":{"id":18274762,"uuid":"21438178","full_name":"lostsource/JSHexGrid","owner":"lostsource","description":null,"archived":false,"fork":false,"pushed_at":"2016-02-25T06:42:29.000Z","size":148,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-02T01:41:24.590Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lostsource.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-02T19:48:48.000Z","updated_at":"2019-01-24T23:36:45.000Z","dependencies_parsed_at":"2022-08-28T08:22:44.202Z","dependency_job_id":null,"html_url":"https://github.com/lostsource/JSHexGrid","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostsource%2FJSHexGrid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostsource%2FJSHexGrid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostsource%2FJSHexGrid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostsource%2FJSHexGrid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lostsource","download_url":"https://codeload.github.com/lostsource/JSHexGrid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248151542,"owners_count":21056129,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-24T04:18:04.719Z","updated_at":"2025-04-10T03:33:08.018Z","avatar_url":"https://github.com/lostsource.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"JSHexGrid\n=========\n\nJSHexGrid is a JavaScript object which allows analysis of data in byte and text form. It can be used to analyze file content or any other data sources.\n\nAn implementation is currently used in the [HexReader] app for Chrome. \n\nUsage\n=====\n\nJSHexGrid can be initialized by using the `grid` constructor. Parameters are passed using the various properties listed below.\n\n**Creating a grid instance**\n\n    var Grid = new JSHexGrid.grid({\n        rows:       // Number of rows to display in grid. \n        (required)  // eg. 16\n                \n                    \n        container:  // Calling Grid.render will append grid to this element\n        (required)  // eg. document.getElementById('myGrid')\n        \n        dataSrc:    // This should contain a DataHandler object described below\n        (required)  \n\n        colors:     // set colors of grid based on passed object\n                    // built in themes are available\n                    // JSHexGrid.theme.default, JSHexGrid.theme.dark, JSHexGrid.theme.light\n    });\n\n**DataHandler**\n\nDataHandlers are used to supply the grid with bytes during load time and any time the user scrolls the view.\n\nJSHexGrid comes with a built in File DataHandler. (assuming `myFile` contains a File retrieved via an `\u003cinput type='file'/\u003e` dialog)\n\n    dataSrc: JSHexGrid.dataHandler.file(myFile)\n\nIf you're not retrieving data from a File, you can implement your own DataHandler. \n\nWhatever the source of your data, DataHandlers should eventually expose these methods:\n\n`getSize(void)` should return the total amount of bytes available to be read.\n\n`getByteArray(int start, int end, function callback)` should get the data bytes starting at offset *start* and ending at offset *end* and apply them to the passed *callback* function as a Uint8Array parameter.\n\n\nGrid Methods\n============\n\n    getBuffer(void)\n    \nReturns `ArrayBuffer` of bytes in current view. \n\nThe returned buffer will contain 7 more bytes following the current view (if available). These may be useful for computing 16bit/32bit/64bit values when mouse hovers over last byte in view.\n    \n    getDimensions(void)\n    \nReturns dimension information for grid. This could be useful for proper styling of grid surroundings. The object returned contains this structure:\n\n    {\n        height:336,    // height of grid in pixels\n        width:647,     // width of grid in pixels\n        row:{\n            height:21, // height of one row in pixels\n            count:16   // total number of rows in view\n        }\n    }\n\n\u0026nbsp;\n\n    getElementsByIndex(int index)\n    \nReturn object with two properties. \n\n\n    getOffset(void)\n    \nReturns current view offset. (absolute address of first byte in view)\n\n    getSelection\n    \nReturns `GridSelection` object for current selection in view.\n    \n    getSize(void)\n    \nReturns total number of bytes which can fit the current view. (16 x number of rows)\n    \n    render(void)\n    \nAppends the grid element to the element specified by the constructor parameter 'container'.\n    \n    scrollBy(int rowOffset)\n    \nScrolls view by `rowOffset`. (use negative values for upward scrolling)\n\n    scrollByPage(int pageOffset)\n    \nScrolls view by `pageOffset`. (use negative values for upward scrolling) \n    \n    scrollToBottom(void)\n    \nScrolls view to absolute bottom.\n\n    scrollToTop(void)\n    \nScrolls view to absolute top. This is identical to `showFrom(0)`.\n    \n    showFrom(int offset)\n    \nScrolls view so that first byte is at specified `offset`. Value must be 0 or a multiple of 16.\n\nGrid Events\n===========\n\nSeveral events are emitted by a JSHexGrid instance. Listeners can be added by using the `on` method.\n\n**Event: bytecontext**\n\nEmitted when a user right clicks on a byte in the current view.\n\n    Grid.on('bytecontext',function(offset) {\n        // offset.absolute, position in buffer\n        // offset.relative, position in current view\n    });\n\n**Event: byteout**\n\nEmitted when the mouse pointer moves out of a byte cell in the current view. (no parameters in callback)\n\n**Event: bytehover**\n\nEmitted when the mouse pointer moves over a byte cell in the current view.\n\n    Grid.on('bytehover',function(offset) {\n        // offset.absolute, position in buffer\n        // offset.relative, position in current view\n    });\n\n**Event: rangechange**\n    \nEmitted when a new selection is created or an existant selection is modified.\n    \n    Grid.on('rangechange',function(curSelect, preSelect) {\n        // curSelect, GridSelection object for current selection\n        // preSelect, GridSelection object for previous selection\n    });\n    \n**Event: update**    \n\nEmitted when data in the current view changes.\n\n    Grid.on('update',function(viewInfo) {\n        // viewInfo.offset, position in buffer of first byte in view\n        // viewInfo.length, total bytes in view\n    });\n\n\n[HexReader]:https://chrome.google.com/webstore/detail/hexreader/fejgbfmdlplhjkbpmnedfonifhajinck\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flostsource%2Fjshexgrid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flostsource%2Fjshexgrid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flostsource%2Fjshexgrid/lists"}