Nkawd phiaj SharePoint npe/ntawv qiv Views (tsawm tsawv thiab) Tau nrog jQuery

Qhov no yog ib qho rau kuv kuas series yuav ua li cas los siv jQuery nrog SharePoint.
Yog koj xav paub ntau ntxiv txog cov jQuery, Kuv mas xav: jQuery hauv nkaus ntawm Xyooj Bibeault thiab Yehuda Katz.

Yog ib tus thawj yam uas kuv xav, thaum kuv pib ua si ib ncig nrog jQuery, Yog hais tias peb yuav siv nws luag ib SharePoint saib. Teb hais tias "tsis yog" (los yog tsawg kawg, Kuv yuav tsis thov tau). Txawm li cas los, yeej ua tau kom nyuaj heev rau cov neeg mus ntsib ib tug pom.

Kuv nrog kuv ib puag ncig sandbox pib thaum ua hauj lwm rau qhov no. Kuv thiaj sau txog qhov chaw ntawm no: Txoj kev sai thiab yooj yim: Sau koj tus kheej jQuery Sandbox rau SharePoint.

"Luag" ib saib, ua raws li cov kauj ruam:

  1. Ua kom muaj ib tug saib koj xav kom luag. Kuv tau ua uas thiab hu nws "Ruaj saib".

    Qhov no yog seb nws zoo li thaum nws tseem tsis "ruaj":

    image

  2. Ntxiv ib editor cov Web site qhov tus saib sab siv qhov ua kom yuam kev nyob hauv tsab xov xwm sandbox (i.e. ntxiv "PageView = Shared&ToolPaneView = 2 "rau qhov URL).
  3. Xyuas seb koj SharePoint _spUserId los ua raws li cov kauj ruam vwm, ntseeg los tsis:
    1. Teev rau hauv koj cheeb tsam SharePoint.
    2. Nyob hauv web browser lub chaw nyob teb, hom: "javascript:alert(_spUserId").
    3. Cov ntaub ntawv (Nws yog "13" hauv kuv tsev neeg).

      image

  4. Ntxiv cov nram qab no javascript koj CEWP nyob rau hauv txoj kev pom:

    <tsab ntawv yam ="ntawv nyeem/javascript"
        src =".. /.. /jQuery Library/jquery-1.3.2.min.js">
    </tsab ntawv>
    
    <Script yam ="ntawv nyeem/javascript">
      $(muaj nuj nqi() {
    
        alert(_spUserId);
    
        Var theSecuredView = $(' iframe[FilterLink * = ruaj % 20View]');
    
        Yog hais tias ((theSecuredView.length > 0) && (_spUserId == 13))
          $(' iframe[FilterLink * = ruaj % 20View]').niam txiv().niam txiv().niam txiv().html("<tr bgcolor = liab><Td>Tsis pom koj!</Td></tr>");
      });
    
    </tsab ntawv>
    

Kuv twb nyob ntawd alert(_spUserId) kab nyob ntawd mus li cas qhov no yog tsis muaj tiag tiag "phiaj" ib saib, tab sis tsuas ua nyuaj saib. Ntxiv rau cov uas nyob rau hauv ib pliag.

Yeej, jQuery nrhiav rau ib iFrame nyob rau sab uas tau muaj ib attribute uas muaj "Secured % 20View" nyob rau hauv nws cov nqi. Thaum nws pom nws, peb xyuas saib yog hais tias tus neeg siv tam sim no yog "13". Yog hais tias nws yog, peb mus pem lub DOM rau ib <TR> lossis (uas kuv figured los saib tau qhov twg los thiab nws tracing) thiab ho hloov ntawd tus TR lossis nrog kuv cov lus. Kuv yeej tsis paub li cas robust qhov no (Kuv yog tej yam txawv heev, qhov tseeb), tab sis nws ua hauj lwm nyob rau hauv kuv sandbox. Yog kuv nrhiav tau ib txoj kev zoo, Kuv mam li blog hais txog nws. Qhov no yog qhov no:

image

Kuv nias lub khawm tau thiab cov ntaub ntawv yog hloov rau liab lus loj loj:

image

Raws li koj hais, txoj kev uas kuv twb siv qhov "kev ruaj ntseg" tov yog cia qhov Web site los kav xwb. Tom qab nws finishes, Kuv overwrite nws cov ntsiab lus uas kuv "tsis pom koj!"lus.

Txawm fact ntawd nws tsis yog ib tug tiag tiag "secured'" saib, Nws yog ib qho uas uas pab tau thiab nrog tej chaw ua hauj lwm uas ntse, nws thiaj li yuav securable muaj kev txiav txim zoo tsim ntau. Tus kho qhov teeb meem yog tias tus neeg no tau txais tag nrho cov ntaub ntawv thiab luag, tsuas yog tom qab nws tau txais cov ntaub ntawv, muab cov ntaub so nws. Yog hais tias tus neeg no yuav tau txais cov ntaub ntawv, ib tus neeg ntse yuav tiv thaiv tau qhov jQuery ntawm khiav txhua thiab saib seb nws xav saib.

Muaj ntau lwm drawbacks. "Kev ruaj ntseg" kauj yog los so ib _spUserId. Peb yuav tau xav kom ruaj ntseg tiag raws li hauv daim ntawv qhia txog SharePoint ruaj ntseg qauv, los yog tsawg kawg los ntawm cov neeg siv lub npe. Ntawd yuav nyuaj zog progressively, tab sis, kuv pom ib co zoo khoom sau ntawv hauv no kawm, vim li ntawd kuv hopeful yog ib tug zoo teb tias teeb meem.

Yuav tsum tau trimmed daim ntawv ntawm lawv tus kheej views, yog ua tau. Kuv tsis tau sim uas paub tseeb. Kuv xav tias tej zaum, tab sis tsis tshua daws qhov kev ruaj ntseg uas siv no vim hais tias muaj ib tug neeg tseem nyuam qhuav ntaus qhov URL ntawm tus saib lawv xav (yog lawv paub). Txawm li cas los, trimming yuav ua rau kev txiav txim zoo. Nws yog ib tug zoo usability feature thiab yuav obfuscate khoom. Yog hais tias tus neeg siv tag tsis paub tias cov kev tshwm sim pom tshwm sim, lawv tej zaum yuav tsis txhob siv txoj kev no. Tej zaum, tias nws zoo txaus.

Cov tau koob hmoov, Kuv mam muaj ntau tshaj ntawm cov ntawv no sau lub sij hawm.

</kawg>

Subscribe rau kuv blog.

Raws li kuv nyob Twitter tom http://www.twitter.com/pagalvin

Ntawv cim npe Technorati: ,,

sau ntawv cia

Koj email chaw nyob yuav tsis muab luam tawm. Search cim *