📄 sort.lua.svn-base
字号:
#!/usr/bin/lua-- Copyright (C) 2008 OpenRB.comrequire('fslib')data = datajson() or {}if (data.id ~= nil and data.extra ~= nil) then qos = uci.get_array('qos') moveid = data.id moveto = data.extra found = false -- scan through qos config, found id of next and previous rules for i, params in ipairs(qos) do type = params['.type'] id = params['.name'] if (type == 'default' or type == 'classify' or type == 'reclassify') then if (found) then nextid = id nextnum = i break elseif (id == moveid) then found = true movenum = i else previd = id prevnum = i end end end -- make sure we are not moving first rule up and last one down if (moveto == 'up' and previd ~= nil) then switchid = previd switchnum = prevnum elseif (moveto == 'down' and nextid ~= nil) then switchid = nextid switchnum = nextnum end -- found id to switch values, delete all previous values and set new if (switchid ~= nil) then uci.set('qos', moveid, qos[ switchnum ]['.type']) uci.set('qos', switchid, qos[ movenum ]['.type']) for param, value in pairs(qos[ movenum ]) do first = param:sub(1,1) if (first == '.') then qos[ movenum ][ param ] = nil else uci.delete('qos', moveid, param) end end for param, value in pairs(qos[ switchnum ]) do first = param:sub(1,1) if (first == '.') then qos[ switchnum ][ param ] = nil else uci.delete('qos', switchid, param) end end for param, value in pairs(qos[ movenum ]) do uci.set('qos', switchid, param, value) end for param, value in pairs(qos[ switchnum ]) do uci.set('qos', moveid, param, value) end uci.commit('qos') endend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -