Closed xudafeng closed 7 years ago
// Structure of Node
class Action {
var type:Int
var data:HashMap
var status:Int // Pending, Done, (? Other types of actions)
}
class Node {
__weakRef var parent:Node
var actions:[Action]
var done:Bool
function digest() => String
}
// Models
var currentNode:Node
var nodes:[Node]
// Initialization
void function init() {
var firstNode = currentPage()
traverse(firstNode)
}
// Depth-First
void function traverse(node:Node) {
// Check if node is already in node list by comparing digest
if nodes.contains(node) {
if node.actions.allclear {
nodes.remove(node)
popViewController()
return
}
} else {
// Create actions list for node
// Fetch source
var source = getSource(node)
// Scan whether source contains specific requirements from yml
// If so, only those specific elements are recorded as actions .
// else, all clickable types of elements are recorded as actions.
var actions = filterActions(node, configuration)
node.actions = actions
}
for actions in node.actions {
perform(action)
action.status = done
traverse(currentPage())
}
}
// Perform Actions
void function perform(actions) {
// Based on types of actions, perform corresponding operations indicated by action.data
}