You can access search results via JSON API by adding format=json
to your query:
https://codesearch.val.run/$%7Bart_info.art.src%7D?q=function&page=2&format=json
For typeahead suggestions, use the /typeahead
endpoint:
https://codesearch.val.run/typeahead?q=function
Returns an array of strings in format "username" or "username/projectName"
Found 20423 results for "function"(480ms)
2627// Initialize the application
28function init() {
29setupCanvas();
30setupEventListeners();
3435// Set up the canvas
36function setupCanvas() {
37const container = document.getElementById('canvas-container');
38const canvas = document.getElementById('diagram-canvas');
41
42// Set canvas size to match container
43function resizeCanvas() {
44canvas.width = container.clientWidth;
45canvas.height = container.clientHeight;
5253// Set up event listeners
54function setupEventListeners() {
55// Tool buttons
56document.getElementById('add-entity').addEventListener('click', () => setActiveTool('entity'));
8586// Set the active tool
87function setActiveTool(tool) {
88// Remove active class from all tools
89document.querySelectorAll('.tool-btn').forEach(btn => {
119120// Handle mouse down on canvas
121function handleCanvasMouseDown(e) {
122const rect = state.canvas.getBoundingClientRect();
123const x = e.clientX - rect.left;
165166// Handle mouse move on canvas
167function handleCanvasMouseMove(e) {
168const rect = state.canvas.getBoundingClientRect();
169const x = e.clientX - rect.left;
193194// Handle mouse up on canvas
195function handleCanvasMouseUp(e) {
196const rect = state.canvas.getBoundingClientRect();
197const x = e.clientX - rect.left;
213214// Find element at position
215function findElementAt(x, y) {
216// Check in reverse order to select top elements first
217const ids = Object.keys(state.elements).reverse();
237238// Create a new entity
239function createEntity(x, y) {
240const id = generateId();
241state.elements[id] = {
254255// Create a new relationship
256function createRelationship(x, y) {
257const id = generateId();
258state.elements[id] = {
272273// Create a new attribute
274function createAttribute(x, y) {
275const id = generateId();
276state.elements[id] = {
289290// Create a connection between elements
291function createConnection(sourceId, targetId) {
292const id = generateId();
293const source = state.elements[sourceId];
327328// Delete an element
329function deleteElement(id) {
330const element = state.elements[id];
331
371372// Select an element
373function selectElement(id) {
374state.selectedElement = id;
375render();
382383// Show properties modal for an element
384function showPropertiesModal(element) {
385const modal = document.getElementById('properties-modal');
386const modalTitle = document.getElementById('modal-title');
475476// Close properties modal
477function closePropertiesModal() {
478const modal = document.getElementById('properties-modal');
479modal.classList.add('hidden');
481482// Save properties from modal
483function savePropertiesModal() {
484if (!state.selectedElement) return;
485
511512// Render the diagram
513function render() {
514const ctx = state.ctx;
515const canvas = state.canvas;
537538// Draw grid
539function drawGrid() {
540const ctx = state.ctx;
541const canvas = state.canvas;
561562// Draw an element
563function drawElement(element) {
564const ctx = state.ctx;
565const isSelected = state.selectedElement === element.id;
617618// Draw a rectangle (for entities)
619function drawRectangle(x, y, width, height, className, isSelected) {
620const ctx = state.ctx;
621
637638// Draw a diamond (for relationships)
639function drawDiamond(x, y, width, height, className, isSelected) {
640const ctx = state.ctx;
641const centerX = x + width / 2;
664665// Draw an ellipse (for attributes)
666function drawEllipse(centerX, centerY, radiusX, radiusY, className, isSelected, attributeType) {
667const ctx = state.ctx;
668
713714// Draw a connection
715function drawConnection(connection) {
716const sourceElement = state.elements[connection.sourceId];
717const targetElement = state.elements[connection.targetId];
773774// Calculate intersection point of a line with an element's boundary
775function calculateIntersection(start, end, element) {
776// For simplicity, we'll use a rectangular boundary for all elements
777const left = element.position.x;
870871// Calculate position for a label along a line
872function calculateLabelPosition(start, end, ratio) {
873return {
874x: start.x + (end.x - start.x) * ratio,
878879// Generate a unique ID
880function generateId() {
881return 'el_' + Math.random().toString(36).substr(2, 9);
882}
883884// Create a new diagram
885function createNewDiagram() {
886if (state.isDirty && !confirm('You have unsaved changes. Create a new diagram anyway?')) {
887return;
900901// Save the current diagram
902async function saveDiagram() {
903const diagramName = document.getElementById('diagram-name').value || 'Untitled Diagram';
904const diagramContent = JSON.stringify({ elements: state.elements });
942943// Load saved diagrams
944async function loadSavedDiagrams() {
945try {
946const response = await fetch('/api/diagrams');
995996// Load a diagram
997async function loadDiagram(id) {
998if (state.isDirty && !confirm('You have unsaved changes. Load another diagram anyway?')) {
999return;
10261027// Delete a diagram from the server
1028async function deleteDiagramFromServer(id) {
1029try {
1030const response = await fetch(\`/api/diagrams/\${id}\`, {
10511052// Export the diagram as an image
1053function exportDiagram() {
1054// Create a temporary canvas with white background
1055const tempCanvas = document.createElement('canvas');
10981099// Update status message
1100function updateStatusMessage(message = '') {
1101const statusElement = document.getElementById('status-message');
1102
16* Get all diagrams
17*/
18export async function getDiagrams(): Promise<Diagram[]> {
19const result = await sqlite.execute(
20`SELECT * FROM ${DIAGRAMS_TABLE} ORDER BY updated_at DESC`
26* Get a single diagram by ID
27*/
28export async function getDiagram(id: number): Promise<Diagram | null> {
29const result = await sqlite.execute(
30`SELECT * FROM ${DIAGRAMS_TABLE} WHERE id = ?`,
42* Save a diagram (create or update)
43*/
44export async function saveDiagram(
45name: string,
46content: string,
70* Delete a diagram
71*/
72export async function deleteDiagram(id: number): Promise<void> {
73await sqlite.execute(
74`DELETE FROM ${DIAGRAMS_TABLE} WHERE id = ?`,