/* Pipeline Module - Main JavaScript */ (function() { 'use strict'; var API_BASE = ''; // Will be set on init var currentView = 'list'; var currentPipelineId = null; // === Initialization === function init() { // Detect API base from current URL var base = window.location.pathname.replace(/\/pipeline\/index\.ui.*$/, '/pipeline'); API_BASE = base; showListView(); } // === API Helpers === function apiGet(path, callback) { var xhr = new XMLHttpRequest(); xhr.open('GET', API_BASE + path, true); xhr.onreadystatechange = function() { if (xhr.readyState === 4) { try { var data = JSON.parse(xhr.responseText); callback(null, data); } catch(e) { callback('解析响应失败', null); } } }; xhr.onerror = function() { callback('网络请求失败', null); }; xhr.send(); } function apiPost(path, body, callback) { var xhr = new XMLHttpRequest(); xhr.open('POST', API_BASE + path, true); xhr.setRequestHeader('Content-Type', 'application/json'); xhr.onreadystatechange = function() { if (xhr.readyState === 4) { try { var data = JSON.parse(xhr.responseText); callback(null, data); } catch(e) { callback('解析响应失败', null); } } }; xhr.onerror = function() { callback('网络请求失败', null); }; xhr.send(JSON.stringify(body)); } // === View Rendering === function getContainer() { return document.getElementById('pipeline_content'); } function showListView() { currentView = 'list'; currentPipelineId = null; var c = getContainer(); if (!c) return; c.innerHTML = '