sort.lua.svn-base

来自「嵌入式无线路由系统openwrt的web配置工具」· SVN-BASE 代码 · 共 77 行

SVN-BASE
77
字号
#!/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 + =
减小字号Ctrl + -
显示快捷键?