[31794] | 1 | /**
|
---|
| 2 | * This method extracts all strings within curly brackets
|
---|
| 3 | * in the passed json string. This method is used in conjunction
|
---|
| 4 | * with getExistingImageNotes(matches) below to load in and
|
---|
| 5 | * display any existing image annotations.
|
---|
| 6 | **/
|
---|
| 7 | function getImageNoteMatches(imageJson){
|
---|
| 8 | var matches = [];
|
---|
| 9 | var regex = /{([^}]+)}/g;
|
---|
| 10 | var currMatch;
|
---|
| 11 |
|
---|
| 12 | while(currMatch = regex.exec(imageJson)){
|
---|
| 13 | matches.push(currMatch[1]);
|
---|
| 14 | }
|
---|
| 15 |
|
---|
| 16 | return matches;
|
---|
| 17 | }
|
---|
| 18 |
|
---|
| 19 | /**
|
---|
| 20 | * This method extracts all notes from an array of
|
---|
| 21 | * strings and creates an associative array with the
|
---|
| 22 | * information from these notes. This is for loading
|
---|
| 23 | * and displaying any existing image annotations.
|
---|
| 24 | **/
|
---|
| 25 | function getExistingImageNotes(matches,pageNum){
|
---|
| 26 |
|
---|
| 27 | var existing_notes = new Array();
|
---|
| 28 |
|
---|
| 29 | //split each string stored in matches at the comma.
|
---|
| 30 | for(var i = 0; i < matches.length; i++){
|
---|
| 31 | var a = {};
|
---|
| 32 | var split = matches[i].split(',');
|
---|
| 33 |
|
---|
| 34 | for(var j =0; j < split.length; j++){
|
---|
| 35 | //split each string by the colon mark.
|
---|
| 36 | var splitAgain = split[j].split(':');
|
---|
| 37 | var val;
|
---|
| 38 |
|
---|
| 39 | //check word in first string of splitAgain
|
---|
| 40 | if(splitAgain[0].indexOf("top") != -1){
|
---|
| 41 | val = splitAgain[1].substring(1);
|
---|
| 42 | a['top'] = val;
|
---|
| 43 | }else if(splitAgain[0].indexOf("left") != -1){
|
---|
| 44 | val = splitAgain[1].substring(1);
|
---|
| 45 | a['left'] = val;
|
---|
| 46 | }else if(splitAgain[0].indexOf("width") != -1){
|
---|
| 47 | val = splitAgain[1].substring(1);
|
---|
| 48 | a['width'] = val;
|
---|
| 49 | }else if(splitAgain[0].indexOf("height") != -1){
|
---|
| 50 | val = splitAgain[1].substring(1);
|
---|
| 51 | a['height'] = val;
|
---|
| 52 | }else if(splitAgain[0].indexOf("text") != -1){
|
---|
| 53 | val = splitAgain[1].substring(2,splitAgain[1].length-1);
|
---|
| 54 | a['text'] = val;
|
---|
| 55 | }else if(splitAgain[0].indexOf("id") != -1){
|
---|
| 56 | val = splitAgain[1].substring(1);
|
---|
| 57 | a['id'] = val;
|
---|
| 58 | }else if(splitAgain[0].indexOf("editable") != -1){
|
---|
| 59 | val = splitAgain[1].substring(1,splitAgain[1].length-1);
|
---|
| 60 | a['editable'] = val;
|
---|
| 61 | }else if(splitAgain[0].indexOf("page") != -1){
|
---|
| 62 | val = splitAgain[1].substring(1,splitAgain[1].length-1);
|
---|
| 63 | a['page'] = val;
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | if(a['page'] === null || a['page'] == undefined){
|
---|
| 67 | if(pageNum !== undefined && pageNum !== null)
|
---|
| 68 | a['page'] = pageNum;
|
---|
| 69 | }
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | //only obtain the notes associated with the given page number.
|
---|
| 73 | if(a['page'] == pageNum)
|
---|
| 74 | existing_notes.push(a);
|
---|
| 75 |
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | return existing_notes;
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | function addSocialLinks(){
|
---|
| 82 |
|
---|
| 83 |
|
---|
| 84 | } |
---|